Add the prepost-action script into the binary package if exists.

--HG--
extra : convert_revision : 3d1db89a9347d423550984e7ff5c941d0d7b6cbe
This commit is contained in:
Juan RP 2008-12-29 09:26:49 +01:00
parent 5d3e701b3a
commit 78b036f346
2 changed files with 15 additions and 8 deletions

View file

@ -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);

View file

@ -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