#!/bin/sh STAGE=/tmp DEST=/tmp NOBODY=nobody ##################### PKG=$(basename $(pwd)) TARGET=$STAGE/$PKG-$$ PREFIX=$1 EXTRA=$2 [ ! "$PREFIX" ] && PREFIX=$(grep -i '^prefix *=' Makefile | cut -f1 -d= | cut -f1 -d' ') if [ ! "$PREFIX" ]; then echo "You must provide a prefix name to pass to make(1)! Examine the Makefile to determine this." exit 1; fi if [ "$(id -u)" != "0" ]; then echo "You really want to be root to run this!" exit 1; fi if [ ! "$USERNAME" -o "$USER" = "$USERNAME" ]; then # You really are root. Hrmmm. You don't want to be root to 'make install'. USERNAME=nobody fi # Do this step as an unprivileged user, on the off-chance we got PREFIX wrong. # (so we don't dump everything into, say, /usr/local by accident.) # sudo -u $USERNAME mkdir $TARGET || { echo "Can't mkdir $TARGET"; exit 1; } sudo -u $USERNAME make $PREFIX=$TARGET$EXTRA install || { echo "Make install failed!"; exit 1; } cd $TARGET makepkg $PKG.tgz || { echo "makepkg failed!"; exit 1; } cd $DEST mv $TARGET/$PKG.tgz $DEST || { echo "Cant move $PKG.tgz to $DEST!"; exit 1; } chown $USERNAME $DEST/$PKG.tgz rm -r $TARGET