summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Reynolds <fauno@kiwwwi.com.ar>2012-01-21 11:12:01 -0300
committerNicolas Reynolds <fauno@kiwwwi.com.ar>2012-01-21 11:12:01 -0300
commit918e09f1a47dc3d23440f08a91d91d31d62dcb5a (patch)
treeeffadb1e2c76d3e06975c92516647148ed9f420a
parent0e9e94d70a0442e2c0aebdfb282269e90d688712 (diff)
parent971e5b7d0cd614e1be3a82380ef16911f2d9cefe (diff)
Merge branch 'master' into fauno
Conflicts: fullpkg toru
-rw-r--r--AUTHORS2
-rwxr-xr-xaur6
-rw-r--r--cleansystem89
-rwxr-xr-xfullpkg376
-rwxr-xr-xfullpkg-build211
-rw-r--r--fullpkg-find194
-rwxr-xr-xis_built17
-rwxr-xr-xlibrechroot127
-rwxr-xr-xlibrecommit2
-rwxr-xr-xlibremakepkg175
-rwxr-xr-xlibremessages59
-rwxr-xr-xlibremkchroot67
-rwxr-xr-xlibrerelease11
-rwxr-xr-xlibrerepkg23
-rwxr-xr-xlibrestage7
-rw-r--r--libretools.conf24
-rw-r--r--mips64el/mips64el.conf4
-rwxr-xr-xpkgbuild-check-nonfree177
-rwxr-xr-xtoru56
19 files changed, 1000 insertions, 627 deletions
diff --git a/AUTHORS b/AUTHORS
index c35d4e3..6ab8015 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,2 @@
-Joshua Ismael
+Joshua Haase
Nicolás Reynolds
diff --git a/aur b/aur
index ca7d587..1b17358 100755
--- a/aur
+++ b/aur
@@ -39,9 +39,13 @@ missing_deps=()
for _pkg in ${@}; do
# Remove the version
-# TODO check downloaded PKGBUILD version
_pkg="${_pkg%%[<>=]*}"
+ if [ -f "${_pkg}/PKGBUILD" ]; then
+ warning "${_pkg} already existed. skipping..."
+ continue
+ fi
+
msg "Downloading $_pkg..."
wget -O - -q http://aur.archlinux.org/packages/$_pkg/$_pkg.tar.gz | \
tar xzf - >/dev/null 2>&1
diff --git a/cleansystem b/cleansystem
index 8da434b..b91bf86 100644
--- a/cleansystem
+++ b/cleansystem
@@ -1,55 +1,111 @@
-bzip2
-filesystem
-initscripts
-licenses-libre
-linux-libre
-pacman
-pacman-mirrorlist-libre
-your-freedom
+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
-syslog-ng
sysvinit
tar
texinfo
+tzdata
udev
usbutils
util-linux
@@ -58,15 +114,6 @@ wget
which
wpa_supplicant
xfsprogs
-autoconf
-automake
-bison
-fakeroot
-flex
-gcc
-libtool
-m4
-make
-patch
-pkg-config
-sudo
+xz
+your-freedom
+zlib
diff --git a/fullpkg b/fullpkg
index a282926..227f329 100755
--- a/fullpkg
+++ b/fullpkg
@@ -3,39 +3,18 @@
# Builds packages from ABS recursively. It tries to find dependencies that
# aren't built or need update and then makepkg them in order.
-# TODO move __build to chroot
-
-source /etc/makepkg.conf
-source /etc/abs.conf
-source /etc/libretools.conf
-
-if [ -z $XDG_CONFIG_HOME ]; then # Avoid /libretools dir doesn't exist errors
-
- error "There's no XDG_CONFIG_HOME var set"; exit 1
-
-elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then
-
- source $XDG_CONFIG_HOME/libretools/libretools.conf
-
-fi
-
usage() {
echo "cd to a dir containing a PKGBUILD and run:"
- echo "$0 [options]"
- printf "This script will check dependencies, build them if possible "
- printf "and stage the packages on it's repo."
- echo
+ echo "$0 [build_dir]"
+ echo ""
+ echo "This script will check dependencies, build them if possible "
+ echo "and stage the packages on it's repo."
+ echo ""
echo "OPTIONS:"
echo " -h : this message."
- echo " -a absdir : set absdir as ABSROOT."
- echo " -b build_dir : use a fullpkg build_dir and only build."
- echo " -c : check deps only, do not build."
- echo " -d build_dir : use this dir to build. Defaults to mktemp."
- echo " -n : don't update pacman db."
- echo " -m max_level : check deps until this level"
- echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\""
- echo
+ echo ""
+ echo "Wrapper for \`fullpkg-find' and \`fullpkg-build'"
exit 1
}
@@ -48,347 +27,14 @@ where_is() {
cut -d: -f2 2>/dev/null
}
-# Removes a package from the buildorder
-# $1 package name
-# $2 buildorder file
-remove_buildorder() {
- grep -Evw "${1}" ${2} > ${2}2
- mv -f ${2}2 ${2}
-
- return $?
-}
-
-# Get repo name. Asumes ${ABSROOT}/repo/package/PKGBUILD
-guess_repo() {
- basename $(dirname $(pwd))
-}
-
-# return : full version spec, including epoch (if necessary), pkgver, pkgrel
-# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel )
-get_fullver() {
- if [[ $1 -eq 0 ]]; then
-# zero epoch case, don't include it in version
- echo $2-$3
- else
- echo $1:$2-$3
- fi
-
-}
-
-# Cleans the build_dir.
-cleanup() {
-# Do nothing or already cleaned.
- [[ "${do_cleanup}" = false || ! -d ${build_dir} ]] && return 0
-
-# Only do cleanup on level 0.
- msg "Cleaning up..."
- [ $level -eq 0 ] && rm -rf $build_dir/
-
-}
-
-# Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated.
-find_deps() {
-# Check this level
- source PKGBUILD
-
-# unset PKGBUILD variables
- unset pkgdesc url license groups optdepends provides conflicts replaces \
- backup options install changelog source noextract md5sums build \
- check package
- for _pkg in ${pkgname[@]}; do
- unset package_${_pkg} >/dev/null 2>&1
- done
-
- local repo=${repo:-$(guess_repo)}
- local pkgbase=${pkgbase:-${pkgname[0]}}
-# Provide a default 0 to epoch
- local epoch=${epoch:-0}
- local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel})
-
-# Check if the package is already built
- if is_built "${pkgbase}>=${fullver}"; then
-# pkg is built and updated
- exit 0
- fi
-
-# greater levels are built first
- echo "${level}:${pkgbase}" >>"${build_dir}/BUILDORDER"
-# PKGBUILD is already there
- if [ -d "${build_dir}/${pkgbase}" ]; then
- exit 0
-# Copy dir to build_dir
- else
- cp -r ../${pkgbase}/ ${build_dir}/
-
-# to identify repo later
- echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO"
- fi
-
-# current package plus a space for every level
- msg2 "%${level}s${pkgbase}-${fullver}"
-
-## Check next levels
- declare -i next_level=$level+1
-
-# All deps in separate line, only once, without version.
- deps=($(echo "${depends[@]} ${makedepends[@]}" | \
- sed "s/[=<>]\+[^ ]\+//g" | \
- tr ' ' "\n" | \
- sort -u))
-
- for _dep in ${deps[@]}; do
-
- msg2 "Checking ${_dep}"
-
- local found=false
- local pkgdir=$(where_is ${_dep})
-
- if [ -d "${pkgdir}" ]; then
- found=true
-
- pushd "${pkgdir}" > /dev/null
-# runs itself on dep's PKGBUILD dir
- $0 -c -d ${build_dir} -l ${next_level}
-
-# probable circular deps
- [ $? -eq 20 ] && return 20
- popd > /dev/null
- else
- error "Not found"
- echo "dep_not_found:$_dep" >>$build_dir/log
- fi
-
- done
-
-## End variable block
-
- unset next_level dir
-}
-
-__build() {
- pushd ${build_dir} >/dev/null
-
-# greater levels must be built first
- build_packages=($(sort -gr $buildorder | cut -d: -f2))
-
- while [ ${#build_packages[@]} -ge 1 ]; do
- pushd $build_dir/${build_packages[0]} >/dev/null
- source PKGBUILD
-
- msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel"
-
- msg2 "Checking for non free deps"
- pkgbuild-check-nonfree || {
-# this error means nonfree others means fail.
- if [ $? -eq 15 ]; then
-
- echo "nonfree:$(basename $PWD)" >>$build_dir/log
-
-# take out package from $buildorder
- remove_buildorder "$(basename $PWD)" $buildorder
-
-# build next package
- continue
- fi
- }
-
- msg2 "Building $(basename $PWD)"
-
-# this buildcmd is on libretools.conf
- $FULLBUILDCMD; r=$?
-
- case $r in
-
-## Succesfull build
- 0)
-
- plain "The build was succesful."
- if source .INFO && [ -n $repo ]; then
-
-# Calls a local release script if it's used
- if [ ! -z $HOOKLOCALRELEASE ]; then
- find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo
- fi
-
- librestage $repo || echo "unstaged:$(basename $PWD)" >>$build_dir/log
-
- msg "Updating pacman db and packages"
- sudo pacman -Sy || true
-
- fi
-
- echo "built:$(basename $PWD)" >>$build_dir/log
- ;;
-
-# # Build failed
- *)
- error "There were errors while trying to build the package."
- echo "failed:$(basename $PWD)" >>$build_dir/log
- ;;
- esac
-
- remove_buildorder "${build_packages[0]}" $buildorder || true
-
-# which is next package?
- build_packages=($(sort -gr $buildorder | cut -d: -f2))
- popd > /dev/null
- done
-
- pkgs=($(grep "nonfree:" $build_dir/log)) && {
- error "Those packages contain nonfree deps:"
- echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2
- }
-
- pkgs=($(grep "built:" $build_dir/log)) && {
- msg "Those packages were built and staged:"
- echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2
- }
-
- pkgs=($(grep "failed:" $build_dir/log)) && {
- error "Those packages failed to build:"
- echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2
- }
-
- pkgs=($(grep "unstaged:" $build_dir/log)) && {
- error "Those packages couldn't be staged because of missing reponame:"
- echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2
- }
-
- popd >/dev/null
-}
-
-# End inmediately but print a useful message
-trap_exit() {
- error "$@"
- warning "Leftover files left on $build_dir"
-
- exit 1
-}
-
-# Trap signals from makepkg
-set -E
-trap 'cleanup' 0
-trap 'trap_exit "(prfullpkg:${level}) TERM signal caught. Exiting..."' TERM HUP QUIT
-trap 'trap_exit "(prfullpkg:${level}) Aborted by user! Exiting..."' INT
-trap 'trap_exit "(prfullpkg:${level}) An unknown error has occurred. Exiting..."' ERR
-
-force_build=""
-level=0
-noupdate=false
-build_only=false
-check_deps_only=false
-do_cleanup=false
-max_level=21
-
-while getopts 'ha:b:cCd:l:nm:r:' arg; do
- case $arg in
+while getopts 'haA:l:nm:' arg; do
+ case "$arg" in
h) usage ;;
- a) ABSROOT="$OPTARG" ;;
- b) build_only=true
- build_dir="$OPTARG"
-
- if [ -z "${build_dir}" ]; then
- usage
- fi
-
- if [ ! -r "${build_dir}/BUILDORDER" ] ; then
- error "${build_dir}/BUILDORDER doesn't exist."
- exit 1
- fi
-
- ;;
- c) check_deps_only=true ;;
- C) do_cleanup=true;;
- d) build_dir="$OPTARG" ;;
-# hidden option to know dep level.
- l) level=$OPTARG ;;
- n) noupdate=true;;
- m) max_level=$OPTARG ;;
- r) FULLBUILDCMD="$OPTARG" ;;
esac
done
-if ! $build_only; then
-
-# Check if we are actually on a build directory. Do this early.
- if [ ! -r PKGBUILD ]; then
- error "This isn't a build directory"
- usage
- fi
-
-# Run the pre build hook
- if [ ! -z "${HOOKPKGBUILDMOD}" ]; then
- ${HOOKPKGBUILDMOD}
- fi
-
-fi
-
-if [ ${level} -eq 0 ]; then
-
-# use -d option or else mktemp
- build_dir="${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)}"
-
-# in case of custom -d option
- if [ ! -d "${build_dir}" ]; then
- mkdir -p "${build_dir}"
- else
-# files already there can screw find_deps
- cleanup
- fi
-
-# make files for log and buildorder
- touch "${build_dir}"/{log,BUILDORDER}
- buildorder="${build_dir}/BUILDORDER"
-
- if ! $noupdate; then
-
- msg "Updating pacman db"
- sudo pacman -Sy --noconfirm || true
-
- fi
-
- if $build_only; then
-
- msg "Building Packages"
-
- __build
-
- exit 0
-
- fi
-
- msg "Checking dependencies"
-fi
-
-# Probable circular deps
-[ $level -ge $max_level ] && exit 20
-
-# Find the dependencies on the ABS itself
-find_deps || {
-
-# Probable circular deps
- if [ $? -eq 20 ]; then
-
-# Show error only on level 0
- if [ $level -eq 0 ]; then
- error "Check for circular deps on $build_dir/BUILDORDER";
- fi
-
- fi
-# Pass message 20
- exit 20
-}
-
-# only build on level 0
-if (( check_deps_only )) || [ $level -gt 0 ]; then
- exit 0
-fi
-
-# Build the packages
-msg "Building packages:"
-__build
+shift $(( OPTIND - 1 ))
-echo
-msg2 "Check if your system works fine and librerelease if it does."
+fullpkg-find "$1" && fullpkg-build -N "$1"
exit 0
diff --git a/fullpkg-build b/fullpkg-build
new file mode 100755
index 0000000..b497db5
--- /dev/null
+++ b/fullpkg-build
@@ -0,0 +1,211 @@
+#!/bin/bash
+# set -x # uncomment for debug
+# Builds packages from ABS recursively. It tries to find dependencies that
+# aren't built or need update and then makepkg them in order.
+
+# TODO move __build to chroot
+
+source /etc/makepkg.conf
+source /etc/libretools.conf
+
+if [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then
+ source $XDG_CONFIG_HOME/libretools/libretools.conf
+fi
+
+
+## List packages on log that are on status
+## usage: list_pkgs <status> <message>
+#
+## status: nonfree, built, failed, unstaged
+list_pkgs() {
+ msg="$2"
+ local pkgs=($(grep "$1:" $build_dir/log)) && {
+ msg "$2"
+ echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2
+ }
+}
+
+# return : full version spec, including epoch (if necessary), pkgver, pkgrel
+# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel )
+get_fullver() {
+ if [[ $1 -eq 0 ]]; then
+# zero epoch case, don't include it in version
+ echo $2-$3
+ else
+ echo $1:$2-$3
+ fi
+
+}
+
+## Check all build_dir, fails if one PKGBUILD is nonfree
+check_nonfree() {
+ find "$build_dir" -name PKGBUILD \
+ -exec pkgbuild-check-nonfree {} +
+ if [ "$?" -eq 15 ]; then
+ error "Some PKGBUILD have nonfree problems"
+ exit 15
+ fi
+
+}
+
+# Removes a package from the buildorder
+# $1 package name
+# $2 buildorder file
+remove_buildorder() {
+ grep -Evw "${1}" ${2} > ${2}2
+ mv -f ${2}2 ${2}
+
+ return $?
+}
+
+succesfull_build() {
+
+ if [ "$RUN" != "$FULLBUILDCMD" ]; then
+ return 0 # Custom command or download sources
+ fi
+
+ if source .INFO && [ -n "$repo" ]; then
+
+ if [ ! -z "$HOOKLOCALRELEASE" ]; then
+ find -name "*.pkg.tar.?z" -print0 | xargs -0 "$HOOKLOCALRELEASE" "$repo"
+ fi
+
+ librestage $repo || echo "unstaged:$(basename $PWD)" >>$build_dir/log
+
+ msg "Updating pacman db and packages"
+ sudo pacman -Sy || true
+
+ fi
+
+ echo "built:$(basename $PWD)" >>$build_dir/log
+}
+
+build_description() {
+ list_pkgs "nonfree" "Those packages contain nonfree deps:"
+ list_pkgs "built" "Those packages were built and staged:"
+ list_pkgs "failed" "Those packages failed to build:"
+ list_pkgs "unstaged" "Those packages couldn't be staged (missing reponame):"
+}
+
+__build() {
+ pushd ${build_dir} >/dev/null
+
+ build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first
+
+ while [ ${#build_packages[@]} -ge 1 ]; do
+
+ pushd "$build_dir/${build_packages[0]}" >/dev/null
+
+ if [ -n "${HOOKPKGBUILDMOD}" ]; then
+ ${HOOKPKGBUILDMOD} || true
+ fi
+
+ eval "$RUN"; r=$?
+
+ case $r in
+
+ 0) succesfull_build ;;
+
+ *) error "There were errors while trying to build the package."
+ echo "failed:$(basename $PWD)" >>$build_dir/log
+ ;;
+ esac
+
+ remove_buildorder "${build_packages[0]}" $buildorder || true
+
+# which is next package?
+ build_packages=($(sort -gr $buildorder | cut -d: -f2))
+ popd > /dev/null
+ done
+
+ popd >/dev/null
+}
+
+# End inmediately but print a useful message
+trap_exit() {
+ error "$@"
+ warning "Leftover files left on $build_dir"
+ mv .BUILDORDER BUILDORDER
+ exit 1
+}
+
+# Trap signals from makepkg
+set -E
+trap 'trap_exit "(fullpkg-build) TERM signal caught. Exiting..."' TERM HUP QUIT
+trap 'trap_exit "(fullpkg-build) Aborted by user! Exiting..."' INT
+trap 'trap_exit "(fullpkg-build) An unknown error has occurred. Exiting..."' ERR
+
+CLEANUP="false"
+CHECKNONFREE="true"
+RUN="$FULLBUILDCMD"
+MESSAGE="Building packages"
+
+usage() {
+
+ echo ""
+ echo "$(basename $0) [options] <build_dir>"
+ echo ""
+ echo "Builds packages from build_dir, create a build_dir using:"
+ echo "'fullpkg-find <build_dir>'"
+ echo ""
+ echo "If no <build_dir> is specified, it uses the current directory."
+ echo ""
+ echo "OPTIONS:"
+ echo " -h : this message."
+ echo " -c : clean <build_dir> on succesfull build"
+ echo " -N : don't check for freedom issues." #Also made by fullpkg-find
+ echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\"."
+ echo " -g : get sources for building packages on build_dir."
+ echo ""
+ exit 1
+
+}
+
+while getopts 'hNr:g' arg; do
+ case $arg in
+ h) usage ;;
+ c) CLEAN ;;
+ N) CHECKNONFREE="false" ;;
+ r) RUN="$OPTARG"
+ MESSAGE="Executing custom action";;
+ g) RUN='makepkg -g > /dev/null'
+ MESSAGE="Downloading packages";;
+ esac
+done
+
+shift $(( OPTIND - 1 ))
+build_dir="${1:-`pwd`}"
+buildorder="${build_dir}/BUILDORDER"
+
+if [ ! -e "$buildorder" ]; then
+ error "This is not a build_dir. Make one using fullpkg."
+ usage
+else
+# backup BUILDORDER
+ cp "$buildorder" "$build_dir/.BUILDORDER"
+fi
+
+if "$CHECKNONFREE"; then
+ check_nonfree
+fi
+
+if [ -z "$FULLBUILDCMD" ]; then
+ error "Set your FULLBUILDCMD on libretools.conf"
+fi
+
+msg "$MESSAGE"
+__build
+
+if [ "$RUN" != "$FULLBUILDCMD" ]; then
+ # Used for downloading or custom command
+ mv "$build_dir/.BUILDORDER" "$buildorder"
+ exit 0
+elif "$CLEANUP"; then
+ find "$build_dir" -mindepth 1 -delete
+fi
+
+build_description
+
+plain "Test packages on and if they work fine librerelease."
+
+exit 0
diff --git a/fullpkg-find b/fullpkg-find
new file mode 100644
index 0000000..25565ae
--- /dev/null
+++ b/fullpkg-find
@@ -0,0 +1,194 @@
+#!/bin/bash
+# set -x # uncomment for debug
+# Builds packages from ABS recursively. It tries to find dependencies that
+# aren't built or need update and then makepkg them in order.
+
+# TODO: fullpkg-find should find packages wich depend on the
+# package to be build, so we can avoid "missing $name.so errors"
+
+# Get repo name. Asumes ${ABSROOT}/repo/package/PKGBUILD
+guess_repo() {
+ basename $(dirname $(pwd))
+}
+
+# return : full version spec, including epoch (if necessary), pkgver, pkgrel
+# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel )
+get_fullver() {
+ if [[ $1 -eq 0 ]]; then
+# zero epoch case, don't include it in version
+ echo $2-$3
+ else
+ echo $1:$2-$3
+ fi
+
+}
+
+# Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated.
+find_deps() {
+# Check this level
+ source PKGBUILD
+
+ local repo="${repo:-$(guess_repo)}"
+ local pkgbase="${pkgbase:-${pkgname[0]}}"
+ local fullver="$(get_fullver ${epoch:-0} ${pkgver} ${pkgrel})"
+
+ if ! pkgbuild-check-nonfree > /dev/null 2> /dev/null; then
+ if [ "$?" -eq 15 ]; then
+ error "pkgbase" has nonfree issues
+ return 15
+ fi
+ fi
+
+ if is_built "${pkgbase}>=${fullver}"; then
+ exit 0 # pkg is built and updated
+ fi
+
+# greater levels are built first
+ echo "${LEVEL}:${pkgbase}" >>"$build_dir/BUILDORDER"
+# PKGBUILD is already there
+ if [ -d "${build_dir}/${pkgbase}" ]; then
+ exit 0
+# Copy dir to build_dir
+ else
+ cp -r ../${pkgbase}/ ${build_dir}/
+
+# to identify repo later
+ echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO"
+ fi
+
+# current package plus a space for every level
+ msg2 "%${LEVEL}s${pkgbase}-${fullver}"
+
+## Check next levels
+ declare -i next_level=$LEVEL+1
+
+# All deps in separate line, only once, without version.
+ deps=($(echo "${depends[@]} ${makedepends[@]}" | \
+ sed "s/[=<>]\+[^ ]\+//g" | \
+ tr ' ' "\n" | \
+ sort -u))
+
+ for _dep in ${deps[@]}; do
+
+ local found=false
+ local pkgdir=$(toru -p ${_dep})
+
+ if [ -n "$pkgdir" -a -d "${pkgdir}" ]; then
+ found=true
+
+ pushd "${pkgdir}" > /dev/null
+# runs itself on dep's PKGBUILD dir
+ $0 -l ${next_level} ${build_dir}
+
+# probable circular deps
+ [ $? -eq 20 ] && return 20
+ popd > /dev/null
+ fi
+
+ if ! (( found )); then
+ echo "dep_not_found:$_dep" >>$build_dir/log
+ fi
+
+ done
+
+## End variable block
+
+ unset next_level dir
+}
+
+source /etc/libretools.conf
+
+if [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then
+ source $XDG_CONFIG_HOME/libretools/libretools.conf
+fi
+
+LEVEL=0
+MAXLEVEL=20
+CLEANFIRST='false'
+UPDATEDB='true'
+
+usage() {
+
+ echo ""
+ echo "cd to a dir containing a PKGBUILD and run:"
+ echo "$(basename $0) [options] <build_dir>"
+ echo ""
+ echo "This script will create a build_dir for recursive building"
+ echo "it tries to find dependencies that aren't built or need update."
+ echo ""
+ echo "If no <build_dir> is specified, the script works on a tempdir"
+ echo ""
+ echo "OPTIONS:"
+ echo " -h : this message."
+# echo " -A <absroot> : use this ABSROOT." # Is it needed anymore?
+ echo " -c : clean <build_dir> before working."
+ echo " -m <max_level> : check deps until this level"
+ echo " -n : don't update pacman db."
+ echo ""
+ exit 1
+
+}
+
+while getopts 'hA:l:cmn' arg; do
+ case "$arg" in
+ h) usage ;;
+# A) ABSROOT="$OPTARG" ;;
+ l) LEVEL="$OPTARG" ;; # hidden option to know dep level.
+ c) CLEANFIRST='true' ;;
+ m) MAXLEVEL="$OPTARG" ;;
+ n) UPDATEDB='false' ;;
+ esac
+done
+
+if [ ! -r PKGBUILD ]; then
+ error "This directory doesnt contain a PKGBUILD"
+ usage
+fi
+
+shift $(( OPTIND - 1 ))
+build_dir="${1}"
+
+if [ "$LEVEL" -eq 0 ]; then
+
+ build_dir="${1:-$(mktemp -d /tmp/fullpkg.XXXXXX)}"
+
+ if [ ! -d "$build_dir" ]; then
+ mkdir -p "$build_dir"
+ elif "$CLEANFIRST"; then
+ # Erase files already in dir
+ msg "Cleaning up files in dir"
+ find "$build_dir" -mindepth 1 -delete
+ fi
+
+ if "$UPDATEDB"; then
+ msg "Updating pacman db"
+ sudo pacman -Sy --noconfirm || true
+ fi
+
+# make files for log and buildorder
+ touch "${build_dir}"/{log,BUILDORDER}
+ buildorder="${build_dir}/BUILDORDER"
+
+ msg "Checking dependencies"
+fi
+
+# Probable circular deps
+[ "$LEVEL" -gt "$MAXLEVEL" ] && exit 20
+
+# Find the dependencies on the ABS itself
+find_deps || {
+
+# Probable circular deps
+ if [ "$?" -eq 20 ]; then
+
+# Show error only on level 0
+ if [ "$LEVEL" -eq 0 ]; then
+ error "Check for circular deps on $build_dir/BUILDORDER";
+ fi
+
+ fi
+# Pass message 20
+ exit 20
+}
+
+exit 0
diff --git a/is_built b/is_built
index f789e4f..60f24e9 100755
--- a/is_built
+++ b/is_built
@@ -1,11 +1,24 @@
#!/bin/bash
-# Detect is a package is installed or in a database
+usage() {
+ echo "$0 "
+ echo
+ echo "Detect is a package is installed or in a database"
+ echo
+ echo "Example usage: is_built \"pcre>=20\""
+}
+
+while getopts 'h' arg; do
+ case $arg in
+ h) usage; exit 0 ;;
+ *) usage; exit 1 ;;
+ esac
+done
# Checks for package, if -T returns non-zero output, egrep will return 0
# because it finds it, so we negate the value to say it's not built.
# -Sp works backwards, it will print output only when the package already
# exists
-# Example usage: is_built "pcre>=20"
+
!(sudo pacman -T "$1" | egrep "*" >/dev/null) || \
sudo pacman -Sp "$1" --print-format "%n-%v" 2>/dev/null | egrep "*" >/dev/null
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/librecommit b/librecommit
index d3ddbff..1698bed 100755
--- a/librecommit
+++ b/librecommit
@@ -25,7 +25,7 @@ usage () {
echo
echo "$0 [optionally files to commit]"
echo
- echo "This script commits the package using name, pkgver an pkgver"
+ echo "This script commits the package using name, pkgver and pkgrel"
echo
exit 1
}
diff --git a/libremakepkg b/libremakepkg
index 292e4b5..99ab1a4 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
-
-}
-
-function clean_chroot { # Clean packages with pacman
-
- plain "making list of packages in ${CHROOTDIR}/${CHROOTNAME}/root/"
- cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem"
- (cat <<EOF
-#!/bin/bash
-export LANG=C
-
-clean='false'
-
-while [ "\$clean" = 'false' ]; do
-
- pkgs=(\$(comm -23 <(pacman -Qq | sort) <(sort /root/cleansystem)))
-
- if [ \${#pkgs[@]} -gt 0 ]; then
- pacman --noconfirm -Rcs \${pkgs[@]}
- else
- clean="true"
- echo "clean"
- fi
-done
-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}/${CHROOT}/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,83 @@ 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 {
-while getopts ${libremakepkgargs} arg ; do
+ echo ''
+ 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 '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
diff --git a/libremessages b/libremessages
index d333f3f..5d817dd 100755
--- a/libremessages
+++ b/libremessages
@@ -26,24 +26,27 @@ export TEXTDOMAINDIR='/usr/share/locale'
# check if messages are to be printed using color
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
-
-if tput setaf 0 &>/dev/null; then
- ALL_OFF="$(tput sgr0)"
- BOLD="$(tput bold)"
- BLUE="${BOLD}$(tput setaf 4)"
- GREEN="${BOLD}$(tput setaf 2)"
- RED="${BOLD}$(tput setaf 1)"
- YELLOW="${BOLD}$(tput setaf 3)"
- PURPLE="${ALL_OFF}$(tput setaf 5)"
-else
- ALL_OFF="\033[1;0m"
- BOLD="\033[1;1m"
- BLUE="${BOLD}\033[1;34m"
- GREEN="${BOLD}\033[1;32m"
- RED="${BOLD}\033[1;31m"
- YELLOW="${BOLD}\033[1;33m"
- PURPLE="${BOLD}\033[1;30;40m"
+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
stdnull() {
eval "$@ >/dev/null 2>&1"
@@ -74,3 +77,25 @@ error() {
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
+}
+
+stat_done() {
+ printf "${BOLD}done${ALL_OFF}\n" >&2
+}
+
+# usage : in_array( $needle, $haystack )
+in_array() {
+ [[ $2 ]] || return 1 # Not found
+
+ local needle=$1; shift
+ local item
+
+ for item in "$@"; do
+ [[ ${item#@} = $needle ]] && return 0 # Found
+ done
+
+ return 1 # Not Found
+}
diff --git a/libremkchroot b/libremkchroot
new file mode 100755
index 0000000..c1f2072
--- /dev/null
+++ b/libremkchroot
@@ -0,0 +1,67 @@
+#!/bin/bash
+# LibreMkChroot
+# Creates a chroot
+
+# Copyright 2011 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
+
+#CHROOTNAME="${CHROOT:-${SUDO_USER:-root}}"
+
+cmd=${0##*/}
+
+function usage {
+ echo "Usage: $cmd [OPTIONS]"
+ 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 '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="$mkchroot_args -$arg" ;;
+ c|C|M) mkchroot_args="$mkchroot_args -$arg $OPTARG" ;;
+ d) CHROOTDIR=$OPTARG ;;
+ ?) usage; exit 1 ;;
+ esac
+done
+
+if (( EUID )); then
+ error "This script must be run as root"
+ exit 1
+fi
+
+mkdir -p "${CHROOTDIR}"
+xargs -d'\n' mkarchroot $mkchroot_args "${CHROOTDIR}/root" < /etc/libretools.d/cleansystem
diff --git a/librerelease b/librerelease
index 64f8887..f31bc3a 100755
--- a/librerelease
+++ b/librerelease
@@ -47,6 +47,11 @@ function list_packages {
}
function sign_packages {
+ if [ -z "${SIGEXT}" ]; then
+ SIGEXT=.sig
+ warning "Empty SIGEXT var, using default .sig"
+ fi
+
if [ -z "${GPG_AGENT_INFO}" ]; then
warning "It's better to use gpg-agent to sign packages in batches"
fi
@@ -66,6 +71,7 @@ function sign_packages {
fi
fi
+ msg2 "Signing ${package}..."
gpg --default-key "${SIGID}" --output "${package}${SIGEXT}" --detach-sig "${package}"
done
}
@@ -83,6 +89,11 @@ function clean {
find ${WORKDIR}/staging/ -type f -delete
}
+if [ -w / ]; then
+ error "Run $0 as normal user"
+ exit 1
+fi
+
while getopts 'hlcn' arg; do
case $arg in
h) usage; exit 0 ;;
diff --git a/librerepkg b/librerepkg
index 706b603..c33a538 100755
--- a/librerepkg
+++ b/librerepkg
@@ -44,21 +44,26 @@ usage() {
while getopts 'h' arg; do
case $arg in
h) usage; exit 0 ;;
- *) makepkgflags=$@ ;;
esac
done
+makepkgflags=$@
+
tempdir=$(mktemp -d /tmp/$(basename $PWD).XXXXX)
-msg "Repackaging: $pkgname $pkgver-$pkgrel ($(date -u))"
-cp ./* ${tempdir}/
+for _arch in ${arch[@]}; do
+ export CARCH=${_arch}
+
+ msg "Repackaging: $pkgname $pkgver-$pkgrel ($(date -u))"
+ cp ./* ${tempdir}/
-stdnull pushd ${tempdir}
+ stdnull pushd ${tempdir}
-msg2 "Updating md5sums"
-makepkg -gp rePKGBUILD >> 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}
+ stdnull popd ${tempdir}
+done
diff --git a/librestage b/librestage
index 65ee19b..d8eae19 100755
--- a/librestage
+++ b/librestage
@@ -21,10 +21,17 @@
# 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
[[ -e $custom_config ]] && source $custom_config
+if [ -w / ]; then
+ error "This script should be run as regular user"
+ exit 1
+fi
+
+
# End Config
usage() {
diff --git a/libretools.conf b/libretools.conf
index 05971d3..9e7f938 100644
--- a/libretools.conf
+++ b/libretools.conf
@@ -19,9 +19,10 @@ ARCHES=('i686' 'x86_64' 'mips64el' 'any')
CHROOTDIR=/home/chroot
## 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=root
+## 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
## Obtains CacheDir from pacman.conf
CACHEDIR=`grep "^#\?CacheDir" /etc/pacman.conf | cut -d'=' -f2`
@@ -46,10 +47,11 @@ ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git
#COMMITCMD=git
#COMMITCMD=hg
-## Build cmd for fullpkg-ng
## Uncomment one of those or make one of your choice
-FULLBUILDCMD="sudo libremakepkg -cumL -M --noconfirm -M --nocheck"
-#FULLBUILDCMD="here is a place for cross-compiling build cmd"
+# Normal fullpkg
+FULLBUILDCMD="sudo libremakepkg -cuN -- -d"
+# Cross compiling fullkpg
+# FULLBUILDCMD="sudo libremakepkg -cuN -d '/path/to/cross-compiling/chroot' -- -d"
## Toru
# Section for toru's vars
@@ -71,18 +73,14 @@ for VAR in CHROOTDIR CHROOT CACHEDIR PARABOLAHOST LIBREDESTDIR \
echo "Configure $VAR var in /etc/libretools.conf"
ret=1
}
- [ $ret -ne 0 ] && exit 1
+ [ $ret -ne 0 ] && exit 1
done
source /usr/bin/libremessages
## These are architecture specific files.
-## Uncomment them if you installed libretools-arch
-#source /etc/libretools.d/mips64el.conf
-#source /etc/libretools.d/x86_64.conf
-#source /etc/libretools.d/i686.conf
-
-
+## 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
diff --git a/mips64el/mips64el.conf b/mips64el/mips64el.conf
index 0825fad..836b407 100644
--- a/mips64el/mips64el.conf
+++ b/mips64el/mips64el.conf
@@ -2,11 +2,11 @@
## Run a command for PKGBUILD modifications before building
## Like adding 'mips64el' to arch if it's not there
-HOOKPKGBUILDMOD="mips-add"
+# HOOKPKGBUILDMOD="mips-add"
## Run a command for local releasing of packages
# Useful for mass packaging (ie. mips port)
# Must accept the following parameters even if the command won't use them:
# $1 repo name
# $2+ packages
-HOOKLOCALRELEASE="mipsrelease"
+# HOOKLOCALRELEASE="mipsrelease"
diff --git a/pkgbuild-check-nonfree b/pkgbuild-check-nonfree
index fd7b69e..bd6fa4b 100755
--- a/pkgbuild-check-nonfree
+++ b/pkgbuild-check-nonfree
@@ -19,80 +19,187 @@
# 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 log_end {
+# kill "$teepid"
+# rm "$logpipe"
+# }
+
+# function log {
+# 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")"
+# mkfifo "$logpipe"
+# tee "$LOG" < "$logpipe" &
+# teepid=$!
+# trap log_end ERR EXIT
+# }
+
+
+function 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 {
+
+ if [ -e "$1" ]; then
+
+ source "$1"
+ if [ -n "${pkgname[0]}" ]; then
+ return 0 # valid PKGBUILD
+ fi
-function in_array { # usage : in_array( $needle, $haystack )
+ fi
- [[ $2 ]] || return 1 # Not found
+ error "$1 is not a valid PKGBUILD"
+ return 1
+}
+
+function check_replacement {
+
+ [ $2 ] || return 0 # Free (not found)
local needle=$1; shift
local item
- for item in "$@"; do
- [[ ${item#@} = $needle ]] && return 0 # Found
+ local rep
+ for line in $@; do
+
+ item="$(echo "$line" | cut -d':' -f1)"
+ rep="$(echo "$line" | cut -s -d':' -f2)"
+
+ if [ "$item" == "$needle" ]; then
+ if [ -z "$rep" ]; then
+ return 15 # Nonfree (found)
+ else
+ echo "$rep"
+ return 0 # Free (has replacement)
+ fi
+ fi
+
done
- return 1 # Not Found
+ return 0 # Free (not found)
}
function get_blacklist { # Download the blacklist.
pushd "$XDG_CONFIG_HOME/libretools" >/dev/null
+
msg "Downloading the blacklist of proprietary software packages."
- wget -N -q -O blacklist.txt "${BLACKLIST}" 2>/dev/null || {
- [ -e $XDG_CONFIG_HOME/libretools/blacklist.txt ] || {
+
+ if ! wget -N -q -O blacklist.txt "${BLACKLIST}" 2>/dev/null; then
+
+ if [ -e "$XDG_CONFIG_HOME/libretools/blacklist.txt" ]; then
+ warning "Using local copy of blacklist"
+ else
error "Download failed, exiting"
- exit 1
- }
- warning "Using local copy of blacklist"
- }
+ fi
+
+ fi
+
popd > /dev/null
}
function check_deps { # Check wheter a package depends on non-free
- pushd "$XDG_CONFIG_HOME/libretools/" >/dev/null
- local unfree=($(cut -d: -f1 blacklist.txt)) # pkgname:free-replacement:comments
- local freerep=($(cut -d: -f2 blacklist.txt)) # pkgname:free-replacement:comments
- popd >/dev/null
+ unset_pkgbuild
- msg "Looking for unfree dependencies"
- for item in ${pkgname[@]} ${depends[@]} ${makedepends[@]} ; do
+ if ! assert_pkgbuild "$1"; then
+ return 1 # not PKGBUILD
+ fi
- if in_array $item ${unfree[@]} ; then
+ msg2 "${pkgbase:-${pkgname[0]}} $pkgver $pkgrel ${epoch:-""}" # > "$logpipe"
- if in_array $item ${freerep[@]} ; then
- warning "$item is repackaged with the same name."
- continue
+ for pkg in ${pkgname[@]} ${depends[@]} ${makedepends[@]} ${checkdepends[@]}; do
+
+ lines=($(grep "$pkg" "$XDG_CONFIG_HOME/libretools/blacklist.txt" | tr " " "_"))
+
+ rep="$(check_replacement $pkg ${lines[@]})"
+ freedom=$?
- elif in_array $item-libre ${freerep[@]} ; then
- warning "$item -> $item-libre"
+ if [ "$freedom" -eq 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
- ev=15
- msg2 "found $item"
+ plain "$pkg -> $rep" # > "$logpipe"
+ continue
fi
+
fi
+
done
+
}
-if [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then
- source $XDG_CONFIG_HOME/libretools/libretools.conf
+function usage {
+ # TODO: implement PKGBUILD arguments
+ echo ""
+ echo "$(basename $0) [options] [PKGBUILD1 PKGBUILD2 ...]"
+ echo ""
+ echo "OPTIONS"
+ echo ""
+ echo " -h : this message"
+ echo ""
+ echo "If no PKGBUILD is specified, one is searched on current directory"
+
+ exit 1
+}
+
+while getopts 'h' arg; do
+ case "$arg" in
+ h) usage ;;
+ esac
+done
+
+if (( ! EUID )); then
+ error "Run as normal user"
fi
-if [ -z "${BLACKLIST}" ]; then
- error "BLACKLIST variable is not set your libretools.conf file"; exit 1
+source /etc/libretools.conf
+if [ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]; then
+ source "$XDG_CONFIG_HOME/libretools/libretools.conf"
fi
-if [ -r PKGBUILD ]; then
- source PKGBUILD
-else
- error "There is no PKGBUILD in dir"; exit 1
+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
+
+shift $(( OPTIND - 1))
+
+msg "Looking for unfree dependencies"
+
+if [ $# -ge 1 ]; then
+
+ for p in $@; do
+ if [ -n "$p" ]; then
+ check_deps "$p"
+ fi
+ done
+
+else
+
+ check_deps "`pwd`/PKGBUILD"
-check_deps
+fi
exit $ev
diff --git a/toru b/toru
index 55e4119..9616119 100755
--- a/toru
+++ b/toru
@@ -79,7 +79,7 @@ split_pkgname_from_pkgver() {
sed "s/^\(.\+\)-\([^-]\+-[^-]\+\)$/\1 \2/" $1
}
-# Get the fullpkgver
+# Get the fullpkgver
# pkgname from pkgver separator can be either '-' or ' '
extract_fullpkgver() {
echo "$@" | tr " " "\n" | sed "s/^.\+[ -]\([^-]\+-[^-]\+\)$/\1/"
@@ -248,23 +248,61 @@ missing() {
true
}
+## Finds a PKGBUILD on toru's path cache
+## usage: where_is <pkgname>
+# Look in all caches but pick the first one
+where_is() {
+ local _repo
+ local _path
+ for _repo in ${REPOS[@]}; do
+ _path=$(grep "^${1}:" "${TORUPATH}/${_repo}.paths.cache" 2>/dev/null |
+ cut -d: -f2)
+ [ -n "${_path}" ] && break
+ done
+
+ [ -z "$_path" ] && return 1
+
+ echo ${_path}
+}
+
+# TODO: clean usage instructions
+function usage {
+ echo ""
+ echo "$0 [options] repo1 ... repon"
+ echo ""
+ echo "Make a db containing PKGBUILD metadata."
+ echo ""
+ echo "-h : this message"
+# echo "-a : update all repos at once"
+ echo "-u : update repo information"
+ echo "-q : quiet"
+ echo "-f : rebuild the db even if it is updated"
+ echo "-p <pkgname>: return the path for pkgname"
+ echo ""
+ exit 1
+}
## MAIN
commands=()
repos=()
quiet=false
force=false
-while getopts 'hqfum' arg; do
+while getopts 'haqfpum' arg; do
case $arg in
- h) usage; exit 0 ;;
- q) quiet=true ;;
- f) force=true ;;
- u) commands+=(update);;
- m) commands+=(missing);;
+ h) usage; exit 0 ;;
+# TODO: Update all repos on $REPOS array
+# a) update_all_repos ;;
+ q) quiet=true ;;
+ f) force=true ;;
+ u) commands+=(update);;
+ p) shift $(( OPTIND - 1 ))
+ where_is "$1"
+ exit $?;;
+ m) commands+=(missing);;
esac
- shift $((OPTIND-1))
+ shift $(( OPTIND - 1 ))
done
@@ -274,6 +312,4 @@ TMPDIR=$(mktemp -d)
${commands[0]} ${@}
-#rm -rf ${TMPDIR}
-
exit $?