summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cleansystem124
-rwxr-xr-xfullpkg14
-rwxr-xr-xlibremakepkg114
3 files changed, 216 insertions, 36 deletions
diff --git a/cleansystem b/cleansystem
new file mode 100644
index 0000000..1cf9224
--- /dev/null
+++ b/cleansystem
@@ -0,0 +1,124 @@
+acl
+attr
+autoconf
+automake
+bash
+binutils
+bison
+bzip2
+cloog
+coreutils
+cracklib
+cryptsetup
+dash
+db
+dbus-core
+dcron
+device-mapper
+dhcpcd
+diffutils
+distcc
+e2fsprogs
+eventlog
+expat
+fakeroot
+file
+filesystem
+findutils
+flex
+gawk
+gcc
+gcc-fortran
+gcc-libs
+gcc-objc
+gdbm
+gen-init-cpio
+gettext
+glib2
+glibc
+gmp
+grep
+gzip
+heirloom-mailx
+iana-etc
+initscripts
+iproute2
+iputils
+isl
+jfsutils
+kbd
+kernel26-libre
+keyutils
+krb5
+less
+libarchive
+libcap
+libedit
+libfetch
+libgcrypt
+libgpg-error
+libldap
+libmpc
+libnl
+libpcap
+libpipeline
+libretools
+libretools
+libsasl
+libtool
+libusb
+libusb-compat
+licenses-libre
+linux-api-headers
+logrotate
+lvm2
+m4
+make
+mdadm
+mkinitcpio
+mkinitcpio-busybox
+module-init-tools
+mpfr
+nano
+ncurses
+net-tools
+openssh
+openssl
+pacman
+pacman-mirrorlist-libre
+pam
+patch
+pciutils
+pcmciautils
+pcre
+perl
+pkg-config
+popt
+ppl
+ppp
+procps
+psmisc
+readline
+reiserfsprogs
+rp-pppoe
+rsync
+sed
+shadow
+sudo
+sysfsutils
+syslog-ng
+sysvinit
+tar
+tcp_wrappers
+texinfo
+tzdata
+udev
+usbutils
+util-linux
+vi
+wget
+which
+wpa_supplicant
+xfsprogs
+xz
+zlib
diff --git a/fullpkg b/fullpkg
index 31bf835..f6640dc 100755
--- a/fullpkg
+++ b/fullpkg
@@ -407,6 +407,13 @@ if [ ${build_only} == 'n' ]; then
fi
fi
+# If the queue file isn't writable go into offline mode
+[ ! -w $queue_file ] && {
+ error "Can't write queue file"
+ OFFLINE=true
+}
+
+
# Only on level 0
if [ $level -eq 0 ]; then
# if build_dir exist use it, else make a build_dir
@@ -423,6 +430,7 @@ if [ $level -eq 0 ]; then
# Build only
[ ${build_only} == 'y' ] && {
+ msg "Build Packages"
_pkg_build
exit 0
}
@@ -473,12 +481,6 @@ find_deps || {
## START Building
msg "Building packages:"
-# If the queue file isn't writable go into offline mode
-[ ! -w $queue_file ] && {
- error "Can't write queue file"
- OFFLINE=true
-}
-
# Build the package
_pkg_build
diff --git a/libremakepkg b/libremakepkg
index 2226f81..dfcdbe0 100755
--- a/libremakepkg
+++ b/libremakepkg
@@ -20,30 +20,65 @@
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
source /etc/libretools.conf
+source /etc/makepkg.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 '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 'OPTIONS:'
echo
- echo " -h : show this message."
- echo " -c : cleans CHCOPY before building."
- echo " -u : updates CHROOT before building."
- echo " -n : use this dir instead of CHCOPY."
- echo " -M \"makepkg long arg\" : passes long args to makepkg, use it as many times as needed."
- echo " -I pkgname : install this package, use it as many times needed."
+ 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 "${CHCOPY}".'
+ echo ' -I <pkg> install this package, use it as many times needed.'
+ echo ' -M <--arg> passes long args to makepkg, use it as many times as needed.'
echo
}
-_CLEAN=""
+function buildenv {
+ msg "Building env"
+ for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST} ${WORKDIR}; do
+ msg2 "binding /$mp"
+ mkdir -p "${CHROOTDIR}/${CHCOPY}${mp}"
+ mount -o bind ${mp} "${CHROOTDIR}/${CHCOPY}${mp}" || exit 1
+ done
+
+ for config in etc/makepkg.conf etc/pacman.conf etc/mtab; do
+ msg2 "copying config /$etc"
+ cp --remove-destination /$etc $CHROOTDIR/$CHCOPY/$etc || exit 1
+ done
+}
+
+# End inmediately but print a useful message
+trap_exit() {
+
+ for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST} ${WORKDIR}; do
+ umount "${CHROOTDIR}/${CHCOPY}${mp}"
+ done
+
+ error "$@"
+
+ exit 1
+}
+
+## Trap signals
+# From makepkg
+set -E
+trap 'trap_exit "TERM signal caught. Exiting..."' TERM HUP QUIT
+trap 'trap_exit "Aborted by user! Exiting..."' INT
+trap 'trap_exit "An unknown error has occurred. Exiting..."' ERR
+
+CLEAN_FIRST="n"
CLEAN_CACHE=""
-update_first="n"
-use_log='n'
-chrootname=${CHCOPY}
-_PKGINSTALL=""
-_MAKEPKG_ARGS=""
+UPDATE_FIRST="n"
+USE_LOG='n'
+CHROOTNAME=${CHCOPY}
+PKGINSTALL=""
+MAKEPKG_ARGS=""
+
#libremakepkg own args
libremakepkgargs='hcun:I:M:'
#now makepkg args
@@ -52,44 +87,63 @@ libremakepkgargs+='ACdefiLmop:rRs'
while getopts ${libremakepkgargs} arg ; do
case "${arg}" in
h) usage; exit 0 ;;
- c) _CLEAN="-c" ;;
+ c) CLEAN_FIRST="y" ;;
u) update_first="y" ;;
n) chrootname="$OPTARG"; echo $chrootname ;;
- I) _PKGINSTALL+="-I $OPTARG " ;;
- M) _MAKEPKG_ARGS+=" $OPTARG" ;;
- L) _MAKEPKG_ARGS+=" -$arg $OPTARG"
+ I) PKGINSTALL+="-I $OPTARG " ;;
+ M) MAKEPKG_ARGS+=" $OPTARG" ;;
+ L) MAKEPKG_ARGS+=" -$arg $OPTARG"
use_log='y';;
- *) _MAKEPKG_ARGS+=" -$arg $OPTARG" ;;
+ *) MAKEPKG_ARGS+=" -$arg $OPTARG" ;;
esac
done
-if [ ! -w / ]; then
+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 ||{
-# pkgbuild-check-nonfree uses 15 for nonfree and
-# other errors if something failed.
- if [[ $? -eq 15 ]]; then
+ if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree
error "PKGBUILD contains non-free issues"
exit 15
fi
}
-if [ $update_first = y ]; then
- msg "Updating the main chroot"
+if [ "${UPDATE_FIRST}" = y ]; then
+ msg "Updating the chroot in use"
# -c option in mkarchroot indicates cache
- mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOT}"
+ mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOTNAME}"
+
+elif [ "${CLEAN_FIRST}" = y ]; then
+ msg "Cleaning ..."
+ cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root"
+ (cat <<EOF
+#!/bin/bash
+export LANG=C
+
+pkgs=($(comm -23 <(pacman -Qq | sort) <(sort /root/cleansystem)))
+
+[ ${#pkgs[@]} -gt 0 ] && pacman --noconfirm -Rcs ${pkgs} || echo "done"
+
+EOF
+ ) > "${CHROOTDIR}/${CHROOTNAME}/clean"
+ mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}"
+
+elif [ -n ${PKGINSTALL} ]; then
+ msg "Installing packages"
+ makechrootpkg -r ${PKGINSTALL}
fi
+buildenv
msg "Creating the package"
-makechrootpkg $_CLEAN -r ${CHROOTDIR} -l "${chrootname}" $_PKGINSTALL -- $_MAKEPKG_ARGS
+makechrootpkg -r ${CHROOTDIR} -l "${chrootname}" -- ${MAKEPKG_ARGS}
ev=$? # exit value
-[ "$use_log" == 'y' -a -e ${CHROOTDIR}/${chrootname}/build/*.log ] && {
+[ "${USE_LOG}" == 'y' -a -e ${CHROOTDIR}/${chrootname}/build/*.log ] && {
cp ${CHROOTDIR}/${chrootname}/build/*.log ./
}
+
exit $ev