summaryrefslogtreecommitdiff
path: root/src/devtools
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-05-02 15:06:04 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-05-02 15:06:04 -0400
commit962250da23024224fc9e0be782b16ae08df46671 (patch)
tree2cc17939d6fc064b65eb3ce20e43ba49565d925c /src/devtools
parentbf2e3833c4158c8ec94e6af621f7d50d11353957 (diff)
Update for the new devtools-par (major)
* `src/devtools`: Redo to get devtools from another location, and patch it * `src/chroot-tools/{chcleanup,chroot.conf}`: Only install 'base-devel' by default * libremkchroot: deprecate in favor of `librechroot make` * librechroot: - redo option parsing to be a "sub-command" (git-like) interface, instead of having esoteric flags (pacman-like). - add more documentation. - allow COPY to be an absolute path - generally clean up and use updated functions from `makechrootpkg.sh` * libremakepkg: - allow COPY to be an absolute path - update to work with the new `makechrootpkg.sh`: - `makechrootpkg.sh:chroot_exec()` -> `libremakepkg:run()` - `makechrootpkg.sh:chroot_init()` -> `libremakepkg:chroot_init()` - All functions from `makechrootpkg.sh` are wrapped, because they don't work with `set -euE`. - Other small changes
Diffstat (limited to 'src/devtools')
-rw-r--r--src/devtools/.gitignore22
-rw-r--r--src/devtools/Makefile115
-rw-r--r--src/devtools/README12
-rw-r--r--src/devtools/bash_completion.in23
-rw-r--r--src/devtools/checkpkg.in83
-rw-r--r--src/devtools/find-libdeps.in87
-rw-r--r--src/devtools/finddeps.in39
-rw-r--r--src/devtools/gitconfig17
-rw-r--r--src/devtools/lddd.in48
-rw-r--r--src/devtools/lib/common.sh186
-rw-r--r--src/devtools/lib/makechrootpkg.sh.patch254
-rw-r--r--src/devtools/makechrootpkg.in328
-rw-r--r--src/devtools/mkarchroot.in302
-rw-r--r--src/devtools/zsh_completion.in34
14 files changed, 335 insertions, 1215 deletions
diff --git a/src/devtools/.gitignore b/src/devtools/.gitignore
index e5e29ed..c9eaca9 100644
--- a/src/devtools/.gitignore
+++ b/src/devtools/.gitignore
@@ -1,17 +1,5 @@
-*~
-devtools-*.tar.gz*
-archbuild
-archco
-archrelease
-archrm
-bash_completion
-checkpkg
-commitpkg
-finddeps
-lddd
-makechrootpkg
-mkarchroot
-rebuildpkgs
-zsh_completion
-find-libdeps
-crossrepomove
+*
+!*/
+!Makefile
+!*.patch
+!lib/makechrootpkg.sh.in
diff --git a/src/devtools/Makefile b/src/devtools/Makefile
index 94f1f6b..d78e5f3 100644
--- a/src/devtools/Makefile
+++ b/src/devtools/Makefile
@@ -1,57 +1,94 @@
-V=20121128.6
+# Configuration
+DESTDIR=
-#prefix = /usr/local
-prefix = /usr
-PREFIX = $(prefix)
-pkgdatadir=$(PREFIX)/share/devtools
+#prefix=/usr/local
+prefix=/usr
+exec_prefix=$(prefix)
+datarootdir=$(prefix)/share
-BINPROGS = \
+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 \
+ 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: $(devtoolsdir)/lib/common.sh ; cp $< $@
+lib/makechrootpkg.sh.in: $(devtoolsdir)/makechrootpkg.in ; cp $< $@
+
+######################################################################
+
+build: \
+ archroot \
checkpkg \
find-libdeps \
finddeps \
- lddd
+ lddd \
+ lib/common.sh \
+ lib/makechrootpkg.sh
-SBINPROGS = \
- mkarchroot
+edit = sed -e 's|m4_include(lib/\(.*\))|. @pkgdatadir@/\1|' -e "s|@pkgdatadir[@]|$(pkgdatadir)|g"
-all: $(BINPROGS) $(SBINPROGS) bash_completion zsh_completion
+indent = emacs --batch $1 \
+ --eval '(setq sh-basic-offset 8)' \
+ --eval '(indent-region (point-min) (point-max) nil)' \
+ -f save-buffer &>/dev/null
-edit = sed -e "s|@pkgdatadir[@]|$(pkgdatadir)|g"
+M4GEN = @echo "M4GEN $2 ($1)"; $(edit) <"$1" >"$2"
+INDENT = @echo "INDENT $2 ($1)"; cp "$1" "$2"; $(call indent,$2)
%: %.in Makefile
- @echo "GEN $@"
- @$(RM) "$@"
- @m4 -P $@.in | $(edit) >$@
- @chmod a-w "$@"
- @chmod +x "$@"
-
-clean:
- rm -f $(BINPROGS) $(SBINPROGS) bash_completion zsh_completion
+ $(call M4GEN,$<,$@); chmod 755 "$@"
-install: all
- install -dm0755 $(DESTDIR)$(PREFIX)/bin
- install -dm0755 $(DESTDIR)$(PREFIX)/sbin
- install -dm0755 $(DESTDIR)$(pkgdatadir)
+lib/makechrootpkg.sh.ugly: %.ugly: %.in %.patch Makefile
+ @echo "PATCH $@"
+ @cp $*.in $@
+ @patch $@ $*.patch
- install -m0755 ${BINPROGS} $(DESTDIR)$(PREFIX)/bin
-# install -m0755 ${SBINPROGS} $(DESTDIR)$(PREFIX)/sbin
- install -m0755 mkarchroot $(DESTDIR)$(PREFIX)/sbin/archroot
+lib/makechrootpkg.sh: %: %.ugly Makefile
+ $(call INDENT,$<,$@)
- ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides
+######################################################################
- install -m0644 lib/common.sh $(DESTDIR)$(pkgdatadir)/common.sh
- install -m0644 makechrootpkg.in $(DESTDIR)$(pkgdatadir)/makechrootpkg.sh
- install -Dm0644 bash_completion $(DESTDIR)$(PREFIX)/share/bash-completion/completions/devtools
- install -Dm0644 zsh_completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools
+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
-uninstall:
- for f in ${BINPROGS} ; do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done
-# for f in ${SBINPROGS} ; do rm -f $(DESTDIR)$(PREFIX)/sbin/$$f; done
- rm -f $(DESTDIR)$(PREFIX)/sbin/archroot
+$(DESTDIR)$(PREFIX)/sbin/%: %
+ install -Dm755 $< $@
- rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides
+$(DESTDIR)$(PREFIX)/bin/%: %
+ install -Dm755 $< $@
- rm -f $(DESTDIR)$(PREFIX)/share/bash-completion/completions/devtools
- rm -f $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools
+$(DESTDIR)$(pkgdatadir)/%: lib/%
+ install -Dm644 $< $@
-.PHONY: all clean install uninstall
+$(DESTDIR)$(PREFIX)/bin/find-libprovides:
+ install -d $(@D)
+ ln -sf find-libdeps $@
diff --git a/src/devtools/README b/src/devtools/README
deleted file mode 100644
index e10394f..0000000
--- a/src/devtools/README
+++ /dev/null
@@ -1,12 +0,0 @@
-This is a minimal fork of Arch's `devtools'.
-
-It is a fork in that bugs are fixed and features added.
- This happens on the "complete" branch. Most development should happen here,
- and it should be able to be merged back into devtools.
-It is minimal in that it doesn't include most of what is in devtools.
- This happens on the "master" branch.
-
-A sample .git/config file is included to make it easy to merge from devtools.
-
-Tags in the format "%YYYY%MM%DD" are devtools.
-Tags in the format "v%YYYY%MM%DD" are chroottools.
diff --git a/src/devtools/bash_completion.in b/src/devtools/bash_completion.in
deleted file mode 100644
index 5e4fe66..0000000
--- a/src/devtools/bash_completion.in
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-_mkarchroot() {
- local cur
- COMPREPLY=()
- _get_comp_words_by_ref cur
-
- case $cur in
- -*)
- COMPREPLY=( $( compgen -W '-C -M -c -f -h -n -r -u' -- "$cur" ) )
- ;;
- *)
- _filedir
- return 0
- ;;
- esac
-
- true
-} &&
-complete -F _mkarchroot archroot
-
-
-# ex:et ts=2 sw=2 ft=sh
diff --git a/src/devtools/checkpkg.in b/src/devtools/checkpkg.in
deleted file mode 100644
index a761df7..0000000
--- a/src/devtools/checkpkg.in
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/bin/bash
-
-source @pkgdatadir@/common.sh
-
-# Source makepkg.conf; fail if it is not found
-if [[ -r '/etc/makepkg.conf' ]]; then
- source '/etc/makepkg.conf'
-else
- die '/etc/makepkg.conf not found!'
-fi
-
-# Source user-specific makepkg.conf overrides
-if [[ -r ~/.makepkg.conf ]]; then
- source ~/.makepkg.conf
-fi
-
-if [[ ! -f PKGBUILD ]]; then
- die 'This must be run in the directory of a built package.'
-fi
-
-. PKGBUILD
-if [[ $arch == 'any' ]]; then
- CARCH='any'
-fi
-
-STARTDIR=$(pwd)
-TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX)
-cd "$TEMPDIR"
-
-for _pkgname in "${pkgname[@]}"; do
- pkgfile=${_pkgname}-$(get_full_version $_pkgname)-${CARCH}${PKGEXT}
-
- if [[ -f "$STARTDIR/$pkgfile" ]]; then
- ln -s "$STARTDIR/$pkgfile" "$pkgfile"
- elif [[ -f "$PKGDEST/$pkgfile" ]]; then
- ln -s "$PKGDEST/$pkgfile" "$pkgfile"
- else
- die "File \"$pkgfile\" doesn't exist"
- fi
-
- pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$_pkgname")
-
- if [[ $? -ne 0 ]]; then
- die "Couldn't download previous package for $_pkgname."
- fi
-
- oldpkg=${pkgurl##*://*/}
-
- if [[ ${oldpkg##*/} = ${pkgfile##*/} ]]; then
- die "The built package ($_pkgname) is the one in the repo right now!"
- fi
-
- if [[ ! -f $oldpkg ]]; then
- if [[ $pkgurl = file://* ]]; then
- ln -s "${pkgurl#file://}" "${pkgurl##file://*/}"
- elif [[ -f "$PKGDEST/$oldpkg" ]]; then
- ln -s "$PKGDEST/$oldpkg" "$oldpkg"
- elif [[ -f "$STARTDIR/$oldpkg" ]]; then
- ln -s "$STARTDIR/$oldpkg" "$oldpkg"
- else
- curl -fsLC - --retry 3 --retry-delay 3 -o "$oldpkg" "$pkgurl"
- fi
- fi
-
- bsdtar tf "$oldpkg" | sort > "filelist-$_pkgname-old"
- bsdtar tf "$pkgfile" | sort > "filelist-$_pkgname"
-
- sdiff -s "filelist-$_pkgname-old" "filelist-$_pkgname"
-
- if diff "filelist-$_pkgname-old" "filelist-$_pkgname" | grep '\.so' > /dev/null 2>&1; then
- mkdir -p pkg
- cd pkg
- bsdtar xf ../"$pkgfile" > /dev/null
- diff "../filelist-$_pkgname-old" "../filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do
- echo "${i}: " "$(objdump -p "$i" | grep SONAME)"
- done
- cd ..
- else
- msg "No soname differences for $_pkgname."
- fi
-done
-
-msg "Files saved to $TEMPDIR"
diff --git a/src/devtools/find-libdeps.in b/src/devtools/find-libdeps.in
deleted file mode 100644
index 7618850..0000000
--- a/src/devtools/find-libdeps.in
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/bash
-
-source @pkgdatadir@/common.sh
-
-set -e
-shopt -s extglob
-
-IGNORE_INTERNAL=0
-
-if [[ $1 = "--ignore-internal" ]]; then
- IGNORE_INTERNAL=1
- shift
-fi
-
-script_mode=${0##*/find-lib}
-
-case $script_mode in
- deps|provides) true;;
- *) die "Unknown mode $script_mode" ;;
-esac
-
-if [[ -z $1 ]]; then
- echo "${0##*/} [options] <package file|extracted package dir>"
- echo "Options:"
- echo " --ignore-internal ignore internal libraries"
- exit 1
-fi
-
-if [[ -d $1 ]]; then
- pushd $1 >/dev/null
-else
- setup_workdir
-
- case ${script_mode} in
- deps) bsdtar -C $WORKDIR -xf "$1";;
- provides) bsdtar -C $WORKDIR -xf "$1" --include="*.so*";;
- esac
-
- pushd $WORKDIR >/dev/null
-fi
-
-process_sofile() {
- # extract the library name: libfoo.so
- soname="${sofile%.so?(+(.+([0-9])))}".so
- # extract the major version: 1
- soversion="${sofile##*\.so\.}"
- if [[ "$soversion" = "$sofile" ]] && (($IGNORE_INTERNAL)); then
- continue
- fi
- if ! in_array "${soname}=${soversion}-${soarch}" ${soobjects[@]}; then
- # libfoo.so=1-64
- echo "${soname}=${soversion}-${soarch}"
- soobjects=(${soobjects[@]} "${soname}=${soversion}-${soarch}")
- fi
-}
-
-case $script_mode in
- deps) find_args="-perm -u+x";;
- provides) find_args="-name *.so*";;
-esac
-
-find . -type f $find_args | while read filename; do
- if [[ $script_mode = "provides" ]]; then
- # ignore if we don't have a shared object
- if ! LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
- continue
- fi
- fi
-
- # get architecture of the file; if soarch is empty it's not an ELF binary
- soarch=$(LC_ALL=C readelf -h "$filename" 2>/dev/null | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
- [[ -n $soarch ]] || continue
-
- if [[ $script_mode = "provides" ]]; then
- # get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1
- sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
- [[ -z $sofile ]] && sofile="${filename##*/}"
- process_sofile
- elif [[ $script_mode = "deps" ]]; then
- # process all libraries needed by the binary
- for sofile in $(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p'); do
- process_sofile
- done
- fi
-done
-
-popd >/dev/null
diff --git a/src/devtools/finddeps.in b/src/devtools/finddeps.in
deleted file mode 100644
index 656fe5a..0000000
--- a/src/devtools/finddeps.in
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash
-#
-# finddeps - find packages that depend on a given depname
-#
-
-source @pkgdatadir@/common.sh
-
-match=$1
-
-if [[ -z $match ]]; then
- echo 'Usage: finddeps <depname>'
- echo ''
- echo 'Find packages that depend on a given depname.'
- echo 'Run this script from the top-level directory of your ABS tree.'
- echo ''
- exit 1
-fi
-
-find . -type d | while read d; do
- if [[ -f "$d/PKGBUILD" ]]; then
- unset pkgname depends makedepends optdepends
- . "$d/PKGBUILD"
- for dep in "${depends[@]}"; do
- # lose the version comparator, if any
- depname=${dep%%[<>=]*}
- [[ $depname = $match ]] && echo "$d (depends)"
- done
- for dep in "${makedepends[@]}"; do
- # lose the version comparator, if any
- depname=${dep%%[<>=]*}
- [[ $depname = $match ]] && echo "$d (makedepends)"
- done
- for dep in "${optdepends[@]/:*}"; do
- # lose the version comaparator, if any
- depname=${dep%%[<>=]*}
- [[ $depname = $match ]] && echo "$d (optdepends)"
- done
- fi
-done
diff --git a/src/devtools/gitconfig b/src/devtools/gitconfig
deleted file mode 100644
index 890a5d0..0000000
--- a/src/devtools/gitconfig
+++ /dev/null
@@ -1,17 +0,0 @@
-[core]
- repositoryformatversion = 0
- filemode = true
- bare = false
- logallrefupdates = true
-[remote "origin"]
- url = ssh://git@parabolagnulinux.org:1863/srv/git/packages/chroottools.git
- fetch = +refs/heads/*:refs/remotes/origin/*
-[remote "devtools"]
- url = git://projects.archlinux.org/devtools.git
- fetch = +refs/heads/*:refs/remotes/devtools/*
-[branch "master"]
- remote = origin
- merge = refs/heads/master
-[branch "complete"]
- remote = devtools
- merge = refs/heads/master
diff --git a/src/devtools/lddd.in b/src/devtools/lddd.in
deleted file mode 100644
index 4040ce6..0000000
--- a/src/devtools/lddd.in
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-#
-# lddd - find broken library links on your machine
-#
-
-source @pkgdatadir@/common.sh
-
-ifs=$IFS
-IFS="${IFS}:"
-
-libdirs="/lib /usr/lib /usr/local/lib $(cat /etc/ld.so.conf.d/*)"
-extras=
-
-TEMPDIR=$(mktemp -d --tmpdir lddd-script.XXXX)
-
-msg 'Go out and drink some tea, this will take a while :) ...'
-# Check ELF binaries in the PATH and specified dir trees.
-for tree in $PATH $libdirs $extras; do
- msg2 "DIR $tree"
-
- # Get list of files in tree.
- files=$(find $tree -type f ! -name '*.a' ! -name '*.la' ! -name '*.py*' ! -name '*.txt' ! -name '*.h' ! -name '*.ttf' ! \
- -name '*.rb' ! -name '*.ko' ! -name '*.pc' ! -name '*.enc' ! -name '*.cf' ! -name '*.def' ! -name '*.rules' ! -name \
- '*.cmi' ! -name '*.mli' ! -name '*.ml' ! -name '*.cma' ! -name '*.cmx' ! -name '*.cmxa' ! -name '*.pod' ! -name '*.pm' \
- ! -name '*.pl' ! -name '*.al' ! -name '*.tcl' ! -name '*.bs' ! -name '*.o' ! -name '*.png' ! -name '*.gif' ! -name '*.cmo' \
- ! -name '*.cgi' ! -name '*.defs' ! -name '*.conf' ! -name '*_LOCALE' ! -name 'Compose' ! -name '*_OBJS' ! -name '*.msg' ! \
- -name '*.mcopclass' ! -name '*.mcoptype')
- IFS=$ifs
- for i in $files; do
- if (( $(file $i | grep -c 'ELF') != 0 )); then
- # Is an ELF binary.
- if (( $(ldd $i 2>/dev/null | grep -c 'not found') != 0 )); then
- # Missing lib.
- echo "$i:" >> $TEMPDIR/raw.txt
- ldd $i 2>/dev/null | grep 'not found' >> $TEMPDIR/raw.txt
- fi
- fi
- done
-done
-grep '^/' $TEMPDIR/raw.txt | sed -e 's/://g' >> $TEMPDIR/affected-files.txt
-# invoke pacman
-for i in $(cat $TEMPDIR/affected-files.txt); do
- pacman -Qo $i | awk '{print $4,$5}' >> $TEMPDIR/pacman.txt
-done
-# clean list
-sort -u $TEMPDIR/pacman.txt >> $TEMPDIR/possible-rebuilds.txt
-
-msg "Files saved to $TEMPDIR"
diff --git a/src/devtools/lib/common.sh b/src/devtools/lib/common.sh
deleted file mode 100644
index d6fbe7c..0000000
--- a/src/devtools/lib/common.sh
+++ /dev/null
@@ -1,186 +0,0 @@
-# Avoid any encoding problems
-export LANG=C
-
-# 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)"
- 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"
- fi
-fi
-readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
-
-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}==> WARNING:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-error() {
- local mesg=$1; shift
- printf "${RED}==> 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
-}
-
-_setup_workdir=false
-setup_workdir() {
- [[ -z $WORKDIR ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
- _setup_workdir=true
- trap 'trap_abort' INT QUIT TERM HUP
- trap 'trap_exit' EXIT
-}
-
-cleanup() {
- if [[ -n $WORKDIR ]] && $_setup_workdir; then
- rm -rf "$WORKDIR"
- fi
- [[ -n $1 ]] && exit $1
-}
-
-abort() {
- msg 'Aborting...'
- cleanup 0
-}
-
-trap_abort() {
- trap - EXIT INT QUIT TERM HUP
- abort
-}
-
-trap_exit() {
- trap - EXIT INT QUIT TERM HUP
- cleanup
-}
-
-die() {
- error "$*"
- cleanup 1
-}
-
-##
-# usage : in_array( $needle, $haystack )
-# return : 0 - found
-# 1 - not found
-##
-in_array() {
- local needle=$1; shift
- local item
- for item in "$@"; do
- [[ $item = $needle ]] && return 0 # Found
- done
- return 1 # Not Found
-}
-
-##
-# usage : lock_open_write( $fd, $path, $wait_message )
-##
-lock_open_write() {
- local fd=$1
- local path=$2
- local msg=$3
-
- # Only reopen the FD if it wasn't handed to us
- if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then
- mkdir -p "${path%/*}"
- eval "exec $fd>${path}.lock"
- fi
-
- if ! flock -n $fd; then
- stat_busy "$msg"
- flock $fd
- stat_done
- fi
-}
-
-##
-# usage : lock_open_read( $fd, $path, $wait_message )
-##
-lock_open_read() {
- local fd=$1
- local path=$2
- local msg=$3
-
- # Only reopen the FD if it wasn't handed to us
- if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then
- mkdir -p "${path%/*}"
- eval "exec $fd>${path}.lock"
- fi
-
- if ! flock -sn $fd; then
- stat_busy "$msg"
- flock -s $fd
- stat_done
- fi
-}
-
-
-##
-# usage : lock_close( $fd )
-##
-lock_close() {
- local fd=$1
- eval "exec $fd>&-"
-}
-
-##
-# usage : get_full_version( [$pkgname] )
-# return : full version spec, including epoch (if necessary), pkgver, pkgrel
-##
-get_full_version() {
- # set defaults if they weren't specified in buildfile
- pkgbase=${pkgbase:-${pkgname[0]}}
- epoch=${epoch:-0}
- if [[ -z $1 ]]; then
- if [[ $epoch ]] && (( ! $epoch )); then
- echo $pkgver-$pkgrel
- else
- echo $epoch:$pkgver-$pkgrel
- fi
- else
- for i in pkgver pkgrel epoch; do
- local indirect="${i}_override"
- eval $(declare -f package_$1 | sed -n "s/\(^[[:space:]]*$i=\)/${i}_override=/p")
- [[ -z ${!indirect} ]] && eval ${indirect}=\"${!i}\"
- done
- if (( ! $epoch_override )); then
- echo $pkgver_override-$pkgrel_override
- else
- echo $epoch_override:$pkgver_override-$pkgrel_override
- fi
- fi
-}
diff --git a/src/devtools/lib/makechrootpkg.sh.patch b/src/devtools/lib/makechrootpkg.sh.patch
new file mode 100644
index 0000000..618d7e9
--- /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 -s "$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/devtools/makechrootpkg.in b/src/devtools/makechrootpkg.in
deleted file mode 100644
index 9e5b04f..0000000
--- a/src/devtools/makechrootpkg.in
+++ /dev/null
@@ -1,328 +0,0 @@
-#!/bin/bash
-# Copyright 2011-2012 The Arch Linux Development Team
-# Copyright 2012 Luke Shumaker
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# Because of how we pull changes from devtools.git, some of the function
-# bodies are not indented. I appologize for my sins against the reader.
-
-# Any function beginning with "_makechrootpkg_" is basically a multiline
-# comment to minimize the diff. These functions may use different variable
-# names.
-
-# Otherwise, a function may be affected by the variables:
-# makepkg.conf
-# - PKGDEST
-# - SRCDEST
-# chroot.conf (and derived)
-# - CHROOT
-# - CHROOTCOPY
-# - rootdir # = $CHROOTDIR/$CHROOT/root
-# - copydir # = $CHROOTDIR/$CHROOT/$CHROOTCOPY
-# environment
-# - LIBREUSER # conf.sh
-# - LIBREHOME # conf.sh
-# - INCHROOT # libremakepkg
-# invocation
-# - repack
-
-[[ -n ${repack:-} ]] || repack=false
-
-_makechrootpkg_init() {
-m4_include(lib/common.sh)
-
-shopt -s nullglob
-
-makepkg_args='-s --noconfirm -L'
-repack=false
-update_first=false
-clean_first=false
-install_pkg=
-add_to_db=false
-run_namcap=false
-chrootdir=
-passeddir=
-
-default_copy=$USER
-[[ -n $SUDO_USER ]] && default_copy=$SUDO_USER
-[[ -z $default_copy || $default_copy = root ]] && default_copy=copy
-src_owner=${SUDO_USER:-$USER}
-}
-
-_makechrootpkg_usage() {
- echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]"
- echo ' Run this script in a PKGBUILD dir to build a package inside a'
- echo ' clean chroot. All unrecognized arguments passed to this script'
- echo ' will be passed to makepkg.'
- echo ''
- echo ' The chroot dir consists of the following directories:'
- echo ' <chrootdir>/{root, copy} but only "root" is required'
- echo ' by default. The working copy will be created as needed'
- echo ''
- echo 'The chroot "root" directory must be created via the following'
- echo 'command:'
- echo ' mkarchroot <chrootdir>/root base base-devel sudo'
- echo ''
- echo "Default makepkg args: $makepkg_args"
- echo ''
- echo 'Flags:'
- echo '-h This help'
- echo '-c Clean the chroot before building'
- echo '-u Update the working copy of the chroot before building'
- echo ' This is useful for rebuilds without dirtying the pristine'
- echo ' chroot'
- echo '-d Add the package to a local db at /repo after building'
- echo '-r <dir> The chroot dir to use'
- echo '-I <pkg> Install a package into the working copy of the chroot'
- echo '-l <copy> The directory to use as the working copy of the chroot'
- echo ' Useful for maintaining multiple copies.'
- echo " Default: $default_copy"
- echo '-n Run namcap on the package'
- exit 1
-}
-
-_makechrootpkg_parse_options_init() {
-while getopts 'hcudr:I:l:n' arg; do
- case "$arg" in
- h) usage ;;
- c) clean_first=true ;;
- u) update_first=true ;;
- d) add_to_db=true ;;
- r) passeddir="$OPTARG" ;;
- I) install_pkg="$OPTARG" ;;
- l) copy="$OPTARG" ;;
- n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;
- *) makepkg_args="$makepkg_args -$arg $OPTARG" ;;
- esac
-done
-
-# Canonicalize chrootdir, getting rid of trailing /
-chrootdir=$(readlink -e "$passeddir")
-
-if [[ ${copy:0:1} = / ]]; then
- copydir=$copy
-else
- [[ -z $copy ]] && copy=$default_copy
- copydir="$chrootdir/$copy"
-fi
-
-# Pass all arguments after -- right to makepkg
-makepkg_args="$makepkg_args ${*:$OPTIND}"
-
-# See if -R was passed to makepkg
-for arg in ${*:$OPTIND}; do
- if [[ $arg = -R ]]; then
- repack=true
- break
- fi
-done
-
-if (( EUID )); then
- die 'This script must be run as root.'
-fi
-
-if [[ ! -f PKGBUILD && -z $install_pkg ]]; then
- die 'This must be run in a directory containing a PKGBUILD.'
-fi
-
-if [[ ! -d $chrootdir ]]; then
- die "No chroot dir defined, or invalid path '$passeddir'"
-fi
-
-if [[ ! -d $chrootdir/root ]]; then
- die "Missing chroot dir root directory. Try using: mkarchroot $chrootdir/root base base-devel sudo"
-fi
-
-umask 0022
-
-# Lock the chroot we want to use. We'll keep this lock until we exit.
-# Note this is the same FD number as in mkarchroot
-lock_open_write 9 "$copydir.lock" "Locking chroot copy '$copy'"
-}
-
-chroot_sync() {
- if [[ $CHROOTCOPY = root ]]; then
- error "Cannot sync the root copy with itself"
- exit 1
- fi
- # Get a read lock on the root chroot to make
- # sure we don't clone a half-updated chroot
- lock_open_read 8 "$rootdir" \
- "Waiting for existing lock on \`$rootdir' to be released"
-
- stat_busy 'Creating clean working copy'
- local use_rsync=false
- if type -P btrfs >/dev/null; then
- [[ -d $copydir ]] && btrfs subvolume delete "$copydir" &>/dev/null
- btrfs subvolume snapshot "$rootdir" "$copydir" &>/dev/null ||
- use_rsync=true
- else
- use_rsync=true
- fi
-
- if $use_rsync; then
- mkdir -p "$copydir"
- rsync -a --delete -q -W -x "$rootdir/" "$copydir"
- fi
- stat_done
-
- # Drop the read lock again
- lock_close 8
-}
-
-_makechrootpkg_install_pkg() {
- pkgname="${install_pkg##*/}"
- cp "$install_pkg" "$copydir/$pkgname"
-
- mkarchroot -r "pacman -U /$pkgname --noconfirm" "$copydir"
- ret=$?
-
- rm "$copydir/$pkgname"
-
- # Exit early, we've done all we need to
- exit $ret
-}
-
-chroot_init() {
-# make sure the chroot exists
-librechroot -n "$CHROOT" -l "$CHROOTCOPY" -m
-
-mkdir -p "$copydir/build"
-mkdir -p "$copydir/pkgdest"
-mkdir -p "$copydir/srcdest"
-
-# Remove anything in there UNLESS -R (repack) was passed to makepkg
-$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
-
-_let_nobody_use_pacman
-}
-
-chroot_copy_in() {
-# Copy PKGBUILD and sources
-cp PKGBUILD "$copydir/build/"
-(
- set +euE
- source PKGBUILD
- # Copy source files
- for file in "${source[@]}"; do
- file="${file%%::*}"
- file="${file##*://*/}"
- if [[ -f $file ]]; then
- cp "$file" "$copydir/srcdest/"
- elif [[ -f $SRCDEST/$file ]]; then
- cp "$SRCDEST/$file" "$copydir/srcdest/"
- fi
- done
-
- # Find all changelog and install files, even inside functions
- for i in 'changelog' 'install'; do
- while read -r file; do
- # evaluate any bash variables used
- eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
- [[ -f $file ]] && cp "$file" "$copydir/build/"
- done < <(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD)
- done
-)
-
-chown -R nobody "$copydir"/{build,pkgdest,srcdest}
-}
-
-_let_nobody_use_pacman() {
-cat > "$copydir/etc/sudoers.d/nobody-pacman" <<EOF
-Defaults env_keep += "HOME"
-nobody ALL = NOPASSWD: /usr/bin/pacman
-EOF
-chmod 440 "$copydir/etc/sudoers.d/nobody-pacman"
-}
-
-chroot_exec() {
-local HASNET=true
-[[ $1 == -N ]] && { HASNET=false; shift; }
-
-local cmd="$*"
-# This is a little gross, but this way the script is recreated every time in the
-# working copy
-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 -n "$CHROOT" -l "$CHROOTCOPY" -r /chrootexec
-fi
-}
-
-add_to_local_repo() {
- for pkgfile in "$copydir"/pkgdest/*.pkg.tar*; do
- if true; then
- mkdir -p "$copydir/repo"
- pushd "$copydir/repo" >/dev/null
- cp "$pkgfile" .
- repo-add repo.db.tar.gz "${pkgfile##*/}"
- popd >/dev/null
- fi
- done
-}
-_chroot_copy_out_pkgs() {
- for pkgfile in "$copydir"/pkgdest/*.pkg.tar*; do
- chown "$LIBREUSER" "$pkgfile"
- mv "$pkgfile" "$PKGDEST"
- if [[ $PKGDEST != . ]]; then
- ln -s "$PKGDEST/${pkgfile##*/}" .
- fi
- done
-}
-
-_chroot_copy_out_logs() {
- for l in "$copydir"/build/*.log; do
- chown "$LIBREUSER" "$l"
- [[ -f $l ]] && mv "$l" .
- done
-}
-
-_chroot_copy_out_srcs() {
-for f in "$copydir"/srcdest/*; do
- chown "$LIBREUSER" "$f"
- mv "$f" "$SRCDEST"
-done
-}
-
-chroot_copy_out() {
- _chroot_copy_out_pkgs
- _chroot_copy_out_logs
- _chroot_copy_out_srcs
-}
diff --git a/src/devtools/mkarchroot.in b/src/devtools/mkarchroot.in
deleted file mode 100644
index 96f4399..0000000
--- a/src/devtools/mkarchroot.in
+++ /dev/null
@@ -1,302 +0,0 @@
-#!/bin/bash
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-source @pkgdatadir@/common.sh
-
-CHROOT_VERSION='v2'
-
-FORCE='n'
-RUN=''
-NOCOPY='n'
-NONETWORK='n'
-
-working_dir=''
-
-APPNAME=$(basename "${0}")
-
-# usage: usage <exitvalue>
-usage() {
- echo "Usage: ${APPNAME} [options] working-dir [action]"
- echo ' options:'
- echo ' -f Force overwrite of files in the working-dir'
- echo ' -C <file> Location of a pacman config file'
- echo ' -M <file> Location of a makepkg config file'
- echo ' -n Do not copy config files into the chroot'
- echo ' -c <dir> Set pacman cache'
- echo ' -N Disable networking in the chroot'
- echo ' actions:'
- echo ' -i <pkg-list> Install "pkg-list" in the chroot.'
- echo ' Creates the chroot if necessary, workding-dir must exist'
- echo ' -r <cmd> Run "cmd" within the context of the chroot'
- echo ' -u Update the chroot via pacman'
- echo ' -h Print this message'
-
- exit ${1-1}
-}
-
-################################################################################
-
-while getopts 'fC:M:nc:Nh' arg; do
- case "${arg}" in
- f) FORCE='y' ;;
- C) pac_conf="$OPTARG" ;;
- M) makepkg_conf="$OPTARG" ;;
- n) NOCOPY='y' ;;
- c) cache_dir="$OPTARG" ;;
- N) NONETWORK='y' ;;
-
- h) action="-$arg" ;;
-
- *) error "invalid argument '${arg}'"; usage ;;
- esac
-done
-
-shift $(($OPTIND - 1))
-
-if (( $# < 2 )); then
- error 'You must specify a directory and an action.'
- usage
-fi
-
-working_dir="$(readlink -f "${1}")"
-shift 1
-[[ -z $working_dir ]] && die 'Please specify a working directory.'
-
-action=$1
-shift 1
-case "$action" in
- -i) PKGS=("$@") ;;
- -r) RUN="$*" ;;
- -u)
- (( $# > 0 )) && { error 'Extra arguments.'; usage; }
- RUN='/bin/sh -c "pacman -Syu --noconfirm && (pacman -Qqu >/dev/null && pacman -Su --noconfirm || exit 0)"'
- ;;
- -h) usage 0 ;;
- -*) error "invalid argument '${action#-}'"; usage ;;
- *) error "invalid action '${action}'"; usage ;;
-esac
-unset action
-
-################################################################################
-
-if (( $EUID != 0 )); then
- die 'This script must be run as root.'
-fi
-
-if [[ -z $cache_dir ]]; then
- cache_dirs=($(pacman -v $cache_conf 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g'))
-else
- cache_dirs=(${cache_dir})
-fi
-
-host_mirror=$(pacman -Sddp extra/devtools 2>/dev/null | sed -E 's#(.*/)extra/os/.*#\1$repo/os/$arch#')
-if echo "${host_mirror}" | grep -q 'file://'; then
- host_mirror_path=$(echo "${host_mirror}" | sed -E 's#file://(/.*)/\$repo/os/\$arch#\1#g')
-fi
-
-# {{{ functions
-bind_mount() {
- local mode="${2:-rw}"
- local target="${working_dir}${1}"
-
- if [[ ! -e "$target" ]]; then
- if [[ -d "$1" ]]; then
- install -d "$target"
- else
- install -D /dev/null "$target"
- fi
- fi
-
- mount -o bind "$1" "$target"
- mount -o remount,${mode},bind "$target"
- mount --make-slave "$target"
-}
-
-chroot_mount() {
- trap 'trap_chroot_umount' EXIT INT QUIT TERM HUP
-
- if (( ! have_nspawn )); then
- bind_mount /sys ro
-
- [[ -e "${working_dir}/proc" ]] || mkdir "${working_dir}/proc"
- mount -t proc proc -o nosuid,noexec,nodev "${working_dir}/proc"
- bind_mount /proc/sys ro
-
- [[ -e "${working_dir}/dev" ]] || mkdir "${working_dir}/dev"
- mount -t tmpfs dev "${working_dir}/dev" -o mode=0755,size=10M,nosuid,strictatime
- mknod -m 666 "${working_dir}/dev/null" c 1 3
- mknod -m 666 "${working_dir}/dev/zero" c 1 5
- mknod -m 600 "${working_dir}/dev/console" c 5 1
- mknod -m 644 "${working_dir}/dev/random" c 1 8
- mknod -m 644 "${working_dir}/dev/urandom" c 1 9
- mknod -m 666 "${working_dir}/dev/tty" c 5 0
- mknod -m 666 "${working_dir}/dev/ptmx" c 5 2
- mknod -m 666 "${working_dir}/dev/tty0" c 4 0
- mknod -m 666 "${working_dir}/dev/full" c 1 7
- mknod -m 666 "${working_dir}/dev/rtc0" c 254 0
- ln -s /proc/kcore "${working_dir}/dev/core"
- ln -s /proc/self/fd "${working_dir}/dev/fd"
- ln -s /proc/self/fd/0 "${working_dir}/dev/stdin"
- ln -s /proc/self/fd/1 "${working_dir}/dev/stdout"
- ln -s /proc/self/fd/2 "${working_dir}/dev/stderr"
-
- [[ -e "${working_dir}/dev/shm" ]] || mkdir "${working_dir}/dev/shm"
- mount -t tmpfs shm "${working_dir}/dev/shm" -o nodev,nosuid,size=128M
-
- bind_mount /dev/pts
-
- [[ -e "${working_dir}/run" ]] || mkdir "${working_dir}/run"
- mount -t tmpfs tmpfs "${working_dir}/run" -o mode=0755,nodev,nosuid,strictatime,size=64M
-
- for host_config in resolv.conf localtime; do
- bind_mount /etc/$host_config ro
- done
- fi
-
- [[ -n $host_mirror_path ]] && bind_mount "$host_mirror_path" ro
-
- bind_mount "${cache_dirs[0]}"
- for cache_dir in ${cache_dirs[@]:1}; do
- bind_mount "$cache_dir" ro
- done
-}
-
-copy_hostconf () {
- cp -a /etc/pacman.d/gnupg "${working_dir}/etc/pacman.d"
- echo "Server = ${host_mirror}" > ${working_dir}/etc/pacman.d/mirrorlist
-
- if [[ -n $pac_conf && $NOCOPY = 'n' ]]; then
- cp ${pac_conf} ${working_dir}/etc/pacman.conf
- fi
-
- if [[ -n $makepkg_conf && $NOCOPY = 'n' ]]; then
- cp ${makepkg_conf} ${working_dir}/etc/makepkg.conf
- fi
-
- sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i ${working_dir}/etc/pacman.conf
-}
-
-trap_unmount_err () {
- error "Error unmounting"
-}
-
-trap_chroot_umount () {
- trap 'trap_unmount_err' INT QUIT TERM HUP EXIT
-
- for cache_dir in ${cache_dirs[@]}; do
- umount "${working_dir}/${cache_dir}"
- done
- [[ -n $host_mirror_path ]] && umount "${working_dir}/${host_mirror_path}"
-
- if (( ! have_nspawn )); then
- for host_config in resolv.conf localtime; do
- umount "${working_dir}/etc/${host_config}"
- done
- umount "${working_dir}/proc/sys"
- umount "${working_dir}/proc"
- umount "${working_dir}/sys"
- umount "${working_dir}/dev/pts"
- umount "${working_dir}/dev/shm"
- umount "${working_dir}/dev"
- umount "${working_dir}/run"
- fi
-
- trap 'trap_abort' INT QUIT TERM HUP
- trap 'trap_exit' EXIT
-}
-
-chroot_lock () {
- lock_open_write 9 "${working_dir}" "Locking chroot"
-}
-
-chroot_run() {
- local dir=$1
- shift
- if (( have_nspawn)); then
- local nspawn_args=(-D "$dir")
- if [[ $NONETWORK = y ]]; then
- nspawn_args+=(--private-network)
- fi
- eval systemd-nspawn "${nspawn_args[@]}" -- "${@}" 2>/dev/null
- else
- local unshare_args=(-mui)
- if [[ $NONETWORK = y ]]; then
- unshare_args+=(-n)
- fi
- eval unshare "${unshare_args[@]}" -- chroot "${dir}" "${@}"
- fi
-}
-
-# }}}
-
-# use systemd-nspawn if we have it available and systemd is running
-if type -P systemd-nspawn >/dev/null && mountpoint -q /sys/fs/cgroup/systemd; then
- have_nspawn=1
-fi
-
-umask 0022
-if [[ -n $RUN ]]; then
- # run chroot {{{
- #Sanity check
- if [[ ! -f "${working_dir}/.arch-chroot" ]]; then
- die "'${working_dir}' does not appear to be a Arch chroot."
- elif [[ $(cat "${working_dir}/.arch-chroot") != ${CHROOT_VERSION} ]]; then
- die "'${working_dir}' is not compatible with ${APPNAME} version ${CHROOT_VERSION}. Please rebuild."
- fi
-
- chroot_lock
- chroot_mount
- copy_hostconf
-
- chroot_run "${working_dir}" ${RUN}
-
- # }}}
-else
- # {{{ build chroot
- if [[ -e $working_dir && $FORCE = 'n' ]]; then
- die "Working directory '${working_dir}' already exists - try using -f"
- fi
-
- if { type -P btrfs && btrfs subvolume create "${working_dir}"; } &>/dev/null; then
- chmod 0755 "${working_dir}"
- fi
-
- chroot_lock
- chroot_mount
-
- pacargs="${cache_dirs[@]/#/--cachedir=}"
- if [[ -n $pac_conf ]]; then
- pacargs="$pacargs --config=${pac_conf}"
- fi
-
- if (( $# != 0 )); then
- if [[ $FORCE = 'y' ]]; then
- pacargs="$pacargs --force"
- fi
- if ! pacstrap -GMcd "${working_dir}" ${pacargs} "${PKGS[@]}"; then
- die 'Failed to install all packages'
- fi
- fi
-
- if [[ -d "${working_dir}/lib/modules" ]]; then
- chroot_run "${working_dir}" ldconfig
- fi
-
- if [[ -e "${working_dir}/etc/locale.gen" ]]; then
- sed -i 's@^#\(en_US\|de_DE\)\(\.UTF-8\)@\1\2@' "${working_dir}/etc/locale.gen"
- chroot_run "${working_dir}" locale-gen
- fi
- echo 'LANG=C' > "${working_dir}/etc/locale.conf"
-
- copy_hostconf
-
- echo "${CHROOT_VERSION}" > "${working_dir}/.arch-chroot"
- # }}}
-fi
diff --git a/src/devtools/zsh_completion.in b/src/devtools/zsh_completion.in
deleted file mode 100644
index ec07b3b..0000000
--- a/src/devtools/zsh_completion.in
+++ /dev/null
@@ -1,34 +0,0 @@
-#compdef finddeps archroot
-
-_archbuild_args=(
- '-c[Recreate the chroot before building]'
- '-r[Create chroots in this directory]:base_dir:_files -/'
-)
-
-_finddeps_args=(
- '1:packages:_devtools_completions_all_packages'
-)
-
-_archroot_args=(
- '-r[Run a program within the context of the chroot]:app'
- '-u[Update the chroot via pacman]'
- '-f[Force overwrite of files in the working-dir]'
- '-C[Location of a pacman config file]:pacman_config:_files'
- '-M[Location of a makepkg config file]:makepkg_config:_files'
- '-n[Do not copy config files into the chroot]'
- '-c[Set pacman cache]:pacman_cache:_files -/'
- '-h[Display usage]'
-)
-
-_devtools_completions_all_packages() {
- typeset -U packages
- packages=($(_call_program packages pacman -Sql))
- compadd - "${(@)packages}"
-}
-
-_devtools() {
- local argname="_${service}_args[@]"
- _arguments -s "${(P)argname}"
-}
-
-_devtools