diff options
-rw-r--r-- | Makefile | 48 | ||||
-rwxr-xr-x | abslibre-commit | 36 | ||||
-rwxr-xr-x | aur | 123 | ||||
-rwxr-xr-x | buildenv | 28 | ||||
-rwxr-xr-x | chcleanup | 57 | ||||
-rw-r--r-- | common.mk | 37 | ||||
-rwxr-xr-x | diff-unfree | 85 | ||||
-rw-r--r-- | doc/Makefile | 2 | ||||
-rw-r--r-- | doc/workflows.markdown | 60 | ||||
-rwxr-xr-x | lb | 16 | ||||
-rwxr-xr-x | librechroot | 108 | ||||
-rwxr-xr-x | librecommit | 65 | ||||
-rwxr-xr-x | librediff | 65 | ||||
-rwxr-xr-x | libremakepkg | 126 | ||||
-rwxr-xr-x | libremessages | 107 | ||||
-rwxr-xr-x | libremkchroot | 64 | ||||
-rwxr-xr-x | librerepkg | 72 | ||||
-rw-r--r-- | libretools.conf | 122 | ||||
-rwxr-xr-x | prtools/prfullpkg | 398 | ||||
-rwxr-xr-x | prtools/prmipsrelease | 98 | ||||
-rw-r--r-- | prtools/prtools.conf | 4 | ||||
-rw-r--r-- | prtools/prtoru | 173 | ||||
-rw-r--r-- | rePKGBUILD.proto | 29 | ||||
-rw-r--r-- | src/Makefile | 3 | ||||
-rw-r--r-- | src/abslibre-tools/Makefile | 3 | ||||
-rwxr-xr-x | src/abslibre-tools/createworkdir (renamed from createworkdir) | 0 | ||||
-rwxr-xr-x | src/abslibre-tools/libreaddiff (renamed from libreaddiff) | 0 | ||||
-rwxr-xr-x | src/abslibre-tools/librerelease (renamed from librerelease) | 14 | ||||
-rwxr-xr-x | src/abslibre-tools/librestage (renamed from librestage) | 3 | ||||
-rwxr-xr-x | src/aur | 133 | ||||
-rw-r--r-- | src/chroot-tools/Makefile | 3 | ||||
-rwxr-xr-x | src/chroot-tools/chcleanup | 76 | ||||
-rw-r--r-- | src/chroot-tools/chroot.conf | 13 | ||||
-rwxr-xr-x | src/chroot-tools/librechroot | 230 | ||||
-rwxr-xr-x | src/chroot-tools/libremakepkg | 311 | ||||
-rw-r--r-- | src/devtools/.gitignore | 4 | ||||
-rw-r--r-- | src/devtools/Makefile | 103 | ||||
-rw-r--r-- | src/devtools/lib/makechrootpkg.sh.patch | 254 | ||||
-rwxr-xr-x | src/diff-unfree | 86 | ||||
-rw-r--r-- | src/fullpkg/Makefile | 3 | ||||
-rwxr-xr-x | src/fullpkg/fullpkg (renamed from fullpkg) | 2 | ||||
-rwxr-xr-x | src/fullpkg/fullpkg-build (renamed from fullpkg-build) | 0 | ||||
-rwxr-xr-x | src/fullpkg/fullpkg-find (renamed from fullpkg-find) | 3 | ||||
-rwxr-xr-x | src/is_built (renamed from is_built) | 0 | ||||
-rwxr-xr-x | src/is_unfree (renamed from is_unfree) | 5 | ||||
-rw-r--r-- | src/lib/Makefile | 2 | ||||
-rw-r--r-- | src/lib/conf.sh | 121 | ||||
-rwxr-xr-x | src/librediff | 57 | ||||
-rw-r--r-- | src/librefetch/Makefile | 3 | ||||
-rwxr-xr-x | src/librefetch/librefetch | 301 | ||||
-rw-r--r-- | src/librefetch/librefetch.conf | 2 | ||||
-rwxr-xr-x | src/libremessages | 65 | ||||
-rw-r--r-- | src/libretools.conf | 98 | ||||
-rw-r--r-- | src/mips64el-tools/Makefile | 3 | ||||
-rwxr-xr-x | src/mips64el-tools/add-mips64el (renamed from add-mips64el) | 0 | ||||
-rwxr-xr-x | src/mips64el-tools/librebasebuilder (renamed from librebasebuilder) | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | src/mips64el-tools/mips-add (renamed from mips64el/mips-add) | 0 | ||||
-rw-r--r-- | src/mips64el-tools/mips64el.conf (renamed from mips64el/mips64el.conf) | 0 | ||||
-rwxr-xr-x | src/mips64el-tools/mipsrelease (renamed from mips64el/mipsrelease) | 0 | ||||
-rwxr-xr-x | src/pkgbuild-check-nonfree (renamed from pkgbuild-check-nonfree) | 142 | ||||
-rw-r--r-- | src/toru/Makefile | 3 | ||||
-rwxr-xr-x | src/toru/toru (renamed from toru) | 0 | ||||
-rwxr-xr-x | src/toru/toru-info (renamed from toru-info) | 0 | ||||
-rwxr-xr-x | src/toru/toru-path (renamed from toru-path) | 2 | ||||
-rwxr-xr-x | src/toru/toru-utils (renamed from toru-utils) | 0 | ||||
-rwxr-xr-x | src/toru/toru-where (renamed from toru-where) | 0 | ||||
-rwxr-xr-x | src/treepkg | 237 | ||||
-rwxr-xr-x | treepkg | 237 | ||||
-rwxr-xr-x | update-cleansystem | 68 | ||||
-rwxr-xr-x | updateabslibre | 39 |
70 files changed, 2338 insertions, 2216 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e5b38b1 --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +# Configuration +DESTDIR= + +#prefix=/usr/local +prefix=/usr +exec_prefix=$(prefix) +datarootdir=$(prefix)/share + +bindir=$(exec_prefix)/bin +sbindir=$(exec_prefix)/sbin +#sysconfdir=$(prefix)/etc +sysconfdir=/etc +datadir=$(datarootdir) +docdir=$(datarootdir)/doc + +################################################################################ + +# these are the resulting packages +packages=libretools libretools-mips64el +# and which directories they contains +libretools=abslibre-tools chroot-tools devtools fullpkg lib librefetch misc toru +libretools-mips64el=mips64el-tools + +################################################################################ + +all: PHONY build +build: PHONY build-libretools build-doc +install: PHONY install-libretools install-doc + +%-doc: PHONY doc + $(MAKE) -C doc $* +%-misc: PHONY src + $(MAKE) -C src $* + +build-%: PHONY src/% + $(MAKE) -C src/$* +install-%: PHONY src/% + $(MAKE) -C src/$* install + +.SECONDEXPANSION: +$(addprefix build-, $(packages)): build-%: PHONY $$(addprefix build-, $$($$*)) +$(addprefix install-,$(packages)): install-%: PHONY $$(addprefix install-,$$($$*)) + +################################################################################ + +FORCE: PHONY +PHONY: +.PHONY: FORCE PHONY diff --git a/abslibre-commit b/abslibre-commit deleted file mode 100755 index e906fbd..0000000 --- a/abslibre-commit +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# ABSLibreCommit -# Commits a PKGBUILD to ABSLibre.git - -# Copyright 2010 Nicolás Reynolds - -# ---------- 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/>. - -for _pkg in ${@}; do - [[ ! -e ${_pkg}/PKGBUILD ]] && continue - - unset pkgbase pkgname - source ${_pkg}/PKGBUILD - -# use . instead of * will use .gitignore - git stage ${_pkg}/. - - git commit -m "${pkgbase:-$pkgname}-${pkgver}-${pkgrel}" -done - -exit 0 @@ -1,123 +0,0 @@ -#!/bin/bash -# 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." -} - -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[@]} -} - -exit 0 diff --git a/buildenv b/buildenv deleted file mode 100755 index 84a1fc2..0000000 --- a/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/chcleanup b/chcleanup deleted file mode 100755 index 17c1f02..0000000 --- a/chcleanup +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# (c) Nicolás Reynolds <fauno@parabola.nu> -# Released under GPLv3 -# -# Performs chroot cleanup smartly, it only removes the unneeded packages or -# leaves you with a cleansystem -# -# See: HOOKPREBUILD - -set -e -DRYRUN=${DRYRUN:-false} - -source /etc/makepkg.conf -source /etc/libretools.conf -source ${HOME}/.makepkg.conf 2>/dev/null|| true - -msg "Cleaning chroot..." - -TMPDIR="$(mktemp -d /tmp/$(basename $0)-XXXXX)" -cleanup_log="${TMPDIR}"/libretools-cleanup.log - -cp -a /var/lib/pacman/sync "${TMPDIR}/" -touch ${cleanup_log} - -# If we're running makepkg -if [ -f PKGBUILD ]; then - source PKGBUILD || true - - check=(${depends[@]} ${makedepends[@]} ${checkdepends[@]}) - -fi - -# Get the full list of packages needed by dependencies, including the base system -sudo pacman -b "${TMPDIR}" \ - -Sp \ - --print-format "%n" \ - base base-devel sudo \ - ${CHROOTEXTRAPKG[@]} \ - ${check[@]} \ - >${cleanup_log} - -# Diff installed packages against a clean chroot then remove leftovers -packages=($(comm -23 <(pacman -Qq | sort) \ - <(sort -u ${cleanup_log}))) - -[ ${#packages[@]} -eq 0 ] && exit 0 - -msg2 "Removing %d packages" ${#packages[@]} - -# Only remove leftovers, -Rcs removes too much -${DRYRUN} || sudo pacman --noconfirm -Rn ${packages[@]} -${DRYRUN} && echo ${packages[@]} - -# Cleanup -${DRYRUN} || rm -fr ${TMPDIR} - -exit $? diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..6248b80 --- /dev/null +++ b/common.mk @@ -0,0 +1,37 @@ +# Configuration +DESTDIR= + +#prefix=/usr/local +prefix=/usr +exec_prefix=$(prefix) +datarootdir=$(prefix)/share + +bindir=$(exec_prefix)/bin +sbindir=$(exec_prefix)/sbin +#sysconfdir=$(prefix)/etc +sysconfdir=/etc +datadir=$(datarootdir) +docdir=$(datarootdir)/doc + +################################################################################ +progs = $(shell find . -maxdepth 1 -type f -executable -printf '%f\n') +confs = $(shell find . -maxdepth 1 -type f -not -executable -printf '%f\n'|fgrep -v Makefile) +files = $(addprefix $(DESTDIR)$(libre_execdir)/,$(progs)) \ + $(addprefix $(DESTDIR)$(libre_datadir)/,$(confs)) + +all: PHONY build + +build: PHONY + +install: PHONY $(files) + +$(DESTDIR)$(libre_execdir)/%: % + install -Dm755 '$<' '$@' +$(DESTDIR)$(libre_datadir)/%: % + install -Dm755 '$<' '$@' + +################################################################################ + +FORCE: PHONY +PHONY: +.PHONY: FORCE PHONY diff --git a/diff-unfree b/diff-unfree deleted file mode 100755 index a0a8d63..0000000 --- a/diff-unfree +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# This script will help you diff a *-libre PKGBUILD against the unfree one -# to check for updates. -# Copyright 2010 Nicolás Reynolds - -# ---------- 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 -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 -} - -[[ ! -r PKGBUILD ]] && { - error "This is not a build dir." - exit 1 -} - -package_guess=$(basename $PWD) - -repo=${1:-$(basename $(dirname $PWD))} -package=${2:-${package_guess/-libre}} -trunk=${3:-trunk} - -tmp_dir=$(mktemp -d /tmp/${package}.XXXXXX) - -svnrepo="packages" -case $repo in - community*) - svnrepo="community" - ;; - multilib*) - svnrepo="community" - ;; - *) - ;; -esac - -unfree_dir="${tmp_dir}/${svnrepo}/${package}/${trunk}" - -[[ ! -d "${tmp_dir}" ]] && { - error "Can't create temp dir" - exit 1 -} - -stdnull 'pushd "${tmp_dir}"' - -msg "Getting diff from $repo/$package..." - -stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo' - -cd ${svnrepo} -svn update ${package} - -# Back to start dir -stdnull popd - -msg "Diffing files" - -for _file in ${unfree_dir}/*; do - msg2 "$(basename "${_file}")" - ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}" -done - -exit $? diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..7af3750 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,2 @@ +libre_datadir=$(docdir)/libretools +include ../common.mk diff --git a/doc/workflows.markdown b/doc/workflows.markdown new file mode 100644 index 0000000..f55ae7e --- /dev/null +++ b/doc/workflows.markdown @@ -0,0 +1,60 @@ +# Workflows + +Describe your packaging workflow here! + + +## fauno's way + +During packaging, I don't usually restart a build from scratch if I have to +make changes to the PKGBUILD. I use a lot of commenting out commands already +ran, `makepkg -R`, etc. When I used `libremakepkg` I ended up using a lot more +`librechroot` and working from inside the unconfigured chroot, because +`makechrootpkg` (the underlying technology for `libremakepkg`) tries to be too +smart. + +When I started writing `treepkg` I found that mounting what I need directly on +the chroot and working from inside it was much more comfortable and simple than +having a makepkg wrapper doing funny stuff (for instance, mangling makepkg.conf +and breaking everything.) + +This is how the chroot is configured: + +* Create the same user (with same uid) on the chroot that the one I use regularly. + +* Give it password-less sudo on the chroot. + +* Bind mount /home to /chroot/home, where I have the abslibre-mips64el clone. + +* Bind mount /var/cache/pacman/pkg to /chroot/var/cache/pacman/pkg + +* Put these on system's fstab so I don't have to do it everytime + +* Configure makepkg.conf to PKGDEST=CacheDir and SRCDEST to something on my home. + +Workflow: + +* Enter the chroot with `systemd-nspawn -D/chroot` and `su - fauno`. + +* From another shell (I use tmux) edit the abslibre or search for updates with + `git log --no-merges --numstat`. + +* Pick a package and run `treepkg` from its dir on the chroot, or retake + a build with `treepkg /tmp/package-treepkg-xxxx`. (Refer to doc/treepkg + here). + +What this allows: + +* Not having to worry about the state of the chroot. `chcleanup` removes and + adds packages in a smart way so shared dependencies stay and others move + along (think of installing and removing qt for a complete kde rebuild). + +* Building many packages in a row without recreating a chroot for every one of + them. + +* Knowing that any change you made to the chroot stays as you want (no one + touches your makepkg.conf) + +* Hability to run regular commands, not through a chroot wrapper. I can `cd` to + a dir and use `makepkg -whatever` on it and nothing breaks. + +* No extra code spent on wrappers. @@ -1,16 +0,0 @@ -#!/bin/bash -# LibreTools wrapper -# License: GPLv3 - -source /etc/libretools.conf - -command=$1; shift - -[[ ! -x ~/l/libre"${command}" ]] && { - error "Command not found" - exit 1 -} - -~/l/libre${command} "$@" - -exit $? diff --git a/librechroot b/librechroot deleted file mode 100755 index c8e02b0..0000000 --- a/librechroot +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/bash -# LibreChRoot -# Enters a chroot - -# Copyright 2010 Nicolás Reynolds -# Copyright 2011 Joshua Haase - -# ---------- 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/>. - -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 "" - -} - -function clean_chroot { # Clean packages with pacman - cp -a "$(dirname $0)/chcleanup" "${CHROOTDIR}/${CHROOTNAME}/clean" - - mkarchroot -r "cd /build; /clean" "${CHROOTDIR}/${CHROOTNAME}" -} - -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" -} -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 diff --git a/librecommit b/librecommit deleted file mode 100755 index 1698bed..0000000 --- a/librecommit +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# Copyright 2010 Nicolás Reynolds - -# ---------- 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 - -usage () { - echo "cd to the dir with the PKGBUILD you are commiting and" - echo - echo "$0 [optionally files to commit]" - echo - echo "This script commits the package using name, pkgver and pkgrel" - echo - exit 1 -} - -msg="Commiting libre package \"\$pkg-\$pkgver-\$pkgrel\"" - -for opt in $@ ; do - case ${opt} in - -h) usage ;; - -m) shift; msg=${1}; shift ;; - *) files+="${1} " ; shift ;; - esac -done - -if [ ! -e PKGBUILD -o -z "$files" ]; then usage; fi - -source PKGBUILD - -pkg=${pkgbase:-${pkgname}} - -msg=$(eval echo $msg) - -if [ "$COMMITCMD" = 'git' ]; then - - ${COMMITCMD} add ${files} && ${COMMITCMD} commit -m "$(echo $msg)" - -elif [ "$COMMITCMD" = 'hg' ]; then - - ${COMMITCMD} commit ${files} -m "$msg" -v || exit 1 - -else - - error "COMMITCMD is not correctly set on libretools.conf" - -fi - -exit 0 diff --git a/librediff b/librediff deleted file mode 100755 index 1f39eb9..0000000 --- a/librediff +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# Generates a patch for a nonfree PKGBUILD -# -# Copyright 2010 Nicolás Reynolds - -# ---------- 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/>. - -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" -} - -# 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 - -# Print usage if no package has been given -[[ -z "$@" ]] && { - usage - exit 1 -} - - -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 - } - - source ./${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 - -done - -exit 0 diff --git a/libremakepkg b/libremakepkg deleted file mode 100755 index f7924f6..0000000 --- a/libremakepkg +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -# Copyright 2010 - 2011 Nicolás Reynolds -# Copyright 2011 Joshua Ismael Haase Hernández - -# ---------- 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 -x # uncomment for debug - -function copy_log { # copy logs if they exist - - find "${CHROOTDIR}/${CHROOT}/build/" -maxdepth 1 -name "*\.log" -exec cp {} ./ \; - -} - - -function trap_exit { # End inmediately but print a useful message - - copy_log - error "$@" - exit 1 - -} - -# 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 - -source /etc/libretools.conf - -CLEANFIRST="false" -UPDATEFIRST="false" -CHECKNONFREE="true" -LIBRECHROOT_ARGS="" -MAKEPKG_ARGS="" - -function usage { - - 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) 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 diff --git a/libremessages b/libremessages deleted file mode 100755 index 68badb8..0000000 --- a/libremessages +++ /dev/null @@ -1,107 +0,0 @@ -# Copyright (c) 2006-2010 Pacman Development Team <pacman-dev@archlinux.org> -# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.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) 2011 by Joshua Haase <hahj87@gmail.com> -# -# 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; either version 3 of the License, or -# (at your option) any later version. -# -# 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. -# -# 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' - -# 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 - -stdnull() { - eval "$@ >/dev/null 2>&1" -} - -plain() { - local mesg=$1; shift - printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -msg() { - local mesg=$1; shift - printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -msg2() { - local mesg=$1; shift - printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -warning() { - 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 -} - -stat_done() { - printf "${BOLD}done${ALL_OFF}\n" >&2 -} - -# Set the terminal title -# TODO test on several terms - it works on screen/tmux -term_title() { - printf "\033k%s\033\\" "$@" -} - -# 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 deleted file mode 100755 index b576209..0000000 --- a/libremkchroot +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# LibreMkChroot -# Creates a chroot - -# 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 - -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+=("-$arg");; - c|C|M) 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/librerepkg b/librerepkg deleted file mode 100755 index d506003..0000000 --- a/librerepkg +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# Copyright 2011 Joshua Ismael Haase Hernandez - -# ---------- 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 -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 -} - -source /etc/makepkg.conf -source /etc/abs.conf -source rePKGBUILD - -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" -} - -while getopts 'h' arg; do - case $arg in - h) usage; exit 0 ;; - esac -done - -makepkgflags=$@ - -tempdir=$(mktemp -d /tmp/$(basename $PWD).XXXXX) - -msg "Copying files" -cp ./* ${tempdir}/ - -for _arch in ${arch[@]}; do - - msg "Repackaging: $pkgname $pkgver-$pkgrel ($(date -u))" - - stdnull pushd ${tempdir} - - msg2 "Updating md5sums" - makepkg -gp rePKGBUILD >> rePKGBUILD - - echo "export CARCH=${_arch}" >> rePKGBUILD - - msg "Repackaging using makepkg" - makepkg -Lcdp rePKGBUILD ${makepkgflags} - - stdnull popd ${tempdir} -done diff --git a/libretools.conf b/libretools.conf deleted file mode 100644 index 8032397..0000000 --- a/libretools.conf +++ /dev/null @@ -1,122 +0,0 @@ -## Blacklist URL -BLACKLIST=http://repo.parabolagnulinux.org/docs/blacklist.txt - -# Diff tool (vimdiff, gvimdiff, meld, etc) -DIFFTOOL=vimdiff - -# The dir where you work on -WORKDIR=/home/$USER/packages -# The repos you'll be packaging for -# -# 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') - -# The architectures -ARCHES=('i686' 'x86_64' 'mips64el' 'any') - -## 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) - -## 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 - -## Obtains CacheDir from pacman.conf -CACHEDIR=`grep "^#\?CacheDir" /etc/pacman.conf | cut -d'=' -f2` - -## Parabola hostname (should be the same used on ssh_config -PARABOLAHOST=parabola - -## Server destination of libre packages -# Don't change unless you know what you're doing and you won't screw -# anything ;) -LIBREDESTDIR=/srv/http/repo/public - -## ABSLibre -ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git - -## Commit Command -## Should be git or hg -## Uncomment only one of those -#COMMITCMD=git -#COMMITCMD=hg - -## Uncomment one of those or make one of your choice -# Normal fullpkg -FULLBUILDCMD="sudo libremakepkg -cuN" -# Cross compiling fullkpg -# FULLBUILDCMD="sudo libremakepkg -cuN -d '/path/to/cross-compiling/chroot'" -# Build from within the chroot (or host system) -# FULLBUILDCMD="makepkg -sL --noconfirm" - -# Run a command before releasing a package (ie. SSH connection, SSH tunnel, etc.) -HOOKPRERELEASE="ssh -fN parabola" - -# Run a command before running FULLBUILDCMD, usually to cleanup uneeded packages -# Note! chcleanup *is not* chroot aware, if you run it as it is it will cleanup -# your system -# HOOKPREBUILD="chcleanup" - -# Locally release the package or any other action after running FULLBUILDCMD -# succesfully -# HOOKLOCALRELEASE="" - -## 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 -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 diff --git a/prtools/prfullpkg b/prtools/prfullpkg deleted file mode 100755 index bbb8d73..0000000 --- a/prtools/prfullpkg +++ /dev/null @@ -1,398 +0,0 @@ -#!/bin/bash - -source /etc/makepkg.conf -source /etc/abs.conf -source /etc/libretools.conf -source /etc/libretools.d/prtools.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 - - -function 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 "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 - exit 1 - -} - -function remove_buildorder { # Removes a package from the buildorder -# $1 package name -# $2 buildorder file - - grep -Evw "${1}" ${2} > ${2}2 - mv -f ${2}2 ${2} - -} - -function guess_repo { # Get repo name. Asumes ${ABSROOT}/package/repo/PKGBUILD - - basename $(pwd) - -} - -function get_fullver { # return : full version spec, including epoch (if necessary), pkgver, pkgrel - -# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) - - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi - -} - -function cleanup { # Cleans the build_dir. - - [ ! -d "${build_dir}" -o "${build_only}" = 'y' ] && return 0 # Do nothing or already cleaned. - - - if [ $level -eq 0 ]; then # Only do cleanup on level 0. - msg "Cleaning up ${build_dir}" - rm -rf "$build_dir/*" - fi -} - -function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated. - - source PKGBUILD ## Check this level. - - local repo=${repo:-$(guess_repo)} - local pkgbase=${pkgbase:-${pkgname[0]}} - local epoch=${epoch:-0} - local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel}) - - if is_built "${pkgbase}" "${fullver}"; then - exit 0 # pkg is built and updated - fi - - echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" # greater levels are built first - - if [ -d "${build_dir}/${pkgbase}" ]; then # PKGBUILD is already there - - exit 0 - - else # Copy dir to build_dir - - mkdir ${build_dir}/${pkgbase} - cp -r $(pwd)/* ${build_dir}/${pkgbase} - - echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" # to identify repo later - fi - - msg2 "%${level}s${pkgbase}-${fullver}" # current package plus a space for every level - - declare -i next_level=$level+1 ## Check next deps level. - - deps=$(echo "${depends[@]} ${makedepends[@]}" | \ - sed "s/[=<>]\+[^ ]\+//g" | \ - tr ' ' "\n" | \ - sort -u) # All deps in separate line, only once, without version. - - for _dep in ${deps[@]}; do - - local found=false - - if [ -d "${ABSROOT}/${_dep}" ]; then # ABSROOT/package/repo - - for _repo in ${REPOS[@]}; do # Use PKGBUILD from repo in REPOS array order - - if [ -e "${ABSROOT}/${_dep}/${_repo}/PKGBUILD" ]; then - - pushd "${ABSROOT}/${_dep}/${_repo}" > /dev/null - $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir - [ $? -eq 20 ] && return 20 # probable circular deps - popd > /dev/null - local found=true - break 1 # found, go to next dep - fi - - done - - else # pkgsplit, needs guess - - for _repo in ${REPOS[@]}; do - - if _dir=($(find "$ABSROOT/" -type f \ - -wholename "*/${_repo}/PKGBUILD" -print0 2>/dev/null | \ - "xargs" -0 -e grep -HEw "pkgname=|pkgbase=|provides=" | \ - grep -w "$_dep" 2>&1)) ; - - then - - _dir=$(dirname $(echo $_dir | cut -d: -f1)) - plain "guess for $_dep -> $_dir" - - pushd "$_dir" > /dev/null - $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir - [ $? -eq 20 ] && return 20 # probable circular dep - popd > /dev/null - local found=true - break 1 # found, go to next dep - fi - - done - - fi - - if ( ${found} ); then - continue 1 # go to next dep - else - echo "dep_not_found:$_dep" >> $build_dir/log - fi - - done - - unset next_level dir - # unset PKGBUILD variables - unset pkgbase pkgname pkgver pkgrel epoch pkgdesc arch url license groups depends \ - makedepens checkdepends optdepends provides conflicts replaces backup \ - options install changelog source noextract md5sums build check package -} - -function __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 - source PKGBUILD - - msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel" - - msg2 "Checking for non free deps" - pkgbuild-check-nonfree || { - if [ $? -eq 15 ]; then # this error means nonfree others means fail. - - echo "nonfree:$(basename $PWD)" >> $build_dir/log - - remove_buildorder "$(basename $PWD)" $buildorder # take out package from $buildorder - - continue # build next package - fi - } - - msg2 "Building $(basename $PWD)" - - $FULLBUILDCMD; r=$? # this buildcmd is on libretools.conf - - case $r in - - 0) ## Succesfull build - - plain "The build was succesful." - if source .INFO && [ -n $repo ]; then - - if [ ! -z $HOOKLOCALRELEASE ]; then # Calls a local release script if it's used - 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 - - build_packages=($(sort -gr $buildorder | cut -d: -f2)) # which is next package? - 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 -} - -function trap_exit { # End inmediately but print a useful message - - error "$@" - warning "Leftover files left on $build_dir" - - exit 1 -} - -# Trap signals from makepkg -set -E -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 - -ban_file=$XDG_CONFIG_HOME/libretools/ban -force_build="" -level=0 -noupdate='n' -build_only='n' -check_deps_only='n' -max_level=21 - -while getopts 'ha:b:cd:l:nm:r:' arg; do - case $arg in - h) usage ;; - a) ABSROOT="$OPTARG" ;; - b) build_only='y' - 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='y' ;; - d) build_dir="$OPTARG" ;; - l) level=$OPTARG ;; # hidden option to know dep level. - n) noupdate='y';; - m) max_level=$OPTARG ;; - r) FULLBUILDCMD="$OPTARG" ;; - esac -done - -if [ ${build_only} == 'n' ]; then - - [ ! -r PKGBUILD ] && { # Check if we are actually on a build directory. Do this early. - error "This isn't a build directory" - usage - } - - if [ ! -z "$HOOKPKGBUILDMOD" ]; then - "$HOOKPKGBUILDMOD" - fi - -fi - -if [ $level -eq 0 ]; then - - if [ ! -d ${build_dir} ]; then # in case of custom -d option - mkdir -p ${build_dir} - else - cleanup # files already there can screw find_deps - fi - - build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp - - touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder - buildorder=${build_dir}/BUILDORDER - - if [ ${noupdate} = 'n' ]; then - - msg "Updating pacman db and packages" - sudo pacman -Syu --noconfirm || true - - fi - - if [ ${build_only} == 'y' ]; then - - msg "Build Packages" - - __build - - exit 0 - - fi - - msg "Checking dependencies" -fi - -[ $level -ge $max_level ] && exit 20 # Probable circular deps - -find_deps || { - - if [ $? -eq 20 ]; then # Probable circular deps - - if [ $level -eq 0 ]; then # Show error only on level 0 - error "Check for circular deps on $build_dir/BUILDORDER"; - fi - - fi - exit 20 # Pass message 20 -} - -[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0 # only build on level 0 - -if [ $level -eq 0 -a -d $build_dir ]; then # Sanity check - - if [ ! -w $ban_file -o ! -r $ban_file ]; then # Check ban_file permisions - - chmod a+rw $ban_file || error "Ban file is not readable/writable ($ban_file)" - - else - - rsync -e ssh -aq $PARABOLAHOST:mips64el/ban >/dev/null 2>&1 || { - - warning "Failed to get ban list" && [ -r ${ban_file} ] && { # use local copy if it exist - - search=$(cat ${ban_file} | tr "\n" "|") - - egrep -w "$search" ${buildorder} >> ${build_dir}/banned # Keep track of banned files - - egrep -vw "$search" ${buildorder} > ${buildorder}2 # Take banned packages out of buildorder - - mv -f ${buildorder}2 ${buildorder} - - unset search - } - } - fi -fi - -msg "Building packages:" - -__build # Build the packages - -echo -msg2 "Check if your system works fine and librerelease if it does" - -exit 0 diff --git a/prtools/prmipsrelease b/prtools/prmipsrelease deleted file mode 100755 index 1fbd696..0000000 --- a/prtools/prmipsrelease +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# Lic: GPLv3+ -# Author: Nicolas Reynolds <fauno@kiwwwi.com.ar> -# Local release of mips64el packages + clean ABS sync -# Called by HOOKLOCALRELEASE - -# $1 repo -# $2+ packages - - source /etc/makepkg.conf - source /etc/libretools.conf - source /etc/libretools.d/prtools.conf - - usage() { - echo "$0 repo package1 [ package2 ... packageN ]" - echo - echo " release packages locally on ${PKGDEST}/stage3." - echo " and make a clean ABS sync " - } - -## -# usage : get_full_version( $epoch, $pkgver, $pkgrel ) -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -## - get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi - } - - repo=$1; shift - repo-add "${PKGDEST}/stage3.db.tar.gz" $@ - -# Get all needed sources - source PKGBUILD - fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) - pkgbase=${pkgbase:-$pkgname} - - msg "Adding packages to [stage3]..." - repo-add $@ - for name in ${pkgname[@]}; do - msg2 "${name} ${fullver}" - repo-add ${PKGDEST}/stage3.db.tar.gz ${PKGDEST}/${name}-${fullver}-*.pkg.tar.* - done - -# Copy PKGBUILD and sources - - msg "Adding clean source to $WORKDIR/abs/${CARCH}/$repo/$pkgbase" - dest_dir="$WORKDIR/abs/${CARCH}/$repo/$pkgbase" - mkdir -p ${dest_dir} >/dev/null - rm -rf ${dest_dir}/* # if package existed already there - - eval $(grep '^CARCH=' "$copydir/etc/makepkg.conf") # CARCH might be used in PKGBUILD to select sources. - export CARCH - source=($(. "PKGBUILD"; echo ${source[@]})) - cp --remove-destination "PKGBUILD" "${dest_dir}" || echo "copy 1" - for f in ${source[@]}; do - basef=$(echo $f | sed 's|::.*||' | sed 's|^.*://.*/||g') - if [ -f "$basef" ]; then - cp --remove-destination "$basef" "${dest_dir}" - fi - done - - ( . PKGBUILD - for i in 'changelog' 'install'; do - filelist=$(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD) - for file in $filelist; do - # evaluate any bash variables used - eval file=${file} - if [ -f "$file" ]; then - cp --remove-destination "$file" "${dest_dir}" - fi - done - done - ) -# END add clean abs - -# Commit the changes - - pushd "$dest_dir" >/dev/null - - source "${dest_dir}/PKGBUILD" - epoch=${epoch:-0} - fullver=$(get_full_version ${epoch} ${pkgver} ${pkgrel}) - pkgbase=${pkgbase:-${pkgname[0]}} - - git add "${dest_dir}/." # add using .gitignore - - git commit -m "${pkgbase}-${fullver} ${repo}" >/dev/null && msg2 "${pkgbase} ${fullver} ${repo}" - - popd >/dev/null - -# END commit - - exit $? diff --git a/prtools/prtools.conf b/prtools/prtools.conf deleted file mode 100644 index 5b41216..0000000 --- a/prtools/prtools.conf +++ /dev/null @@ -1,4 +0,0 @@ - -# Absroot for libretools-pr -ABSROOT=$WORKDIR/prabs -HOOKLOCALRELEASE="prmipsrelease"
\ No newline at end of file diff --git a/prtools/prtoru b/prtools/prtoru deleted file mode 100644 index 2898b66..0000000 --- a/prtools/prtoru +++ /dev/null @@ -1,173 +0,0 @@ -#!/bin/bash -# Queries the ABS -# License: GPL3 - -## TODO -# * Add license text -# * Create symlinks from pkgbase to pkgname[@] for easy package finding -# * Use lastsync to store processed packages - -## GOALS -# * Have a searchable database of PKGBUILD metadata -# * Have an interface for source-only builds -# * Possibility to hook up ABS dirs besides ABSROOT (low priority) -# * Tell updates and non available binary packages (working on this) - -source /etc/abs.conf -source /etc/libretools.conf -source /etc/libretools.d/prtools.conf - -# Stores the lastsync date -lastsync() { - [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && { - error "The sync date can't be saved. ${lastsyncfile} isn't writable." - return 1 - } - - date +%s > "$lastsyncfile" - touch "$lastsyncfile" -} - -## -# usage : get_full_version( $epoch, $pkgver, $pkgrel ) -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -## -get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi -} - -# Outputs an ordered package-fullpkgver array -print_package_array() { - echo "$@" | tr " " "\n" | sort -V -u -} - - -# Gets repo.db contents -# $1 repo -get_db_contents() { - [ ! -r /var/lib/pacman/sync/$1.db ] && return 0 - - bsdtar -tf /var/lib/pacman/sync/$1.db | \ - cut -d'/' -f1 | \ - sort -V -u -} - - -extract_pkgname() { - echo "$@" | tr " " "\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+$/\1/" -} - -extract_fullpkgver() { - echo "$@" | tr " " "\n" | sed "s/^.\+-\([^-]\+-[^-]\+\)$/\1/" -} - - -# Updates the database by finding all PKGBUILDS -# Workflow: -# * Find all PKGBUILDs on the ABS repo specified -# * Get all packages already on package repos -# * Compare them -# Args: -update() { -# The PKGBUILDs found - local pkgbuilds=() -# The list of pkgname-fullpkgver - local packages_to_sync=() - local packages_in_sync=() - local needed_updates=() - local old_versions=() - -# Find all the PKGBUILDs newer than the last update -# Update newer, otherwise everything - if [ $force ] || [ ! -e ${lastsyncfile} ]; then - $quiet || msg "Forcing upgrade" - pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD')) - else - pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile})) - fi - -# Inform how many PKGBUILDS were found and quit immediately if none - $quiet || msg "Found $((${#pkgbuilds[*]}-1)) packages to update" - [ ${#pkgbuilds[*]} -eq 1 ] && { - $quiet || msg2 "There's nothing to be done. Phew!" - exit 0 - } - - for _pkgbuild in ${pkgbuilds[@]}; do - -# The repo name is guessed -# You *must* use repo/pkgbase structure - _pkgpath=$(dirname "${_pkgbuild}") - _pkgbase=$(basename "${_pkgpath}") - _pkgrepo=$(basename $(dirname "${_pkgpath}")) - - source ${_pkgbuild} - - for _pkg in ${pkgname[@]}; do -# Fill the list of packages to find - packages_to_sync+=($_pkg-$(get_full_version ${epoch:-0} $pkgver $pkgrel)) - done - - unset pkgbase pkgname pkgver pkgrel source epoch - done - -# Get repo database contents - packages_in_sync=($(get_db_contents ${_pkgrepo})) - print_package_array "${packages_to_sync[@]}" > ${TMPDIR}/packages_to_sync - print_package_array "${packages_in_sync[@]}" > ${TMPDIR}/packages_in_sync - -# We've orderer the files! - needed_updates=($(comm --nocheck-order -32 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) - old_versions=($(comm --nocheck-order -31 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) - - $quiet || msg "This packages are available to update" - for _update in ${needed_updates[@]}; do - pkg=$(extract_pkgname $_update) - - $quiet && echo $pkg - $quiet || { - ver=$(extract_fullpkgver $_update) - oldver=$(extract_fullpkgver $(grep -w $pkg ${TMPDIR}/packages_in_sync)) - - msg2 "$pkg $oldver => $ver" - } - - done - -# lastsync - -} - -## MAIN -commands=() -repos=() -quiet=false -force=false -while getopts 'hqfu' arg; do - case $arg in - h) usage; exit 0 ;; - q) quiet=true ;; - f) force=true ;; - u) commands+=(update);; - esac - - shift $((OPTIND-1)) -done - -# This is the syncfile, stores the last date as content and mtime -lastsyncfile=${ABSROOT}/toru.lastsync - -TMPDIR=$(mktemp -d) - -[[ -z ${TMPDIR} ]] && exit 1 - -${commands[0]} ${@} - -rm -rf ${TMPDIR} - -exit $? diff --git a/rePKGBUILD.proto b/rePKGBUILD.proto deleted file mode 100644 index c8b19bf..0000000 --- a/rePKGBUILD.proto +++ /dev/null @@ -1,29 +0,0 @@ -# This is an example rePKGBUILD file. Use this as a start to creating your own, -# and remove these comments. For more information, see 'man PKGBUILD'. -# NOTE: Please fill out the license field for your package! If it is unknown, -# then please put 'unknown'. - -# Maintainer: Your Name <youremail@domain.com> -source PKGBUILD -unset build package md5sums source -_repo= # Put the repo here -_mirror=http://mirrors.kernel.org/archlinux # Put mirror here -source=(PKGBUILD - "${_mirror}/${_repo}/os/${CARCH}/${pkgname%-libre}-$pkgver-$pkgrel-$CARCH$PKGEXT" - # files for pkg modifications below this line - ) - -build() { - cd "${srcdir}/" - rm .{INSTALL,PKGINFO} - # put actions for package modifications below this line - -} - -package() { - find ${srcdir} -maxdepth 1 -type l -delete - cp -a ${srcdir}/* ${pkgdir} -} - - -# vim:set ts=2 sw=2 et: diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..ff8d399 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,3 @@ +libre_execdir=$(bindir) +libre_datadir=$(sysconfdir) +include ../common.mk diff --git a/src/abslibre-tools/Makefile b/src/abslibre-tools/Makefile new file mode 100644 index 0000000..f2cec54 --- /dev/null +++ b/src/abslibre-tools/Makefile @@ -0,0 +1,3 @@ +libre_execdir=$(bindir) +libre_datadir=$(sysconfdir)/libretools.d +include ../../common.mk diff --git a/createworkdir b/src/abslibre-tools/createworkdir index b443c08..b443c08 100755 --- a/createworkdir +++ b/src/abslibre-tools/createworkdir diff --git a/libreaddiff b/src/abslibre-tools/libreaddiff index 98646a2..98646a2 100755 --- a/libreaddiff +++ b/src/abslibre-tools/libreaddiff diff --git a/librerelease b/src/abslibre-tools/librerelease index efb698e..5a98cf8 100755 --- a/librerelease +++ b/src/abslibre-tools/librerelease @@ -69,12 +69,14 @@ function sign_packages { fi fi - msg2 "Signing ${package}..." - gpg --default-key "${SIGID}" --output "${package}${SIGEXT}" \ - --detach-sig "${package}" || { - error "Signing failed" - exit 2 - } + if ! [ -f "${package}${SIGEXT}" ]; then + msg2 "Signing ${package}..." + gpg --default-key "${SIGID}" --output "${package}${SIGEXT}" \ + --detach-sig "${package}" || { + error "Signing failed" + exit 2 + } + fi done } diff --git a/librestage b/src/abslibre-tools/librestage index b474bb1..ae66cce 100755 --- a/librestage +++ b/src/abslibre-tools/librestage @@ -85,8 +85,7 @@ for _arch in ${ARCHES[@]}; do for pkg in ${pkgname[@]}; do pkgpath=$(find ${PKGDEST}/ -type f \ - -name "${pkg}-${pkgver}-${pkgrel}-${_arch}${PKGEXT}" -or \ - -name "${pkg}-${epoch}:${pkgver}-${pkgrel}-${_arch}${PKGEXT}") + -name "${pkg}-$(get_full_version "${pkg}")-${_arch}${PKGEXT}") [[ -z ${pkgpath} ]] && continue @@ -0,0 +1,133 @@ +#!/bin/bash +# 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/>. + +. /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." +} + +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 +} + +main "$@" diff --git a/src/chroot-tools/Makefile b/src/chroot-tools/Makefile new file mode 100644 index 0000000..3ae95ea --- /dev/null +++ b/src/chroot-tools/Makefile @@ -0,0 +1,3 @@ +libre_execdir=$(sbindir) +libre_datadir=$(sysconfdir)/libretools.d +include ../../common.mk diff --git a/src/chroot-tools/chcleanup b/src/chroot-tools/chcleanup new file mode 100755 index 0000000..f957d3b --- /dev/null +++ b/src/chroot-tools/chcleanup @@ -0,0 +1,76 @@ +#!/bin/bash -eE +# (c) Nicolás Reynolds <fauno@parabola.nu> +# Released under GPLv3 +# +# Performs chroot cleanup smartly, it only removes the unneeded packages or +# leaves you with a cleansystem +# +# See: HOOKPREBUILD + +DRYRUN=${DRYRUN:-false} + +################################################################################ +# Define these here to avoid having dependencies on outside files + +msg() { + local mesg=$1; shift + printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +msg2() { + local mesg=$1; shift + printf "${BLUE} ->${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 +} + +################################################################################ + +if [[ ! -f /.arch-chroot ]] && ! ${DRYRUN}; then + error "(chcleanup): Must be run inside of a chroot" + exit 1 +fi + +source /etc/libretools.d/chroot.conf +# If we're running makepkg +if [ -f PKGBUILD ]; then + source PKGBUILD + CHROOTEXTRAPKG+=("${depends[@]}" + "${makedepends[@]}" + "${checkdepends[@]}") +fi + +msg "Cleaning chroot..." + +TEMPDIR="$(mktemp --tmpdir -d $(basename $0).XXXXX)" +cp -a /var/lib/pacman/sync "${TEMPDIR}/" +cleanup_log="${TEMPDIR}"/libretools-cleanup.log + +# Get the full list of packages needed by dependencies, including the base system +pacman -b "${TEMPDIR}" \ + -Sp --print-format "%n" \ + base-devel "${CHROOTEXTRAPKG[@]}" \ + >"${cleanup_log}" + +# Diff installed packages against a clean chroot then remove leftovers +packages=($(comm -23 <(pacman -Qq | sort -u) \ + <(sort -u "${cleanup_log}"))) + +RET=0 +if [[ ${#packages[@]} != 0 ]]; then + msg2 "Removing %d packages" ${#packages[@]} + + if ${DRYRUN}; then + echo "${packages[@]}" + else + # Only remove leftovers, -Rcs removes too much + pacman --noconfirm -Rn "${packages[@]}" || RET=$? + fi +fi +# Cleanup +rm -rf "${TEMPDIR}" + +exit $RET diff --git a/src/chroot-tools/chroot.conf b/src/chroot-tools/chroot.conf new file mode 100644 index 0000000..a161a61 --- /dev/null +++ b/src/chroot-tools/chroot.conf @@ -0,0 +1,13 @@ +# The full path to the chroot is +# $CHROOTDIR/$CHROOT/$CHROOTCOPY +# where $CHROOTCOPY is set at runtime, either +# - based on the username +# - set with the `-l COPY` flag +# The purpose of having a $CHROOT setting is that multiple clones of the same +# base $CHROOT can quickly and easily be created. +CHROOTDIR=/var/lib/archbuild +CHROOT=default + +# Extra packages to have installed on the chroot. +# This is in addition to CHROOTPKG=(base-devel) +CHROOTEXTRAPKG=(distcc ccache tsocks libretools) diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot new file mode 100755 index 0000000..45aec10 --- /dev/null +++ b/src/chroot-tools/librechroot @@ -0,0 +1,230 @@ +#!/bin/bash -euE +# librechroot + +# Copyright 2010 Nicolás Reynolds +# Copyright 2011 Joshua Haase +# Copyright 2012-2013 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/>. + +. /usr/share/libretools/conf.sh +load_conf_libretools_chroot + +. libremessages +. /usr/share/devtools/makechrootpkg.sh + +# Because the makechrootpkg.sh library functions don't work with -euE +normshell() ( + set +euE + "$@" +) + +cmd=${0##*/} +usage() { + echo "Usage: $cmd [OPTIONS] COMMAND [ARGS...]" + echo 'Interacts with an archroot (arch chroot).' + echo '' + echo 'There may be multiple chroots; they are stored in $CHROOTDIR.' + echo '' + echo 'Each chroot is named; the default is configured with $CHROOT.' + echo '' + echo "Each named chroot has a master clean copy (named 'root'), and any" + echo 'number of other named copies; the copy used by default is the' + echo "current username (or \$SUDO_USER, or 'copy' if root)." + echo '' + echo 'The full path to the chroot copy is "$CHROOTDIR/$CHROOT/$COPY",' + echo 'Unless the copy name is manually specified as an absolute path,' + echo 'in which case, that path is used.' + echo '' + echo 'The current settings for the above varibles are:' + echo " CHROOTDIR : $CHROOTDIR" + echo " CHROOT : $CHROOT" + echo " COPY : $COPY" + echo " root path : $rootdir" + echo " copy path : $copydir" + echo '' + echo 'If the chroot, or copy does not exist, it will be created' + echo 'automatically.' + echo '' + echo 'This command will make the following configuration changes in' + echo 'the chroot:' + echo " - overwrite \`/etc/libretools.d/chroot.conf'" + echo " - overwrite \`/etc/pacman.d/mirrorlist'" + echo " - set \`CacheDir' in \`/etc/pacman.conf'" + echo '' + echo 'Creating a copy, deleting a copy, or syncing a copy can be fairly' + echo 'slow; but are very fast if $CHROOTDIR is on a btrfs partition.' + echo '' + echo 'Options:' + echo ' -n <CHROOT> Name of the chroot to use' + echo ' -l <COPY> Name of, or absolute path to, the copy to use' + echo ' -N Disable networking in the chroot' + echo ' -C <file> Location of pacman config file' + echo ' -M <file> Location of makepkg config file' + echo '' + echo 'Commands:' + echo ' Create/copy/delete:' + echo ' noop|make Do not do anything, but still creates the' + echo ' chroot copy if it does not exist' + echo " sync Sync the copy with the clean ('root') copy" + echo " delete delete the chroot copy" + echo ' Dealing with packages:' + echo ' install-file FILES... Like `pacman -U FILES...`' + echo ' install-name NAMES... Like `pacman -S NAMES...`' + echo ' update Like `pacman -Syu`' + echo ' clean-pkgs Remove all "exta" packages from the chroot copy' + echo ' Other:' + echo ' run CMD... Run CMD in the chroot copy' + echo ' enter Enter an interactive shell in the chroot copy' + echo ' clean-repo Clean /repo in the chroot copy' + echo ' help Show this message' # usage +} + +# Globals: $CHROOTDIR, $CHROOT, $COPY, $rootdir and $copydir +main() { + COPY=$LIBREUSER + [[ $COPY != root ]] || COPY=copy + + # defaults + rootdir="${CHROOTDIR}/${CHROOT}/root" + copydir="${CHROOTDIR}/${CHROOT}/${COPY}" + + local mode=enter + local archroot_args=() + while getopts 'n:l:NC:M:' arg; do + case $arg in + n) CHROOT=$OPTARG;; + l) COPY=$OPTARG;; + N) + # We do this so that it carries through to + # chroot_* functions + archroot() { + $(which archroot) -N "$@" + } + ;; + C|M) archroot_args+=(-$arg "$OPTARG");; + *) usage; return 1;; + esac + done + shift $(($OPTIND - 1)) + if [[ $# < 1 ]]; then + error "Must specify a command" + usage + return 1 + fi + mode=$1 + shift + + rootdir="${CHROOTDIR}/${CHROOT}/root" + if [[ ${COPY:0:1} = / ]]; then + copydir=$COPY + else + copydir="${CHROOTDIR}/${CHROOT}/${COPY}" + fi + + ######################################################################## + + if [[ $mode == help ]]; then + usage + return 0 + fi + + if (( EUID )); then + error "This program must be run as root." + return 1 + fi + + umask 0022 + + # 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" \ + "Waiting for existing lock on chroot copy to be released: [$COPY]" + + if [[ ! -d $rootdir ]]; then + msg "Creating 'root' copy for chroot [$CHROOT]" + set +u # if archroot_args is empty, it counts as unbound + archroot "${archroot_args[@]}" -m "$rootdir" base-devel + set -u + fi + + if [[ ! -d $copydir ]] || [[ $mode == sync ]]; then + msg "Syncing copy [$COPY] with root copy" + normshell chroot_sync "$CHROOTDIR/$CHROOT" "$COPY" + fi + + mkdir -p "$copydir/etc/libretools.d" + { + if [[ -n ${CHROOTEXTRAPKG[@]:-} ]]; then + printf 'CHROOTEXTRAPKG=(' + printf "'%s' " "${CHROOTEXTRAPKG[@]}" + printf ')\n' + else + printf 'CHROOTEXTRAPKG=()\n' + fi + } > "$copydir"/etc/libretools.d/chroot.conf + + if [[ $mode != delete ]]; then + # "touch" the chroot first + # this will + # - overwrite \`/etc/pacman.d/mirrorlist'" + # - set \`CacheDir' in \`/etc/pacman.conf'" + # - apply -C or -M flags + set +u # if archroot_args is empty, it counts as unbound + archroot "${archroot_args[@]}" -r "$copydir" true + set -u + fi + + ######################################################################## + + case "$mode" in + # Creat/copy/delete + noop|make|sync) :;; + delete) + if [[ -d $copydir ]]; then + normshell chroot_delete "$copydir" + fi + ;; + + # Dealing with packages + install-file) normshell chroot_install_pkgs "$copydir" "$@";; + install-name) archroot -r "$copydir" pacman -Sy "$@";; + clean-pkgs) + trap "rm -f '$copydir'/clean '$copydir'/chrootexec" EXIT + cp -a "$(which chcleanup)" "$copydir/clean" + echo '#!/bin/bash' > "$copydir/chrootexec" + echo 'mkdir /build' >> "$copydir/chrootexec" + echo 'cd /build; /clean' >> "$copydir/chrootexec" + chmod 755 "$copydir/chrootexec" + archroot -r "$copydir" /chrootexec + ;; + + # Other + run) archroot -r "$copydir" "$@";; + enter) archroot -r "$copydir" bash;; + clean-repo) + rm -rf "${copydir}/repo/*" + bsdtar -czf "${copydir}/repo/repo.db.tar.gz" -T /dev/null + ln -s "repo.db.tar.gz" "${copydir}/repo/repo.db" + ;; + *) + error "Unrecognized command: \`$mode'" + return 1 + ;; + esac +} + +main "$@" diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg new file mode 100755 index 0000000..b8cdca1 --- /dev/null +++ b/src/chroot-tools/libremakepkg @@ -0,0 +1,311 @@ +#!/bin/bash -euE +# libremakepkg + +# Copyright 2010 - 2011 Nicolás Reynolds +# Copyright 2011 Joshua Ismael Haase Hernández +# Copyright 2012-2013 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/>. + +. /usr/share/libretools/conf.sh +load_conf_libretools_chroot + +. libremessages + +shopt -s nullglob +umask 0022 + +# Boring/mundane functions ##################################################### + +# End inmediately but print a useful message +trap_exit() { + error "$*" + set +euE + . /usr/share/devtools/makechrootpkg.sh + chroot_copy_out_logs "$@" + exit 1 +} + +# Usage run [-N] $copydir "$cmd" +# Runs cmd properly, whether in a chroot already or not. +# +# Note that $cmd is a quoted string, not a list of arguments. +# $copydir=/ if INCHROOT=true +# +# Environment +# - $INCHROOT is set +run() { + local HASNET=true + [[ $1 == -N ]] && { HASNET=false; shift; } + local copydir=$1; shift + local cmd="$*" + + cat >"$copydir/chrootexec" <<EOF +#!/bin/bash +. /etc/profile +${INCHROOT} || export HOME=/build +${INCHROOT} || cd /build + +${cmd} +EOF + chmod 755 "$copydir/chrootexec" + + local flags='' + if $INCHROOT; then + $HASNET || flags='-n' + unshare $flags -- /chrootexec + else + $HASNET || flags='-N' + librechroot $flags -l "$copydir" run /chrootexec + fi +} + +# Usage: add_to_local_repo $copydir +add_to_local_repo() ( + set +euE + . /usr/share/devtools/makechrootpkg.sh + chroot_add_to_local_repo "$@" +) + +# Usage: chroot_copy_in $copydir +# Environment: +# - In the dirctory of a PKGBUILD +# - $SRCDEST is set +chroot_copy_in() ( + set +euE + . /usr/share/devtools/makechrootpkg.sh + chroot_copy_in "$@" +) + +# Usage: chroot_copy_out $copydir $owner +# Environment: +# - $SRCDEST is set +# - $PKGDEST is set +chroot_copy_out() ( + set +euE + . /usr/share/devtools/makechrootpkg.sh + chroot_copy_out_pkgs "$@" + chroot_copy_out_logs "$@" + chroot_copy_out_srcs "$@" +) + +# Usage: chroot_let_nobody_use_pacman $copydir +chroot_let_nobody_use_pacman() ( + set +euE + . /usr/share/devtools/makechrootpkg.sh + chroot_let_nobody_use_pacman "$@" +) + +# Usage: chroot_init $copydir $repack +# Environment +# - $LIBREHOME is set +chroot_init() { + local copydir=$1 + local repack=$2 + + librechroot -l "$copydir" make # make sure the chroot exists + mkdir -p "$copydir"/{build,pkgdest,srcdest} + + # Remove anything in there UNLESS -R (repack) was passed + $repack || rm -rf "$copydir"/build/* + + if [[ -r "$LIBREHOME/.gnupg/pubring.gpg" ]]; then + install -D "$LIBREHOME/.gnupg/pubring.gpg" "$copydir/build/.gnupg/pubring.gpg" + fi + rm -f "$copydir/build/.makepkg.conf" + + MAKEPKG_CONF="$copydir/etc/makepkg.conf" set_conf_makepkg PKGDEST /pkgdest + MAKEPKG_CONF="$copydir/etc/makepkg.conf" set_conf_makepkg SRCDEST /srcdest + + if grep -q '^\[repo\]' "$copydir/etc/pacman.conf"; then + cat >> "$copydir/etc/makepkg.conf" <<EOF +[repo] +SigLevel = Optional TrustAll +Server = file:///repo +EOF + fi + + chroot_let_nobody_use_pacman "$copydir" +} + +# Core functions ############################################################### + +# Usage: extract +# Extracts the sources (`makepkg -o`) +# Environment: +# - $INCHROOT is set +# - $copydir is set +# - $LIBREUSER is set +extract() { + local user=$LIBREUSER + $INCHROOT || user=nobody + + local clean + if $INCHROOT; then + clean=chcleanup + else + cp -a "$(which chcleanup)" "${copydir}/clean" + clean=/clean + fi + + run "$copydir" "${clean} && sudo -u ${user} makepkg ${makepkg_args} -o" + rm -f "$copydir"/clean +} + +# Usage: build +# Builds the package (`makepkg -e`) +# Environment: +# - $INCHROOT is set +# - $copydir is set +# - $LIBREUSER is set +build() { + local user=$LIBREUSER + $INCHROOT || user=nobody + + run -N "$copydir" "sudo -u ${user} makepkg ${makepkg_args} -e" +} + +# Functions that check for issues with the build ############################### + +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 +} + +check_src() { + msg "Checking src directory for issues" + # TODO +} + +check_pkg() { + msg "Checking final package for issues" + # TODO +} + + +# The main program ############################################################# + +cmd=${0##*/} +usage() { + echo "Usage: $cmd [options] [-- makepkg args]" + echo 'This program will build your package.' + echo '' + echo 'If run from outside of a chroot, this will set PKGDEST and' + echo "SRCDEST in the chroot's \`/etc/makepkg.conf', as well as making" + echo "whataver alterations to the chroot \`librechroot' makes." + echo '' + echo "The \`-n' and \`-l' options behave identically to librechroot," + echo 'see the documentation there.' + echo '' + echo 'Options:' + echo ' -n <CHROOT> Name of the chroot to use' + echo ' -l <COPY> Name of, or absolute path to, the copy to use' + echo ' -R Repackage contents of the package without rebuilding' + echo ' -h Show this message' +} + +# Globals: $CHROOTDIR, $CHROOT, $COPY and $copydir +# Globals: $makepkg_args, $INCHROOT +main() { + # Parse command line ################################################### + + COPY=$LIBREUSER + [[ $COPY != root ]] || COPY=copy + + makepkg_args='-s --noconfirm -L ' + local repack=false + + INCHROOT=false + if [[ -f /.arch-chroot ]]; then + INCHROOT=true + fi + + while getopts 'n:l:Rh' arg ; do + case "${arg}" in + n) CHROOT=$OPTARG;; + l) COPY=$OPTARG;; + R) repack=true; makepkg_args+=" -R";; + h) usage; return 0;; + *) usage; return 1;; + esac + done + shift $(($OPTIND - 1)) + # Pass all arguments after -- right to makepkg + makepkg_args+=" $*" + + if $INCHROOT; then + copydir='/' + elif [[ ${COPY:0:1} = / ]]; then + copydir=$COPY + else + copydir="${CHROOTDIR}/${CHROOT}/${COPY}" + fi + + # Init ################################################################# + + if (( EUID )); then + error "This script must be run as root" + exit 1 + fi + + if [[ ! -f PKGBUILD ]]; then + # This is the message used by makepkg + error "PKGBUILD does not exist." + 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 error has occurred. Exiting..."' ERR + + SRCDEST="$(get_conf_makepkg SRCDEST .)" + PKGDEST="$(get_conf_makepkg PKGDEST .)" + + # OK, we're starting now ############################################### + + $INCHROOT || lock_open_write 9 "$copydir" \ + "Waiting for existing lock on chroot copy to be released: [$COPY]" + + # Set target CARCH as it might be used within the PKGBUILD to select + # correct sources + MAKEPKG_CONF=$copydir/etc/makepkg.conf + export CARCH="$(get_conf_makepkg CARCH)" + unset MAKEPKG_CONF + + $INCHROOT || chroot_init "$copydir" "$repack" + + check_pkgbuild + $INCHROOT || chroot_copy_in "$copydir" + $repack || extract + check_src + build + check_pkg + + add_to_local_repo "$copydir" + $INCHROOT || chroot_copy_out "$copydir" "$LIBREUSER" +} + +main "$@" diff --git a/src/devtools/.gitignore b/src/devtools/.gitignore new file mode 100644 index 0000000..06a1942 --- /dev/null +++ b/src/devtools/.gitignore @@ -0,0 +1,4 @@ +* +!*/ +!Makefile +!*.patch diff --git a/src/devtools/Makefile b/src/devtools/Makefile new file mode 100644 index 0000000..e357675 --- /dev/null +++ b/src/devtools/Makefile @@ -0,0 +1,103 @@ +# Configuration +DESTDIR= + +#prefix=/usr/local +prefix=/usr +exec_prefix=$(prefix) +datarootdir=$(prefix)/share + +bindir=$(exec_prefix)/bin +sbindir=$(exec_prefix)/sbin +datadir=$(datarootdir) + +pkgdatadir=$(datadir)/devtools + +devtoolsdir=../../../devtools-par + +default: all +all: build + +###################################################################### + +copy: \ + archroot.in \ + checkpkg.in \ + find-libdeps.in \ + finddeps.in \ + lddd.in \ + lib/common.sh.in \ + lib/makechrootpkg.sh.in + +archroot.in: $(devtoolsdir)/mkarchroot.in ; cp $< $@ +checkpkg.in: $(devtoolsdir)/checkpkg.in ; cp $< $@ +find-libdeps.in: $(devtoolsdir)/find-libdeps.in ; cp $< $@ +finddeps.in: $(devtoolsdir)/finddeps.in ; cp $< $@ +lddd.in: $(devtoolsdir)/lddd.in ; cp $< $@ +lib/common.sh.in: $(devtoolsdir)/lib/common.sh ; cp $< $@ +lib/makechrootpkg.sh.in: $(devtoolsdir)/makechrootpkg.in ; cp $< $@ + +###################################################################### + +build: \ + archroot \ + checkpkg \ + find-libdeps \ + finddeps \ + lddd \ + lib/common.sh \ + lib/makechrootpkg.sh + +edit = sed -e 's|m4_include(lib/\(.*\))|. @pkgdatadir@/\1|' -e "s|@pkgdatadir[@]|$(pkgdatadir)|g" + +indent = emacs --batch $1 \ + --eval '(setq sh-basic-offset 8)' \ + --eval '(indent-region (point-min) (point-max) nil)' \ + -f save-buffer &>/dev/null + +%: %.in Makefile + @echo "GEN $@" + @$(edit) <"$<" >"$@" + @chmod 755 "$@" + +lib/common.sh: %: %.in Makefile + @echo "GEN $@" + @{ \ + echo 'if [[ -z $${_INCLUDE_COMMON_SH:-} ]]; then' && \ + echo '_INCLUDE_COMMON_SH=true' && \ + cat "$<" && \ + echo 'fi'; } > "$@" + +lib/makechrootpkg.sh.ugly: %.ugly: %.in %.patch Makefile + @echo "GEN $@" + @cp $*.in $@ + @patch $@ $*.patch + +lib/makechrootpkg.sh: %: %.ugly Makefile + @echo "GEN $@" + @$(edit) <"$<" >"$@" + $(call indent,$@) + +###################################################################### + +install: \ + $(DESTDIR)$(sbindir)/archroot \ + $(DESTDIR)$(bindir)/checkpkg \ + $(DESTDIR)$(bindir)/find-libdeps \ + $(DESTDIR)$(bindir)/find-libprovides \ + $(DESTDIR)$(bindir)/finddeps \ + $(DESTDIR)$(bindir)/lddd \ + $(DESTDIR)$(pkgdatadir)/common.sh \ + $(DESTDIR)$(pkgdatadir)/makechrootpkg.sh + +$(DESTDIR)$(sbindir)/%: % + install -Dm755 $< $@ + +$(DESTDIR)$(bindir)/%: % + install -Dm755 $< $@ + +$(DESTDIR)$(pkgdatadir)/%: lib/% + install -Dm644 $< $@ + +$(DESTDIR)$(bindir)/find-libprovides: + install -d $(@D) + ln -sf find-libdeps $@ diff --git a/src/devtools/lib/makechrootpkg.sh.patch b/src/devtools/lib/makechrootpkg.sh.patch new file mode 100644 index 0000000..6016ba4 --- /dev/null +++ b/src/devtools/lib/makechrootpkg.sh.patch @@ -0,0 +1,254 @@ +--- makechrootpkg.sh.in ++++ makechrootpkg.sh.ugly +@@ -12,12 +12,7 @@ + + shopt -s nullglob + +-# So that usage conflicts between upstream and -par mkarchroot don't get hidden +-# silently in a merge. +-archroot() { +- mkarchroot "$@" +-} +- ++init_variables() { + makepkg_args='-s --noconfirm -L' + repack=false + update_first=false +@@ -28,13 +23,14 @@ + temp_chroot=false + chrootdir= + passeddir= +-declare -a install_pkgs +-declare -i ret=0 ++declare -ag install_pkgs ++declare -ig ret=0 + + copy=$USER + [[ -n $SUDO_USER ]] && copy=$SUDO_USER + [[ -z "$copy" || $copy = root ]] && copy=copy + src_owner=${SUDO_USER:-$USER} ++} + + usage() { + echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]" +@@ -69,6 +65,7 @@ + exit 1 + } + ++parse_options_init() { + while getopts 'hcudr:I:l:nT' arg; do + case "$arg" in + h) usage ;; +@@ -129,8 +126,20 @@ + # Note this is the same FD number as in mkarchroot + lock_open_write 9 "$copydir" \ + "Waiting for existing lock on chroot copy to be released: [$copy]" ++} ++ ++# Usage: chroot_sync $CHROOTDIR/$CHROOT [$CHROOTCOPY|$copydir] ++chroot_sync() { ++ local chrootdir=$1 ++ local copy=$2 ++ local copydir='' ++ if [[ ${copy:0:1} = / ]]; then ++ copydir=$copy ++ else ++ copydir="$chrootdir/$copy" ++ fi ++ local chroottype=$(stat -f -c %T "$chrootdir") + +-if [[ ! -d $copydir ]] || $clean_first; then + # Get a read lock on the root chroot to make + # sure we don't clone a half-updated chroot + lock_open_read 8 "$chrootdir/root" \ +@@ -152,9 +161,16 @@ + + # Drop the read lock again + lock_close 8 +-fi ++} ++ ++# Usage: chroot_install_pkgs $copydir $pkgs... ++chroot_install_pkgs() { ++ local copydir=$1 ++ shift ++ declare -i ret=0 ++ declare -a install_pkgs=("$@") ++ local pkgname + +-if [[ -n "${install_pkgs[*]}" ]]; then + for install_pkg in "${install_pkgs[@]}"; do + pkgname="${install_pkg##*/}" + cp "$install_pkg" "$copydir/$pkgname" +@@ -165,10 +181,10 @@ + rm "$copydir/$pkgname" + done + +- # If there is no PKGBUILD we have done +- [[ -f PKGBUILD ]] || exit $ret +-fi ++ return $ret ++} + ++func1() { + $update_first && archroot -u "$copydir" + + mkdir -p "$copydir/build" +@@ -230,7 +246,14 @@ + # Set target CARCH as it might be used within the PKGBUILD to select correct sources + eval $(grep '^CARCH=' "$copydir/etc/makepkg.conf") + export CARCH ++} + ++# Usage: chroot_copy_in $copydir ++# Environment: ++# - In the dirctory of a PKGBUILD ++# - $SRCDEST is set ++chroot_copy_in() { ++local copydir=$1 + # Copy PKGBUILD and sources + cp PKGBUILD "$copydir/build/" + ( +@@ -256,13 +279,23 @@ + ) + + chown -R nobody "$copydir"/{build,pkgdest,srcdest} ++} + ++# Usage: chroot_let_nobody_use_pacman $copydir ++chroot_let_nobody_use_pacman() { ++local copydir=$1 + 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" ++} + ++# Usage: chroot_build $copydir $makepkg_args $run_namcap ++chroot_build() { ++local copydir=$1 ++local makepkg_args=$2 ++local run_namcap=$3 + # This is a little gross, but this way the script is recreated every time in the + # working copy + cat >"$copydir/chrootbuild" <<EOF +@@ -284,37 +317,62 @@ + exit 0 + EOF + chmod +x "$copydir/chrootbuild" ++archroot -r "$copydir" "/chrootbuild" ++} + +-if archroot -r "$copydir" "/chrootbuild"; then +- for pkgfile in "$copydir"/pkgdest/*.pkg.tar.?z; do +- if $add_to_db; then ++# Usage: chroot_add_to_local_repo $copydir ++chroot_add_to_local_repo() { ++ local copydir=$1 ++ 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 +- fi ++ done ++} + ++# Usage: chroot_copy_out_pkgs $copydir $user ++# Environment: ++# - $PKGDEST is set ++chroot_copy_out_pkgs() { ++ local copydir=$1 ++ local src_owner=$2 ++ for pkgfile in "$copydir"/pkgdest/*.pkg.tar*; do + chown "$src_owner" "$pkgfile" + mv "$pkgfile" "$PKGDEST" ++ if [[ $PKGDEST != . ]]; then ++ ln -sf "$PKGDEST/${pkgfile##*/}" . ++ fi + done ++} + +- for l in "$copydir"/build/*-{build,check,namcap,package,package_*}.log; do ++# Usage: chroot_copy_out_pkgs $copydir $user ++chroot_copy_out_logs() { ++ local copydir=$1 ++ local src_owner=$2 ++ for l in "$copydir"/build/*.log; do + chown "$src_owner" "$l" + [[ -f $l ]] && mv "$l" . + done +-else +- # Just in case. We returned 1, make sure we fail +- ret=1 +-fi ++} + ++# Usage: chroot_copy_out_srcs $copydir $user ++# Environment: ++# - $SRCDEST is set ++chroot_copy_out_srcs() { ++local copydir=$1 ++local src_owner=$2 + for f in "$copydir"/srcdest/*; do + chown "$src_owner" "$f" + mv "$f" "$SRCDEST" + done ++} + +-if $temp_chroot; then +- stat_busy "Removing temporary directoy [$copy]" ++# Usage: chroot_delete $copydir ++chroot_delete() { ++ local chroottype=$(stat -f -c %T "$copydir") ++ stat_busy "Removing chroot copy [$copy]" + if [[ "$chroottype" == btrfs ]]; then + btrfs subvolume delete "$copydir" >/dev/null || + die "Unable to delete subvolume $copydir" +@@ -326,8 +384,39 @@ + # remove lock file + rm --force "$copydir.lock" + stat_done +-elif (( ret != 0 )); then +- die "Build failed, check $copydir/build" +-else +- true +-fi ++} ++ ++main() { ++ init_variables ++ parse_options_init "$@" ++ if [[ ! -d $copydir ]] || $clean_first; then ++ chroot_sync "$chrootdir" "$copy" ++ fi ++ if [[ -n "${install_pkgs[*]}" ]]; then ++ chroot_install_pkgs "$copydir" "${install_pkgs[@]}" ++ ret=$? ++ # If there is no PKGBUILD we have done ++ [[ -f PKGBUILD ]] || exit $ret ++ fi ++ func1 ++ chroot_copy_in "$copydir" ++ chroot_let_nobody_use_pacman "$copydir" ++ chroot_build "$copydir" "$makepkg_args" "$run_namcap" ++ func2 ++ if chroot_build; then ++ chroot_add_to_local_repo "$copydir" ++ chroot_copy_out_pkgs "$copydir" "$src_owner" ++ chroot_copy_out_logs "$copydir" "$src_owner" ++ else ++ # Just in case. We returned 1, make sure we fail ++ ret=1 ++ fi ++ chroot_copy_out_srcs "$copydir" "$src_owner" ++ if $temp_chroot; then ++ chroot_delete "$copydir" ++ elif (( ret != 0 )); then ++ die "Build failed, check $copydir/build" ++ else ++ true ++ fi ++} diff --git a/src/diff-unfree b/src/diff-unfree new file mode 100755 index 0000000..24ada67 --- /dev/null +++ b/src/diff-unfree @@ -0,0 +1,86 @@ +#!/bin/bash +# This script will help you diff a *-libre PKGBUILD against the unfree one +# to check for updates. +# Copyright 2010 Nicolás Reynolds + +# ---------- 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/>. + +. /etc/libretools.conf + +cmd=${0##*/} + +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." +} + +main() { + if [[ "$1" == "--help" ]]; then + usage + exit 0 + fi + + local package_guess=${PWD##*/} + local repo=${1:-$(basename ${PWD%/*})} + local package=${2:-${package_guess%-libre}} + local trunk=${3:-trunk} + + 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 + + + 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}"' + + msg "Getting diff from $repo/$package..." + + stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo' + + cd ${svnrepo} + svn update ${package} + + # Back to start dir + stdnull popd + + msg "Diffing files" + + for _file in ${unfree_dir}/*; do + msg2 "$(basename "${_file}")" + ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}" + done +} + +main "$@" diff --git a/src/fullpkg/Makefile b/src/fullpkg/Makefile new file mode 100644 index 0000000..f2cec54 --- /dev/null +++ b/src/fullpkg/Makefile @@ -0,0 +1,3 @@ +libre_execdir=$(bindir) +libre_datadir=$(sysconfdir)/libretools.d +include ../../common.mk diff --git a/fullpkg b/src/fullpkg/fullpkg index 9a03b82..6d6153a 100755 --- a/fullpkg +++ b/src/fullpkg/fullpkg @@ -20,7 +20,7 @@ usage() { } -while getopts 'haA:l:nm:' arg; do +while getopts 'h' arg; do case "$arg" in h) usage ;; esac diff --git a/fullpkg-build b/src/fullpkg/fullpkg-build index b497db5..b497db5 100755 --- a/fullpkg-build +++ b/src/fullpkg/fullpkg-build diff --git a/fullpkg-find b/src/fullpkg/fullpkg-find index e188ec8..b09edf9 100755 --- a/fullpkg-find +++ b/src/fullpkg/fullpkg-find @@ -56,7 +56,6 @@ copy_files() { # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated. find_deps() { # Check this level - source /etc/makepkg.conf source PKGBUILD local repo="${repo:-$(guess_repo)}" @@ -131,6 +130,7 @@ find_deps() { } source /etc/libretools.conf +source /etc/makepkg.conf if [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then source $XDG_CONFIG_HOME/libretools/libretools.conf @@ -206,7 +206,6 @@ if [ "$LEVEL" -eq 0 ]; then msg "Checking dependencies" fi -# Find the dependencies on the ABS itself find_deps exit 0 diff --git a/is_unfree b/src/is_unfree index f32c193..c2a37c9 100755 --- a/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/lib/Makefile b/src/lib/Makefile new file mode 100644 index 0000000..0c69ba3 --- /dev/null +++ b/src/lib/Makefile @@ -0,0 +1,2 @@ +libre_datadir=$(datadir)/libretools +include ../../common.mk diff --git a/src/lib/conf.sh b/src/lib/conf.sh new file mode 100644 index 0000000..43a30af --- /dev/null +++ b/src/lib/conf.sh @@ -0,0 +1,121 @@ +#!/bin/bash + +INCLUDE_CONF_SH=conf.sh + +LIBREUSER="${SUDO_USER:-$USER}" +LIBREHOME="$(eval echo ~$LIBREUSER)" +if [[ -z ${XDG_CONFIG_HOME:-} ]]; then + export XDG_CONFIG_HOME="${LIBREHOME}/.config" +fi + +# Generic functions ############################################################ + +get_files() { + local slug=$1 + case $slug in + makepkg.conf) + if [[ $MAKEPKG_CONF != /etc/$slug && -r $MAKEPKG_CONF ]]; then + echo "$MAKEPKG_CONF" + else + echo /etc/$slug + echo "$LIBREHOME/.$slug" + fi + ;; + libretools.conf) + echo /etc/$slug + echo "$XDG_CONFIG_HOME/libretools/$slug" + ;; + *.conf) + echo /etc/libretools.d/$slug + echo "$XDG_CONFIG_HOME/libretools/$slug" + ;; + esac +} + +load_files() { + for file in $(get_files $1.conf); do + if [[ -r $file ]]; then + . "$file" + fi + done +} + +check_vars() { + local slug=$1 + shift + local ret=0 + for VAR in "$@"; do + if [[ -z ${!VAR} ]]; then + if [[ $(get_files $slug|wc -l) > 1 ]]; then + echo "Configure '$VAR' in one of:" + get_files $slug | sed 's/./ -> &/' + else + echo "Configure '$VAR' in $(get_files $slug)" + fi + ret=1 + fi >>/dev/stderr + done + if [[ $ret != 0 ]]; then + return 1 + fi +} + +# makepkg configuration ######################################################## + +[[ -n ${MAKEPKG_CONF:-} ]] || MAKEPKG_CONF=/etc/makepkg.conf + +load_conf_makepkg() { + load_files makepkg +} + +get_conf_makepkg() ( + set +euE + local setting=$1 + local default=$2 + load_conf_makepkg + printf '%s\n' "${!setting:-${default}}" +) + +set_conf_makepkg() { + local key=$1 + local val=$2 + for file in `get_files makepkg.conf|tac`; do + if [[ -w $file ]]; then + sed -i "/^\s*$key=/d" "$file" + echo "$key='$val'" >> "$file" + return 0 + fi + done + return 1 +} + + +# libretools configuration ##################################################### + +check_conf_libretools() { + check_vars libretools.conf \ + PARABOLAHOST LIBREDESTDIR BLACKLIST WORKDIR REPOS ARCHES \ + ABSLIBREGIT DIFFTOOL FULLBUILDCMD SIGEXT SIGID +} + +load_conf_libretools() { + load_files libretools + check_conf_libretools +} + +load_conf_libretools_chroot() { + load_files chroot + # Exclude CHROOTEXTRAPKG from the checks because an empty value is valid + if [[ -f /.arch-chroot ]]; then + # inside of a chroot, only CHROOTEXTRAPKG needs to be set, but + # as stated above, we don't check for it. + : + else + check_vars chroot.conf CHROOTDIR CHROOT + fi +} + +load_conf_libretools_librefetch() { + load_files librefetch + check_vars librefetch.conf MIRROR DOWNLOADER +} diff --git a/src/librediff b/src/librediff new file mode 100755 index 0000000..6dbe41b --- /dev/null +++ b/src/librediff @@ -0,0 +1,57 @@ +#!/bin/bash +# Generates a patch for a nonfree PKGBUILD +# +# Copyright 2010 Nicolás Reynolds + +# ---------- 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/>. + +. /etc/libretools.conf + +cmd=${0##*/} + +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 "${packages[@]}"; do + if [[ ! -f ./${package}/PKGBUILD || ! -f ./${package}-libre/PKGBUILD ]] + then + error "Build scripts not found for ${package}(-libre)" + else + + . ./${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 + done + + exit 0 +} + +main "$@" diff --git a/src/librefetch/Makefile b/src/librefetch/Makefile new file mode 100644 index 0000000..f2cec54 --- /dev/null +++ b/src/librefetch/Makefile @@ -0,0 +1,3 @@ +libre_execdir=$(bindir) +libre_datadir=$(sysconfdir)/libretools.d +include ../../common.mk diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch new file mode 100755 index 0000000..6a05cb9 --- /dev/null +++ b/src/librefetch/librefetch @@ -0,0 +1,301 @@ +#!/bin/bash +# librefetch +# +# Copyright 2013 Luke Shumaker <lukeshu@sbcglobal.net> +# +# 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/>. + +. /usr/share/libretools/conf.sh +. libremessages + +declare -r tempdir="$(mktemp -d --tmpdir ${0##*/}.XXXXXXXXXXX)" +cleanup() { rm -rf -- "$tempdir"; } +trap cleanup EXIT + +cmd=${0##*/} +usage() { + print "Usage: %s [options] <source-url> <output-file>" "$cmd" + print "Usage: %s -[g|V|h]" "$cmd" + print "Downloads or creates a liberated source tarball." + echo + print "The default build script is 'PKGBUILD', or 'SRCBUILD' if it exists." + echo + print "Unrecognized options are passed straight to makepkg." + echo + print "Example usage:" + print ' $ %s libre://mypackage-1.0.tar.gz $SRCDEST/mypackage-1.0.tar.gz.part' "$cmd" + echo + print "Options:" + print " Settings:" + print " -C Force create mode (don't download)" + print " -D Force download mode (don't create)" + print " -p <file> Use an alternate build script (instead of 'PKGBUILD')" + print " If an SRCBUILD exists in the same directory, it is used" + print " instead" + print " Alternate modes:" + print " -g, --geninteg Generage integrity checks for source files" + print " -V, --version Show version information" + print " -h, --help Show this message" +} + +version() { + print "librefetch (libretools) beta 4" + echo + print "Copyright (C) 2013 Luke Shumaksr <lukeshu@sbcglobal.net>" + print "This is free software; see the source for copying conditions." + print "There is NO WARRANTY, to the extent permitted by law." +} + +main() { + BUILDFILE="$(readlink -m PKGBUILD)" + makepkg_opts=() + extra_opts=() + mode=download-create + parse_options "$@" + + local startdir=$PWD + export BUILDDIR="${BUILDFILE%/*}" + if [[ -f "${BUILDDIR}/SRCBUILD" ]]; then + BUILDFILE="${BUILDDIR}/SRCBUILD" + srcbuild="$(modified_srcbuild "$BUILDFILE")" + else + srcbuild="$(modified_pkgbuild "$BUILDFILE")" + fi + makepkg="$(modified_makepkg "$(which "${MAKEPKG:-makepkg}")")" + + # Mode: version, help ################################################## + + if [[ $mode =~ version ]]; then + version + return 0 + fi + if [[ $mode =~ help ]]; then + usage + return 0 + fi + + # Mode: checksums ###################################################### + + if [[ $mode =~ checksums ]]; then + if [[ ${#extra_opts[@]} != 0 ]]; then + print "%s: found extra non-flag arguments: %s" "$cmd" "${extra_opts[*]}" + usage >> /dev/stderr + return 1 + fi + "$makepkg" "${makepkg_opts[@]}" -g -p "$srcbuild" | + case ${BUILDFILE##*/} in + PKGBUILD) sed -e 's/^[a-z]/mk&/' -e 's/^\s/ &/';; + SRCBUILD) cat;; + esac + return 0 + fi + + ######################################################################## + + if [[ ${#extra_opts[@]} != 2 ]]; then + print "%s: %d non-flag arguments found, expected 2: %s" "$cmd" ${#extra_opts[@]} + usage >> /dev/stderr + return 1 + fi + local src="${extra_opts[0]#*://}" + local dst="$(readlink -m "${extra_opts[1]}")" + + # Mode: download ####################################################### + + if [[ $mode =~ download ]]; then + load_conf_libretools_librefetch || return 1 + + local url="${MIRROR}/${src}" + + local dlcmd="${DOWNLOADER}" + dlcmd="${dlcmd//\%o/\"$dst\"}" + dlcmd="${dlcmd//\%u/\"$url\"}" + { eval "$dlcmd"; } && return 0 + fi + + # Mode: create ######################################################### + + if [[ $mode =~ create ]]; then + PKGEXT=${dst##*/} + export PKGEXT=${PKGEXT%.part} + export PKGDEST=$startdir + export pkg_file=$dst + "$makepkg" "${makepkg_opts[@]}" -p "$srcbuild" + fi +} + +# sets the variables BUILDFILE, makepkg_opts, extra_opts, mode +parse_options() { + # Detect makepkg options that take a second argument + local makepkg_orig="$(which "${MAKEPKG:-makepkg}")" + local makepkg_opt2long=($("${makepkg_orig}" -h | sed -rn 's/\s*(--\S*) <.*/\1/p')) + local makepkg_opt2short=($("${makepkg_orig}" -h | sed -rn 's/\s*(-.) <.*/\1/p')) + + local opt + local have_opt + while [[ $# > 0 ]]; do + arg=$1 + have_opt=false + if in_array "${arg%%=*}" "${makepkg_opt2long[@]}"; then + opt="${arg#*=}" + arg="${arg%%=*}" + have_opt=true + fi + if in_array "${arg}" "${makepkg_opt2short[@]}"; then + shift + opt=$1 + have_opt=true + fi + case "$arg" in + -C) mode=create;; + -D) mode=download;; + -g|--geninteg) mode=checksums;; + -p) BUILDFILE="$(readlink -m "$opt")";; + -V|--version) mode=version;; + -h|--help) mode=help;; + -*) + makepkg_opts+=("$arg") + $have_opt && makepkg_opts+=("$opt") + ;; + --) shift; break;; + *) extra_opts+=("$arg");; + esac + shift + done + extra_opts+=("$@") +} + +# Modify makepkg ############################################################### + +# an ERE +makepkg_modify=' +/create_package\(\) \{/,/^\}$/ { + /pkg_file=/d # allow us to set pkg_file + /check_package/d # do not run check_package + s/"?\$\{comp_files\[@\]\}"?// # do not include .{PKGINFO,INSTALL,CHANGELOG} +} + +/tidy_install\(\) \{/,/^\}$/ { + /for .*PURGE_TARGETS/itidy_install_purge + /for .*PURGE_TARGETS/,/done/d + /^\}$/ifind . -exec touch --date="1990-01-01 0:0:0 +0" {} + +} + +s|srcdir=.*|srcdir="$BUILDDIR/src-libre"| +s|pkgdir=.*|pkgdir="$BUILDDIR/pkg-libre"| +s|check_build_status$|:| +' + +tidy_install_purge() { + local pt + for pt in "${PURGE_TARGETS[@]}"; do + if [[ ${pt} = "${pt%/}" ]]; then + if [[ ${pt} = "${pt//\/}" ]]; then + find . ! -type d -name "${pt}" -exec rm -f -- '{}' + + else + rm -f "${pt}" + fi + else + if [[ ${pt%/} = "${pt//\/}" ]]; then + find . -type d -name "${pt%/}" -exec rm -rf -- '{}' + + else + rm -rf "${pt}" + fi + fi + done +} + +modified_makepkg() { + local makepkg_orig=$1 + local makepkg_mine="$tempdir/makepkg" + { + echo '#!/bin/bash' + declare -f tidy_install_purge + sed -r "$makepkg_modify" < "$makepkg_orig" + } > "$makepkg_mine" + chmod 755 "$makepkg_mine" + printf "%s\n" "$makepkg_mine" +} + +# Modify PKGBUILD ############################################################## + +# a string to be appended +pkgbuild_append=' +# do not do split packages +if [[ -n $pkgbase ]]; then + pkgname=$pkgbase +else + pkgname=$pkgname +fi + +# copy source variables +source=("${mksource[@]}") +noextract=("${mknoextract[@]}") +md5sums=("${mkmd5sums[@]}") +sha1sums=("${mksha1sums[@]}") +sha256sums=("${mksha256sums[@]}") +sha384sums=("${mksha384sums[@]}") +sha512sums=("${mksha512sums[@]}") + +depends=() +checkdepends=() +makedepends=("${mkdepends[@]}") + +#### +options+=(!strip docs libtool emptydirs !zipman purge !upx) +PURGE_TARGETS+=(.bzr/ .cvs/ .git/ .hg/ .svn/) + +#### +if ! declare -f mksource >/dev/null; then + mksource() { :; } +fi +build() { mksource; } +package() { + if [[ $(ls "$pkgdir" | wc -l) == 0 ]]; then + # pkgdir is empty; provide good default behavior + cp -a "${srcdir}"/*/ "$pkgdir/" + fi +} +' + +modified_pkgbuild() { + local pkgbuild=$1 + local srcbuild="$tempdir/SRCBUILD" + printf '%s' "$pkgbuild_append" | cat "$pkgbuild" - > "$srcbuild" + printf '%s\n' "$srcbuild" +} + + +# Modify SRCBUILD ############################################################## + +modified_srcbuild() { + local orig=$1 + local new="$tempdir/SRCBUILD" + sed -e '/PKGDEST=/d' -e 's/PKGEXT=/d' < "$orig" > "$new" + printf '%s\n' "$new" +} + +# "Library" crap ############################################################### + +print() { + local fmt=$1 + shift + printf -- "$(gettext "$fmt")\n" "$@" +} + +################################################################################ + +main "$@" diff --git a/src/librefetch/librefetch.conf b/src/librefetch/librefetch.conf new file mode 100644 index 0000000..40d2078 --- /dev/null +++ b/src/librefetch/librefetch.conf @@ -0,0 +1,2 @@ +MIRROR='https://repo.parabolagnulinux.org/sources/' +DOWNLOADER='/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u' diff --git a/src/libremessages b/src/libremessages new file mode 100755 index 0000000..5c5a02a --- /dev/null +++ b/src/libremessages @@ -0,0 +1,65 @@ +#!/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) 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 +# 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. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +################################################################################ +# Inherit most functions from devtools # +################################################################################ + +# This is only installed in Parabola's distribution of devtools, not Arch's +. /usr/share/devtools/common.sh + +################################################################################ +# gettext initialization # +################################################################################ + +export TEXTDOMAIN='libretools' +export TEXTDOMAINDIR='/usr/share/locale' + +################################################################################ +# Own functions # +################################################################################ + +stdnull() { + eval "$@ >/dev/null 2>&1" +} + +# Set the terminal title +term_title() { + local fmt='' + case "$TERM" in + screen|tmux) fmt='\ek%s\e\\';; + xterm*|rxvt*) fmt='\e]0;%s\a';; + esac + printf "$fmt" "$*" +} + +################################################################################ +# Run one of the defined functions if invoked directly # +################################################################################ + +if [[ "${0##*/}" = libremessages ]]; then + _libremessages_cmd=$1 + shift + "$_libremessages_cmd" "$@" + unset _libremessages_cmd +fi diff --git a/src/libretools.conf b/src/libretools.conf new file mode 100644 index 0000000..da5abc0 --- /dev/null +++ b/src/libretools.conf @@ -0,0 +1,98 @@ +#!/bin/bash + +################################################################################ +# misc # +################################################################################ + +## Blacklist URL +## Used by `pkgbuild-check-nonfree` +BLACKLIST=http://repo.parabolagnulinux.org/docs/blacklist.txt + +## Diff tool (vimdiff, gvimdiff, meld, etc) +## Used by `aur`, `diff-unfree` +DIFFTOOL=`which vimdiff gvimdiff meld colordiff diff 2>/dev/null|sed 's/\s.*//;1q'` + +## 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' 'pcr' 'java') + +## The architectures +## Used by `librestage` +ARCHES=('i686' 'x86_64' 'mips64el' 'any') + +################################################################################ +# abslibre # +################################################################################ + +# The dir where you work on +WORKDIR=/home/$USER/packages + +## Package signing +SIGEXT=".sig" +#SIGID="0xYOURID" + +## 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 +# anything ;) +LIBREDESTDIR=/srv/http/repo/public + +## ABSLibre +ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git + +################################################################################ +# fullpkg # +################################################################################ + +## Uncomment one of those or make one of your choice +# Normal fullpkg +FULLBUILDCMD="sudo libremakepkg" +# Cross compiling fullkpg +# FULLBUILDCMD="sudo libremakepkg -n cross-compile-chroot" +# Build from within the chroot (or host system) +# FULLBUILDCMD="makepkg -sL --noconfirm" + +# Run a command before releasing a package (ie. SSH connection, SSH tunnel, etc.) +HOOKPRERELEASE="ssh -fN parabola" + +# Run a command before running FULLBUILDCMD, usually to cleanup uneeded packages +# Note! chcleanup *is not* chroot aware, if you run it as it is it will cleanup +# your system +# HOOKPREBUILD="chcleanup" + +# Locally release the package or any other action after running FULLBUILDCMD +# succesfully +# HOOKLOCALRELEASE="" + +################################################################################ +# toru # +################################################################################ + +TORUPATH=/var/lib/libretools/toru + +################################################################################ +# Stub for old programs; wouldn't normally be in a .conf file # +################################################################################ + +if [[ -z ${INCLUDE_CONF_SH:-} ]]; then + . /usr/share/libretools/conf.sh + if [[ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]]; then + . "$XDG_CONFIG_HOME/libretools/libretools.conf" + fi + check_conf_libretools || exit $? + + . /usr/bin/libremessages +fi diff --git a/src/mips64el-tools/Makefile b/src/mips64el-tools/Makefile new file mode 100644 index 0000000..f2cec54 --- /dev/null +++ b/src/mips64el-tools/Makefile @@ -0,0 +1,3 @@ +libre_execdir=$(bindir) +libre_datadir=$(sysconfdir)/libretools.d +include ../../common.mk diff --git a/add-mips64el b/src/mips64el-tools/add-mips64el index e06d857..e06d857 100755 --- a/add-mips64el +++ b/src/mips64el-tools/add-mips64el diff --git a/librebasebuilder b/src/mips64el-tools/librebasebuilder index f7d3a25..604f1c7 100755 --- a/librebasebuilder +++ b/src/mips64el-tools/librebasebuilder @@ -45,7 +45,7 @@ done tempdir=/home/chroot/base outdir=$(pwd) -mkarchroot -n $tempdir mkinitcpio base sudo parted nano zile vi ed openssh +archroot -n $tempdir mkinitcpio base sudo parted nano zile vi ed openssh cd $tempdir diff --git a/mips64el/mips-add b/src/mips64el-tools/mips-add index da9b431..da9b431 100644..100755 --- a/mips64el/mips-add +++ b/src/mips64el-tools/mips-add diff --git a/mips64el/mips64el.conf b/src/mips64el-tools/mips64el.conf index 836b407..836b407 100644 --- a/mips64el/mips64el.conf +++ b/src/mips64el-tools/mips64el.conf diff --git a/mips64el/mipsrelease b/src/mips64el-tools/mipsrelease index 4d7a7de..4d7a7de 100755 --- a/mips64el/mipsrelease +++ b/src/mips64el-tools/mipsrelease diff --git a/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree index df0ff36..0fd480c 100755 --- a/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/toru/Makefile b/src/toru/Makefile new file mode 100644 index 0000000..f2cec54 --- /dev/null +++ b/src/toru/Makefile @@ -0,0 +1,3 @@ +libre_execdir=$(bindir) +libre_datadir=$(sysconfdir)/libretools.d +include ../../common.mk diff --git a/toru-info b/src/toru/toru-info index 523f682..523f682 100755 --- a/toru-info +++ b/src/toru/toru-info diff --git a/toru-path b/src/toru/toru-path index 957f49b..baeaeb5 100755 --- a/toru-path +++ b/src/toru/toru-path @@ -22,6 +22,8 @@ fi fullrepos=() for (( i = ${#REPOS[@]}-1 ; i >= 0 ; i-- )); do ${VERBOSE} && msg "Processing [%s]" ${REPOS[$i]} + + [ -d "${ABSROOT}${REPOS[$i]}" ] && \ fullrepos+=("${ABSROOT}${REPOS[$i]}") done pkgbuilds=($(get_pkgbuilds ${fullrepos[@]})) diff --git a/toru-utils b/src/toru/toru-utils index 316e6b8..316e6b8 100755 --- a/toru-utils +++ b/src/toru/toru-utils diff --git a/toru-where b/src/toru/toru-where index e9ab29d..e9ab29d 100755 --- a/toru-where +++ b/src/toru/toru-where diff --git a/src/treepkg b/src/treepkg new file mode 100755 index 0000000..1453f41 --- /dev/null +++ b/src/treepkg @@ -0,0 +1,237 @@ +#!/bin/bash +#set -x +# (c) 2012 Nicolás Reynolds <fauno@parabola.nu> +# +# 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, either version 3 of the License, or +# (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +source /etc/libretools.conf +source $XDG_CONFIG_HOME/libretools/libretools.conf >/dev/null 2>&1|| true + +term_title "$(basename $0)" + +# Get system variables +source /etc/makepkg.conf +source $HOME/makepkg.conf >/dev/null 2>&1|| true + +# End inmediately but print an useful message +trap_exit() { + term_title "error!" + error "($(basename $0)) $@ (leftovers on ${BUILDDIR})" + 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 + +# 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 + +} + +# Add line to build order cache in CSV format +# *must* be run from the PKGBUILD path +# status;depth;pkgbase;[epoch:]pkgver-pkgrel;path;repo +# $1 status +# $2 pkgname +add_order() { + echo "${1};${DEPTH};${2:-${pkgbase}};${fullver};${PWD};$(guess_repo "$PWD")" >> "${BUILDORDER}" + ${VERBOSE} && msg2 "%${DEPTH}s${2:-${pkgbase}} [${1}]" || true +} + +# Bury a package deeper in the tree +# $1 pkgbase +# $2 nextdepth +bury() { + # Bury only if we are going to build the dep + # Get it's current depth and dir name + local current_depth=$(grep "build;[0-9]\+;${1};" "${BUILDORDER}" | cut -d ';' -f 2) + local current_name="$(printf "%03d" ${current_depth})_${1}" + + # If there's a depth or the package is not the root of the build tree (which + # can lead to funny chicken-and-egg problems), update the depth to the current + # package next-depth and rename the dir too + if [ -z "${current_depth}" ]; then return; fi + if [ -z "${current_name}" ]; then return; fi + if [ ${current_depth} -eq 0 ]; then return; fi + if [ ${current_depth} -ge $2 ]; then return; fi + + ${VERBOSE} && msg "Burying ${1} from ${current_depth} to ${2}" + + { + sed -i "s|^\(build;\)\([0-9]\+\)\(;${1};.*\)$|\1${2}\3|" "${BUILDORDER}" && \ + mv "${BUILDDIR}/${current_name}" "${BUILDDIR}/$(printf "%03d" ${2})_${1}" + } || return 1 +} + +# Guess the repo from the pkgbase path +# $1 path, pwd or toru-where +guess_repo() { + basename "$(dirname "${1}")" +} + +if [ ! -f PKGBUILD ]; then + error "Missing PKGBUILD ($PWD)" + exit 1 +fi + +if ! source PKGBUILD ; then + error "Can't source PKGBUILD" + exit 1 +fi + +# Save resources +unset pkgdesc arch license groups backup install md5sums sha1sums \ + sha256sums source options >/dev/null 2>&1 + +unset build package >/dev/null 2>&1 + +for _pkg in ${pkgname[@]}; do + unset package_${_pkg} >/dev/null 2>&1 || true +done +## + +# Get useful values +pkgbase="${pkgbase:-${pkgname[0]}}" +fullver=$(get_fullver ${epoch:-0} ${pkgver} ${pkgrel}) + +# Get or set the work dir +BUILDDIR="${1:-$(mktemp -d /tmp/${pkgbase}-treepkg-XXXx)}" +BUILDORDER="${BUILDDIR}/BUILDORDER" +DEPTH=${2:-0} +NEXTDEPTH=$((${DEPTH} + 1)) +# This can be set as env vars (ie: $ V=false B=false treepkg) +# TODO Turn into flags? +VERBOSE=${V:-true} +BUILD=${B:-true} +CLEANUP=${C:-true} +# Skip BUILDORDER creation and build anything on BUILDDIR +BUILDNOW=${N:-false} + +if [ ! -z "${1}" -a ${DEPTH} -eq 0 ]; then + BUILDNOW=true +fi + +if ! ${BUILDNOW}; then + # ensure it exists + touch "${BUILDORDER}" + + # If this package is already built quit silently + for _pkg in ${pkgname[@]}; do + if is_built "${_pkg}" "${fullver}"; then + add_order "ignore" + exit 0 + fi + done + + # Ignore if already in build order + egrep -q ";${pkgbase};" "${BUILDORDER}" && exit 0 + + # Add pkgbase to build order + add_order "build" + + # Copy the directory to the build dir + # TODO run makepkg --source to avoid moving garbage around? + cp -r "${PWD}" "${BUILDDIR}/$(printf "%03d" ${DEPTH})_${pkgbase}" + + # Cleanup dep versioning + deps=($(echo "${depends[@]} ${makedepends[@]}" | \ + sed "s/[=<>]\+[^ ]\+//g" | \ + tr ' ' "\n" | \ + sort -u)) + + # NOTE: getting depends from package() is a PITA + for _dep in ${deps[@]}; do + # Move deps deeper in the tree if + # pkgbase - dep1 + # \ dep2 - dep1 + # dep1 should be depth + 1 + egrep -q ";${_dep};" "${BUILDORDER}" && bury "${_dep}" ${NEXTDEPTH} + + # Ask toru where's a PKGBUILD + depdir="$(toru-where ${_dep})" + + if [ -z "${depdir}" -o ! -d "${depdir}" ]; then + # We specify the pkgname because we can't source the dep PKGBUILD + # Normally 'any' packages are missing from our work ABS + add_order "missing" "${_dep}" + continue + fi + + pushd "${depdir}" >/dev/null + + # Run itself over dependencies + $0 "${BUILDDIR}" ${NEXTDEPTH} + + done + # End BUILD now +fi + +# Only build at the end +if [ ${DEPTH} -eq 0 ]; then + ${VERBOSE} && msg "Starting build" || true + + if ${BUILD}; then + ${VERBOSE} && msg "Build tree stored in ${BUILDORDER}" || true + + # Build everything sorting the build dir + # The reverse order ensures we start by the deepest packages + for _pkg in $(ls -r "${BUILDDIR}"); do + # Ignore if there's no PKGBUILD + if [ ! -f "${BUILDDIR}/${_pkg}/PKGBUILD" ]; then continue; fi + # Skip if already built (faster than calling is_build again) + if [ -f "${BUILDDIR}/${_pkg}/built_ok" ]; then continue; fi + + ${VERBOSE} && msg "Building ${_pkg/_/ }" || true + + # Remove leading zeros and space if any + term_title "$(echo ${_pkg/_/ } | sed "s/^0\+ \?//")" + + # Run build command + pushd "${BUILDDIR}/${_pkg}" >/dev/null + sudo -E pacman -Syu --noconfirm + + ${HOOKPREBUILD} + + ${FULLBUILDCMD} + # Run local release hook with $1 = $repo + ${HOOKLOCALRELEASE} $(egrep ";${_pkg#*_};" "${BUILDORDER}" | cut -d';' -f6) + + touch built_ok + popd >/dev/null + done + + else + # Just print the working dir + ${VERBOSE} || echo "${BUILDORDER}" || true + fi + + if ${CLEANUP} ; then + msg2 "Removing ${BUILDDIR}" + rm -rf "${BUILDDIR}" + fi + +fi + +term_title "done" +exit $? diff --git a/treepkg b/treepkg deleted file mode 100755 index ee4964d..0000000 --- a/treepkg +++ /dev/null @@ -1,237 +0,0 @@ -#!/bin/bash -#set -x -# (c) 2012 Nicolás Reynolds <fauno@parabola.nu> -# -# 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, either version 3 of the License, or -# (at your option) any later version. -# -# 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -source /etc/libretools.conf -source $XDG_CONFIG_HOME/libretools/libretools.conf >/dev/null 2>&1|| true - -term_title "$(basename $0)" - -# Get system variables -source /etc/makepkg.conf -source $HOME/makepkg.conf >/dev/null 2>&1|| true - -# End inmediately but print an useful message -trap_exit() { - term_title "error!" - error "($(basename $0)) $@ (leftovers on ${BUILDDIR})" - 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 - -# 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 - -} - -# Add line to build order cache in CSV format -# *must* be run from the PKGBUILD path -# status;depth;pkgbase;[epoch:]pkgver-pkgrel;path;repo -# $1 status -# $2 pkgname -add_order() { - echo "${1};${DEPTH};${2:-${pkgbase}};${fullver};${PWD};$(guess_repo "$PWD")" >> "${BUILDORDER}" - ${VERBOSE} && msg2 "%${DEPTH}s${2:-${pkgbase}} [${1}]" || true -} - -# Bury a package deeper in the tree -# $1 pkgbase -# $2 nextdepth -bury() { -# Bury only if we are going to build the dep -# Get it's current depth and dir name - local current_depth=$(grep "build;[0-9]\+;${1};" "${BUILDORDER}" | cut -d ';' -f 2) - local current_name="$(printf "%03d" ${current_depth})_${1}" - -# If there's a depth or the package is not the root of the build tree (which -# can lead to funny chicken-and-egg problems), update the depth to the current -# package next-depth and rename the dir too - if [ -z "${current_depth}" ]; then return; fi - if [ -z "${current_name}" ]; then return; fi - if [ ${current_depth} -eq 0 ]; then return; fi - if [ ${current_depth} -ge $2 ]; then return; fi - - ${VERBOSE} && msg "Burying ${1} from ${current_depth} to ${2}" - - { - sed -i "s|^\(build;\)\([0-9]\+\)\(;${1};.*\)$|\1${2}\3|" "${BUILDORDER}" && \ - mv "${BUILDDIR}/${current_name}" "${BUILDDIR}/$(printf "%03d" ${2})_${1}" - } || return 1 -} - -# Guess the repo from the pkgbase path -# $1 path, pwd or toru-where -guess_repo() { - basename "$(dirname "${1}")" -} - -if [ ! -f PKGBUILD ]; then - error "Missing PKGBUILD ($PWD)" - exit 1 -fi - -if ! source PKGBUILD ; then - error "Can't source PKGBUILD" - exit 1 -fi - -# Save resources -unset pkgdesc arch license groups backup install md5sums sha1sums \ - sha256sums source options >/dev/null 2>&1 - -unset build package >/dev/null 2>&1 - -for _pkg in ${pkgname[@]}; do - unset package_${_pkg} >/dev/null 2>&1 || true -done -## - -# Get useful values -pkgbase="${pkgbase:-${pkgname[0]}}" -fullver=$(get_fullver ${epoch:-0} ${pkgver} ${pkgrel}) - -# Get or set the work dir -BUILDDIR="${1:-$(mktemp -d /tmp/${pkgbase}-treepkg-XXXx)}" -BUILDORDER="${BUILDDIR}/BUILDORDER" -DEPTH=${2:-0} -NEXTDEPTH=$((${DEPTH} + 1)) -# This can be set as env vars (ie: $ V=false B=false treepkg) -# TODO Turn into flags? -VERBOSE=${V:-true} -BUILD=${B:-true} -CLEANUP=${C:-true} -# Skip BUILDORDER creation and build anything on BUILDDIR -BUILDNOW=${N:-false} - -if [ ! -z "${1}" -a ${DEPTH} -eq 0 ]; then - BUILDNOW=true -fi - -if ! ${BUILDNOW}; then -# ensure it exists - touch "${BUILDORDER}" - -# If this package is already built quit silently - for _pkg in ${pkgname[@]}; do - if is_built "${_pkg}" "${fullver}"; then - add_order "ignore" - exit 0 - fi - done - -# Ignore if already in build order - egrep -q ";${pkgbase};" "${BUILDORDER}" && exit 0 - -# Add pkgbase to build order - add_order "build" - -# Copy the directory to the build dir -# TODO run makepkg --source to avoid moving garbage around? - cp -r "${PWD}" "${BUILDDIR}/$(printf "%03d" ${DEPTH})_${pkgbase}" - -# Cleanup dep versioning - deps=($(echo "${depends[@]} ${makedepends[@]}" | \ - sed "s/[=<>]\+[^ ]\+//g" | \ - tr ' ' "\n" | \ - sort -u)) - -# NOTE: getting depends from package() is a PITA - for _dep in ${deps[@]}; do -# Move deps deeper in the tree if -# pkgbase - dep1 -# \ dep2 - dep1 -# dep1 should be depth + 1 - egrep -q ";${_dep};" "${BUILDORDER}" && bury "${_dep}" ${NEXTDEPTH} - -# Ask toru where's a PKGBUILD - depdir="$(toru-where ${_dep})" - - if [ -z "${depdir}" -o ! -d "${depdir}" ]; then -# We specify the pkgname because we can't source the dep PKGBUILD -# Normally 'any' packages are missing from our work ABS - add_order "missing" "${_dep}" - continue - fi - - pushd "${depdir}" >/dev/null - -# Run itself over dependencies - $0 "${BUILDDIR}" ${NEXTDEPTH} - - done -# End BUILD now -fi - -# Only build at the end -if [ ${DEPTH} -eq 0 ]; then - ${VERBOSE} && msg "Starting build" || true - - if ${BUILD}; then - ${VERBOSE} && msg "Build tree stored in ${BUILDORDER}" || true - -# Build everything sorting the build dir -# The reverse order ensures we start by the deepest packages - for _pkg in $(ls -r "${BUILDDIR}"); do -# Ignore if there's no PKGBUILD - if [ ! -f "${BUILDDIR}/${_pkg}/PKGBUILD" ]; then continue; fi -# Skip if already built (faster than calling is_build again) - if [ -f "${BUILDDIR}/${_pkg}/built_ok" ]; then continue; fi - - ${VERBOSE} && msg "Building ${_pkg/_/ }" || true - -# Remove leading zeros and space if any - term_title "$(echo ${_pkg/_/ } | sed "s/^0\+ \?//")" - -# Run build command - pushd "${BUILDDIR}/${_pkg}" >/dev/null - sudo -E pacman -Syu --noconfirm - - ${HOOKPREBUILD} - - ${FULLBUILDCMD} -# Run local release hook with $1 = $repo - ${HOOKLOCALRELEASE} $(egrep ";${_pkg#*_};" "${BUILDORDER}" | cut -d';' -f6) - - touch built_ok - popd >/dev/null - done - - else -# Just print the working dir - ${VERBOSE} || echo "${BUILDORDER}" || true - fi - -if ${CLEANUP} ; then - msg2 "Removing ${BUILDDIR}" - rm -rf "${BUILDDIR}" -fi - -fi - -term_title "done" -exit $? diff --git a/update-cleansystem b/update-cleansystem deleted file mode 100755 index 6bec742..0000000 --- a/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 $? diff --git a/updateabslibre b/updateabslibre deleted file mode 100755 index 76f964a..0000000 --- a/updateabslibre +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# UpdateABSLibre -# Updates the ABSLibre git repo - -# Copyright 2010 Nicolás Reynolds - -# ---------- 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 -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf -[[ -e $custom_config ]] && source $custom_config - -# Send every output to /dev/null - -msg "Updating ABSLibre..." - -pushd ${WORKDIR}/abslibre ${stdnull} - git pull ${ABSLIBREGIT} || { - error "Failed pull" - exit 1 -} -stdnull "popd" - -exit 0 |