summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/chroot-tools/librechroot11
-rwxr-xr-xsrc/chroot-tools/librechroot.gpl241
-rwxr-xr-xsrc/chroot-tools/libremakepkg21
-rwxr-xr-xsrc/chroot-tools/libremakepkg.gpl2115
4 files changed, 4 insertions, 184 deletions
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 89fb644..7f113f5 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -24,12 +24,7 @@
load_conf_libretools_chroot
. "$(which libremessages)"
-
-# This file (librechroot) is GPLv3+, but I would like to use some code
-# modified from devtools' "makechrootpkg", which is GPLv2.
-. "$(dirname "$0")/librechroot.gpl2"
-# This gives us the functions:
-# - sync
+. /usr/share/devtools/makechrootpkg.sh
cleanup=(':');
cleanup() {
@@ -120,7 +115,7 @@ main() {
fi
if [[ ! -d $copydir ]] && [[ $mode != sync ]]; then
- sync
+ chroot_sync
fi
mkdir -p $copydir/etc/libretools.d
@@ -160,7 +155,7 @@ main() {
install_pkg) archroot "${archroot_args[@]}" "${copydir}" -i $ARG ;;
noop) :;;
run) archroot "${archroot_args[@]}" "${copydir}" -r "$ARG" ;;
- sync) sync;;
+ sync) chroot_sync;;
update) archroot "${archroot_args[@]}" "${copydir}" -u ;;
enter) archroot "${archroot_args[@]}" "${copydir}" -r bash ;;
esac
diff --git a/src/chroot-tools/librechroot.gpl2 b/src/chroot-tools/librechroot.gpl2
deleted file mode 100755
index 1b5d90a..0000000
--- a/src/chroot-tools/librechroot.gpl2
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-# Contains code derived from devtools' "makechrootpkg"
-
-# Copyright 2011-2012 The Arch Linux Development Team
-# Copyright 2012 Luke Shumaker
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-sync() {
- if [[ $CHROOTCOPY = root ]]; then
- error "Cannot sync the root copy with itself"
- exit 1
- fi
-
- lock_open_read 8 "$rootdir" \
- "Waiting for existing lock on \`$rootdir' to be released"
-
- stat_busy 'Creating clean working copy'
- local use_rsync=false
- if type -P btrfs >/dev/null; then
- [[ -d $copydir ]] && btrfs subvolume delete "$copydir" &>/dev/null
- btrfs subvolume snapshot "$rootdir" "$copydir" &>/dev/null || use_rsync=true
- else
- use_rsync=true
- fi
-
- if $use_rsync; then
- mkdir -p "$copydir"
- rsync -a --delete -q -W -x "$rootdir/" "$copydir"
- fi
- stat_done
-
- lock_close 8
-}
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index 2901b0d..a9e1fb7 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -24,32 +24,13 @@
load_conf_libretools_chroot
. "$(which libremessages)"
+. /usr/share/devtools/makechrootpkg.sh
shopt -s nullglob
-# This file (libremakepkg) is GPLv3+, but I would like to use some code
-# modified from devtools' "makechrootpkg", which is GPLv2.
-. "$(dirname "$0")/libremakepkg.gpl2"
-# This gives us the functions:
-# - chroot_init
-# - chroot_exec
-# - chroot_copy_in
-# - chroot_copy_out
-# - add_to_local_repo
-
# Boring functions #############################################################
##
-# copy logs if they exist
-##
-copy_logs() {
- for l in "$copydir"/build/*.log; do
- chown "$LIBREUSER" "$l"
- mv "$l" .
- done
-}
-
-##
# End inmediately but print a useful message
##
trap_exit() {
diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2
deleted file mode 100755
index 6b7180b..0000000
--- a/src/chroot-tools/libremakepkg.gpl2
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/bin/bash
-# Contains code derived from devtools' "makechrootpkg"
-
-# Copyright 2011-2012 The Arch Linux Development Team
-# Copyright 2012 Luke Shumaker
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-chroot_init() {
- # make sure the chroot exists
- librechroot -n "$CHROOT" -l "$CHROOTCOPY" -m
-
- if [[ -r "$LIBREHOME/.gnupg/pubring.gpg" ]]; then
- install -D "$LIBREHOME/.gnupg/pubring.gpg" "$copydir/build/.gnupg/pubring.gpg"
- fi
- rm -f "$copydir/build/.makepkg.conf"
-
- mkdir -p "$copydir/pkgdest"
- mkdir -p "$copydir/srcdest"
-
- MAKEPKG_CONF=$copydir/etc/makepkg.conf set_conf_makepkg PKGDEST /pkgdest
- MAKEPKG_CONF=$copydir/etc/makepkg.conf set_conf_makepkg SRCDEST /srcdest
-
- cat > "$copydir/etc/sudoers.d/nobody-pacman" <<EOF
-Defaults env_keep += "HOME"
-nobody ALL = NOPASSWD: /usr/bin/pacman
-EOF
- chmod 440 "$copydir/etc/sudoers.d/nobody-pacman"
-}
-
-
-chroot_copy_in() {
- rm -rf "$copydir"/build/*
- cp PKGBUILD "$copydir/build/"
- (
- set +euE
- source PKGBUILD
-
- # Copy source files
- for file in "${source[@]}"; do
- file="${file%%::*}"
- file="${file##*://*/}"
- if [[ -f $file ]]; then
- cp "$file" "$copydir/srcdest/"
- elif [[ -f $SRCDEST/$file ]]; then
- cp "$SRCDEST/$file" "$copydir/srcdest/"
- fi
- done
-
- # Find all changelog and install files, even inside functions
- for i in 'changelog' 'install'; do
- while read -r file; do
- # evaluate any bash variables used
- eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
- if [[ -f $file ]]; then
- cp "$file" "$copydir/build/"
- fi
- done < <(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD)
- done
- )
-
- chown -R nobody "$copydir"/{build,pkgdest,srcdest}
-}
-
-chroot_exec() {
- local HASNET=true
- [[ $1 == -N ]] && { HASNET=false; shift; }
-
- local cmd="$*"
- cat >"$copydir/chrootexec" <<EOF
-#!/bin/bash
-. /etc/profile
-${INCHROOT} || export HOME=/build
-${INCHROOT} || cd /build
-
-${cmd}
-EOF
- chmod 755 "$copydir/chrootexec"
-
- local flags=''
- if $INCHROOT; then
- $HASNET || flags='-n'
- unshare $flags -- /chrootexec
- else
- $HASNET || flags='-N'
- librechroot $flags -n "$CHROOT" -l "$CHROOTCOPY" -r /chrootexec
- fi
-}
-
-add_to_local_repo() {
- for pkgfile in "$copydir"/pkgdest/*.pkg.tar*; do
- mkdir -p "$copydir/repo"
- pushd "$copydir/repo" >/dev/null
- cp "$pkgfile" .
- repo-add repo.db.tar.gz "${pkgfile##*/}"
- popd >/dev/null
- done
-}
-chroot_copy_out() {
- for pkgfile in "$copydir"/pkgdest/*.pkg.tar*; do
- chown "$LIBREUSER" "$pkgfile"
- mv "$pkgfile" "$PKGDEST"
- if [[ $PKGDEST != . ]]; then
- ln -s "$PKGDEST/${pkgfile##*/}" .
- fi
- done
- copy_logs
-}