diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 9 | ||||
-rw-r--r-- | src/abslibre-tools/Makefile | 5 | ||||
-rw-r--r-- | src/abslibre-tools/createworkdir.md | 36 | ||||
-rw-r--r-- | src/chroot-tools/Makefile | 43 | ||||
-rw-r--r-- | src/devtools/Makefile | 12 | ||||
-rw-r--r-- | src/gitget/Makefile | 5 | ||||
-rw-r--r-- | src/lib/Makefile | 44 | ||||
-rw-r--r-- | src/lib/blacklist.sh | 96 | ||||
-rw-r--r-- | src/lib/common.sh.head (renamed from src/lib/common.sh.top) | 0 | ||||
-rw-r--r-- | src/lib/common.sh.tail (renamed from src/lib/common.sh.bottom) | 0 | ||||
-rwxr-xr-x | src/lib/libreblacklist | 141 | ||||
-rw-r--r-- | src/lib/librelib.7.ronn | 3 | ||||
-rwxr-xr-x | src/lib/libremessages | 207 | ||||
-rw-r--r-- | src/lib/messages.sh | 208 | ||||
-rw-r--r-- | src/librefetch/Makefile | 18 | ||||
-rw-r--r-- | src/toru/Makefile | 5 | ||||
-rw-r--r-- | src/workflows.md | 64 | ||||
-rw-r--r-- | src/xbs-abs/Makefile | 26 | ||||
-rw-r--r-- | src/xbs-abslibre/Makefile | 10 | ||||
-rw-r--r-- | src/xbs/Makefile | 5 |
20 files changed, 560 insertions, 377 deletions
diff --git a/src/Makefile b/src/Makefile index 63f7782..8fbe735 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,2 +1,7 @@ -pkgconfdir=$(sysconfdir) -include ../common.mk +include $(dir $(lastword $(MAKEFILE_LIST)))/../config.mk +include $(topsrcdir)/automake.head.mk +pkgconfdir = $(sysconfdir) + +am_subdirs = abslibre-tools chroot-tools devtools gitget lib librefetch toru xbs xbs-abs xbs-abslibre + +include $(topsrcdir)/automake.tail.mk diff --git a/src/abslibre-tools/Makefile b/src/abslibre-tools/Makefile index 2c76089..2903f4a 100644 --- a/src/abslibre-tools/Makefile +++ b/src/abslibre-tools/Makefile @@ -1 +1,4 @@ -include ../../common.mk +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/automake.head.mk + +include $(topsrcdir)/automake.tail.mk diff --git a/src/abslibre-tools/createworkdir.md b/src/abslibre-tools/createworkdir.md new file mode 100644 index 0000000..e50b00f --- /dev/null +++ b/src/abslibre-tools/createworkdir.md @@ -0,0 +1,36 @@ +# CreateWorkDir + +This script recreates a proper directory tree for packaging. Its aim is to help +you be organized with the work you do as a packager, and establish a certain +standard for packages' publication, so you don't have to lose much time with +them. Just package and upload! + +It will create a directory tree like this: + + $WORKDIR/ + ├── abslibre/ + │ ├── .git/ + │ ├── libre/<PKGBUILDS> + │ └── libre-testing/<PKGBUILDS> + └── staging/ + ├── libre/ + └── libre-testing/ + +*Related Variables* + - WORKDIR + +## staging/ + +This directory contains one directory for each repository, where the resulting +packages are in moved for syncing against the main repository on Parabola's +server. This directory is architecture independent. + +## abslibre/ + +This is the git repo for Parabola's PKGBUILDs. Here you can find the ABS tree +for our packages, and also where you'll have to put new ones for commit. + +(You'll need push access to Parabola's main server, but pulling is public.) + +*Related Variables* + - ABSLIBREGIT diff --git a/src/chroot-tools/Makefile b/src/chroot-tools/Makefile index 1b77a97..a11e69c 100644 --- a/src/chroot-tools/Makefile +++ b/src/chroot-tools/Makefile @@ -1,28 +1,27 @@ -progs = chcleanup -clean_files = chcleanup.lib -# These files are coming from devtools -copy_files = makechrootpkg.sh.in mkarchroot.in arch-nspawn.in -# These are programs that we will use internally, but shouldn't be in PATH -libexecs = mkarchroot arch-nspawn distcc-tool chcleanup indent -no-progs = $(libexecs) -# These are the shell libraries we will use -libs = makechrootpkg.sh $(wildcard hooks-*.sh) - +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/automake.head.mk pkglibexecdir = $(libexecdir)/libretools/chroot -include ../../common.mk -# makechrootpkg.sh is created from a command, not a library -makechrootpkg.sh.in: %.sh.in: $(devtoolsdir)/%.in +install-bins = chcleanup librechroot libremakepkg +install-libexecs += arch-nspawn chcleanup distcc-tool indent mkarchroot +install-libs += makechrootpkg.sh +devtools-files = makechrootpkg.sh.in mkarchroot.in arch-nspawn.in +am_clean_files += chcleanup.lib + +$(srcdir)/makechrootpkg.sh.in: $(srcdir)/%.sh.in: $(devtoolsdir)/%.in cp $< $@ -chcleanup: chcleanup.in chcleanup.lib - m4 -P $< | $(edit) > $@ - chmod 755 $@ -chcleanup.lib: ../lib/common.sh Makefile - bash -c '. ../lib/common.sh; declare -f _l plain msg msg2 error' > $@ +$(outdir)/chcleanup: $(srcdir)/chcleanup.in $(outdir)/chcleanup.lib + m4 -I$(@D) -P $< | $(edit) | install -m755 /dev/stdin $@ +$(outdir)/chcleanup.lib: $(call _am_path,$(topoutdir)/src/lib/common.sh) $(outdir)/Makefile + bash -c '. $<; declare -f _l plain msg msg2 error' > $@ + +$(outdir)/distcc-tool.pot: LIBREXGETTEXT_FLAGS+=--simple=errusage + +$(DESTDIR)$(bindir)/chcleanup: $(var)bindir $(var)libexecdir + mkdir -p $(@D) + ln -srfT $(DESTDIR)$(libexecdir)/libretools/chroot/chcleanup $@ -distcc-tool.pot: LIBREXGETTEXT_FLAGS+=--simple=errusage +am_depdirs = ../lib -# This is so gross. I hate recursive Make. Why did I implement it this way? -../lib/common.sh: $(devtoolsdir)/lib/common.sh ../lib/common.sh.top ../lib/Makefile - $(MAKE) -C ../lib common.sh +include $(topsrcdir)/automake.tail.mk diff --git a/src/devtools/Makefile b/src/devtools/Makefile index 3fc5d70..7ccbbcc 100644 --- a/src/devtools/Makefile +++ b/src/devtools/Makefile @@ -1,8 +1,12 @@ -progs = checkpkg find-libdeps finddeps lddd -copy_files = $(addsuffix .in,$(progs)) -install_files = $(DESTDIR)$(bindir)/find-libprovides -include ../../common.mk +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/automake.head.mk + +install-bins += checkpkg find-libdeps finddeps lddd +devtools-files = $(addsuffix .in,$(install-bins)) +am_sys_files += $(bindir)/find-libprovides $(DESTDIR)$(bindir)/find-libprovides: install -d $(@D) ln -sf find-libdeps $@ + +include $(topsrcdir)/automake.tail.mk diff --git a/src/gitget/Makefile b/src/gitget/Makefile index 2c76089..2903f4a 100644 --- a/src/gitget/Makefile +++ b/src/gitget/Makefile @@ -1 +1,4 @@ -include ../../common.mk +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/automake.head.mk + +include $(topsrcdir)/automake.tail.mk diff --git a/src/lib/Makefile b/src/lib/Makefile index 97b30eb..f9ec1e8 100644 --- a/src/lib/Makefile +++ b/src/lib/Makefile @@ -1,17 +1,17 @@ -copy_files = common.sh.in -libexecs = $(filter-out librelib,$(progs)) -# include common.sh in libs explicitly, because it might not exist yet -# when the wildcard is performed -libs = $(sort $(wildcard *.sh) common.sh conf.sh) +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/automake.head.mk -include ../../common.mk +install-libs += common.sh conf.sh +devtools-files = common.sh.in # Build ############################################################## -common.sh: %: %.in %.top Makefile - @echo "GEN $@" +$(outdir)/conf.sh: $(var)sysconfdir $(var)pkgconfdir + +$(outdir)/common.sh: $(outdir)/%: $(srcdir)/%.in $(srcdir)/%.head $(srcdir)/%.tail $(outdir)/Makefile + @echo "OUT $@" @{ \ - cat '$*.top' && \ + cat '$(<D)/$*.head' && \ echo && \ sed -r \ -e '/encoding problem/d;/LANG=/d' \ @@ -19,21 +19,27 @@ common.sh: %: %.in %.top Makefile -e 's/gettext /_l _ /g' \ -e "s/^(\s+)(msg|error) '/\1_l \2 '/" \ -e 's|lock\(\)\s*\{|lock()\n{|' \ - '$*.in' && \ + '$(<D)/$*.in' && \ echo && \ - cat '$*.bottom' && \ + cat '$(<D)/$*.tail' && \ :; } > '$@' # Translate ########################################################## -LIBREXGETTEXT_FLAGS += --simple=_l:2 - -libreblacklist.pot: libreblacklist librexgettext - { \ +$(outdir)/blacklist.sh.pot: $(srcdir)/blacklist.sh $(srcdir)/librexgettext + @echo "OUT $@" + @{ \ sed -n '/^# Usage:/,/()/{ /^#/ { =; p; } }' $< | \ sed -r -e 's/^# (.*)/msgid "\1"\nmsgstr ""\n/' \ - -e 's/^[0-9]*$$/#. embedded usage text\n#: $<:&/'; \ - ./librexgettext $<; \ - } | $(pofmt) > $@ + -e 's/^[0-9]*$$/#. embedded usage text\n#: $<:&/' && \ + $(<D)/librexgettext --simple=_l:2 $< && \ + :; } | $(pofmt) > $@ +$(outdir)/common.sh.pot : LIBREXGETTEXT_FLAGS += --simple=_l:2 +$(outdir)/conf.sh.pot : LIBREXGETTEXT_FLAGS += --simple=_l:2 +$(outdir)/librelib.pot : LIBREXGETTEXT_FLAGS += --simple=_l:2 +$(outdir)/messages.sh.pot : LIBREXGETTEXT_FLAGS += --simple=_l:2 +$(outdir)/librexgettext.pot: LIBREXGETTEXT_FLAGS += --simple=errusage + +###################################################################### -librexgettext.pot: LIBREXGETTEXT_FLAGS += --simple=errusage +include $(topsrcdir)/automake.tail.mk diff --git a/src/lib/blacklist.sh b/src/lib/blacklist.sh new file mode 100644 index 0000000..0a3cc39 --- /dev/null +++ b/src/lib/blacklist.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +# This may be included with or without `set -euE` + +# Copyright (C) 2013-2014, 2016 Luke Shumaker <lukeshu@sbcglobal.net> +# +# License: GNU GPLv2+ +# +# 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 2 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/>. + +# make sure XDG_CACHE_HOME is set +. "$(librelib conf)" + +# Usage: blacklist-normalize <$file +# Normalizes the syntax of the blacklist on stdin. +blacklist-normalize() { + sed -e '/^#/d' -e 's/^[^:]*$/&::/' -e 's/^[^:]*:[^:]*$/&:/' +} + +# Usage: blacklist-cat +# Prints the blacklist. +# Uses the cache, but downloads it if it doesn't exist. Also normalizes the blacklist for easier parsing. +blacklist-cat() { + local file="$XDG_CACHE_HOME/libretools/blacklist.txt" + if ! [[ -e $file ]]; then + # exit on failure, whether set -e or not + blacklist-update || return $? + fi + blacklist-normalize < "$file" +} + +# Usage: blacklist-update +# Updates (or creates) the cached copy of the blacklist. +blacklist-update() ( + . libremessages + load_files libretools || return 1 + check_vars libretools BLACKLIST || return 1 + + local remote_blacklist="$BLACKLIST" + local local_blacklist="$XDG_CACHE_HOME/libretools/blacklist.txt" + + _l stat_busy "Downloading blacklist of proprietary software packages" + + mkdir -p "${local_blacklist%/*}" + if wget -N -q -O "${local_blacklist}.part" "$remote_blacklist" 2>/dev/null; then + stat_done + mv -f "${local_blacklist}.part" "$local_blacklist" + else + stat_done + rm "${local_blacklist}.part" + if [[ -e "$local_blacklist" ]]; then + _l warning "Using local copy of blacklist" + else + _l error "Download failed, exiting" + return 1 + fi + + fi +) + +# Usage: blacklist-cat | blacklist-lookup $pkgname +# Filters to obtain the line for $pkgname from the blacklist on stdin. +# Exits successfully whether a line is found or not. +blacklist-lookup() { + local pkg=$1 + # we accept that $pkg contains no regex-nes + blacklist-normalize | grep "^$pkg:" || true +} + +# Usage: blacklist-cat | blacklist-get-pkg +# Prints only the package name field of the blacklist line(s) on stdin. +blacklist-get-pkg() { + blacklist-normalize | cut -d: -f1 +} + +# Usage: blacklist-cat | blacklist-get-rep +# Prints only the replacement package field of the blacklist line(s) on stdin. +blacklist-get-rep() { + blacklist-normalize | cut -d: -f2 +} + +# Usage: blacklist-cat | blacklist-get-reason +# Prints only the reason field of the blacklist line(s) on stdin. +blacklist-get-reason() { + blacklist-normalize | cut -d: -f3- +} diff --git a/src/lib/common.sh.top b/src/lib/common.sh.head index 23bfeb8..23bfeb8 100644 --- a/src/lib/common.sh.top +++ b/src/lib/common.sh.head diff --git a/src/lib/common.sh.bottom b/src/lib/common.sh.tail index e133fad..e133fad 100644 --- a/src/lib/common.sh.bottom +++ b/src/lib/common.sh.tail diff --git a/src/lib/libreblacklist b/src/lib/libreblacklist index 1e5a467..6c354fe 100755 --- a/src/lib/libreblacklist +++ b/src/lib/libreblacklist @@ -1,8 +1,5 @@ #!/usr/bin/env bash -# This may be included with or without `set -euE` -# When run directly, it does `set -euE` - -# Copyright (C) 2013-2014 Luke Shumaker <lukeshu@sbcglobal.net> +# Copyright (C) 2013-2014, 2016 Luke Shumaker <lukeshu@sbcglobal.net> # # License: GNU GPLv2+ # @@ -19,88 +16,17 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# make sure XDG_CACHE_HOME is set -. "$(librelib conf)" - -# Usage: blacklist-normalize <$file -# Normalizes the syntax of the blacklist on stdin. -blacklist-normalize() { - sed -e '/^#/d' -e 's/^[^:]*$/&::/' -e 's/^[^:]*:[^:]*$/&:/' -} - -# Usage: blacklist-cat -# Prints the blacklist. -# Uses the cache, but downloads it if it doesn't exist. Also normalizes the blacklist for easier parsing. -blacklist-cat() { - local file="$XDG_CACHE_HOME/libretools/blacklist.txt" - if ! [[ -e $file ]]; then - # exit on failure, whether set -e or not - blacklist-update || return $? - fi - blacklist-normalize < "$file" -} - -# Usage: blacklist-update -# Updates (or creates) the cached copy of the blacklist. -blacklist-update() ( - . libremessages - load_files libretools || return 1 - check_vars libretools BLACKLIST || return 1 - - local remote_blacklist="$BLACKLIST" - local local_blacklist="$XDG_CACHE_HOME/libretools/blacklist.txt" - - _l stat_busy "Downloading blacklist of proprietary software packages" - - mkdir -p "${local_blacklist%/*}" - if wget -N -q -O "${local_blacklist}.part" "$remote_blacklist" 2>/dev/null; then - stat_done - mv -f "${local_blacklist}.part" "$local_blacklist" - else - stat_done - rm "${local_blacklist}.part" - if [[ -e "$local_blacklist" ]]; then - _l warning "Using local copy of blacklist" - else - _l error "Download failed, exiting" - return 1 - fi - - fi -) - -# Usage: blacklist-cat | blacklist-lookup $pkgname -# Filters to obtain the line for $pkgname from the blacklist on stdin. -# Exits successfully whether a line is found or not. -blacklist-lookup() { - local pkg=$1 - # we accept that $pkg contains no regex-nes - blacklist-normalize | grep "^$pkg:" || true -} - -# Usage: blacklist-cat | blacklist-get-pkg -# Prints only the package name field of the blacklist line(s) on stdin. -blacklist-get-pkg() { - blacklist-normalize | cut -d: -f1 -} - -# Usage: blacklist-cat | blacklist-get-rep -# Prints only the replacement package field of the blacklist line(s) on stdin. -blacklist-get-rep() { - blacklist-normalize | cut -d: -f2 -} +if [[ "${0##*/}" != libreblacklist ]]; then + . "$(librelib blacklist)" +else + set -euE -# Usage: blacklist-cat | blacklist-get-reason -# Prints only the reason field of the blacklist line(s) on stdin. -blacklist-get-reason() { - blacklist-normalize | cut -d: -f3- -} + lib_file="$(librelib blacklist)" + . "$lib_file" -if [[ "${0##*/}" == libreblacklist ]]; then - set -euE usage-outside() { - sed -n '/^# Usage:/,/()/p' "$0" | - tr '\n' '\r' | sed 's/\s*()\s*[{(]/\n/g' + sed -n '/^# Usage:/,/()/p' "$lib_file" | + tr '\n' '\r' | sed 's/\s*()\s*[{(]/\n/g' } # The output format of this is: # - The first line is "Usage:" @@ -110,6 +36,7 @@ if [[ "${0##*/}" == libreblacklist ]]; then usage-inside() { sed 's/\r/\n/g'<<<"$1"|sed -e '/^$/d' -e 's/^# //' } + usage() { export TEXTDOMAIN='librelib' export TEXTDOMAINDIR='/usr/share/locale' @@ -120,33 +47,37 @@ if [[ "${0##*/}" == libreblacklist ]]; then echo print "Commands:" usage-outside | while read -r sec; do sec="$(usage-inside "$sec")" - cmd=$(<<<"$sec" sed -n '$s/^blacklist-//p') - desc="$(_ "$(sed -n 2p <<<"$sec")")" - flag "$cmd" "${desc//blacklist-/${0##*/} }" + cmd=$(<<<"$sec" sed -n '$s/^blacklist-//p') + desc="$(_ "$(sed -n 2p <<<"$sec")")" + flag "$cmd" "${desc//blacklist-/${0##*/} }" done else usage-outside | while read -r sec; do sec="$(usage-inside "$sec")" - cmd=$(<<<"$sec" sed -n '$s/^blacklist-//p') - if [[ "$cmd" == "$1" ]]; then - <<<"$sec" sed '$d' | - while read -r line; do print "$line"; done | - sed "s/blacklist-/${0##*/} /g" | - fmt -us - return 0 - fi + cmd=$(<<<"$sec" sed -n '$s/^blacklist-//p') + if [[ "$cmd" == "$1" ]]; then + <<<"$sec" sed '$d' | + while read -r line; do print "$line"; done | + sed "s/blacklist-/${0##*/} /g" | + fmt -us + return 0 + fi done fi } - if [[ $# -eq 0 ]]; then - usage >&2 - exit 1 - fi - _blacklist_cmd=$1 - shift - if [[ $_blacklist_cmd == -h ]]; then - usage "$@" - else - "blacklist-$_blacklist_cmd" "$@" - fi + main() { + if [[ $# -eq 0 ]]; then + usage >&2 + exit 1 + fi + _blacklist_cmd=$1 + shift + if [[ $_blacklist_cmd == -h ]]; then + usage "$@" + else + "blacklist-$_blacklist_cmd" "$@" + fi + } + + main "$@" fi diff --git a/src/lib/librelib.7.ronn b/src/lib/librelib.7.ronn index 31fb65f..33b0c55 100644 --- a/src/lib/librelib.7.ronn +++ b/src/lib/librelib.7.ronn @@ -11,8 +11,7 @@ There are three parts to librelib: 1. The `librelib`(1) executable. 2. The non-executable libraries installed in `/usr/lib/libretools` - 3. The executable libraries installed in both `/usr/bin` and - `/usr/lib/libretools`. + 3. The executable libraries installed in `/usr/bin` The `librelib` executable isn't very exciting, it just finds the libraries installed in `/usr/lib/libretools`. Think of it as a sort diff --git a/src/lib/libremessages b/src/lib/libremessages index 528d9b6..647204a 100755 --- a/src/lib/libremessages +++ b/src/lib/libremessages @@ -1,19 +1,5 @@ #!/usr/bin/env bash -# This may be included with or without `set -euE` -# When run directly, it does `set -euE` - -# Copyright (C) 2011 Joshua Ismael Haase Hernández (xihh) <hahj87@gmail.com> -# Copyright (C) 2012 Nicolás Reynolds <fauno@parabola.nu> -# Copyright (C) 2012-2014 Luke Shumaker <lukeshu@sbcglobal.net> - -# For just the setup_traps() function: -# Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org> -# Copyright (C) 2006-2010 Pacman Development Team <pacman-dev@archlinux.org> -# Copyright (C) 2005 Aurelien Foret <orelien@chez.com> -# Copyright (C) 2005 Christian Hamar <krics@linuxforum.hu> -# Copyright (C) 2006 Alex Smith <alex@alex-smith.me.uk> -# Copyright (C) 2006 Andras Voroskoi <voroskoi@frugalware.org> -# Copyright (C) 2006 Miklos Vajna <vmiklos@frugalware.org> +# Copyright (C) 2012-2014, 2016 Luke Shumaker <lukeshu@sbcglobal.net> # # License: GNU GPLv2+ # @@ -30,189 +16,10 @@ # 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 # -################################################################################ - -. "$(librelib common.sh)" - -################################################################################ -# Own functions # -################################################################################ - -# Usage: panic -# -# For programming errors, bails immediately with little fanfare. -panic() { - echo "$(_l _ 'panic: malformed call to internal function')" >&2 - exit 1 -} - -# Usage: print MESG [ARGS...] -# -# Like printf, but gettext-aware, and prints a trailing newline -print() { - [[ $# -ge 1 ]] || panic - local mesg="$(_ "$1")" - shift - printf -- "$mesg\n" "$@" -} - -# Usage: whitespace_collapse <<<STRING -# -# Collapses whitespace on stadard I/O, similar to HTML whitespace -# collapsing, with the exception that it puts two spaces between -# sentences. It considers newline, tab, and space to be whitespace. -whitespace_collapse() { - [[ $# == 0 ]] || panic - - tr '\n' '\r' | sed -r \ - -e 's/\r/ /g' -e 's/\t/ /g' \ - -e 's/(^|[^.!? ]) +/\1 /g' -e 's/([.!?]) +/\1 /g' -} - - -# Usage: prose MESG [ARGS...] -# -# Do HTML-style whitespace collapsing on the first argument, translate -# it (gettext), then word-wrap it to 75 columns. This is useful for -# printing a paragraph of prose in --help text. -prose() { - [[ $# -ge 1 ]] || panic - local mesg="$(_ "$(whitespace_collapse <<<"$1")")"; shift - printf -- "$mesg" "$@" | fmt -u -} - -# Usage: bullet MESG [ARGS...] -# Like prose, but print a bullet "-" before the first line, and indent the -# remaining lines. -bullet() { - [[ $# -ge 1 ]] || panic - local mesg="$(_ "$(whitespace_collapse <<<"$1")")"; shift - # Wrap the text to 71 columns; 75 (the default) minus a 4 column indent - printf -- "$mesg" "$@" | fmt -u -w 71 | sed -e '1s/^/ - /' -e '2,$s/^/ /' -} - -# Usage: flag FLAG DESCRIPTION [FLAG2 DESCRIPTION2...] -# -# Print a flag and description formatted for --help text. -# -# ex: flag '-C <FILE>' 'Use this file instead of pacman.conf' -# -# The description is fed through gettext, the flag is not, so if part -# of the flag needs to be translated, you must do that yourself: -# -# ex: flag "-C <$(_ FILE)>" 'Use this file instead of pacman.conf' -# -# If you want to line-break the description in the source, so it isn't -# crazy-long, feel free, it is reflowed/wrapped the same way as prose -# and bullet. If you pass in multiple flag/description pairs at once, -# the descriptions are all alligned together. -flag() { - [[ $# == $(($#/2*2)) ]] || panic - local args=("$@") - - declare -i flaglen=0 - while [[ $# -gt 0 ]]; do - if [[ $1 == *: ]]; then - shift 1 - else - if [[ ${#1} -gt $flaglen ]]; then - flaglen=${#1} - fi - shift 2 - fi - done - set -- "${args[@]}" - - # Unless the $flaglen is extra-wide, the $desc should start at - # column 16 (that is two literal-tabs). If $flaglen is wide, - # this should be increased in increments of 8 (that is, a - # literal-tab). Everything should be wrapped to 75 columns. - - # The printf-format we use has 4 spaces built into it (two at - # the beginning, and two for a seperator). Therefore, the - # default indent is 16-4=12 columns. And the width left for - # $desc is (75-4)-indent = 71-indent. - - declare -i indent=12 - while [[ $indent -lt $flaglen ]]; do - indent+=8 - done - local fmt2 fmt1 - fmt2=" %-${indent}s %s\n" - printf -v fmt1 " %-${indent}s %%s\n" '' - - while [[ $# -gt 0 ]]; do - if [[ $1 == *: ]]; then - printf -- ' %s\n' "$(_ "$1")" - shift - else - local flag=$1 - local desc="$(_ "$(whitespace_collapse <<<"$2")")" - shift 2 - - local lines - IFS=$'\n' lines=($(fmt -u -w $((71-indent)) <<<"$desc")) - printf -- "$fmt2" "$flag" "${lines[0]}" - [[ ${#lines[@]} -lt 2 ]] || printf -- "$fmt1" "${lines[@]:1}" - fi - done -} - -# Usage: term_title MESG [ARGS...] -# -# Sets the terminal title. -term_title() { - [[ $# -ge 1 ]] || panic - local fmt='' - case "$TERM" in - screen|tmux) fmt='\ek%s\e\\';; - xterm*|rxvt*) fmt='\e]0;%s\a';; - esac - printf "$fmt" "$(printf -- "$@")" -} - -# Usage: setup_traps [handler] -# -# Sets up traps on TERM, HUP, QUIT and INT signals, as well as the ERR -# event, similar to makepkg. -# -# If `handler` is specified, instead of using the default handler -# (which is good for most purposes), it will call the command handler -# with the arguments: -# -# ${handler} SIGNAL_NAME MESSAGE_FMT [MESSAGE_PARAMS...] -# -# where MESSAGE_* are printf-like stuff. -# -# This function is based on code from pacman:makepkg -setup_traps() { - [[ $# -le 1 ]] || panic - if [[ $# == 1 ]]; then - eval "_libremessages_trap_exit() { $1 \"\$@\"; }" - else - _libremessages_trap_exit() { - local signal=$1; shift - echo - error "$@" - trap -- "$signal" - kill "-$signal" "$$" - } - fi - set -E - for signal in TERM HUP QUIT; do - trap "_libremessages_trap_exit $signal '%s signal caught. Exiting...' $signal" $signal - done - trap '_libremessages_trap_exit INT "Aborted by user! Exiting..."' INT - trap '_libremessages_trap_exit USR1 "An unknown error has occurred. Exiting..."' ERR -} - -################################################################################ -# Run one of the defined functions if invoked directly # -################################################################################ - -if [[ "${0##*/}" == libremessages ]]; then - set -euE - "$@" +if [[ "${0##*/}" != libremessages ]]; then + . "$(librelib messages)" +else + set -euE + . "$(librelib messages)" + "$@" fi diff --git a/src/lib/messages.sh b/src/lib/messages.sh new file mode 100644 index 0000000..4b4897e --- /dev/null +++ b/src/lib/messages.sh @@ -0,0 +1,208 @@ +#!/usr/bin/env bash +# This may be included with or without `set -euE` + +# Copyright (C) 2011 Joshua Ismael Haase Hernández (xihh) <hahj87@gmail.com> +# Copyright (C) 2012 Nicolás Reynolds <fauno@parabola.nu> +# Copyright (C) 2012-2014, 2016 Luke Shumaker <lukeshu@sbcglobal.net> +# +# For just the setup_traps() function: +# Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org> +# Copyright (C) 2006-2010 Pacman Development Team <pacman-dev@archlinux.org> +# Copyright (C) 2005 Aurelien Foret <orelien@chez.com> +# Copyright (C) 2005 Christian Hamar <krics@linuxforum.hu> +# Copyright (C) 2006 Alex Smith <alex@alex-smith.me.uk> +# Copyright (C) 2006 Andras Voroskoi <voroskoi@frugalware.org> +# Copyright (C) 2006 Miklos Vajna <vmiklos@frugalware.org> +# +# License: GNU GPLv2+ +# +# 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 2 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 # +################################################################################ + +. "$(librelib common.sh)" + +################################################################################ +# Own functions # +################################################################################ + +# Usage: panic +# +# For programming errors, bails immediately with little fanfare. +panic() { + echo "$(_l _ 'panic: malformed call to internal function')" >&2 + exit 1 +} + +# Usage: print MESG [ARGS...] +# +# Like printf, but gettext-aware, and prints a trailing newline +print() { + [[ $# -ge 1 ]] || panic + local mesg="$(_ "$1")" + shift + printf -- "$mesg\n" "$@" +} + +# Usage: whitespace_collapse <<<STRING +# +# Collapses whitespace on stadard I/O, similar to HTML whitespace +# collapsing, with the exception that it puts two spaces between +# sentences. It considers newline, tab, and space to be whitespace. +whitespace_collapse() { + [[ $# == 0 ]] || panic + + tr '\n' '\r' | sed -r \ + -e 's/\r/ /g' -e 's/\t/ /g' \ + -e 's/(^|[^.!? ]) +/\1 /g' -e 's/([.!?]) +/\1 /g' +} + + +# Usage: prose MESG [ARGS...] +# +# Do HTML-style whitespace collapsing on the first argument, translate +# it (gettext), then word-wrap it to 75 columns. This is useful for +# printing a paragraph of prose in --help text. +prose() { + [[ $# -ge 1 ]] || panic + local mesg="$(_ "$(whitespace_collapse <<<"$1")")"; shift + printf -- "$mesg" "$@" | fmt -u +} + +# Usage: bullet MESG [ARGS...] +# Like prose, but print a bullet "-" before the first line, and indent the +# remaining lines. +bullet() { + [[ $# -ge 1 ]] || panic + local mesg="$(_ "$(whitespace_collapse <<<"$1")")"; shift + # Wrap the text to 71 columns; 75 (the default) minus a 4 column indent + printf -- "$mesg" "$@" | fmt -u -w 71 | sed -e '1s/^/ - /' -e '2,$s/^/ /' +} + +# Usage: flag FLAG DESCRIPTION [FLAG2 DESCRIPTION2...] +# +# Print a flag and description formatted for --help text. +# +# ex: flag '-C <FILE>' 'Use this file instead of pacman.conf' +# +# The description is fed through gettext, the flag is not, so if part +# of the flag needs to be translated, you must do that yourself: +# +# ex: flag "-C <$(_ FILE)>" 'Use this file instead of pacman.conf' +# +# If you want to line-break the description in the source, so it isn't +# crazy-long, feel free, it is reflowed/wrapped the same way as prose +# and bullet. If you pass in multiple flag/description pairs at once, +# the descriptions are all alligned together. +flag() { + [[ $# == $(($#/2*2)) ]] || panic + local args=("$@") + + declare -i flaglen=0 + while [[ $# -gt 0 ]]; do + if [[ $1 == *: ]]; then + shift 1 + else + if [[ ${#1} -gt $flaglen ]]; then + flaglen=${#1} + fi + shift 2 + fi + done + set -- "${args[@]}" + + # Unless the $flaglen is extra-wide, the $desc should start at + # column 16 (that is two literal-tabs). If $flaglen is wide, + # this should be increased in increments of 8 (that is, a + # literal-tab). Everything should be wrapped to 75 columns. + + # The printf-format we use has 4 spaces built into it (two at + # the beginning, and two for a seperator). Therefore, the + # default indent is 16-4=12 columns. And the width left for + # $desc is (75-4)-indent = 71-indent. + + declare -i indent=12 + while [[ $indent -lt $flaglen ]]; do + indent+=8 + done + local fmt2 fmt1 + fmt2=" %-${indent}s %s\n" + printf -v fmt1 " %-${indent}s %%s\n" '' + + while [[ $# -gt 0 ]]; do + if [[ $1 == *: ]]; then + printf -- ' %s\n' "$(_ "$1")" + shift + else + local flag=$1 + local desc="$(_ "$(whitespace_collapse <<<"$2")")" + shift 2 + + local lines + IFS=$'\n' lines=($(fmt -u -w $((71-indent)) <<<"$desc")) + printf -- "$fmt2" "$flag" "${lines[0]}" + [[ ${#lines[@]} -lt 2 ]] || printf -- "$fmt1" "${lines[@]:1}" + fi + done +} + +# Usage: term_title MESG [ARGS...] +# +# Sets the terminal title. +term_title() { + [[ $# -ge 1 ]] || panic + local fmt='' + case "$TERM" in + screen|tmux) fmt='\ek%s\e\\';; + xterm*|rxvt*) fmt='\e]0;%s\a';; + esac + printf "$fmt" "$(printf -- "$@")" +} + +# Usage: setup_traps [handler] +# +# Sets up traps on TERM, HUP, QUIT and INT signals, as well as the ERR +# event, similar to makepkg. +# +# If `handler` is specified, instead of using the default handler +# (which is good for most purposes), it will call the command handler +# with the arguments: +# +# ${handler} SIGNAL_NAME MESSAGE_FMT [MESSAGE_PARAMS...] +# +# where MESSAGE_* are printf-like stuff. +# +# This function is based on code from pacman:makepkg +setup_traps() { + [[ $# -le 1 ]] || panic + if [[ $# == 1 ]]; then + eval "_libremessages_trap_exit() { $1 \"\$@\"; }" + else + _libremessages_trap_exit() { + local signal=$1; shift + echo + error "$@" + trap -- "$signal" + kill "-$signal" "$$" + } + fi + set -E + for signal in TERM HUP QUIT; do + trap "_libremessages_trap_exit $signal '%s signal caught. Exiting...' $signal" $signal + done + trap '_libremessages_trap_exit INT "Aborted by user! Exiting..."' INT + trap '_libremessages_trap_exit USR1 "An unknown error has occurred. Exiting..."' ERR +} diff --git a/src/librefetch/Makefile b/src/librefetch/Makefile index dcb64dc..b28e96e 100644 --- a/src/librefetch/Makefile +++ b/src/librefetch/Makefile @@ -1,5 +1,13 @@ -progs = librefetch-install -confs = librefetch-makepkg.conf -libexecs = $(shell find librefetchdir -type f -executable) -libs = $(shell find librefetchdir -type f -not -executable) -include ../../common.mk +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/automake.head.mk + +install-bins = librefetch librefetch-install +install-confs += librefetch-makepkg.conf +install-libexecs += $(filter librefetchdir/%,$(detect-exec)) +install-libs += $(filter-out $(install-libexecs),$(filter librefetchdir/%,$(detect-all))) +pots = $(install-bins) + +$(outdir)/librefetch-install: $(var)pkgconfdir +$(outdir)/librefetch-makepkg.conf: $(var)bindir + +include $(topsrcdir)/automake.tail.mk diff --git a/src/toru/Makefile b/src/toru/Makefile index 2c76089..2903f4a 100644 --- a/src/toru/Makefile +++ b/src/toru/Makefile @@ -1 +1,4 @@ -include ../../common.mk +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/automake.head.mk + +include $(topsrcdir)/automake.tail.mk diff --git a/src/workflows.md b/src/workflows.md new file mode 100644 index 0000000..03dca4f --- /dev/null +++ b/src/workflows.md @@ -0,0 +1,64 @@ +# 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`. + + > Note: `treepkg` has been deprecated in favor of `dagpkg`. + +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. diff --git a/src/xbs-abs/Makefile b/src/xbs-abs/Makefile index 8688ed7..81e1b4f 100644 --- a/src/xbs-abs/Makefile +++ b/src/xbs-abs/Makefile @@ -1,23 +1,27 @@ +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/automake.head.mk pkgconfdir = $(sysconfdir)/xbs pkglibexecdir = $(libexecdir)/xbs -libexecs = helper-abs _helpers = archrelease commitpkg -no-progs = $(libexecs) $(_helpers) -copy_files = $(addsuffix .in,$(_helpers)) -install_files = $(addprefix $(DESTDIR)$(pkglibexecdir)/helper-abs.d/,$(_helpers)) -pots = $(_helpers) +install-bins = +install-libexecs = helper-abs +pots += $(_helpers) +devtools-files += $(addsuffix .in,$(_helpers)) +am_out_files += $(_helpers) +am_sys_files += $(addprefix $(pkglibexecdir)/helper-abs.d/,$(_helpers)) -include ../../common.mk - -commitpkg: commitpkg.in - { \ +$(outdir)/commitpkg: $(srcdir)/commitpkg.in + @echo "OUT $@" + @{ \ echo '#!/usr/bin/env bash'; \ echo '. "$$(librelib common)"'; \ echo '. ./PKGBUILD'; \ echo 'repo=$$1; arch=$$2;'; \ sed -n "/== 'any'/,\$$p" $<; \ - } > $@ + } | install -Dm755 /dev/stdin $@ -$(DESTDIR)$(pkglibexecdir)/helper-abs.d/%: % +$(DESTDIR)$(pkglibexecdir)/helper-abs.d/%: $(srcdir)/% install -Dm755 '$<' '$@' + +include $(topsrcdir)/automake.tail.mk diff --git a/src/xbs-abslibre/Makefile b/src/xbs-abslibre/Makefile index 420ae52..6c61803 100644 --- a/src/xbs-abslibre/Makefile +++ b/src/xbs-abslibre/Makefile @@ -1,4 +1,8 @@ +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/automake.head.mk pkglibexecdir = $(libexecdir)/xbs -libexecs = helper-abslibre -no-progs = $(libexecs) -include ../../common.mk + +install-bins = +install-libexecs = helper-abslibre + +include $(topsrcdir)/automake.tail.mk diff --git a/src/xbs/Makefile b/src/xbs/Makefile index ea5e924..974586e 100644 --- a/src/xbs/Makefile +++ b/src/xbs/Makefile @@ -1,2 +1,5 @@ +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/automake.head.mk pkgconfdir = $(sysconfdir)/xbs -include ../../common.mk + +include $(topsrcdir)/automake.tail.mk |