summaryrefslogtreecommitdiff
path: root/libremakepkg
diff options
context:
space:
mode:
Diffstat (limited to 'libremakepkg')
-rwxr-xr-xlibremakepkg47
1 files changed, 38 insertions, 9 deletions
diff --git a/libremakepkg b/libremakepkg
index 8cce89d..ef276f3 100755
--- a/libremakepkg
+++ b/libremakepkg
@@ -1,5 +1,6 @@
#!/bin/bash
-# Copyright 2010 Nicolás Reynolds
+# Copyright 2010 - 2011 Nicolás Reynolds
+# Copyright 2011 Joshua Ismael Haase Hernández
# ---------- GNU General Public License 3 ----------
@@ -25,26 +26,54 @@ if [ $UID -ne 0 ]; then
exit 1
fi
+usage() {
+ echo "cd to a dir containing a PKGBUILD and run:"
+ echo "$0 [options] [makepkg args]"
+ 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"
+}
+
+CLEAN=""
+CLEAN_CACHE=""
+update_first=0
+chrootname=${CHCOPY}
+
+while getopts 'hcCun' arg; do
+ case "${arg}" in
+ h) usage ;;
+ c) CLEAN="-c" ;;
+ C) CLEAN_CACHE="-C"
+ u) update_first=1 ;;
+ n) chrootname="$OPTARG" ;;
+ *) MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;;
+ esac
+done
+
msg "Checking PKGBUILD for non-free issues"
pkgbuild-check-nonfree ||{
- if [[$?=15]]; then
+ if [[ $? -eq 15 ]]; then
error "PKGBUILD contains non-free issues"
exit 15
else
- error "Check failed, continuing"
+ exit $?
fi
}
-[[ -z $1 ]] && {
- CLEAN="-c"
-
+if [ $update_first -eq 1 ]; then
msg "Updating the main chroot"
+ # -c option in mkarchroot indicates cache
mkarchroot -c ${CACHEDIR} -u -- ${CHROOTDIR}/${CHROOT}
+fi
- mount -o bind ${CACHEDIR} ${CHROOTDIR}/${CHCOPY}/var/cache/pacman/pkg || exit 1
-}
msg "Creating the package"
-makechrootpkg $CLEAN -r ${CHROOTDIR} -l ${CHCOPY} -- $@
+makechrootpkg $CLEAN -r ${CHROOTDIR} -l ${chrootname} -- $CLEAN_CACHE $MAKEPKG_ARGS
+
+umount ${CHROOTDIR}/${chrootname}/var/cache/pacman/pkg
exit 0