summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/aur219
-rwxr-xr-xsrc/chroot-tools/buildenv28
-rwxr-xr-xsrc/chroot-tools/librechroot243
-rwxr-xr-xsrc/chroot-tools/libremakepkg253
-rwxr-xr-xsrc/chroot-tools/libremakepkg.gpl2102
-rwxr-xr-xsrc/chroot-tools/libremkchroot69
-rwxr-xr-xsrc/diff-unfree95
-rwxr-xr-xsrc/is_unfree5
-rwxr-xr-xsrc/librediff60
-rwxr-xr-xsrc/libremessages110
-rwxr-xr-xsrc/librerepkg73
-rw-r--r--src/libretools.conf150
-rwxr-xr-xsrc/pkgbuild-check-nonfree142
-rwxr-xr-xsrc/update-cleansystem68
14 files changed, 861 insertions, 756 deletions
diff --git a/src/aur b/src/aur
index 3d07cd8..12efb81 100755
--- a/src/aur
+++ b/src/aur
@@ -2,125 +2,132 @@
# Copyright 2010 Nicolás Reynolds, Joshua Ismael
# ---------- GNU General Public License 3 ----------
-
+
# This file is part of Parabola.
-
+
# Parabola 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, either version 3 of the License, or
# (at your option) any later version.
-
+
# Parabola 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.
-
+
# 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/abs.conf
-
-function usage {
- echo "Usage: $0 pkgname-from-aur1 [pkgname-from-aur2 ...]"
- echo
- echo "This script will download packages from aur to the current dir"
- echo "and check their license for nonfree issues."
- echo
- echo "Note: it depends on abs to be updated."
- echo "Install 'abs-libre' and run \`abs\` as root before working with $0"
+. /etc/libretools.conf
+. /etc/abs.conf
+
+cmd=${0##*/}
+
+usage() {
+ echo "Usage: $cmd pkgname-from-aur1 [pkgname-from-aur2 ...]"
+ echo
+ echo "This script will download packages from aur to the current dir"
+ echo "and check their license for nonfree issues."
}
-while getopts 'h' arg; do
- case $arg in
- h) usage; exit 0 ;;
- *) usage; exit 1 ;;
- esac
-done
-
-missing_deps=()
-for _pkg in ${@}; do
-
-# Remove the version
- _pkg="${_pkg%%[<>=]*}"
-
- if [ -f "${_pkg}/PKGBUILD" ]; then
- warning "${_pkg} already existed."
-
-# Check if we want to diff
- if [ -z "${DIFFTOOL}" ]; then
- continue
- else
-# Store our copy of the PKGBUILD dir
- _diff="${PWD}/${_pkg}"
- stdnull "pushd $(mktemp -d /tmp/${_pkg}.XXXX)"
- msg2 "Downloading PKGBUILD into ${PWD} for diff"
- fi
- fi
-
- msg "Downloading $_pkg..."
- wget -O - -q https://aur.archlinux.org/packages/$(echo $_pkg | sed "s/^../&\/&/")/$_pkg.tar.gz | \
- tar xzf - >/dev/null 2>&1
-
- if [ $? -ne 0 ]; then
- error "Couldn't get $_pkg"
- continue
- fi
-
- stdnull "pushd $_pkg"
-
- if [ ! -z "$_diff" ]; then
- msg2 "Diffing files"
-# Diff all files with our difftool
- for file in *; do
- ${DIFFTOOL} ${_diff}/${file} ${file}
- done
-
-# Go back to our copy to continue working
- stdnull "pushd ${_diff}"
- fi
-
- source PKGBUILD
-
- if ! pkgbuild-check-nonfree; then
- if [ $? -eq 15 ]; then
- warning "This PKGBUILD links to known unfree packages"
- fi
- fi
-
- msg2 "Checking license..."
- free=0
- for _license in ${license[@]}; do
- if [ ! -d /usr/share/licenses/common/$_license ]; then
- warning "License $_license is not a common license"
- free=1
- fi
- done
-
- if [ $free -eq 1 ]; then
- plain "Please check that the license is included in the package and
- *specially* that it respects your freedom."
- fi
-
- for _dep in ${depends[@]} ${makedepends[@]}; do
- _dep=${_dep/[<>=]*/}
- if ! is_built $_dep; then
- if ! find ${ABSROOT} -maxdepth 2 -type d -name "$_dep" | egrep "*" >/dev/null ; then
- msg2 "$_dep will be get from AUR"
- missing_deps+=($_dep)
- fi
- else
- msg2 "$_dep is on repos"
- fi
- done
-
- stdnull popd
-
-done
-
-[[ ${#missing_deps[*]} -gt 0 ]] && {
- msg2 "Retrieving missing deps: ${missing_deps[@]}"
- $0 ${missing_deps[@]}
+main() {
+ while getopts 'h' arg; do
+ case $arg in
+ h) usage; exit 0;;
+ *) usage; exit 1;;
+ esac
+ done
+
+ local missing_deps=()
+ for _pkg in "$@"; do
+
+ # Remove the version
+ _pkg="${_pkg%%[<>=]*}"
+
+ if [[ -f "${_pkg}/PKGBUILD" ]]; then
+ warning "${_pkg} already existed."
+
+ # Check if we want to diff
+ if [[ -z "${DIFFTOOL}" ]]; then
+ continue
+ else
+ # Store our copy of the PKGBUILD dir
+ _diff="${PWD}/${_pkg}"
+ stdnull "pushd $(mktemp --tmpdir -d ${_pkg}.XXXX)"
+ msg2 "Downloading PKGBUILD into ${PWD} for diff"
+ fi
+ fi
+
+ msg "Downloading $_pkg..."
+ local url=https://aur.archlinux.org/packages/${_pkg:0:2}/${_pkg}/$_pkg.tar.gz
+ wget -O - -q "$url" | tar xzf - >/dev/null 2>&1
+
+ if [[ $? -ne 0 ]]; then
+ error "Couldn't get $_pkg"
+ continue
+ fi
+
+ stdnull "pushd $_pkg"
+
+ if [[ ! -z "$_diff" ]]; then
+ msg2 "Diffing files"
+ # Diff all files with our difftool
+ for file in *; do
+ "${DIFFTOOL}" "${_diff}/${file}" "${file}"
+ done
+
+ # Go back to our copy to continue working
+ stdnull "pushd ${_diff}"
+ fi
+
+ . PKGBUILD
+
+ ################################################################
+
+ if ! pkgbuild-check-nonfree; then
+ if [[ $? = 15 ]]; then
+ warning "This PKGBUILD links to known unfree packages"
+ fi
+ fi
+
+ ################################################################
+
+ msg2 "Checking license..."
+ local free=0
+ for _license in ${license[@]}; do
+ if [[ ! -d /usr/share/licenses/common/$_license ]]; then
+ warning "License $_license is not a common license"
+ free=1
+ fi
+ done
+
+ if [[ $free -eq 1 ]]; then
+ plain "Please check that the license is included in the package and *specially* that it respects your freedom."
+ fi
+
+ ################################################################
+
+ for _dep in "${depends[@]}" "${makedepends[@]}"; do
+ _dep=${_dep/[<>=]*/}
+ if ! is_built $_dep; then
+ if ! find ${ABSROOT} -maxdepth 2 -type d -name "$_dep" | egrep "*" >/dev/null ; then
+ msg2 "$_dep will be get from AUR"
+ missing_deps+=($_dep)
+ fi
+ else
+ msg2 "$_dep is on repos"
+ fi
+ done
+
+ stdnull popd
+ done
+
+ [[ ${#missing_deps[*]} -gt 0 ]] && {
+ msg2 "Retrieving missing deps: ${missing_deps[@]}"
+ $0 ${missing_deps[@]}
+ }
+
+ exit 0
}
-exit 0
+main "$@"
diff --git a/src/chroot-tools/buildenv b/src/chroot-tools/buildenv
deleted file mode 100755
index 84a1fc2..0000000
--- a/src/chroot-tools/buildenv
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-
-trap "umount_all" 0 ERR TERM KILL
-
-user=${SUDO_USER:-${1}}
-
-umount_all() {
- for mp in home/pkgdest home/srcdest home/${user}; do
- msg "Umounting /$mp"
- umount $CHROOTDIR/$CHROOT/$mp || error "Couldn't umount"
- done
-}
-
-source /etc/libretools.conf
-
-for mp in home/pkgdest home/srcdest home/${user} var/lib/toru; do
- msg "Binding /$mp"
- mount -o bind /$mp $CHROOTDIR/$CHROOT/$mp || exit 1
-done
-
-for etc in etc/makepkg.conf etc/abs.conf etc/mtab; do
- msg "Copying config /$etc"
- cp --remove-destination /$etc $CHROOTDIR/$CHROOT/$etc || exit 1
-done
-
-$(dirname $0)/librechroot $CHROOT
-
-exit $?
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 158828b..e39b105 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -1,113 +1,172 @@
-#!/bin/bash
-# LibreChRoot
-# Enters a chroot
+#!/bin/bash -euE
+# librechroot
# Copyright 2010 Nicolás Reynolds
# Copyright 2011 Joshua Haase
-
-# ---------- GNU General Public License 3 ----------
-
+# Copyright 2012 Luke Shumaker
+#
# This file is part of Parabola.
-
+#
# Parabola 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, either version 3 of the License, or
# (at your option) any later version.
-
+#
# Parabola 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.
-
+#
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-function usage {
-
- 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 ""
-
+. /etc/libretools.conf
+
+##
+# This function is almost verbatim from makechrootpkg
+##
+sync() {
+ if [[ $CHROOTCOPY = root ]]; then
+ error "Cannot sync the root copy with itself"
+ exit 1
+ fi
+
+ lock_open_read 8 "$rootdir" "Locking clean chroot"
+
+ 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 "$chrootdir/root" "$copydir" &>/dev/null || use_rsync=true
+ else
+ use_rsync=true
+ fi
+
+ if $use_rsync; then
+ mkdir -p "$copydir"
+ rsync -a --delete -q -W -x "$CHROOTDIR/$CHROOT/root/" "$copydir"
+ fi
+ stat_done
+
+ lock_close 8
}
-function clean_chroot { # Clean packages with pacman
- cp -a "$(dirname $0)/chcleanup" "${CHROOTDIR}/${CHROOTNAME}/clean"
-
- libremessages="$(grep "libremessages" /etc/libretools.conf | cut -d" " -f2)"
-
- cat /etc/libretools.conf ${libremessages} | sed "/libremessages/d" > "${CHROOTDIR}/${CHROOTNAME}/etc/libretools.conf"
-
-
- mkarchroot -r "sh -c 'cd /build; /clean'" "${CHROOTDIR}/${CHROOTNAME}"
+usage() {
+ echo "Usage: $cmd [OPTIONS] [CHROOT] "
+ echo 'Interacts with a chroot.'
+ echo ''
+ echo "The default CHROOT is \`${CHROOT}'."
+ echo ''
+ echo 'Options:'
+ echo ' Settings:'
+ echo ' -l <COPY> Use this as the chroot copy instead of basing it'
+ echo ' on the username'
+ echo ' -N Disable networking in the chroot'
+ echo ''
+ echo ' Modes: (the last mode given will be used)'
+ echo ' -C Clean /repo in the chroot'
+ echo ' -c Clean the packages installed in the chroot'
+ echo ' -I <FILE> Install the package FILE into the chroot'
+ echo ' -i <PKG> Install the package PKG from repos into the chroot'
+ echo ' -n No-op, just make sure that the chroot exists'
+ echo ' -r <CMD> Run CMD in the chroot'
+ echo " -s Sync the copy with the 'root' copy"
+ echo ' -u Update the chroot'
+ echo ' -h Print this message'
}
-function clean_repo {
- msg "Cleaning repo for chroot: ${CHROOTDIR}/${CHROOTNAME}"
- if [ -d "${CHROOTDIR}/${CHROOTNAME}/repo" ]; then
- find "${CHROOTDIR}/${CHROOTNAME}/repo/" -mindepth 1 -delete
- else
- mkdir -p "${CHROOTDIR}/${CHROOTNAME}/repo"
- fi
- bsdtar -czf "${CHROOTDIR}/${CHROOTNAME}/repo/repo.db.tar.gz" -T /dev/null
- ln -s "repo.db.tar.gz" "${CHROOTDIR}/${CHROOTNAME}/repo/repo.db"
+main() {
+ CHROOTCOPY=$LIBREUSER
+ [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy
+
+ local mode=enter
+ local archroot_args=()
+ local ARG=''
+ while getopts 'l:NCcI:i:nrsuh' arg; do
+ case $arg in
+ l) CHROOTCOPY=$OPTARG;;
+ N) archroot_args+=(-N);;
+
+ C) mode=clean_repo;;
+ c) mode=clean_pacman;;
+ I) mode=install_file; ARG=$OPTARG;;
+ I) mode=install_pkg; ARG=$OPTARG;;
+ n) mode=noop;;
+ r) mode=run; ARG=$OPTARG;;
+ s) mode=sync;;
+ u) mode=update;;
+
+ h) usage; exit 0;;
+ *) usage; exit 1;;
+ esac
+ done
+ shift $(($OPTIND - 1))
+ case $# in
+ 0) :;;
+ 1) CHROOT="$1";;
+ *) usage; exit 1;;
+ esac
+
+ # not local
+ rootdir="${CHROOTDIR}/${CHROOT}/root"
+ copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}"
+
+ if (( EUID )); then
+ error "This script must be run as root."
+ exit 1
+ fi
+
+ # Keep this lock as long as we are running
+ # Note that '9' is the same FD number as in (mk)archroot
+ lock_open_write 9 "$copydir" "Locking chroot copy '$copy'"
+
+ if [[ ! -d $rootdir ]]; then
+ libremkchroot "$CHROOT"
+ fi
+
+ if [[ ! -d $copydir ]] && [[ $mode != sync ]]; then
+ sync
+ fi
+
+ case "$mode" in
+ clean_repo)
+ msg "Cleaning local pacman repository"
+ rm -rf "${copydir}/repo"
+ mkdir "${copydir}/repo"
+ bsdtar -czf "${copydir}/repo/repo.db.tar.gz" -T /dev/null
+ ln -s "repo.db.tar.gz" "${copydir}/repo/repo.db"
+ ;;
+ clean_pacman)
+ msg "Intelligently cleaning packages"
+ cp -a "$(dirname $0)/chcleanup" "${copydir}/clean"
+ mkdir -p "$copydir/build"
+ archroot "${archroot_args[@]}" "${copydir}" -r "cd /build; /clean"
+ ;;
+ install_file)
+ msg "Installing package file: $ARG"
+ cp "$ARG" "$copydir/${ARG##*/}"
+ archroot "${archroot_args[@]}" "$copydir" -r "pacman -U /${ARG##*/} --noconfirm"
+ rm "$copydir/${ARG##*/}"
+ ;;
+ install_pkg)
+ msg "Installing package(s): $ARG"
+ archroot "${archroot_args[@]}" "$copydir" -i $ARG
+ ;;
+ noop) :;;
+ run)
+ msg "Running command"
+ archroot "${archroot_args[@]}" "${copydir}" -r "$ARG"
+ ;;
+ sync) sync;;
+ update)
+ msg "Updating chroot"
+ archroot "${archroot_args[@]}" "${copydir}" -u
+ ;;
+ enter)
+ msg "Entering chroot"
+ archroot "${archroot_args[@]}" "${copydir}" -r bash
+ ;;
+ esac
}
-source /etc/libretools.conf
-
-if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then
- source "$XDG_CONFIG_HOME/libretools/libretools.conf"
-fi
-
-CLEANCHROOT='false'
-UPDATE='false'
-CLEANREPO='false'
-CHROOTNAME="${CHROOT:-${SUDO_USER:-root}}"
-
-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
-
-[[ "$UID" != "0" ]] && {
- error "This script must be run as root."
- exit 1
-}
-
-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
+main "$@"
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index f7924f6..b6c84c1 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -1,126 +1,195 @@
-#!/bin/bash
+#!/bin/bash -euE
+# libremakepkg
+
# Copyright 2010 - 2011 Nicolás Reynolds
# Copyright 2011 Joshua Ismael Haase Hernández
-
-# ---------- GNU General Public License 3 ----------
-
+# Copyright 2012 Luke Shumaker
+#
# This file is part of Parabola.
-
+#
# Parabola 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, either version 3 of the License, or
# (at your option) any later version.
-
+#
# Parabola 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.
-
+#
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+. /etc/libretools.conf
+
+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_extract
+# - chroot_build
+# - copy_pkgs
+
+# Boring functions #############################################################
+
+##
+# copy logs if they exist
+##
+copy_logs() {
+ for l in "$copydir"/build/*.log; do
+ chown "$LIBREUSER" "$l"
+ mv "$l" .
+ done
+}
-# set -x # uncomment for debug
-
-function copy_log { # copy logs if they exist
-
- find "${CHROOTDIR}/${CHROOT}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \;
-
+##
+# End inmediately but print a useful message
+##
+trap_exit() {
+ copy_logs
+ error "$*"
+ exit 1
}
+##
+# Usage: makepkg_conf_get SETTING [DEFAULT]
+##
+makepkg_conf_get() {
+ local setting=$1
+ if [[ -f $LIBREHOME/.makepkg.conf ]]; then
+ eval $(grep "^$setting=" "$LIBREHOME/.makepkg.conf")
+ fi
+ if [[ -z ${!setting} ]]; then
+ eval $(grep "^$setting=" "/etc/makepkg.conf")
+ fi
+ if [[ -z ${!setting} && -n ${2} ]]; then
+ eval "$setting='$2'"
+ fi
+}
-function trap_exit { # End inmediately but print a useful message
+chroot_makepkg_conf_get() {
+ local setting=$1
+ eval $(grep "^$setting=" "$copydir/etc/makepkg.conf")
+}
- copy_log
- error "$@"
- exit 1
+chroot_makepkg_conf_set() {
+ local key=$1
+ local val=$2
+ sed -i "/^$KEY=/d" "$copydir/etc/makepkg.conf"
+ echo "$key='$val'" >> "$copydir/etc/makepkg.conf"
+}
+# Functions that check for issues with the build ###############################
+
+libre_check_pkgbuild() {
+ msg "Checking PKGBUILD for issues"
+ # TODO
+ if ! pkgbuild-check-nonfree -f; 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
}
-# Trap signals from makepkg
-set -E
-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
+libre_check_src() {
+ msg "Checking src directory for issues"
+ # TODO
+}
-source /etc/libretools.conf
+libre_check_pkg() {
+ msg "Checking final package for issues"
+ # TODO
+}
-CLEANFIRST="false"
-UPDATEFIRST="false"
-CHECKNONFREE="true"
-LIBRECHROOT_ARGS=""
-MAKEPKG_ARGS=""
-function usage {
+# The main program #############################################################
- echo ''
+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 '$0 [options] [-- makepkg args]'
+ echo 'This script will build your package in a chroot.'
echo ''
echo 'OPTIONS:'
+ 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 ''
- 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 " -m <MAKEPKG> Use the command MAKEPKG instead of 'makepkg'"
+ echo " -R Repackage"
echo ''
- exit 1
+ echo ' -h Show this message'
+}
+main() {
+ # Parse command line ###################################################
+
+ CHROOTCOPY=$LIBREUSER
+ [[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy
+
+ makepkg_args=(-s --noconfirm -L)
+ REPACKAGE=false
+ MAKEPKG=makepkg
+
+ while getopts 'n:l:m:Rh' arg ; do
+ case "${arg}" in
+ n) CHROOT=$OPTARG;;
+ l) CHROOTCOPY=$OPTARG;;
+ m) MAKEPKG=$OPTARG;;
+ R) REPACKAGE=true; makepkg_args+=(-R);;
+ h) usage; exit 0;;
+ *) usage; exit 1;;
+ esac
+ done
+ shift $(($OPTIND - 1))
+ # Pass all arguments after -- right to makepkg
+ makepkg_args+=("$@")
+
+ rootdir="${CHROOTDIR}/${CHROOT}/root"
+ copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}"
+
+ # Init #################################################################
+
+ if (( EUID )); then
+ error "This script must be run as root"
+ exit 1
+ fi
+
+ if [[ ! -f PKGBUILD ]]; then
+ error "This must be run in a directory containing a PKGBUILD"
+ exit 1
+ fi
+
+ # Trap signals from makepkg
+ 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
+
+ makepkg_conf_get SRCDEST .
+ makepkg_conf_get PKGDEST .
+
+ # OK, we're starting now ###############################################
+
+ lock_open_write 9 "$copydir.lock" "Locking chroot '$copy'"
+
+ # Set target CARCH as it might be used within the PKGBUILD to select correct sources
+ chroot_makepkg_conf_get CARCH
+ export CARCH
+
+ chroot_init
+ libre_check_pkgbuild
+ $REPACKAGE || chroot_extract
+ libre_check_src
+ chroot_build
+ libre_check_pkg
+ copy_pkgs
+ copy_logs
}
-while getopts 'hcud:n:N' arg ; do
- case "${arg}" in
- h) usage ;;
- c) CLEANFIRST="true" ;;
- u) UPDATEFIRST="true" ;;
- d) CHROOTDIR="$OPTARG"
- LIBRECHROOT_ARGS='-d "$OPTARG"' ;;
- n) CHROOT="$OPTARG" ;;
- N) CHECKNONFREE="false" ;;
- esac
-done
-
-# 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 [ ! -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 "$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
-
-if "$CLEANFIRST"; then
- librechroot -c "$LIBRECHROOT_ARGS" "$CHROOT"
-fi
-
-if "$UPDATEFIRST"; then
- librechroot -u "$LIBRECHROOT_ARGS" "$CHROOT"
-fi
-
-unset CLEANFIRST UPDATEFIRST LIBRECHROOT_ARGS
-
-makechrootpkg -d -r "$CHROOTDIR" -l "$CHROOT" -- $MAKEPKG_ARGS
-ev="$?" # exit value
-
-copy_log
-
-exit $ev
+main "$@"
diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2
new file mode 100755
index 0000000..1f2d185
--- /dev/null
+++ b/src/chroot-tools/libremakepkg.gpl2
@@ -0,0 +1,102 @@
+#!/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() {
+ # no-op; make sure the chroot exists
+ librechroot -n -l "$CHROOTCOPY" "$CHROOT"
+
+ if [[ -r "$LIBREHOME/.gnupg/pubring.gpg" ]]; then
+ install -D "$HOME/.gnupg/pubring.gpg" "$copydir/build/.gnupg/pubring.gpg"
+ fi
+
+ mkdir -p "$copydir/pkgdest"
+ mkdir -p "$copydir/srcdest"
+ chroot_makepkg_conf_set PKGDEST /pkgdest
+ chroot_makepkg_conf_set 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_extract() {
+ rm -rf "$copydir"/build/*
+ cp PKGBUILD "$copydir/build/"
+ (
+ 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}
+
+ local file="$copydir/chrootextract"
+ echo '#!/bin/bash' > "$file"
+ echo '. /etc/profile' >> "$file"
+ echo 'export HOME=/build' >> "$file"
+ echo 'cd /build' >> "$file"
+ echo "sudo -u nobody ${MAKEPKG} $makepkg_args -o" >> "$file"
+ chmod 755 "$file"
+ archroot "$copydir" -r /chrootextract
+}
+
+chroot_build() {
+ local file="$copydir/chrootbuild"
+ echo '#!/bin/bash' > "$file"
+ echo '. /etc/profile' >> "$file"
+ echo 'export HOME=/build' >> "$file"
+ echo 'cd /build' >> "$file"
+ echo "sudo -u nobody ${MAKEPKG} $makepkg_args -e" >> "$file"
+ chmod 755 "$file"
+ archroot -N "$copydir" -r /chrootbuild
+}
+
+copy_pkgs() {
+ 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
+
+ chown "$LIBREUSER" "$pkgfile"
+ mv "$pkgfile" "$PKGDEST"
+ if [[ $PKGDEST != . ]]; then
+ ln -s "$PKGDEST/${pkgfile##*/}" .
+ fi
+ done
+}
diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot
index b576209..992c6e5 100755
--- a/src/chroot-tools/libremkchroot
+++ b/src/chroot-tools/libremkchroot
@@ -1,64 +1,65 @@
#!/bin/bash
-# LibreMkChroot
-# Creates a chroot
+# libremkchroot
# Copyright 2011, 2012 Luke Shumaker
-
-# ---------- GNU General Public License 3 ----------
-
+#
# This file is part of Parabola.
-
+#
# Parabola 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, either version 3 of the License, or
# (at your option) any later version.
-
+#
# Parabola 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.
-
+#
# 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
-
-if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then
- source "$XDG_CONFIG_HOME/libretools/libretools.conf"
-fi
+. /etc/libretools.conf
cmd=${0##*/}
-function usage {
- echo "Usage: $cmd [OPTIONS]"
+
+usage() {
+ echo "Usage: $cmd [OPTIONS] [CHROOT]"
echo 'This script will create a chroot to build packages in.'
echo "Use \`librechroot' to interact with the chroot after it is created."
echo ''
+ echo "The default CHROOT is \`${CHROOT}'."
+ echo ''
echo 'Options:'
echo ' -h Show this message'
echo ''
- echo ' -f Force overwrite of files in the working-dir'
- echo ''
- echo ' -d <chrootdir> Use this dir instead of "$CHROOTDIR".'
- echo " -c <pacmandir> Location of pacman cache. Default: \`/var/cache/pacman/pkg'."
echo ' -C <file> Location of pacman config file.'
echo ' -M <file> Location of makepkg config file.'
}
-mkchroot_args=();
-while getopts 'hfd:c:C:M:' arg; do
- case "$arg" in
- h) usage; exit 0 ;;
- f) mkchroot_args+=("-$arg");;
- c|C|M) mkchroot_args+=("-$arg" "$OPTARG");;
- d) CHROOTDIR=$OPTARG ;;
- ?) usage; exit 1 ;;
+main() {
+ archroot_args=();
+ while getopts 'hC:M:' arg; do
+ case "$arg" in
+ C|M) archroot_args+=("-$arg" "$OPTARG");;
+
+ h) usage; exit 0;;
+ *) usage; exit 1;;
+ esac
+ done
+ shift $(($OPTIND - 1))
+ case $# in
+ 0) :;;
+ 1) CHROOT="$1";;
+ *) usage; exit 1;;
esac
-done
-if (( EUID )); then
- error "This script must be run as root"
- exit 1
-fi
+ if (( EUID )); then
+ error "This script must be run as root"
+ exit 1
+ fi
+
+ mkdir -p "${CHROOTDIR}/${CHROOT}"
+ archroot "${chroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" -i base base-devel sudo "${CHROOTEXTRAPKG[@]}"
+}
-mkdir -p "${CHROOTDIR}"
-xargs -d'\n' mkarchroot "${mkchroot_args[@]}" "${CHROOTDIR}/root" < /etc/libretools.d/cleansystem
+main "$@"
diff --git a/src/diff-unfree b/src/diff-unfree
index a0a8d63..24ada67 100755
--- a/src/diff-unfree
+++ b/src/diff-unfree
@@ -20,66 +20,67 @@
# 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
-custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
-
-[[ "$1" == "--help" ]] && {
- msg "Diff-Unfree helps you diff build scripts from ABSLibre against
- (Unfree) ABS. Package name and repo will we guessed if you don't
- specify them."
- msg2 "Usage: $0 [community|packages] [unfree-package] [repo]"
- exit 0
-}
+. /etc/libretools.conf
+
+cmd=${0##*/}
-[[ ! -r PKGBUILD ]] && {
- error "This is not a build dir."
- exit 1
+usage() {
+ echo "Usage: $cmd [community|packages] [unfree-package] [repo]"
+ echo "Usage: $cmd --help"
+ echo "Helps you diff build scripts from ABSLibre against (Unfree) ABS."
+ echo ""
+ echo "Package name and repo will we guessed if you don't specify them."
}
-package_guess=$(basename $PWD)
+main() {
+ if [[ "$1" == "--help" ]]; then
+ usage
+ exit 0
+ fi
-repo=${1:-$(basename $(dirname $PWD))}
-package=${2:-${package_guess/-libre}}
-trunk=${3:-trunk}
+ local package_guess=${PWD##*/}
+ local repo=${1:-$(basename ${PWD%/*})}
+ local package=${2:-${package_guess%-libre}}
+ local trunk=${3:-trunk}
-tmp_dir=$(mktemp -d /tmp/${package}.XXXXXX)
+ svnrepo="packages"
+ case $repo in
+ community*) svnrepo="community";;
+ multilib*) svnrepo="community";;
+ *) :;;
+ esac
-svnrepo="packages"
-case $repo in
- community*)
- svnrepo="community"
- ;;
- multilib*)
- svnrepo="community"
- ;;
- *)
- ;;
-esac
+ if [[ ! -r PKGBUILD ]]; then
+ error "This is not a build dir."
+ exit 1
+ fi
-unfree_dir="${tmp_dir}/${svnrepo}/${package}/${trunk}"
-[[ ! -d "${tmp_dir}" ]] && {
- error "Can't create temp dir"
- exit 1
-}
+ tmp_dir="$(mktemp --tmpdir -d ${package}.XXXXXX)"
+ if [[ ! -d "${tmp_dir}" ]]; then
+ error "Can't create temp dir"
+ exit 1
+ fi
+ unfree_dir="${tmp_dir}/${svnrepo}/${package}/${trunk}"
-stdnull 'pushd "${tmp_dir}"'
+ stdnull 'pushd "${tmp_dir}"'
-msg "Getting diff from $repo/$package..."
+ msg "Getting diff from $repo/$package..."
-stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo'
+ stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo'
-cd ${svnrepo}
-svn update ${package}
+ cd ${svnrepo}
+ svn update ${package}
-# Back to start dir
-stdnull popd
+ # Back to start dir
+ stdnull popd
-msg "Diffing files"
+ msg "Diffing files"
-for _file in ${unfree_dir}/*; do
- msg2 "$(basename "${_file}")"
- ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}"
-done
+ for _file in ${unfree_dir}/*; do
+ msg2 "$(basename "${_file}")"
+ ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}"
+ done
+}
-exit $?
+main "$@"
diff --git a/src/is_unfree b/src/is_unfree
index f32c193..c2a37c9 100755
--- a/src/is_unfree
+++ b/src/is_unfree
@@ -1,11 +1,8 @@
#!/bin/bash
# Checks if a package is on blacklist
-# fail immediately on error
-set -E
+. /etc/libretools.conf
blacklist="$XDG_CONFIG_HOME/libretools/blacklist.txt"
-
egrep -q "^${1}:" "${blacklist}"
-
exit $?
diff --git a/src/librediff b/src/librediff
index 1f39eb9..6dbe41b 100755
--- a/src/librediff
+++ b/src/librediff
@@ -20,46 +20,38 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-usage() {
- echo "Usage: $0 <pkgname> [<pkgname2> ...]"
- echo "Requirements:"
- echo "* Have a <pkgname>/ directory with nonfree build scripts inside"
- echo "* Have a <pkgname>-libre/ directory with libre build scripts inside"
-}
+. /etc/libretools.conf
-# Load custom config or system-wide config
-custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
-if [ -e $custom_config ]; then
- source $custom_config
-else
- source /etc/libretools.conf
-fi
+cmd=${0##*/}
-# Print usage if no package has been given
-[[ -z "$@" ]] && {
- usage
- exit 1
+usage() {
+ echo "Usage: $cmd <pkgname> [<pkgname2> ...]"
+ echo "Requirements:"
+ echo " * Have a <pkgname>/ directory with nonfree build scripts inside"
+ echo " * Have a <pkgname>-libre/ directory with libre build scripts inside"
}
+main() {
+ local packages=("$@")
+ if [[ ${packages[#]} = 0 ]]; then
+ usage
+ exit 1
+ fi
-for package in $@; do
-# Continue on errors
- [[ ! -d ./${package} || ! -d ./${package}-libre ]] && {
- error "no matching ${package} and ${package}-libre found"
- continue
- }
-
- [[ ! -f ./${package}/PKGBUILD || ! -f ./${package}-libre/PKGBUILD ]] && {
- error "no matching PKGBUILDs found for ${package}-libre"
- continue
- }
+ for package in "${packages[@]}"; do
+ if [[ ! -f ./${package}/PKGBUILD || ! -f ./${package}-libre/PKGBUILD ]]
+ then
+ error "Build scripts not found for ${package}(-libre)"
+ else
- source ./${package}-libre/PKGBUILD
- [[ -z ${pkgbase} ]] && pkgbase=${pkgname}
+ . ./${package}-libre/PKGBUILD
+ [[ -z ${pkgbase} ]] && pkgbase=${pkgname}
-# Generate a diff file, no -r since we don't want to patch src/ nor pkg/
- diff -auN ${package} ${package}-libre > $PATCHDIR/${pkgbase}-${pkgver}-${pkgrel}.patch
+ # Generate a diff file, no -r since we don't want to patch src/ nor pkg/
+ diff -auN ${package} ${package}-libre > $PATCHDIR/${pkgbase}-${pkgver}-${pkgrel}.patch
+ done
-done
+ exit 0
+}
-exit 0
+main "$@"
diff --git a/src/libremessages b/src/libremessages
index 68badb8..ccb5fb4 100755
--- a/src/libremessages
+++ b/src/libremessages
@@ -1,10 +1,11 @@
-# Copyright (c) 2006-2010 Pacman Development Team <pacman-dev@archlinux.org>
+#!/bin/bash
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
+# Copyright (c) 2006-2010 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
# Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
# Copyright (c) 2006 by Alex Smith <alex@alex-smith.me.uk>
# Copyright (c) 2006 by Andras Voroskoi <voroskoi@frugalware.org>
+# Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
# Copyright (c) 2011 by Joshua Haase <hahj87@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
@@ -20,88 +21,65 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# gettext initialization
-export TEXTDOMAIN='libretools'
-export TEXTDOMAINDIR='/usr/share/locale'
+################################################################################
+# Inherit most functions from devtools #
+################################################################################
-# check if messages are to be printed using color
-unset ALL_OFF BOLD BLUE GREEN RED YELLOW
-if [[ -t 2 ]]; then
- # prefer terminal safe colored and bold text when tput is supported
- if tput setaf 0 &>/dev/null; then
- ALL_OFF="$(tput sgr0)"
- BOLD="$(tput bold)"
- PURPLE="${ALL_OFF}$(tput setaf 5)"
- BLUE="${BOLD}$(tput setaf 4)"
- GREEN="${BOLD}$(tput setaf 2)"
- RED="${BOLD}$(tput setaf 1)"
- YELLOW="${BOLD}$(tput setaf 3)"
- else
- ALL_OFF="\e[1;0m"
- BOLD="\e[1;1m"
- BLUE="${BOLD}\e[1;34m"
- GREEN="${BOLD}\e[1;32m"
- RED="${BOLD}\e[1;31m"
- YELLOW="${BOLD}\e[1;33m"
- PURPLE="${BOLD}\033[1;30;40m"
- fi
-fi
-readonly ALL_OFF BOLD BLUE GREEN RED YELLOW PURPLE
+# This is only installed in Parabola's distribution of devtools, not Arch's
+. /usr/share/devtools/common.sh
-stdnull() {
- eval "$@ >/dev/null 2>&1"
-}
+################################################################################
+# gettext initialization #
+################################################################################
-plain() {
- local mesg=$1; shift
- printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
+export TEXTDOMAIN='libretools'
+export TEXTDOMAINDIR='/usr/share/locale'
-msg() {
- local mesg=$1; shift
- printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
+################################################################################
+# Devtools overrides #
+################################################################################
-msg2() {
- local mesg=$1; shift
- printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
+# Override several functions with built-in text to uses gettext
warning() {
- local mesg=$1; shift
- printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+ local mesg=$1; shift
+ printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
error() {
- local mesg=$1; shift
- printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-stat_busy() {
local mesg=$1; shift
- printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" >&2
+ printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
stat_done() {
- printf "${BOLD}done${ALL_OFF}\n" >&2
+ printf "${BOLD}$(gettext "done")${ALL_OFF}\n" >&2
+}
+
+################################################################################
+# Own functions #
+################################################################################
+
+stdnull() {
+ eval "$@ >/dev/null 2>&1"
}
# Set the terminal title
-# TODO test on several terms - it works on screen/tmux
term_title() {
- printf "\033k%s\033\\" "$@"
+ local fmt=''
+ case "$TERM" in
+ screen|tmux) fmt='\ek%s\e\\';;
+ xterm*|rxvt*) fmt='\e]0;%s\a';;
+ esac
+ printf "$fmt" "$*"
}
-# usage : in_array( $needle, $haystack )
-in_array() {
- [[ $2 ]] || return 1 # Not found
-
- local needle=$1; shift
- local item
+################################################################################
+# Run one of the defined functions if invoked directly #
+################################################################################
- for item in "$@"; do
- [[ ${item#@} = $needle ]] && return 0 # Found
- done
-
- return 1 # Not Found
-}
+if [[ "${0##*/}" = libremessages ]]; then
+ _libremessages_cmd=$1
+ shift
+ "$_libremessages_cmd" "$@"
+ unset _libremessages_cmd
+fi
diff --git a/src/librerepkg b/src/librerepkg
index 5cb0fa3..85c58d9 100755
--- a/src/librerepkg
+++ b/src/librerepkg
@@ -18,55 +18,52 @@
# 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
-custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
-if [ -x $custom_config ]; then
- source $custom_config;
- unset $custom_config
-fi
-
-[[ ! -r rePKGBUILD ]] && {
- error "This build does not contains a rePKGBUILD."
- exit 1
-}
+. /etc/libretools.conf
+. /etc/makepkg.conf
+. /etc/abs.conf
-source /etc/makepkg.conf
-source /etc/abs.conf
-source rePKGBUILD
+cmd=${0##*/}
usage() {
- echo "cd to a dir with a rePKGBUILD and other file info and run"
- echo "$0 [makepkg flags]"
- echo
- echo "This script will repackage an arch package without compiling"
+ echo "cd to a dir with a rePKGBUILD and other file info and run"
+ echo "$cmd [makepkg flags]"
+ echo ""
+ echo "This script will repackage an arch package without compiling"
}
-while getopts 'h' arg; do
- case $arg in
- h) usage; exit 0 ;;
- esac
-done
-
-makepkgflags=$@
+main() {
+ while getopts 'h' arg; do
+ case $arg in
+ h) usage; exit 0 ;;
+ esac
+ done
+ makepkgflags=("$@")
-tempdir=$(mktemp -d /tmp/$(basename $PWD).XXXXX)
+ if [[ ! -r rePKGBUILD ]]; then
+ error "This build does not contains a rePKGBUILD."
+ exit 1
+ fi
+ . rePKGBUILD
-msg "Copying files"
-cp ./* ${tempdir}/
+ tempdir="$(mktemp --tmpdir -d ${PWD##*/}.XXXXX)"
-for _arch in ${arch[@]}; do
+ msg "Copying files"
+ cp ./* "${tempdir}/"
- msg "Repackaging: $pkgname $pkgver-$pkgrel ($(date -u))"
+ for _arch in "${arch[@]}"; do
+ msg "Repackaging: $pkgname $pkgver-$pkgrel ($(date -u))"
+ stdnull pushd "${tempdir}"
- stdnull pushd ${tempdir}
+ msg2 "Updating md5sums"
+ makepkg -gp rePKGBUILD >> rePKGBUILD
- echo "export CARCH=${_arch}" >> PKGBUILD
+ echo "export CARCH=${_arch}" >> rePKGBUILD
- msg2 "Updating md5sums"
- makepkg -gp rePKGBUILD >> rePKGBUILD
+ msg "Repackaging using makepkg"
+ makepkg -Lcdp rePKGBUILD "${makepkgflags[@]}"
- msg "Repackaging using makepkg"
- makepkg -Lcdp rePKGBUILD ${makepkgflags}
+ stdnull popd "${tempdir}"
+ done
+}
- stdnull popd ${tempdir}
-done
+main "$@"
diff --git a/src/libretools.conf b/src/libretools.conf
index 8032397..20c7d90 100644
--- a/src/libretools.conf
+++ b/src/libretools.conf
@@ -1,38 +1,62 @@
+#!/bin/bash
+
+################################################################################
+# misc #
+################################################################################
+
## Blacklist URL
+## Used by `pkgbuild-check-nonfree`
BLACKLIST=http://repo.parabolagnulinux.org/docs/blacklist.txt
-# Diff tool (vimdiff, gvimdiff, meld, etc)
-DIFFTOOL=vimdiff
+## Diff tool (vimdiff, gvimdiff, meld, etc)
+## Used by `aur`, `diff-unfree`
+DIFFTOOL=`which vimdiff gvimdiff meld colordiff 2>/dev/null|sed 's/\s.*//'`
-# The dir where you work on
-WORKDIR=/home/$USER/packages
-# The repos you'll be packaging for
-#
+## The repos you'll be packaging for
+## Used by `toru`, `createworkdir`, `prfullpkg`
# Tip: As early repos take precedence on $REPOS loops, you can use this as
# inverted order of precedence. Put testing repos first so fullpkg find new
# PKGBUILDs first, for instance. Toru-path uses reverse order to enforce repo
# precedence on the path cache (the last path added replaces the rest)
-REPOS=('core' 'libre' 'extra' 'community' 'libre-testing' 'social' 'sugar')
+REPOS=('core' 'libre' 'extra' 'community' 'libre-testing' 'social' 'sugar' 'pcr' 'java')
-# The architectures
+## The architectures
+## Used by `librestage`
ARCHES=('i686' 'x86_64' 'mips64el' 'any')
+################################################################################
+# chroot #
+################################################################################
+
## The directory where the chroots are stored
CHROOTDIR=/home/chroot
-# Extra packages to have installed on the chroot (besides base base-devel and sudo)
-CHROOTEXTRAPKG=(distcc ccache tsocks tokyocabinet)
+## Extra packages to have installed on the chroot (besides base base-devel and sudo)
+CHROOTEXTRAPKG=(distcc ccache tsocks)
+## The meaning of this changes based on the version of libretools+devtools
+## do NOT set it to 'root'
+CHROOT=default
+
+################################################################################
+# abslibre #
+################################################################################
-## The working chroot
-## A chroot is useful to build packages isolated from the current system and avoid
-## unwanted (as in not in dependencies) automatic library linking
-# CHROOT=$SUDO_USER
-# CHROOT=root
+# The dir where you work on
+WORKDIR=/home/$USER/packages
-## Obtains CacheDir from pacman.conf
-CACHEDIR=`grep "^#\?CacheDir" /etc/pacman.conf | cut -d'=' -f2`
+## Package signing
+# Leave commented to disable signing
+#SIGEXT=".sig"
+#SIGID="0xYOURID"
-## Parabola hostname (should be the same used on ssh_config
+## Parabola hostname
PARABOLAHOST=parabola
+## Assumes something similar in your .ssh/config:
+
+## Repo server
+# Host parabola
+# Port 1863
+# HostName repo.parabolagnulinux.org
+# User repo
## Server destination of libre packages
# Don't change unless you know what you're doing and you won't screw
@@ -45,9 +69,13 @@ ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git
## Commit Command
## Should be git or hg
## Uncomment only one of those
-#COMMITCMD=git
+COMMITCMD=git
#COMMITCMD=hg
+################################################################################
+# fullpkg #
+################################################################################
+
## Uncomment one of those or make one of your choice
# Normal fullpkg
FULLBUILDCMD="sudo libremakepkg -cuN"
@@ -68,55 +96,43 @@ HOOKPRERELEASE="ssh -fN parabola"
# succesfully
# HOOKLOCALRELEASE=""
-## Toru
+################################################################################
+# toru #
+################################################################################
+
# Section for toru's vars
TORUPATH=/var/lib/libretools/toru
-## Package signing
-# Leave commented to disable signing
-#SIGEXT=".sig"
-#SIGID="0xYOURID"
-
-# Checks if vars aren't empty
-
-for VAR in CHROOTDIR CHROOT CACHEDIR PARABOLAHOST LIBREDESTDIR \
- BLACKLIST WORKDIR REPOS ARCHES ABSLIBREGIT \
- COMMITCMD DIFFTOOL FULLBUILDCMD; do
-
- ret=0
- [[ -z ${!VAR} ]] && {
- echo "Configure $VAR var in /etc/libretools.conf"
- ret=1
- }
- [ $ret -ne 0 ] && exit 1
+################################################################################
+# This probably shouldn't be in a .conf file... #
+################################################################################
+
+LIBREUSER="${SUDO_USER:-$USER}"
+LIBREHOME="$(eval echo ~$SUDO_USER)"
+if [[ -z $XDG_CONFIG_HOME ]]; then
+ export XDG_CONFIG_HOME="${LIBREHOME}/.config"
+fi
+if [[ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]]; then
+ . "$XDG_CONFIG_HOME/libretools/libretools.conf"
+fi
+
+ret=0
+for VAR in CHROOTDIR CHROOT PARABOLAHOST LIBREDESTDIR \
+ BLACKLIST WORKDIR REPOS ARCHES ABSLIBREGIT \
+ COMMITCMD DIFFTOOL FULLBUILDCMD; do
+
+ if [[ -z ${!VAR} ]]; then
+ echo "Configure $VAR var in /etc/libretools.conf"
+ ret=1
+ fi
done
-
-source /usr/bin/libremessages
-
-## These are architecture specific files.
-## Uncomment them if you installed libretools-mips64el
-# source /etc/libretools.d/mips64el.conf
-
-## Recommended SSH Config follows
-# SSH host, it's better if you have it configured on ~/.ssh/config
-# with ControlMaster auto (and a shell opened somewhere else)
-#
-# Example:
-# Host *
-# Protocol 2
-# ControlMaster auto
-# ControlPath /tmp/ssh-%r@%h:%p
-#
-## Repo server
-# Host parabola
-# Port 22
-# HostName repo.parabolagnulinux.org
-# User parabolavnx
-# IdentityFile ~/.ssh/id_rsa
-#
-## Git server
-# Host vparabola
-# Port 1863
-# HostName parabolagnulinux.org
-# User parabola
-# IdentityFile ~/.ssh/id_rsa
+if [[ $CHROOT == root ]]; then
+ echo "Configured var CHROOT cannot equal 'root'"
+ ret=1
+fi
+if [[ $ret != 0 ]]; then
+ exit 1
+fi
+unset ret
+
+. /usr/bin/libremessages
diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree
index df0ff36..0fd480c 100755
--- a/src/pkgbuild-check-nonfree
+++ b/src/pkgbuild-check-nonfree
@@ -1,6 +1,7 @@
#!/bin/bash
# pkgbuild-check-nonfree
# Copyright 2010 Joshua Ismael Haase Hernández, Joseph Graham
+# Copyright 2012 Luke Shumaker
# ---------- GNU General Public License 3 ----------
@@ -19,15 +20,20 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-# function log_end {
+. /etc/libretools.conf
+
+cmd=${0##*/}
+ev=0
+
+# log_end() {
# kill "$teepid"
# rm "$logpipe"
# }
-# function log {
-# LOG="pkgbuild-check-nonfree-$(date -u +%Y%m%d).log"
+# log() {
+# local LOG="pkgbuild-check-nonfree-$(date -u +%Y%m%d).log"
# # ensure overridden package variables survive tee with split packages
-# logpipe="$(mktemp -u "$startdir/logpipe.XXXXXXXX")"
+# logpipe="$(mktemp)"
# mkfifo "$logpipe"
# tee "$LOG" < "$logpipe" &
# teepid=$!
@@ -35,18 +41,15 @@
# }
-function unset_pkgbuild {
-
+unset_pkgbuild() {
unset 'pkgbase' 'pkgname' 'pkgver' 'pkgrel' 'epoch' 'pkgdesc' \
'arch' 'url' 'license' 'groups' 'optdepends' 'provides' \
'conflicts' 'replaces' 'backup' 'options' 'install' \
'changelog' 'source' 'noextract' 'md5sums' 'build' \
'check' 'package' 'depends' 'makedepends' 'checkdepends'
-
}
-function assert_pkgbuild {
-
+assert_pkgbuild() {
if [ -e "$1" ]; then
source "$1"
@@ -60,16 +63,15 @@ function assert_pkgbuild {
return 1
}
-function check_replacement {
-
+check_replacement() {
[ $2 ] || return 0 # Free (not found)
local needle=$1; shift
local item
local rep
for line in $@; do
- item="$(echo "$line" | cut -d':' -f1)"
- rep="$(echo "$line" | cut -s -d':' -f2)"
+ local item="$(echo "$line" | cut -d':' -f1)"
+ local rep="$(echo "$line" | cut -s -d':' -f2)"
if [ "$item" == "$needle" ]; then
if [ -z "$rep" ]; then
@@ -84,8 +86,11 @@ function check_replacement {
return 0 # Free (not found)
}
-function get_blacklist { # Download the blacklist.
-
+##
+# Download the blacklist.
+##
+get_blacklist() {
+ mkdir -p "$XDG_CONFIG_HOME/libretools"
pushd "$XDG_CONFIG_HOME/libretools" >/dev/null
msg "Downloading the blacklist of proprietary software packages."
@@ -103,103 +108,80 @@ function get_blacklist { # Download the blacklist.
popd > /dev/null
}
-function check_deps { # Check wheter a package depends on non-free
-
+##
+# Check wheter a package depends on non-free
+##
+check_deps() {
unset_pkgbuild
-
if ! assert_pkgbuild "$1"; then
- return 1 # not PKGBUILD
+ exit 1 # not PKGBUILD
fi
msg2 "${pkgbase:-${pkgname[0]}} $pkgver $pkgrel ${epoch:-""}" # > "$logpipe"
- for pkg in ${pkgname[@]} ${depends[@]} ${makedepends[@]} ${checkdepends[@]}; do
+ for pkg in "${pkgname[@]}" "${depends[@]}" "${makedepends[@]}" "${checkdepends[@]}"; do
- lines=($(grep "$pkg" "$XDG_CONFIG_HOME/libretools/blacklist.txt" | tr " " "_"))
+ local lines=($(grep "$pkg" "$XDG_CONFIG_HOME/libretools/blacklist.txt" | tr " " "_"))
- rep="$(check_replacement $pkg ${lines[@]})"
- freedom=$?
+ local rep="$(check_replacement $pkg ${lines[@]})"
+ local freedom=$?
- if [ "$freedom" -eq 15 ]; then
+ if [[ $freedom = 15 ]]; then
warning "found $pkg" # > "$logpipe"
ev=15
- continue
-
elif [ -n "$rep" ]; then
-
if [ "$rep" = "$pkg" ]; then
plain "$pkg is repackaged with the same name." # > "$logpipe"
- continue
else
plain "$pkg -> $rep" # > "$logpipe"
- continue
fi
-
fi
-
done
-
}
-function usage {
+usage() {
# TODO: implement PKGBUILD arguments
+ echo "Usage: $cmd [OPTIONS] [PKGBUILD1 PKGBUILD2 ...]"
echo ""
- echo "$(basename $0) [options] [PKGBUILD1 PKGBUILD2 ...]"
- echo ""
- echo "OPTIONS"
+ echo "If no PKGBUILD is specified, \`./PKGBUILD' is implied"
echo ""
- echo " -h : this message"
- echo ""
- echo "If no PKGBUILD is specified, one is searched on current directory"
-
- exit 1
+ echo "Options:"
+ echo " -f Allow running as root user"
+ echo " -h Show this message"
}
-while getopts 'h' arg; do
- case "$arg" in
- h) usage ;;
- esac
-done
-
-if [ -w / ]; then
- error "Run as normal user"
-fi
-
-source /etc/libretools.conf
-if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then
- source "$XDG_CONFIG_HOME/libretools/libretools.conf"
-fi
-
-if [ -z "${BLACKLIST}" ]; then
- error "BLACKLIST variable is not set your libretools.conf file"
- exit 1
-fi
-
-if [ ! -d "$XDG_CONFIG_HOME/libretools" ]; then
- mkdir -p "$XDG_CONFIG_HOME/libretools"
-fi
-
-startdir=`pwd`
-
-get_blacklist
-# log
+main() {
+ local asroot=false
+ while getopts 'fh' arg; do
+ case "$arg" in
+ f) asroot=true;;
+ h) usage; exit 0;;
+ *) usage; exit 1;;
+ esac
+ done
+ shift $(($OPTIND - 1))
+ pkgbuilds=("$@")
+ if [[ $# < 1 ]]; then
+ pkgbuilds=("`pwd`/PKGBUILD")
+ fi
-shift $(( OPTIND - 1))
+ if [[ -w / ]] && ! $asroot; then
+ error "Run as normal user"
+ exit 1
+ fi
-msg "Looking for unfree dependencies"
+ get_blacklist
+ # log
-if [ $# -ge 1 ]; then
+ msg "Looking for unfree dependencies"
- for p in $@; do
- if [ -n "$p" ]; then
+ for p in "${pkgbuilds[@]}"; do
+ if [[ -n "$p" ]]; then
check_deps "$p"
fi
done
-else
-
- check_deps "`pwd`/PKGBUILD"
-
-fi
+ return $ev
+}
-exit $ev
+main "$@"
diff --git a/src/update-cleansystem b/src/update-cleansystem
deleted file mode 100755
index 6bec742..0000000
--- a/src/update-cleansystem
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/bash
-# Updates the cleansystem file
-# Creates a fake Parabola root and writes to cleansystem all
-# packages installable from base and base-devel plus extras.
-
-set -e
-# Copyright 2012 Nicolás Reynolds, Luke Shumaker
-
-# ---------- GNU General Public License 3 ----------
-
-# This file is part of Parabola.
-
-# Parabola 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, either version 3 of the License, or
-# (at your option) any later version.
-
-# Parabola 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.
-
-# You should have received a copy of the GNU General Public License
-# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-
-set -e
-
-# libretools.conf gives us libremessages
-source /etc/libretools.conf
-
-cleansystem=/etc/libretools.d/cleansystem
-
-cmd=${0##*/}
-usage() {
- echo "Usage: $cmd [<EXTRA_PACKAGES>]"
- echo " $cmd -h"
- echo "Creates a fake Parabola root and writes to \`$cleansystem' all"
- echo "packages installable from base and base-devel plus extras."
- echo ''
- echo 'Options:'
- echo ' -h Show this message'
-}
-
-if [ "$1" == '-h' ]; then
- usage
- exit 0
-fi
-
-if [ ! -w "$cleansystem" ]; then
- error 'This script must be run as root'
- exit 1
-fi
-
-# Maintain a clean database in the system
-db_dir="${DB:-/var/lib/libretools/clean}"
-[ ! -d "${db_dir}" ] && mkdir -p "${db_dir}"
-
-# We sync first because updating info gets printed to stdout too
-pacman -b "${db_dir}" --config /etc/pacman.conf -Sy 2>/dev/null
-pacman -b "${db_dir}" \
- --config /etc/pacman.conf \
- -Sp --print-format "%n" \
- base base-devel sudo $@ | sort > "$cleansystem"
-
-# Ensures everything's installed
-pacman -Sy --needed --noconfirm base base-devel sudo $@
-
-exit $?