1#!/bin/sh 2 3set -u 4set -e 5trap onexit INT 6trap onexit TERM 7trap onexit EXIT 8 9TMPDIR= 10SUDO= 11 12onexit() 13{ 14 if [ ! "$TMPDIR" = "" ]; then 15 rm -rf $TMPDIR 16 fi 17} 18 19uid() 20{ 21 id | cut -f2 -d = | cut -f1 -d \(; 22} 23 24PKGNAME=@PKGNAME@ 25VERSION=@VERSION@ 26ARCH=@CPU_TYPE@ 27OS=@CMAKE_SYSTEM_NAME@ 28PREFIX=@CMAKE_INSTALL_PREFIX@ 29 30umask 022 31rm -f $PKGNAME-$VERSION-$OS-$ARCH.tar.bz2 32TMPDIR=`mktemp -d /tmp/$PKGNAME-build.XXXXXX` 33mkdir -p $TMPDIR/install 34 35make install DESTDIR=$TMPDIR/install 36echo tartest >$TMPDIR/tartest 37GNUTAR=0 38BSDTAR=0 39tar cf $TMPDIR/tartest.tar --owner=root --group=root -C $TMPDIR tartest >/dev/null 2>&1 && GNUTAR=1 40if [ "$GNUTAR" = "1" ]; then 41 tar cf - --owner=root --group=root -C $TMPDIR/install .$PREFIX | bzip2 -c >$PKGNAME-$VERSION-$OS-$ARCH.tar.bz2 42else 43 tar cf $TMPDIR/tartest.tar --uid 0 --gid 0 -C $TMPDIR tartest >/dev/null 2>&1 && BSDTAR=1 44 if [ "$BSDTAR" = "1" ]; then 45 tar cf - --uid=0 --gid=0 -C $TMPDIR/install .$PREFIX | bzip2 -c >$PKGNAME-$VERSION-$OS-$ARCH.tar.bz2 46 else 47 tar cf - -C $TMPDIR/install .$PREFIX | bzip2 -c >$PKGNAME-$VERSION-$OS-$ARCH.tar.bz2 48 fi 49fi 50 51exit 52