summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cleansystem119
-rwxr-xr-xlibrechroot127
-rwxr-xr-xlibremakepkg174
3 files changed, 270 insertions, 150 deletions
diff --git a/cleansystem b/cleansystem
new file mode 100644
index 0000000..b91bf86
--- /dev/null
+++ b/cleansystem
@@ -0,0 +1,119 @@
+acl
+attr
+autoconf
+automake
+bash
+binutils
+bison
+bzip2
+cloog
+coreutils
+cracklib
+cronie
+cryptsetup
+db
+dbus-core
+device-mapper
+dhcpcd
+diffutils
+e2fsprogs
+expat
+fakeroot
+file
+filesystem
+findutils
+flex
+gawk
+gcc
+gcc-libs
+gdbm
+gettext
+glib2
+glibc
+gmp
+grep
+groff
+gzip
+heirloom-mailx
+iana-etc
+inetutils
+initscripts
+iproute2
+iputils
+isl
+jfsutils
+kbd
+keyutils
+krb5
+less
+libarchive
+libcap
+libfetch
+libffi
+libgcrypt
+libgpg-error
+libgssglue
+libldap
+libltdl
+libmpc
+libnl
+libpcap
+libpipeline
+libsasl
+libtirpc
+libtool
+libusb
+libusb-compat
+licenses-libre
+linux-api-headers
+linux-libre
+logrotate
+lvm2
+m4
+make
+man-db
+man-pages
+mdadm
+mkinitcpio
+mkinitcpio-busybox
+module-init-tools
+mpfr
+nano
+ncurses
+openssl
+pacman
+pacman-mirrorlist-libre
+pam
+patch
+pciutils
+pcmciautils
+pcre
+perl
+pkg-config
+popt
+ppl
+ppp
+procps
+psmisc
+readline
+reiserfsprogs
+run-parts
+sed
+shadow
+sudo
+sysfsutils
+sysvinit
+tar
+texinfo
+tzdata
+udev
+usbutils
+util-linux
+vi
+wget
+which
+wpa_supplicant
+xfsprogs
+xz
+your-freedom
+zlib
diff --git a/librechroot b/librechroot
index d3e02f1..31516ac 100755
--- a/librechroot
+++ b/librechroot
@@ -3,6 +3,7 @@
# Enters a chroot
# Copyright 2010 Nicolás Reynolds
+# Copyright 2011 Joshua Haase
# ---------- GNU General Public License 3 ----------
@@ -21,52 +22,114 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-source /etc/libretools.conf
-
function usage {
- echo "Usage: $0 chrootname"
- echo "Change to a chroot in $CHROOTDIR. Use it as root."
- echo
+
+ echo "Usage: $0 [options] [chrootname]"
+ echo "Use it as root."
+ echo ''
echo "Default chroot name: $CHROOT"
+ echo "Default chrootdir: $CHROOTDIR"
+ echo ''
+ echo "OPTIONS:"
+ echo ''
+ echo " -c : clean the chroot using pacman"
+ echo " only 'base', 'base-devel' and 'sudo' on chroot"
+ echo " -d <chrootdir> : use <chrootdir> instead of default"
+ echo " -r : clean /repo on the chroot"
+ echo " -h : this message"
+ echo " -u : update the chroot"
+ echo ""
+
}
-while getopts 'h' arg; do
- case $arg in
- h) usage; exit 0 ;;
- esac
+function clean_chroot { # Clean packages with pacman
+
+ msg "Cleaning chroot: ${CHROOTDIR}/${CHROOTNAME}"
+
+ cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/cleansystem"
+ (cat <<EOF
+#!/bin/bash
+export LANG=C
+
+count='0'
+
+while [ "\$count" -lt "3" ]; do
+
+ pkgs=(\$(comm -23 <(pacman -Qq | sort) <(sort /cleansystem)))
+
+ if [ \${#pkgs[@]} -gt 0 ]; then
+ pacman --noconfirm -Rcs \${pkgs[@]}
+ else
+ echo "clean"
+ exit 0
+ fi
+
+ declare -i "count=\$count + 1"
+
done
-[[ "$UID" != "0" ]] && {
- error "This script must be run as root."
- exit 1
-}
+echo "Cleaning failed: please report error"
-custom_config=${XDG_CONFIG_HOME}/libretools/libretools.conf
-[[ -e ${custom_config} ]] && source ${custom_config}
+EOF
+ ) > "${CHROOTDIR}/${CHROOTNAME}/clean"
-# Enter the chroot copy by default
-chrootname=${1:-$CHROOT}
-CACHEDIR=${CACHEDIR:-/var/cache/pacman/pkg}
+ chmod +x "${CHROOTDIR}/${CHROOTNAME}/clean"
+ mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}"
-[[ ! -d ${CHROOTDIR}/${chrootname} ]] && {
- error "${CHROOTDIR}/${chrootname} is not a dir."
- exit 1
+ rm "${CHROOTDIR}/${CHROOTNAME}/clean"
+ rm "${CHROOTDIR}/${CHROOTNAME}/cleansystem"
+}
+
+function clean_repo {
+ msg "Cleaning repo for chroot: ${CHROOTDIR}/${CHROOTNAME}"
+ if [ -d "${CHROOTDIR}/${CHROOTNAME}/repo" ]; then
+ rm -rf "${CHROOTDIR}/${CHROOTNAME}/repo"
+ fi
}
+source /etc/libretools.conf
-mount -t proc proc ${CHROOTDIR}/${chrootname}/proc/
-mount -t sysfs sys ${CHROOTDIR}/${chrootname}/sys/
-mount -o bind /dev ${CHROOTDIR}/${chrootname}/dev/
+if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then
+ source "$XDG_CONFIG_HOME/libretools/libretools.conf"
+fi
-# Share pacman cache
-mount -o bind ${CACHEDIR} ${CHROOTDIR}/${chrootname}/var/cache/pacman/pkg
+CLEANCHROOT='false'
+UPDATE='false'
+CLEANREPO='false'
+CHROOTNAME="${CHROOT:-${SUDO_USER:-root}}"
-cp -L /etc/resolv.conf ${CHROOTDIR}/${chrootname}/etc/resolv.conf
+while getopts 'hrcud:' arg; do
+ case $arg in
+ h) usage; exit 0 ;;
+ c) CLEANCHROOT='true' ;;
+ u) UPDATE='true' ;;
+ r) CLEANREPO='true' ;;
+ d) CHROOTDIR="$(readlink -e $OPTARG)" ;;
+ esac
+done
-chroot ${CHROOTDIR}/${chrootname} /bin/bash
+[[ "$UID" != "0" ]] && {
+ error "This script must be run as root."
+ exit 1
+}
-umount ${CHROOTDIR}/${chrootname}/proc/
-umount ${CHROOTDIR}/${chrootname}/sys/
-umount ${CHROOTDIR}/${chrootname}/dev/
-umount ${CHROOTDIR}/${chrootname}/var/cache/pacman/pkg
+shift $(($OPTIND - 1))
+
+if [ $# -eq 1 ]; then
+ CHROOTNAME="$1"
+fi
+
+if "$CLEANREPO"; then
+ clean_repo
+fi
+
+if "$CLEANCHROOT"; then
+ clean_chroot
+elif "$UPDATE"; then
+ msg "Updating chroot: ${CHROOTDIR}/${CHROOTNAME}"
+ mkarchroot -u "${CHROOTDIR}/${CHROOTNAME}"
+else
+ msg "Entering chroot: ${CHROOTDIR}/${CHROOTNAME}"
+ mkarchroot -r "bash" "${CHROOTDIR}/${CHROOTNAME}"
+fi
exit 0
diff --git a/libremakepkg b/libremakepkg
index 2f90cce..7885f1e 100755
--- a/libremakepkg
+++ b/libremakepkg
@@ -19,97 +19,22 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-source /etc/libretools.conf
-source /etc/makepkg.conf
-
-# Local vars may differ from chroot's
-LOCALPKGDEST=${PKGDEST}
-LOCALSRCDEST=${SRCDEST}
-LOCALSRCPKGDEST=${SRCPKGDEST}
-
-source ${CHROOTDIR}/${CHROOT}/etc/makepkg.conf
-
-function usage { # Display message and exit
-
- 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 the chroot before building.'
- echo ' -u updates the chroot before building.'
- echo ' -n use this dir instead of "${CHROOT}".'
- echo ' -M <--arg> passes long args to makepkg, use it as many times as needed.'
- echo
- exit 1
-}
-
-function buildenv { # Mounts *DEST from makepkg.conf
-
- msg "Building env"
-# for mp in SRCDEST PKGDEST SRCPKGDEST; do
-# The host system directory
-# lmp=LOCAL${mp}
-# msg2 "Binding ${!lmp} to ${CHROOTDIR}/${CHROOT}${!mp}"
-
-# mkdir -p "${CHROOTDIR}/${CHROOT}${!mp}"
-# mount -o bind ${!lmp} "${CHROOTDIR}/${CHROOT}${!mp}" || exit 1
-# done
-
- msg2 "Bind ${CACHEDIR} => ${CHROOTDIR}/${CHROOT}/var/cache/pacman/pkg/"
- mount -o bind ${CACHEDIR} ${CHROOTDIR}/${CHROOT}/var/cache/pacman/pkg/
-
-}
-
-function clean_chroot { # Clean packages with pacman
-
- plain "making list of packages in ${CHROOTDIR}/${CHROOTNAME}/root/"
- echo "sudo
-" > "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem"
- pacman -Sgq base base-devel >> "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem"
- (cat <<EOF
-#!/bin/bash
-export LANG=C
-
- pkgs=(\$(comm -23 <(pacman -Qq | sort) <(sort /root/cleansystem)))
-
- if [ \${#pkgs[@]} -gt 0 ]; then
- pacman --noconfirm -Rcs \${pkgs[@]}
- pacman --noconfirm -S --needed base-devel gettext
- else
- echo "clean"
- fi
-EOF
- ) > "${CHROOTDIR}/${CHROOTNAME}/clean"
- chmod +x "${CHROOTDIR}/${CHROOTNAME}/clean"
- mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}"
-
-}
+# set -x # uncomment for debug
function copy_log { # copy logs if they exist
- if [ "${USE_LOG}" == 'y' ]; then
- find ${CHROOTDIR}/${CHROOTNAME}/build/ -name "*\.log" -exec cp {} ./ \;
- fi
+ find "${CHROOTDIR}/${CHROOTNAME}/build/" -name "*\.log" -exec cp {} ./ \;
}
-function trap_exit { # End inmediately but print a useful message
-
-# args are treated as part of the message
- for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST}; do
- umount "${CHROOTDIR}/${CHROOT}${mp}"
- done
+function trap_exit { # End inmediately but print a useful message
copy_log
-
error "$@"
-
exit 1
+
}
# Trap signals from makepkg
@@ -118,69 +43,82 @@ trap 'trap_exit "(libremakepkg): TERM signal caught. Exiting..."' TERM HUP QUIT
trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT
trap 'trap_exit "(libremakepkg): An unknown error has occurred. Exiting..."' ERR
-CLEAN_FIRST="n"
-CLEAN_CACHE=""
-UPDATE_FIRST="n"
-USE_LOG='n'
-CHROOTNAME=${CHROOT}
+source /etc/libretools.conf
+
+CLEANFIRST="false"
+UPDATEFIRST="false"
+CHECKNONFREE="true"
+LIBRECHROOT_ARGS=""
MAKEPKG_ARGS=""
-libremakepkgargs='hcuUn:I:M:' # libremakepkg own args
-libremakepkgargs+='ACdefiLmop:rRs' # makepkg args
+function usage {
+
+ echo 'cd to a dir containing a PKGBUILD and run:'
+ echo '$0 [options] [-- makechrootpkg args] [-- makepkg args]'
+ echo 'This script will build your package on a chroot.'
+ echo ''
+ echo 'OPTIONS:'
+ echo ''
+ echo ' -h : show this message.'
+ echo ' -c : clean the chroot before building.'
+ echo ' -u : update the chroot before building.'
+ echo ' -d <chrootdir> : use this dir instead of "$CHROOTDIR"'
+ echo ' -n <chrootname> : use this dir instead of "$CHROOT".'
+ echo ' -N : do not check freedom issues' # As fullpkg-check will do that before
+ echo ''
+ exit 1
+
+}
-while getopts ${libremakepkgargs} arg ; do
+while getopts 'hcud:n:N' arg ; do
case "${arg}" in
h) usage ;;
- c) CLEAN_FIRST="y" ;;
- u) UPDATE_FIRST="y" ;;
- n) CHROOTNAME="$OPTARG" ;;
- M) MAKEPKG_ARGS+=" $OPTARG" ;;
- L) MAKEPKG_ARGS+=" -$arg $OPTARG"
- USE_LOG='y';;
- *) MAKEPKG_ARGS+=" -$arg $OPTARG" ;;
+ c) CLEANFIRST="true" ;;
+ u) UPDATEFIRST="true" ;;
+ d) CHROOTDIR="$OPTARG"
+ LIBRECHROOT_ARGS='-d "$OPTARG"' ;;
+ n) CHROOT="$OPTARG" ;;
+ N) CHECKNONFREE="false" ;;
esac
done
-if [ ${UID} -ne 0 ]; then
+# Pass all arguments after -- right to makechrootpkg
+MAKEPKG_ARGS="$makepkg_args ${*:$OPTIND}"
+
+if (( EUID )); then
error "This script must be run as root"
exit 1
fi
-if [ ! -r PKGBUILD ]; then # Check if we are actually on a build directory. Do this early.
+if [ ! -e PKGBUILD ]; then # Check if we are actually on a build directory. Do this early.
error "This isn't a build directory"; usage
fi
msg "Checking PKGBUILD for non-free issues"
-if ! pkgbuild-check-nonfree; then
-
- if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree
- error "PKGBUILD contains non-free issues"
- exit 15
- else
- true
+if (( CHECKNONFREE )); then
+ if ! pkgbuild-check-nonfree; then
+
+ if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree
+ error "PKGBUILD contains non-free issues"
+ exit 15
+ else
+ warning "PKGBUILD couldn't be check aganist non-free issues"
+ fi
fi
-
fi
-buildenv
-
-msg "Creating the package"
-if [ ! -d "${CHROOTDIR}/${CHROOTNAME}" ]; then # use chroot
- mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOT}" # -c option is for cache
+if (( CLEANFIRST )); then
+ librechroot -c "$LIBRECHROOT_ARGS" "$CHROOT"
fi
-if [ "${CLEAN_FIRST}" = 'y' ]; then
- msg "Cleaning"
- clean_chroot
+if (( UPDATEFIRST )); then
+ librechroot -u "$LIBRECHROOT_ARGS" "$CHROOT"
fi
-if [ "${UPDATE_FIRST}" = 'y' ]; then
- msg "Updating the chroot in use..."
- mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOTNAME}" # -c option is for cache
-fi
+unset CLEANFIRST UPDATEFIRST LIBRECHROOT_ARGS
-makechrootpkg -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS}"
-ev=$? # exit value
+makechrootpkg -r "$CHROOTDIR" -l "$CHROOT" "$MAKEPKG_ARGS"
+ev="$?" # exit value
copy_log