summaryrefslogtreecommitdiff
path: root/libremakepkg
diff options
context:
space:
mode:
Diffstat (limited to 'libremakepkg')
-rwxr-xr-xlibremakepkg61
1 files changed, 47 insertions, 14 deletions
diff --git a/libremakepkg b/libremakepkg
index af0b7a9..54a5578 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 ----------
@@ -20,31 +21,63 @@
source /etc/libretools.conf
+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 : use this dir instead of CHCOPY."
+ echo " -I pkgname : install this package, use it as many times needed."
+ echo
+}
+
+_CLEAN=""
+CLEAN_CACHE=""
+update_first="n"
+chrootname=${CHCOPY}
+_PKGINSTALL=""
+#libremakepkg own args
+libremakepkgargs='hcun:I:'
+#now makepkg args
+libremakepkgargs+='ACdefiLmoprRs'
+
+while getopts ${libremakepkgargs} arg ; do
+ case "${arg}" in
+ h) usage; exit 0 ;;
+ c) _CLEAN="-c" ;;
+ u) update_first="y" ;;
+ n) chrootname="$OPTARG"; echo $chrootname ;;
+ 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 [[ $? = 15 ]]; then
- error "PKGBUILD contains non-free issues"
- exit 15
- else
- error "Check failed, continuing"
+pkgbuild-check-nonfree ||{
+ if [[ $? -eq 15 ]]; then
+ error "PKGBUILD contains non-free issues"
+ exit 15
fi
}
-[[ -z $1 ]] && {
- CLEAN="-c"
-
+if [ $update_first = y ]; then
msg "Updating the main chroot"
- mkarchroot -c ${CACHEDIR} -u -- ${CHROOTDIR}/${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}" $_PKGINSTALL -- $_MAKEPKG_ARGS
exit 0