package kit: Add pre-uninstall scripts feature.

Just like post-install scripts which run shortly after a package is
installed, pre-uninstall scripts are run just before a package is
removed.  Implements enhancement #13427

* Fix script exit code handling vs script launch errors.
* Bump package and repo file version numbers due to new attribute,
  unfortunately makes new .hpkg files not backwards compatible.
* Add pre-uninstall functionality, mostly cloning the post-install
  except in a few places.
* Discover that _RunQueuedScripts() is never called, a future TODO:?
* Update package documentation for pre-uninstall scripts, and use of
  the boot/post-install directory.

Change-Id: I45596255ce74bc102f6e5b606cbf83e4e4347a17
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1504
Reviewed-by: Alexander G. M. Smith <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Alexander G. M. Smith
2020-09-21 10:47:57 +00:00
committed by Adrien Destugues
parent e6f60cad2a
commit a22fa0c977
18 changed files with 178 additions and 39 deletions
@@ -59,6 +59,9 @@ public:
B_POST_INSTALL_SCRIPT_NOT_FOUND,
B_STARTING_POST_INSTALL_SCRIPT_FAILED,
B_POST_INSTALL_SCRIPT_FAILED,
B_PRE_UNINSTALL_SCRIPT_NOT_FOUND,
B_STARTING_PRE_UNINSTALL_SCRIPT_FAILED,
B_PRE_UNINSTALL_SCRIPT_FAILED,
};
public:
+5
View File
@@ -96,6 +96,7 @@ public:
const BStringList& Groups() const;
const BStringList& PostInstallScripts() const;
const BStringList& PreUninstallScripts() const;
const BObjectList<BPackageResolvable>& ProvidesList() const;
const BObjectList<BPackageResolvableExpression>&
@@ -159,6 +160,9 @@ public:
void ClearPostInstallScripts();
status_t AddPostInstallScript(const BString& path);
void ClearPreUninstallScripts();
status_t AddPreUninstallScript(const BString& path);
void ClearProvidesList();
status_t AddProvides(const BPackageResolvable& provides);
@@ -297,6 +301,7 @@ private:
BStringList fGroups;
BStringList fPostInstallScripts;
BStringList fPreUninstallScripts;
ResolvableList fProvidesList;
@@ -51,6 +51,8 @@ enum BPackageInfoAttributeID {
// list of (Unix) groups defined/needed
B_PACKAGE_INFO_POST_INSTALL_SCRIPTS,
// list of scripts to be executed post-install
B_PACKAGE_INFO_PRE_UNINSTALL_SCRIPTS,
// list of scripts to be run before uninstalling
//
B_PACKAGE_INFO_ENUM_COUNT,
};
+2 -2
View File
@@ -18,11 +18,11 @@ namespace BHPKG {
enum {
B_HPKG_MAGIC = 'hpkg',
B_HPKG_VERSION = 2,
B_HPKG_MINOR_VERSION = 0,
B_HPKG_MINOR_VERSION = 1,
//
B_HPKG_REPO_MAGIC = 'hpkr',
B_HPKG_REPO_VERSION = 2,
B_HPKG_REPO_MINOR_VERSION = 0
B_HPKG_REPO_MINOR_VERSION = 1
};
@@ -82,3 +82,10 @@ B_DEFINE_HPKG_ATTRIBUTE(52, STRING, "package:post-install-script",
B_DEFINE_HPKG_ATTRIBUTE(53, UINT, "package:is-writable-directory",
PACKAGE_IS_WRITABLE_DIRECTORY)
B_DEFINE_HPKG_ATTRIBUTE(54, STRING, "package", PACKAGE)
B_DEFINE_HPKG_ATTRIBUTE(55, STRING, "package:pre-uninstall-script",
PACKAGE_PRE_UNINSTALL_SCRIPT)
// Note: add new entries at the end to avoid breaking index numbers, which are
// in previously built .hpkg files the build process downloads from elsewhere.
// Also remember to bump B_HPKG_MINOR_VERSION and B_HPKG_REPO_MINOR_VERSION.
// And yes, the build (on Haiku) runs packaging tools compiled using your code,
// which makes it extra fun to debug :-)