diff --git a/doc/BINPKG_INFO b/doc/BINPKG_INFO index ef918d87d82..a5eba179022 100644 --- a/doc/BINPKG_INFO +++ b/doc/BINPKG_INFO @@ -9,7 +9,8 @@ with bzip2 and has the following structure: /var/cache/xbps/metadata/$pkgname /var/cache/xbps/metadata/$pkgname/flist /var/cache/xbps/metadata/$pkgname/props.plist - /var/cache/xbps/metadata/$pkgname/postpre-action + /var/cache/xbps/metadata/$pkgname/prepost-inst + /var/cache/xbps/metadata/$pkgname/prepost-rm Metadata info is stored in the "/var/cache/xbps/metadata/$pkgname" directory and two files will be always be present: flist and props.plist. @@ -56,10 +57,8 @@ has the following structure: ... -The prepost-action is an executable script/command that allows you to -trigger any action at pre/post installation/removal of the binary -package. If return value is not 0, the package won't be registered into -the database. +The prepost-* executables allows you to trigger any action +at pre/post installation/removal of the binary package. The package's dictionary will also be written into the repository's package index file, that describes information about a binary package on it. diff --git a/doc/TODO b/doc/TODO index c1fc324ce54..b1b3361e589 100644 --- a/doc/TODO +++ b/doc/TODO @@ -5,7 +5,7 @@ xbps-src: * More robust and fast dependency checking. * $version needs to have a dot to be found by xbps.sh. Some packages do not have a dot on its version, like udev-130. - * Add support to run the prepost-action scripts, so that the same actions are + * Add support to run the prepost-* scripts, so that the same actions are performed in source/bin packages. xbps-cmpver: diff --git a/lib/install.c b/lib/install.c index 30889f1cabf..62f9b4ff619 100644 --- a/lib/install.c +++ b/lib/install.c @@ -269,7 +269,7 @@ xbps_unpack_archive_cb(struct archive *ar, prop_dictionary_t pkg) { struct archive_entry *entry; size_t len; - const char *prepost = "./XBPS_PREPOST_ACTION"; + const char *prepost = "./XBPS_PREPOST_INSTALL"; const char *pkgname, *version; char *buf; int rv = 0; @@ -282,15 +282,15 @@ xbps_unpack_archive_cb(struct archive *ar, prop_dictionary_t pkg) prop_dictionary_get_cstring_nocopy(pkg, "version", &version); /* - * This length is '.%s/metadata/%s/prepost-action' not + * This length is '.%s/metadata/%s/prepost-inst' not * including nul. */ - len = strlen(XBPS_META_PATH) + strlen(pkgname) + 26; + len = strlen(XBPS_META_PATH) + strlen(pkgname) + 24; buf = malloc(len + 1); if (buf == NULL) return ENOMEM; - if (snprintf(buf, len + 1, ".%s/metadata/%s/prepost-action", + if (snprintf(buf, len + 1, ".%s/metadata/%s/prepost-inst", XBPS_META_PATH, pkgname) < 0) { free(buf); return -1; @@ -310,7 +310,7 @@ xbps_unpack_archive_cb(struct archive *ar, prop_dictionary_t pkg) EXTRACT_FLAGS)) != 0) break; - if ((rv = xbps_file_exec(buf, chroot_dir, "preinst", + if ((rv = xbps_file_exec(buf, chroot_dir, "pre", pkgname, version, NULL)) != 0) { printf("%s: preinst action target error %s\n", pkgname, strerror(errno)); @@ -338,7 +338,7 @@ xbps_unpack_archive_cb(struct archive *ar, prop_dictionary_t pkg) * Run the post installaction action target, if package * contains the script. */ - if ((rv = xbps_file_exec(buf, chroot_dir, "postinst", + if ((rv = xbps_file_exec(buf, chroot_dir, "post", pkgname, version, NULL)) != 0) { printf("%s: postinst action target error %s\n", pkgname, strerror(errno)); diff --git a/lib/remove.c b/lib/remove.c index 551551cdd52..1c0d25441e5 100644 --- a/lib/remove.c +++ b/lib/remove.c @@ -96,21 +96,21 @@ xbps_remove_binary_pkg(const char *pkgname, const char *destdir) return ENOENT; /* - * This length is '%s%s/metadata/%s/prepost-action' not + * This length is '%s%s/metadata/%s/prepost-rm' not * including nul. */ - len = strlen(XBPS_META_PATH) + strlen(destdir) + strlen(pkgname) + 26; + len = strlen(XBPS_META_PATH) + strlen(destdir) + strlen(pkgname) + 22; buf = malloc(len + 1); if (buf == NULL) return errno; - if (snprintf(buf, len + 1, "%s%s/metadata/%s/prepost-action", + if (snprintf(buf, len + 1, "%s%s/metadata/%s/prepost-rm", destdir, XBPS_META_PATH, pkgname) < 0) { free(buf); return -1; } - /* Find out if the prepost-action file exists */ + /* Find out if the prepost-rm file exists */ if ((fd = open(buf, O_RDONLY)) == -1) { if (errno != ENOENT) { rv = errno; @@ -120,7 +120,7 @@ xbps_remove_binary_pkg(const char *pkgname, const char *destdir) /* Run the preremove action */ (void)close(fd); prepostf = true; - if ((rv = xbps_file_exec(buf, destdir, "prerm", pkgname, + if ((rv = xbps_file_exec(buf, destdir, "pre", pkgname, NULL)) != 0) { printf("%s: prerm action target error (%s)\n", pkgname, strerror(errno)); @@ -194,7 +194,7 @@ next: if (rv == 0) { if (((rv = xbps_unregister_pkg(pkgname)) == 0) && prepostf) { /* Run the postremove action target */ - if ((rv = xbps_file_exec(buf, destdir, "postrm", + if ((rv = xbps_file_exec(buf, destdir, "post", pkgname, NULL)) != 0) { printf("%s: postrm action target error (%s)\n", pkgname, strerror(errno)); diff --git a/shutils/binpkg.sh b/shutils/binpkg.sh index a3a6de5c4c2..e403ce13d19 100644 --- a/shutils/binpkg.sh +++ b/shutils/binpkg.sh @@ -125,10 +125,15 @@ _EOF chmod 644 $metadir/* rm -f $TMPFLIST $TMPFPROPS - if [ -f "$XBPS_TEMPLATESDIR/$pkgname.prepost-action" ]; then - cp -f $XBPS_TEMPLATESDIR/$pkgname.prepost-action \ - $destdir/XBPS_PREPOST_ACTION - chmod +x $destdir/XBPS_PREPOST_ACTION + if [ -f "$XBPS_TEMPLATESDIR/$pkgname.prepost-inst" ]; then + cp -f $XBPS_TEMPLATESDIR/$pkgname.prepost-inst \ + $destdir/XBPS_PREPOST_INSTALL + chmod +x $destdir/XBPS_PREPOST_INSTALL + fi + if [ -f "$XBPS_TEMPLATESDIR/$pkgname.prepost-rm" ]; then + cp -f $XBPS_TEMPLATESDIR/$pkgname.prepost-rm \ + $metadir/prepost-rm + chmod +x $metadir/prepost-rm fi } diff --git a/templates/initng-ifiles.prepost-action b/templates/initng-ifiles.prepost-inst similarity index 94% rename from templates/initng-ifiles.prepost-action rename to templates/initng-ifiles.prepost-inst index 31772ed49ef..4a1b5a30cb8 100644 --- a/templates/initng-ifiles.prepost-action +++ b/templates/initng-ifiles.prepost-inst @@ -8,9 +8,9 @@ export PATH="/bin:/sbin:/usr/bin:/usr/sbin" # $4 = version case "$2" in -preinst) +pre) ;; -postinst) +post) echo "Running $3-$4 post-installation command..." if [ "$1" = "NOTSET" ]; then run_cmd="/sbin/genrunlevel --all" diff --git a/templates/kernel.prepost-action b/templates/kernel.prepost-inst similarity index 97% rename from templates/kernel.prepost-action rename to templates/kernel.prepost-inst index 3898259db3b..95d4521aa25 100644 --- a/templates/kernel.prepost-action +++ b/templates/kernel.prepost-inst @@ -8,9 +8,9 @@ export PATH="/bin:/sbin:/usr/bin:/usr/sbin" # $4 = version case "$2" in -preinst) +pre) ;; -postinst) +post) echo "Running $3-$4 post-installation command..." if [ "$1" = "NOTSET" ]; then if $(mount|grep "^/proc" 2>&1 >/dev/null); then diff --git a/templates/shadow.prepost-action b/templates/shadow.prepost-inst similarity index 95% rename from templates/shadow.prepost-action rename to templates/shadow.prepost-inst index b39ed5d1898..c1d81eeb37a 100644 --- a/templates/shadow.prepost-action +++ b/templates/shadow.prepost-inst @@ -44,9 +44,9 @@ _EOF } case "$2" in -preinst) +pre) ;; -postinst) +post) if [ "$1" = "NOTSET" ]; then run_cmd="pwconv" else @@ -58,7 +58,7 @@ postinst) if [ ! -f ./etc/shadow ]; then echo "Enabling shadow passwords..." - ${run_cmd} + ${run_cmd} fi ;; esac