Compare commits

..

1 Commits

Author SHA1 Message Date
Levente Polyak
3c1229479c commitpkg: handle option parsind and help before abort checks
Previously it was not possible to call for the help of find early
command line option problems when invoking in any location on the shell
as the command aborted without PKGBUILD being present.

Fix this by moving everything related to options at the very top.
2022-08-23 20:41:49 +02:00
16 changed files with 74 additions and 242 deletions

View File

@@ -1,4 +1,4 @@
V=20230307 V=20220621
BUILDTOOLVER ?= $(V) BUILDTOOLVER ?= $(V)
PREFIX = /usr/local PREFIX = /usr/local
@@ -6,7 +6,6 @@ MANDIR = $(PREFIX)/share/man
BUILDDIR = build BUILDDIR = build
BINPROGS = $(addprefix $(BUILDDIR)/,$(patsubst src/%,bin/%,$(patsubst %.in,%,$(wildcard src/*.in)))) BINPROGS = $(addprefix $(BUILDDIR)/,$(patsubst src/%,bin/%,$(patsubst %.in,%,$(wildcard src/*.in))))
LIBUTILS = $(wildcard lib/*)
MAKEPKG_CONFIGS=$(wildcard config/makepkg/*) MAKEPKG_CONFIGS=$(wildcard config/makepkg/*)
PACMAN_CONFIGS=$(wildcard config/pacman/*) PACMAN_CONFIGS=$(wildcard config/pacman/*)
SETARCH_ALIASES = $(wildcard config/setarch-aliases.d/*) SETARCH_ALIASES = $(wildcard config/setarch-aliases.d/*)
@@ -72,7 +71,7 @@ edit = sed -e "s|@pkgdatadir[@]|$(PREFIX)/share/devtools|g"
GEN_MSG = @echo "GEN $(patsubst $(BUILDDIR)/%,%,$@)" GEN_MSG = @echo "GEN $(patsubst $(BUILDDIR)/%,%,$@)"
define buildInScript define buildInScript
$(1)/%: $(2)%.in $(LIBUTILS) $(1)/%: $(2)%.in
$$(GEN_MSG) $$(GEN_MSG)
@mkdir -p $$(dir $$@) @mkdir -p $$(dir $$@)
@$(RM) "$$@" @$(RM) "$$@"

View File

@@ -46,13 +46,13 @@ CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS" CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now" LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
LTOFLAGS="-flto=auto" LTOFLAGS="-flto=auto"
RUSTFLAGS="" #RUSTFLAGS="-C opt-level=2"
#-- Make Flags: change this for DistCC/SMP systems #-- Make Flags: change this for DistCC/SMP systems
#MAKEFLAGS="-j2" #MAKEFLAGS="-j2"
#-- Debugging flags #-- Debugging flags
DEBUG_CFLAGS="-g" DEBUG_CFLAGS="-g"
DEBUG_CXXFLAGS="$DEBUG_CFLAGS" DEBUG_CXXFLAGS="$DEBUG_CFLAGS"
DEBUG_RUSTFLAGS="-C debuginfo=2" #DEBUG_RUSTFLAGS="-C debuginfo=2"
######################################################################### #########################################################################
# BUILD ENVIRONMENT # BUILD ENVIRONMENT
@@ -94,7 +94,7 @@ BUILDENV=(!distcc color !ccache check !sign)
#-- debug: Add debugging flags as specified in DEBUG_* variables #-- debug: Add debugging flags as specified in DEBUG_* variables
#-- lto: Add compile flags for building with link time optimization #-- lto: Add compile flags for building with link time optimization
# #
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge debug lto) OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug lto)
#-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512, b2 #-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512, b2
INTEGRITY_CHECK=(sha256) INTEGRITY_CHECK=(sha256)

View File

@@ -46,13 +46,13 @@ CFLAGS="-march=x86-64-v3 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS" CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now" LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
LTOFLAGS="-flto=auto" LTOFLAGS="-flto=auto"
RUSTFLAGS="" #RUSTFLAGS="-C opt-level=2"
#-- Make Flags: change this for DistCC/SMP systems #-- Make Flags: change this for DistCC/SMP systems
#MAKEFLAGS="-j2" #MAKEFLAGS="-j2"
#-- Debugging flags #-- Debugging flags
DEBUG_CFLAGS="-g" DEBUG_CFLAGS="-g"
DEBUG_CXXFLAGS="$DEBUG_CFLAGS" DEBUG_CXXFLAGS="$DEBUG_CFLAGS"
DEBUG_RUSTFLAGS="-C debuginfo=2" #DEBUG_RUSTFLAGS="-C debuginfo=2"
######################################################################### #########################################################################
# BUILD ENVIRONMENT # BUILD ENVIRONMENT
@@ -94,7 +94,7 @@ BUILDENV=(!distcc color !ccache check !sign)
#-- debug: Add debugging flags as specified in DEBUG_* variables #-- debug: Add debugging flags as specified in DEBUG_* variables
#-- lto: Add compile flags for building with link time optimization #-- lto: Add compile flags for building with link time optimization
# #
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge debug lto) OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug lto)
#-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512, b2 #-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512, b2
INTEGRITY_CHECK=(sha256) INTEGRITY_CHECK=(sha256)

View File

@@ -6,7 +6,6 @@ m4_include(lib/valid-tags.sh)
m4_include(lib/valid-repos.sh) m4_include(lib/valid-repos.sh)
_binary_arch=${_arch[*]:0:-1} _binary_arch=${_arch[*]:0:-1}
_colors=(never always auto)
_archbuild_args=( _archbuild_args=(
'-c[Recreate the chroot before building]' '-c[Recreate the chroot before building]'
@@ -48,11 +47,6 @@ _diffpkg_args=(
'(-p --pkginfo)'{-p,--pkginfo}'[.PKGINFO diff mode]' '(-p --pkginfo)'{-p,--pkginfo}'[.PKGINFO diff mode]'
'(-b --buildinfo)'{-b,--buildinfo}'[.BUILDINFO diff mode]' '(-b --buildinfo)'{-b,--buildinfo}'[.BUILDINFO diff mode]'
'(-m --makepkg-config)'{-m,--makepkg-config}'[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"' '(-m --makepkg-config)'{-m,--makepkg-config}'[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
'(-u -U --unified)'{-u,-U,--unified}'[Output 3 lines of unified context]'
'(-y --side-by-side)'{-y,--side-by-side}'[Output in two columns]'
'--color=[Color output]:when:($_colors[*])'
'(-W --width=)'{-W,--width=}'[Output at most NUM print columns]:num:(auto columns)'
'(-P --pool=)'{-P,--pool=}'[pool directory]:dir:_files -/'
'(-v --verbose)'{-v,--verbose}'[Provide more detailed/unfiltered output]' '(-v --verbose)'{-v,--verbose}'[Provide more detailed/unfiltered output]'
'(-h --help)'{-h,--help}'[Display usage]' '(-h --help)'{-h,--help}'[Display usage]'
'*:packages:_devtools_completions_all_packages' '*:packages:_devtools_completions_all_packages'

View File

@@ -25,7 +25,6 @@ Description
The symlink used to run it will be inspected by archbuild, to determine which target you want it to use. It will load the available pacman configuration from 'pacman-reponame-arch.conf' with a fallback to 'pacman-reponame.conf' from {pkgdatadir}. The makepkg configuration is loaded from 'makepkg-repo-arch.conf' with a fallback to 'makepkg-reponame.conf' from {pkgdatadir}. The symlink used to run it will be inspected by archbuild, to determine which target you want it to use. It will load the available pacman configuration from 'pacman-reponame-arch.conf' with a fallback to 'pacman-reponame.conf' from {pkgdatadir}. The makepkg configuration is loaded from 'makepkg-repo-arch.conf' with a fallback to 'makepkg-reponame.conf' from {pkgdatadir}.
It will also load the bind mount configuration from 'mount.d/arch' in {pkgdatadir}. The file format is that each line starting with ro and rw will be used, other lines will be ignored, and the rest of the used line is out/path:in/path preceded by a space as a separator. ro means it is a read-only mount, rw means a read-write mount.
Options Options
------- -------

View File

@@ -21,7 +21,7 @@ When given one package, use it to diff against the locally built one.
When given two packages, diff both packages against each other. When given two packages, diff both packages against each other.
In either case, a package name will be converted to a filename from the In either case, a package name will be converted to a filename from the
cache or pool, and diffpkg will proceed as though this filename was initially cache, and diffpkg will proceed as though this filename was initially
specified. specified.
Options Options
@@ -30,32 +30,12 @@ Options
*-M, --makepkg-config*:: *-M, --makepkg-config*::
Set an alternate makepkg configuration file Set an alternate makepkg configuration file
*-P, --pool*='DIR'::
Search diff target in pool dir (default `'/srv/ftp/pool'`)
*-v, --verbose*:: *-v, --verbose*::
Provide more detailed/unfiltered output Provide more detailed/unfiltered output
*-h, --help*:: *-h, --help*::
Show a help text Show a help text
Output Options
--------------
*--color*[='WHEN']::
Color output; 'WHEN' is `'never'`, `'always'`, or `'auto'`; Plain *--color* means *--color='auto'*
*-u, -U, --unified*::
Output 3 lines of unified context
*-y, --side-by-side*::
Output in two columns
*-W, --width*[='NUM']::
Output at most 'NUM' (default `'auto'`) print columns; 'NUM' can be `'auto'`, `'columns'` or a number.
`'auto'` will be resolved to the maximum line length of both files, guaranteeing the diff to be uncut.
Modes Modes
----- -----

View File

@@ -19,6 +19,8 @@ export LANG=C
export BUILDTOOL=devtools export BUILDTOOL=devtools
export BUILDTOOLVER=m4_devtools_version export BUILDTOOLVER=m4_devtools_version
shopt -s extglob
# check if messages are to be printed using color # check if messages are to be printed using color
if [[ -t 2 && "$TERM" != dumb ]]; then if [[ -t 2 && "$TERM" != dumb ]]; then
colorize colorize
@@ -137,20 +139,15 @@ pkgver_equal() {
# $pkgver can be supplied with or without a pkgrel appended. # $pkgver can be supplied with or without a pkgrel appended.
# If not supplied, any pkgrel will be matched. # If not supplied, any pkgrel will be matched.
## ##
shopt -s extglob
find_cached_package() { find_cached_package() {
local searchdirs=("$PWD" "$PKGDEST") results=() local searchdirs=("$PWD" "$PKGDEST") results=()
local targetname=$1 targetver=$2 targetarch=$3 local targetname=$1 targetver=$2 targetarch=$3
local dir pkg packages pkgbasename name ver rel arch r results local dir pkg pkgbasename name ver rel arch r results
for dir in "${searchdirs[@]}"; do for dir in "${searchdirs[@]}"; do
[[ -d $dir ]] || continue [[ -d $dir ]] || continue
shopt -s extglob nullglob for pkg in "$dir"/*.pkg.tar?(.!(sig|*.*)); do
mapfile -t packages < <(printf "%s\n" "$dir"/"${targetname}"-"${targetver}"-*"${targetarch}".pkg.tar?(.!(sig|*.*)))
shopt -u extglob nullglob
for pkg in "${packages[@]}"; do
[[ -f $pkg ]] || continue [[ -f $pkg ]] || continue
# avoid adding duplicates of the same inode # avoid adding duplicates of the same inode
@@ -192,7 +189,7 @@ find_cached_package() {
return 1 return 1
esac esac
} }
shopt -u extglob
check_package_validity(){ check_package_validity(){
local pkgfile=$1 local pkgfile=$1

View File

@@ -23,22 +23,6 @@ if [[ -f "@pkgdatadir@/setarch-aliases.d/${arch}" ]]; then
else else
set_arch="${arch}" set_arch="${arch}"
fi fi
# Architecture-specific Mount
arch_mounts=()
if [[ -f "@pkgdatadir@/mount.d/${arch}" ]]; then
mapfile -t arch_mounts < "@pkgdatadir@/mount.d/${arch}"
fi
for arch_mount in "${arch_mounts[@]}"; do
if [[ $arch_mount = rw* ]]; then
arch_mount=${arch_mount#rw }
in_array "$arch_mount" "${makechrootpkg_args[@]}" || makechrootpkg_args+=("-d" "$arch_mount")
elif [[ $arch_mount = ro* ]]; then
arch_mount=${arch_mount#ro }
in_array "$arch_mount" "${makechrootpkg_args[@]}" || makechrootpkg_args+=("-D" "$arch_mount")
fi
done
chroots='/var/lib/archbuild' chroots='/var/lib/archbuild'
clean_first=false clean_first=false

View File

@@ -2,6 +2,8 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
shopt -s extglob
m4_include(lib/common.sh) m4_include(lib/common.sh)
usage() { usage() {
@@ -50,7 +52,7 @@ while (( $# )); do
shift shift
break break
;; ;;
-*|--*) -*,--*)
die "invalid argument: %s" "$1" die "invalid argument: %s" "$1"
;; ;;
*) *)

View File

@@ -22,16 +22,8 @@ elif [[ -r "$HOME/.makepkg.conf" ]]; then
fi fi
cmd=${0##*/} cmd=${0##*/}
rsyncopts=(-e ssh -p '--chmod=ug=rw,o=r' -c -h -L --progress --partial -y)
if [[ ! -f PKGBUILD ]]; then archreleaseopts=()
die 'No PKGBUILD file'
fi
source=()
# shellcheck source=contrib/makepkg/PKGBUILD.proto
. ./PKGBUILD
pkgbase=${pkgbase:-$pkgname}
case "$cmd" in case "$cmd" in
commitpkg) commitpkg)
if (( $# == 0 )); then if (( $# == 0 )); then
@@ -47,7 +39,26 @@ case "$cmd" in
die 'Usage: commitpkg <reponame> [-f] [-s server] [-l limit] [-a arch] [commit message]' die 'Usage: commitpkg <reponame> [-f] [-s server] [-l limit] [-a arch] [commit message]'
;; ;;
esac esac
while getopts ':l:a:s:f' flag; do
case $flag in
f) archreleaseopts+=('-f') ;;
s) server=$OPTARG ;;
l) rsyncopts+=("--bwlimit=$OPTARG") ;;
a) commit_arch=$OPTARG ;;
:) die "Option requires an argument -- '%s'" "$OPTARG" ;;
\?) die "Invalid option -- '%s'" "$OPTARG" ;;
esac
done
shift $(( OPTIND - 1 ))
if [[ ! -f PKGBUILD ]]; then
die 'No PKGBUILD file'
fi
source=()
# shellcheck source=contrib/makepkg/PKGBUILD.proto
. ./PKGBUILD
pkgbase=${pkgbase:-$pkgname}
if (( ${#validpgpkeys[@]} != 0 )); then if (( ${#validpgpkeys[@]} != 0 )); then
if [[ -d keys ]]; then if [[ -d keys ]]; then
@@ -88,20 +99,6 @@ if (( ${#needsversioning[*]} )); then
(( ${#unversioned[*]} )) && die "%s is not under version control" "${unversioned[@]}" (( ${#unversioned[*]} )) && die "%s is not under version control" "${unversioned[@]}"
fi fi
rsyncopts=(-e ssh -p '--chmod=ug=rw,o=r' -c -h -L --progress --partial -y)
archreleaseopts=()
while getopts ':l:a:s:f' flag; do
case $flag in
f) archreleaseopts+=('-f') ;;
s) server=$OPTARG ;;
l) rsyncopts+=("--bwlimit=$OPTARG") ;;
a) commit_arch=$OPTARG ;;
:) die "Option requires an argument -- '%s'" "$OPTARG" ;;
\?) die "Invalid option -- '%s'" "$OPTARG" ;;
esac
done
shift $(( OPTIND - 1 ))
# check packages for validity # check packages for validity
for _arch in "${arch[@]}"; do for _arch in "${arch[@]}"; do
if [[ -n $commit_arch && ${_arch} != "$commit_arch" ]]; then if [[ -n $commit_arch && ${_arch} != "$commit_arch" ]]; then
@@ -132,17 +129,16 @@ if [[ -n $(svn status -q) ]]; then
svn commit -q -m "${msgtemplate}: ${1}" || die svn commit -q -m "${msgtemplate}: ${1}" || die
stat_done stat_done
else else
[[ -z ${WORKDIR:-} ]] && setup_workdir msgfile="$(mktemp)"
msgfile=$(mktemp --tmpdir="${WORKDIR}" commitpkg.XXXXXXXXXX)
echo "$msgtemplate" > "$msgfile" echo "$msgtemplate" > "$msgfile"
if [[ -n $SVN_EDITOR ]]; then if [[ -n $SVN_EDITOR ]]; then
$SVN_EDITOR "$msgfile" || die $SVN_EDITOR "$msgfile"
elif [[ -n $VISUAL ]]; then elif [[ -n $VISUAL ]]; then
$VISUAL "$msgfile" || die $VISUAL "$msgfile"
elif [[ -n $EDITOR ]]; then elif [[ -n $EDITOR ]]; then
$EDITOR "$msgfile" || die $EDITOR "$msgfile"
else else
vi "$msgfile" || die vi "$msgfile"
fi fi
[[ -s $msgfile ]] || die [[ -s $msgfile ]] || die
stat_busy 'Committing changes to trunk' stat_busy 'Committing changes to trunk'

View File

@@ -57,14 +57,9 @@ for _arch in "${arch[@]}"; do
fi fi
for _pkgname in "${pkgname[@]}"; do for _pkgname in "${pkgname[@]}"; do
fullver=$(get_full_version "$_pkgname") fullver=$(get_full_version "$_pkgname")
pkgpath="/srv/ftp/${source_repo}/os/${repo_arch}/${_pkgname}-${fullver}-${_arch}.pkg.tar.*" pkgpath="/srv/ftp/$source_repo/os/$repo_arch/$_pkgname-$fullver-${_arch}.pkg.tar.*"
debugpath="/srv/ftp/${source_repo}-debug/os/${repo_arch}/${_pkgname}-debug-${fullver}-${_arch}.pkg.tar.*"
# Fail if $pkgpath doesn't match but keep $debugpath optional
# shellcheck disable=2029 # shellcheck disable=2029
ssh "${server}" "bash -c ' ssh "$server" "cp $pkgpath staging/$target_repo" || die
install ${pkgpath} -Dt staging/${target_repo} &&
(install ${debugpath} -Dt staging/${target_repo} 2>/dev/null || true)
'" || die
done done
done done

View File

@@ -2,6 +2,8 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
shopt -s extglob
m4_include(lib/common.sh) m4_include(lib/common.sh)
usage() { usage() {
@@ -22,18 +24,9 @@ usage() {
OPTIONS OPTIONS
-M, --makepkg-config Set an alternate makepkg configuration file -M, --makepkg-config Set an alternate makepkg configuration file
-P, --pool=DIR Search diff target in pool dir (default '/srv/ftp/pool')
-v, --verbose Provide more detailed/unfiltered output -v, --verbose Provide more detailed/unfiltered output
-h, --help Show this help text -h, --help Show this help text
OUTPUT OPTIONS
--color[=WHEN] Color output; WHEN is 'never', 'always', or 'auto';
Plain --color means --color='auto'
-u, -U, --unified Output 3 lines of unified context
-y, --side-by-side Output in two columns
-W, --width=NUM Output at most NUM (default 'auto') print columns
NUM can be 'auto', 'columns' or a number
MODES MODES
-l, --list Activate content list diff mode (default) -l, --list Activate content list diff mode (default)
-d, --diffoscope Activate diffoscope diff mode -d, --diffoscope Activate diffoscope diff mode
@@ -43,19 +36,12 @@ _EOF_
} }
MAKEPKG_CONF=/etc/makepkg.conf MAKEPKG_CONF=/etc/makepkg.conf
POOLDIR=/srv/ftp/pool
VERBOSE=0 VERBOSE=0
TARLIST=0 TARLIST=0
DIFFOSCOPE=0 DIFFOSCOPE=0
PKGINFO=0 PKGINFO=0
BUILDINFO=0 BUILDINFO=0
DIFFMODE=--side-by-side
DIFFCOLOR=--color=auto
DIFFWIDTH=--width=auto
DIFFOPTIONS=(--expand-tabs)
# option checking # option checking
while (( $# )); do while (( $# )); do
case $1 in case $1 in
@@ -64,7 +50,6 @@ while (( $# )); do
exit 0 exit 0
;; ;;
-M|--makepkg-config) -M|--makepkg-config)
(( $# <= 1 )) && die "missing argument for %s" "$1"
MAKEPKG_CONF="$2" MAKEPKG_CONF="$2"
shift 2 shift 2
;; ;;
@@ -88,50 +73,11 @@ while (( $# )); do
VERBOSE=1 VERBOSE=1
shift shift
;; ;;
-u|-U|--unified)
DIFFMODE=--unified
shift
;;
-y|--side-by-side)
DIFFMODE=--side-by-side
shift
;;
--color|--color=*)
if [[ $2 == never || $2 == always || $2 == auto ]]; then
DIFFCOLOR="--color=$2"
shift 2
continue
fi
if [[ $1 == --color ]]; then
DIFFCOLOR="--color=auto"
else
DIFFCOLOR="$1"
fi
shift
;;
-W|--width)
(( $# <= 1 )) && die "missing argument for %s" "$1"
DIFFWIDTH="--width=$2"
shift 2
;;
--width=*)
DIFFWIDTH="$1"
shift
;;
-P|--pool)
(( $# <= 1 )) && die "missing argument for %s" "$1"
POOLDIR="$2"
shift 2
;;
--pool=*)
POOLDIR="${1#*=}"
shift
;;
--) --)
shift shift
break break
;; ;;
-*|--*) -*,--*)
die "invalid argument: %s" "$1" die "invalid argument: %s" "$1"
;; ;;
*) *)
@@ -140,22 +86,6 @@ while (( $# )); do
esac esac
done done
# Set options based on flags or magic values
if (( VERBOSE )); then
if [[ $DIFFMODE == --unified ]]; then
DIFFMODE="--unified=99999"
fi
else
DIFFOPTIONS+=(--suppress-common-lines)
fi
if [[ $DIFFWIDTH == --width=columns ]]; then
DIFFWIDTH="--width=${COLUMNS:-130}"
fi
if [[ $DIFFWIDTH != --width=auto ]]; then
DIFFOPTIONS+=("${DIFFWIDTH}")
fi
DIFFOPTIONS+=("${DIFFMODE}" "${DIFFCOLOR}")
if ! (( DIFFOSCOPE || TARLIST || PKGINFO || BUILDINFO )); then if ! (( DIFFOSCOPE || TARLIST || PKGINFO || BUILDINFO )); then
TARLIST=1 TARLIST=1
fi fi
@@ -190,19 +120,6 @@ tar_list() {
fi | sort fi | sort
} }
file_line_length() {
path="$1"
wc -L "${path}" | tail -n1 | sed -E 's/^ +//g' | cut -d' ' -f1
}
file_diff_columns() {
file1="$1"
file2="$2"
file1_length=$(file_line_length "$file1")
file2_length=$(file_line_length "$file2")
echo $(( file1_length + file2_length + 3 ))
}
diff_pkgs() { diff_pkgs() {
local oldpkg newpkg local oldpkg newpkg
oldpkg=$(readlink -m "$1") oldpkg=$(readlink -m "$1")
@@ -211,44 +128,32 @@ diff_pkgs() {
[[ -f $oldpkg ]] || die "No such file: %s" "${oldpkg}" [[ -f $oldpkg ]] || die "No such file: %s" "${oldpkg}"
[[ -f $newpkg ]] || die "No such file: %s" "${newpkg}" [[ -f $newpkg ]] || die "No such file: %s" "${newpkg}"
DIFFOPTIONS+=(--label "${oldpkg}" --label "${newpkg}")
if (( TARLIST )); then if (( TARLIST )); then
tar_list "$oldpkg" > "$TMPDIR/old" tar_list "$oldpkg" > "$TMPDIR/filelist-old"
tar_list "$newpkg" > "$TMPDIR/new" tar_list "$newpkg" > "$TMPDIR/filelist"
sdiff -s "$TMPDIR/filelist-old" "$TMPDIR/filelist"
fi fi
if (( PKGINFO )); then if (( PKGINFO )); then
bsdtar xOqf "$oldpkg" .PKGINFO > "$TMPDIR/old" bsdtar xOqf "$oldpkg" .PKGINFO > "$TMPDIR/pkginfo-old"
bsdtar xOqf "$newpkg" .PKGINFO > "$TMPDIR/new" bsdtar xOqf "$newpkg" .PKGINFO > "$TMPDIR/pkginfo"
sdiff -s "$TMPDIR/pkginfo-old" "$TMPDIR/pkginfo"
fi fi
if (( BUILDINFO )); then if (( BUILDINFO )); then
bsdtar xOqf "$oldpkg" .BUILDINFO > "$TMPDIR/old" bsdtar xOqf "$oldpkg" .BUILDINFO > "$TMPDIR/buildinfo-old"
bsdtar xOqf "$newpkg" .BUILDINFO > "$TMPDIR/new" bsdtar xOqf "$newpkg" .BUILDINFO > "$TMPDIR/buildinfo"
fi
if (( TARLIST || PKGINFO || BUILDINFO )); then sdiff -s "$TMPDIR/buildinfo-old" "$TMPDIR/buildinfo"
# Resolve dynamic auto width one we know the content to diff
if [[ $DIFFWIDTH == --width=auto ]]; then
AUTOLENGTH=$(file_diff_columns "$TMPDIR/old" "$TMPDIR/new")
DIFFOPTIONS+=("--width=${AUTOLENGTH}")
fi
# Print a header for side-by-side view as it lacks labels
if [[ $DIFFMODE == --side-by-side ]]; then
printf -- "--- %s\n+++ %s\n" "${oldpkg}" "${newpkg}"
fi
diff "${DIFFOPTIONS[@]}" "$TMPDIR/old" "$TMPDIR/new"
fi fi
if (( DIFFOSCOPE )); then if (( DIFFOSCOPE )); then
diffoscope "${DIFFCOLOR/--color/--text-color}" "$oldpkg" "$newpkg" diffoscope "$oldpkg" "$newpkg"
fi fi
} }
shopt -s extglob
fetch_pkg() { fetch_pkg() {
local pkg pkgdest pkgurl local pkg pkgdest pkgurl
case $1 in case $1 in
@@ -264,19 +169,8 @@ fetch_pkg() {
pkg=$1 ;; pkg=$1 ;;
esac esac
if [[ -z ${pkgurl} ]]; then [[ -n $pkgurl ]] || pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$pkg") ||
# Try to find latest package in pool dir die "Couldn't download previous package for %s." "$pkg"
if [[ -d ${POOLDIR} ]]; then
shopt -s extglob nullglob
pkgurl=$(printf "%s\n" "${POOLDIR}"/*/"${_pkgname}"-!(*-*)-!(*-*)-!(*-*).pkg.tar!(*.sig)|sort -Vr|head -1)
shopt -u extglob nullglob
fi
# Search via pacman database if no pool file exists
if [[ ! -f ${pkgurl} ]]; then
pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$pkg") ||
die "Couldn't download previous package for %s." "$pkg"
fi
fi
pkg=${pkgurl##*/} pkg=${pkgurl##*/}
pkgdest=$(mktemp -t -d "${pkg}-XXXXXX")/${pkg} pkgdest=$(mktemp -t -d "${pkg}-XXXXXX")/${pkg}
@@ -296,7 +190,6 @@ fetch_pkg() {
echo "$pkgdest" echo "$pkgdest"
} }
shopt -u extglob
if (( $# < 2 )); then if (( $# < 2 )); then
if [[ ! -f PKGBUILD ]]; then if [[ ! -f PKGBUILD ]]; then

View File

@@ -5,6 +5,7 @@
m4_include(lib/common.sh) m4_include(lib/common.sh)
set -e set -e
shopt -s extglob
IGNORE_INTERNAL=0 IGNORE_INTERNAL=0
@@ -40,12 +41,9 @@ else
pushd "$WORKDIR" >/dev/null pushd "$WORKDIR" >/dev/null
fi fi
shopt -s extglob
process_sofile() { process_sofile() {
# extract the library name: libfoo.so # extract the library name: libfoo.so
shopt -s extglob nullglob
soname="${sofile%.so?(+(.+([0-9])))}".so soname="${sofile%.so?(+(.+([0-9])))}".so
shopt -u extglob nullglob
# extract the major version: 1 # extract the major version: 1
soversion="${sofile##*\.so\.}" soversion="${sofile##*\.so\.}"
if [[ "$soversion" = "$sofile" ]] && ((IGNORE_INTERNAL)); then if [[ "$soversion" = "$sofile" ]] && ((IGNORE_INTERNAL)); then
@@ -57,7 +55,6 @@ process_sofile() {
soobjects+=("${soname}=${soversion}-${soarch}") soobjects+=("${soname}=${soversion}-${soarch}")
fi fi
} }
shopt -u extglob
case $script_mode in case $script_mode in
deps) find_args=(-perm -u+x);; deps) find_args=(-perm -u+x);;

View File

@@ -24,7 +24,6 @@ clean_first=0
run_namcap=0 run_namcap=0
run_checkpkg=0 run_checkpkg=0
temp_chroot=0 temp_chroot=0
tmp_opts="nosuid,nodev,size=50%,nr_inodes=2m"
bindmounts_ro=() bindmounts_ro=()
bindmounts_rw=() bindmounts_rw=()
@@ -312,14 +311,13 @@ fi
# Pass all arguments after -- right to makepkg # Pass all arguments after -- right to makepkg
makepkg_args+=("${@:$OPTIND}") makepkg_args+=("${@:$OPTIND}")
# See if -R, -e or -A was passed to makepkg # See if -R or -e was passed to makepkg
for arg in "${@:$OPTIND}"; do for arg in "${@:$OPTIND}"; do
case ${arg%%=*} in case ${arg%%=*} in
--skip*|--holdver|--ignorearch) verifysource_args+=("$arg") ;; --skip*|--holdver) verifysource_args+=("$arg") ;;
--repackage|--noextract) keepbuilddir=1 ;; --repackage|--noextract) keepbuilddir=1 ;;
--*) ;; --*) ;;
-*A*) verifysource_args+=(-A) ;;& -*R*|-*e*) keepbuilddir=1 ;;
-*R*|-*e*) keepbuilddir=1 ;;&
esac esac
done done
@@ -366,7 +364,6 @@ prepare_chroot
if arch-nspawn "$copydir" \ if arch-nspawn "$copydir" \
--bind="${PWD//:/\\:}:/startdir" \ --bind="${PWD//:/\\:}:/startdir" \
--bind="${SRCDEST//:/\\:}:/srcdest" \ --bind="${SRCDEST//:/\\:}:/srcdest" \
--tmpfs="/tmp:${tmp_opts}" \
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
/chrootbuild "${makepkg_args[@]}" /chrootbuild "${makepkg_args[@]}"
then then

View File

@@ -86,14 +86,13 @@ get_pkgfile() {
get_makepkg_conf() { get_makepkg_conf() {
local fname=${1} local fname=${1}
local arch="${2}" local makepkg_conf="${2}"
local makepkg_conf="${3}"
if ! buildtool_file=$(get_pkgfile "${fname}"); then if ! buildtool_file=$(get_pkgfile "${fname}"); then
error "failed to retrieve ${fname}" error "failed to retrieve ${fname}"
return 1 return 1
fi fi
msg2 "using makepkg.conf from ${fname}" msg2 "using makepkg.conf from ${fname}"
bsdtar xOqf "${buildtool_file/file:\/\//}" "usr/share/devtools/makepkg-${arch}.conf" > "${makepkg_conf}" bsdtar xOqf "${buildtool_file/file:\/\//}" usr/share/devtools/makepkg-x86_64.conf > "${makepkg_conf}"
return 0 return 0
} }
@@ -214,17 +213,17 @@ TEMPDIR=$(mktemp -d --tmpdir makerepropkg.XXXXXXXXXX)
makepkg_conf="${TEMPDIR}/makepkg.conf" makepkg_conf="${TEMPDIR}/makepkg.conf"
# anything before buildtool support is pinned to the last none buildtool aware release # anything before buildtool support is pinned to the last none buildtool aware release
if [[ -z "${BUILDTOOL}" ]]; then if [[ -z "${BUILDTOOL}" ]]; then
get_makepkg_conf "devtools-20210202-3-any" "${CARCH}" "${makepkg_conf}" || exit 1 get_makepkg_conf "devtools-20210202-3-any" "${makepkg_conf}" || exit 1
# prefere to assume devtools up until matching makepkg version so repository packages remain reproducible # prefere to assume devtools up until matching makepkg version so repository packages remain reproducible
elif [[ "${BUILDTOOL}" = makepkg ]] && (( $(vercmp "${BUILDTOOLVER}" 6.0.1) <= 0 )); then elif [[ "${BUILDTOOL}" = makepkg ]] && (( $(vercmp "${BUILDTOOLVER}" 6.0.1) <= 0 )); then
get_makepkg_conf "devtools-20210202-3-any" "${CARCH}" "${makepkg_conf}" || exit 1 get_makepkg_conf "devtools-20210202-3-any" "${makepkg_conf}" || exit 1
# all devtools builds # all devtools builds
elif [[ "${BUILDTOOL}" = devtools ]] && get_makepkg_conf "${BUILDTOOL}-${BUILDTOOLVER}" "${CARCH}" "${makepkg_conf}"; then elif [[ "${BUILDTOOL}" = devtools ]] && get_makepkg_conf "${BUILDTOOL}-${BUILDTOOLVER}" "${makepkg_conf}"; then
true true
# fallback to current makepkg.conf # fallback to current makepkg.conf
else else
warning "Unknown buildtool (${BUILDTOOL}-${BUILDTOOLVER}), using fallback" warning "Unknown buildtool (${BUILDTOOL}-${BUILDTOOLVER}), using fallback"
makepkg_conf=@pkgdatadir@/makepkg-${CARCH}.conf makepkg_conf=@pkgdatadir@/makepkg-x86_64.conf
fi fi
printf '%s\n' "${allpkgfiles[@]}" | mkarchroot -M "${makepkg_conf}" -U "${archroot_args[@]}" "${namespace}/root" - || exit 1 printf '%s\n' "${allpkgfiles[@]}" | mkarchroot -M "${makepkg_conf}" -U "${archroot_args[@]}" "${namespace}/root" - || exit 1

View File

@@ -81,10 +81,10 @@ for file in "${files[@]}"; do
cp "$file" "$working_dir$file" cp "$file" "$working_dir$file"
done done
unshare --mount pacstrap -${umode}Mc ${pac_conf:+-C "$pac_conf"} "$working_dir" \ unshare --mount pacstrap -${umode}Mcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \
"${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages' "${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'
printf '%s.UTF-8 UTF-8\n' en_US de_DE > "$working_dir/etc/locale.gen" printf '%s.UTF-8 UTF-8\n' C en_US de_DE > "$working_dir/etc/locale.gen"
echo 'LANG=C.UTF-8' > "$working_dir/etc/locale.conf" echo 'LANG=C.UTF-8' > "$working_dir/etc/locale.conf"
echo "$CHROOT_VERSION" > "$working_dir/.arch-chroot" echo "$CHROOT_VERSION" > "$working_dir/.arch-chroot"