#!/bin/sh
# (c) Copyright 2006-2009. CodeWeavers, Inc.
# Setup logging
# To trigger logging, use a command of the form:
# pkgadd/rm -v ... 2>&1 | tee pkg.log
if echo $- | grep x >/dev/null
then
echo >&2
echo "***** `date`" >&2
echo "Starting: $0 $@" >&2
env >&2
CX_LOG="-"
export CX_LOG
fi
CX_ROOT="$BASEDIR/$CX_PKGINST"
CX_BOTTLE="@bottle@"
export CX_ROOT CX_BOTTLE
pkgsrc="$INST_DATADIR/$PKG"
if [ -f "$pkgsrc/archive/extra.cpio" ]
then
ext="cpio"
uncompress="cat"
elif [ -f "$pkgsrc/archive/extra.gz" ]
then
ext="gz"
uncompress="gunzip -c"
elif [ -f "$pkgsrc/archive/extra.bz2" ]
then
ext="bz2"
uncompress="bunzip2 -c"
elif [ -f "$pkgsrc/archive/extra.7z" ]
then
ext="7z"
uncompress="7za x -so"
else
uncompress=""
fi
if [ -n "$uncompress" ]
then
# Capture the 7za and cpio output
out=`(($uncompress "$pkgsrc/archive/extra.$ext" || echo "$uncompress failed: $?" >&2) | (cd "$CX_ROOT/support/$CX_BOTTLE" && cpio -i -d -m -u)) 2>&1`
if [ $? -ne 0 ] || echo "$out" | grep "failed:" >/dev/null
then
echo "'$uncompress \"$pkgsrc/archive/extra.$ext\" | cpio -i -d -m -u' failed" >&2
echo "$out" >&2
exit 1
fi
fi
set_uuid=""
if [ -n "$CX_UUID" ]
then
set_uuid="--set-uuid $CX_UUID"
fi
"$CX_ROOT/bin/cxbottle" $set_uuid --restored --removeall --install
exit 0