summaryrefslogtreecommitdiff
path: root/src/chroot-tools/libremakepkg
diff options
context:
space:
mode:
Diffstat (limited to 'src/chroot-tools/libremakepkg')
-rwxr-xr-xsrc/chroot-tools/libremakepkg67
1 files changed, 48 insertions, 19 deletions
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index c66f5cc..0276315 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -32,9 +32,10 @@ shopt -s nullglob
. "$(dirname "$0")/libremakepkg.gpl2"
# This gives us the functions:
# - chroot_init
-# - chroot_extract
-# - chroot_build
-# - copy_pkgs
+# - chroot_exec
+# - chroot_copy_in
+# - chroot_copy_out
+# - add_to_local_repo
# Boring functions #############################################################
@@ -57,9 +58,31 @@ trap_exit() {
exit 1
}
+extract() {
+ local user=$LIBREUSER
+ $INCHROOT || user=nobody
+
+ local clean
+ if $INCHROOT; then
+ clean=chcleanup
+ else
+ cp -a "$(which chcleanup)" "${copydir}/clean"
+ clean=/clean
+ fi
+
+ chroot_exec "${clean} && sudo -u ${user} ${MAKEPKG} ${makepkg_args} -o"
+}
+
+build() {
+ local user=$LIBREUSER
+ $INCHROOT || user=nobody
+
+ chroot_exec -N "sudo -u ${user} ${MAKEPKG} ${makepkg_args} -e"
+}
+
# Functions that check for issues with the build ###############################
-libre_check_pkgbuild() {
+check_pkgbuild() {
msg "Checking PKGBUILD for issues"
# TODO
if ! pkgbuild-check-nonfree -f; then
@@ -73,12 +96,12 @@ libre_check_pkgbuild() {
fi
}
-libre_check_src() {
+check_src() {
msg "Checking src directory for issues"
# TODO
}
-libre_check_pkg() {
+check_pkg() {
msg "Checking final package for issues"
# TODO
}
@@ -95,7 +118,6 @@ usage() {
echo " -n <CHROOT> Use this chroot instead of \`$CHROOT'"
echo ' -l <COPY> Use this chroot copy instead of basing it'
echo ' on the username'
- echo ' -C Do not use a chroot'
echo ''
echo " -m <MAKEPKG> Use the command MAKEPKG instead of 'makepkg'"
echo ''
@@ -110,13 +132,16 @@ main() {
makepkg_args='-s --noconfirm -L '
MAKEPKG=makepkg
- NOCHROOT=false
+
+ INCHROOT=false
+ if [[ -f /.arch-chroot ]]; then
+ INCHROOT=true
+ fi
while getopts 'n:l:m:Rh' arg ; do
case "${arg}" in
n) CHROOT=$OPTARG;;
l) CHROOTCOPY=$OPTARG;;
- C) NOCHROOT=true;;
m) MAKEPKG=$OPTARG;;
h) usage; exit 0;;
*) usage; exit 1;;
@@ -126,8 +151,11 @@ main() {
# Pass all arguments after -- right to makepkg
makepkg_args+=" $*"
- rootdir="${CHROOTDIR}/${CHROOT}/root"
- copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}"
+ if $INCHROOT; then
+ copydir=''
+ else
+ copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}"
+ fi
# Init #################################################################
@@ -160,16 +188,17 @@ main() {
export CARCH="$(get_conf_makepkg CARCH)"
unset MAKEPKG_CONF
- $NOCHROOT || chroot_init
+ $INCHROOT || chroot_init
- libre_check_pkgbuild
- chroot_extract
- libre_check_src
- chroot_build
- libre_check_pkg
+ check_pkgbuild
+ $INCHROOT || chroot_copy_in
+ extract
+ check_src
+ build
+ check_pkg
- $NOCHROOT || copy_pkgs
- $NOCHROOT || copy_logs
+ add_to_local_repo
+ $INCHROOT || chroot_copy_out
}
main "$@"