From 78b036f34672a5625d59d0f7647264d88ee096df Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 29 Dec 2008 09:26:49 +0100 Subject: [PATCH] Add the prepost-action script into the binary package if exists. --HG-- extra : convert_revision : 3d1db89a9347d423550984e7ff5c941d0d7b6cbe --- lib/install.c | 11 ++++++++--- shutils/binpkg.sh | 12 +++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/install.c b/lib/install.c index 131703d07b4..926224d058f 100644 --- a/lib/install.c +++ b/lib/install.c @@ -265,6 +265,7 @@ xbps_unpack_archive_cb(struct archive *ar, const char *pkgname) { struct archive_entry *entry; size_t len; + const char *prepost = "./XBPS_PREPOST_ACTION"; char *buf; int rv = 0, flags; bool actgt = false; @@ -294,13 +295,16 @@ xbps_unpack_archive_cb(struct archive *ar, const char *pkgname) * Run the pre installation action target if there's a script * before writing data to disk. */ - if (strcmp(buf, archive_entry_pathname(entry)) == 0) { + if (strcmp(prepost, archive_entry_pathname(entry)) == 0) { actgt = true; + archive_entry_set_pathname(entry, buf); + if ((rv = archive_read_extract(ar, entry, flags)) != 0) break; - if ((rv = xbps_file_exec(buf, "preinst")) != 0) { + if ((rv = xbps_file_exec(buf, pkgname, + "preinst", NULL)) != 0) { printf("%s: preinst action target error %s\n", pkgname, strerror(errno)); (void)fflush(stdout); @@ -327,7 +331,8 @@ xbps_unpack_archive_cb(struct archive *ar, const char *pkgname) * Run the post installaction action target, if package * contains the script. */ - if ((rv = xbps_file_exec(buf, "postinst")) != 0) { + if ((rv = xbps_file_exec(buf, pkgname, + "postinst", NULL)) != 0) { printf("%s: postinst action target error %s\n", pkgname, strerror(errno)); (void)fflush(stdout); diff --git a/shutils/binpkg.sh b/shutils/binpkg.sh index d922d11bbef..9458e9c23a2 100644 --- a/shutils/binpkg.sh +++ b/shutils/binpkg.sh @@ -120,6 +120,12 @@ _EOF cp -f $TMPFPROPS $metadir/props.plist 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 + fi } # @@ -133,11 +139,7 @@ xbps_make_binpkg() cd $destdir || exit 1 - # - # Sort the tar archive to have a chance that metadata is at - # the beginning. - # - run_rootcmd tar cfjp $XBPS_DESTDIR/$binpkg . | sort -r + run_rootcmd tar cfjp $XBPS_DESTDIR/$binpkg . if [ $? -eq 0 ]; then [ ! -d $XBPS_PACKAGESDIR ] && mkdir -p $XBPS_PACKAGESDIR mv -f $XBPS_DESTDIR/$binpkg $XBPS_PACKAGESDIR