From 7f118f53283d7e228c40a40076815ce94ebb94a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Mon, 16 May 2011 00:44:39 -0500 Subject: Cleaned up some things, added option parse to some scripts. --- libremakepkg | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'libremakepkg') diff --git a/libremakepkg b/libremakepkg index f2b523d..272e61d 100755 --- a/libremakepkg +++ b/libremakepkg @@ -21,47 +21,50 @@ source /etc/libretools.conf -if [ $UID -ne 0 ]; then - error "This script must be run as root" - exit 1 -fi - -usage() { +function usage { echo "cd to a dir containing a PKGBUILD and run:" echo "$0 [options] [makepkg args]" + echo "This script will build your package on a chroot." echo echo "OPTIONS:" echo - echo " -h : show this message" - echo " -c : cleans CHCOPY and cachedir" - echo " -u : updates before building" - echo " -n chrootname : use this dir instead of CHCOPY" + echo " -h : show this message." + echo " -c : cleans CHCOPY and cachedir." + echo " -u : updates before building." + echo " -n : use this dir instead of CHCOPY." + echo " -I pkgname : install this package, use it as many times needed." + echo } -CLEAN="" +_CLEAN="" CLEAN_CACHE="" update_first="n" chrootname=${CHCOPY} - -while getopts 'hcun:' arg; do +_PKGINSTALL="" +while getopts 'hcun:I:' arg; do case "${arg}" in h) usage; exit 0 ;; - c) CLEAN="-c" ;; + c) _CLEAN="-c" ;; u) update_first="y" ;; n) chrootname="$OPTARG"; echo $chrootname ;; - *) MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;; + I) _PKGINSTALL+="-I $OPTARG " ;; + *) _MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;; esac done +if [ $UID -ne 0 ]; then + error "This script must be run as root" + exit 1 +fi + msg "Checking PKGBUILD for non-free issues" pkgbuild-check-nonfree ||{ if [[ $? -eq 15 ]]; then error "PKGBUILD contains non-free issues" exit 15 - exit $? fi - } + if [ $update_first = y ]; then msg "Updating the main chroot" # -c option in mkarchroot indicates cache @@ -70,6 +73,7 @@ fi msg "Creating the package" -makechrootpkg $CLEAN -r ${CHROOTDIR} -l "${chrootname}" -- $MAKEPKG_ARGS +makechrootpkg $_CLEAN -r ${CHROOTDIR} -l "${chrootname}" $_PKGINSTALL \ + -- $_MAKEPKG_ARGS exit 0 -- cgit v1.2.2