diff --git a/doc/BINPKG_INFO b/doc/BINPKG_INFO index cf2f06d004f..1e370f5fa6b 100644 --- a/doc/BINPKG_INFO +++ b/doc/BINPKG_INFO @@ -13,8 +13,8 @@ with bzip2 and has the following structure: /var/db/xbps/metadata/$pkgname /var/db/xbps/metadata/$pkgname/flist /var/db/xbps/metadata/$pkgname/props.plist - /var/db/xbps/metadata/$pkgname/prepost-inst - /var/db/xbps/metadata/$pkgname/prepost-rm + /var/db/xbps/metadata/$pkgname/INSTALL + /var/db/xbps/metadata/$pkgname/REMOVE Metadata info is stored in the "/var/db/xbps/metadata/$pkgname" directory and two files will be always be present: flist and props.plist. @@ -61,7 +61,7 @@ has the following structure: ... -The prepost-* executables allows you to trigger any action +The INSTALL/REMOVE 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 diff --git a/lib/remove.c b/lib/remove.c index 2a2c47b3e1b..b8e98b35d97 100644 --- a/lib/remove.c +++ b/lib/remove.c @@ -189,21 +189,20 @@ xbps_remove_binary_pkg(const char *pkgname, const char *destdir, int flags) return ENOENT; /* - * This length is '%s%s/metadata/%s/prepost-rm' not - * including nul. + * This length is '%s%s/metadata/%s/REMOVE' + NULL. */ - len = strlen(XBPS_META_PATH) + strlen(destdir) + strlen(pkgname) + 22; - buf = malloc(len + 1); + len = strlen(XBPS_META_PATH) + strlen(destdir) + strlen(pkgname) + 19; + buf = malloc(len); if (buf == NULL) return errno; - if (snprintf(buf, len + 1, "%s%s/metadata/%s/prepost-rm", + if (snprintf(buf, len, "%s%s/metadata/%s/REMOVE", destdir, XBPS_META_PATH, pkgname) < 0) { free(buf); return -1; } - /* Find out if the prepost-rm file exists */ + /* Find out if the REMOVE file exists */ if ((fd = open(buf, O_RDONLY)) == -1) { if (errno != ENOENT) { free(buf); diff --git a/lib/unpack.c b/lib/unpack.c index 5646c337b4d..922922fab26 100644 --- a/lib/unpack.c +++ b/lib/unpack.c @@ -151,7 +151,7 @@ unpack_archive_fini(struct archive *ar, const char *destdir, int flags, struct archive_entry *entry; struct stat st; size_t len; - const char *prepost = "./XBPS_PREPOST_INSTALL"; + const char *prepost = "./INSTALL"; const char *pkgname, *version; char *buf, *path; int rv = 0, lflags = 0; @@ -169,15 +169,14 @@ unpack_archive_fini(struct archive *ar, const char *destdir, int flags, lflags = EXTRACT_FLAGS; /* - * This length is '.%s/metadata/%s/prepost-inst' not - * including nul. + * This length is '.%s/metadata/%s/INSTALL' + NULL. */ - len = strlen(XBPS_META_PATH) + strlen(pkgname) + 24; - buf = malloc(len + 1); + len = strlen(XBPS_META_PATH) + strlen(pkgname) + 20; + buf = malloc(len); if (buf == NULL) return ENOMEM; - if (snprintf(buf, len + 1, ".%s/metadata/%s/prepost-inst", + if (snprintf(buf, len, ".%s/metadata/%s/INSTALL", XBPS_META_PATH, pkgname) < 0) { free(buf); return -1; diff --git a/shutils/binpkg.sh b/shutils/binpkg.sh index 3b4b926c8e8..77d10344fa0 100644 --- a/shutils/binpkg.sh +++ b/shutils/binpkg.sh @@ -225,15 +225,13 @@ _EOF chmod 644 $metadir/* rm -f $TMPFLIST $TMPFPLIST $TMPFPROPS - 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 + if [ -f "$XBPS_TEMPLATESDIR/$pkgname/INSTALL" ]; then + cp -f $XBPS_TEMPLATESDIR/$pkgname/INSTALL $destdir + chmod +x $destdir/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 + if [ -f "$XBPS_TEMPLATESDIR/$pkgname/REMOVE" ]; then + cp -f $XBPS_TEMPLATESDIR/$pkgname/REMOVE $metadir + chmod +x $metadir/REMOVE fi } @@ -285,7 +283,22 @@ xbps_make_binpkg_real() binpkg=$pkgname-$version.$arch.xbps pkgdir=$XBPS_PACKAGESDIR/$arch - run_rootcmd $use_sudo tar cfjp $XBPS_DESTDIR/$binpkg . + if [ -x ./INSTALL ]; then + # + # Make sure that INSTALL is the first file on the archive, + # this is to ensure that it's run before any other file is + # unpacked. + # + run_rootcmd $use_sudo tar cfp $XBPS_DESTDIR/$binpkg ./INSTALL && \ + run_rootcmd $use_sudo tar rfp $XBPS_DESTDIR/$binpkg . \ + --exclude "./INSTALL" && \ + run_rootcmd $use_sudo bzip2 -9 $XBPS_DESTDIR/$binpkg && \ + mv $XBPS_DESTDIR/$binpkg.bz2 $XBPS_DESTDIR/$binpkg + else + run_rootcmd $use_sudo tar cfp $XBPS_DESTDIR/$binpkg . && \ + bzip2 -9 $XBPS_DESTDIR/$binpkg && \ + mv $XBPS_DESTDIR/$binpkg.bz2 $XBPS_DESTDIR/$binpkg + fi # Disabled for now. # --exclude "./var/db/xbps/metadata/*/flist" . # diff --git a/templates/initng-ifiles/prepost-inst b/templates/initng-ifiles/INSTALL similarity index 100% rename from templates/initng-ifiles/prepost-inst rename to templates/initng-ifiles/INSTALL diff --git a/templates/kernel/prepost-inst b/templates/kernel/INSTALL similarity index 100% rename from templates/kernel/prepost-inst rename to templates/kernel/INSTALL diff --git a/templates/shadow/prepost-inst b/templates/shadow/INSTALL similarity index 95% rename from templates/shadow/prepost-inst rename to templates/shadow/INSTALL index f38dc6610fe..5e7966eb2bb 100644 --- a/templates/shadow/prepost-inst +++ b/templates/shadow/INSTALL @@ -47,7 +47,7 @@ case "$2" in pre) ;; post) - echo "Running $3-$4 post installation hook..." + echo "Running $3-$4 post installation hooks..." if [ "$1" = "NOTSET" ]; then run_cmd="pwconv" else