Compare commits

..

6 Commits

Author SHA1 Message Date
Jelle van der Waa
1e0a141175 Merge branch 'support-offline-builds' into 'master'
Draft: PoC: build offline support

See merge request archlinux/devtools!207
2025-08-10 21:47:26 +00:00
Aaron Liu
3f0ebbc6d2 fix(license): add .gitignore to REUSE defaults
36 packages use this while 26 use *.pam and 21 use *.logrotate. Seems
anecdotally common enough to add this here.
2025-08-08 14:13:32 +02:00
Jakub Klinkovský
fc56ebedf3 fix(completion): fix bash completion for the license subcommand
Signed-off-by: Jakub Klinkovský <lahwaacz@archlinux.org>
2025-08-05 17:48:12 +02:00
Christian Heusel
01757e6904 fix(commitpkg): Quiet git ls-files output
So far all files in `needsversioning=(...)` have been printed to the
command line if they were found, which is not useful, especially now
that we have more files present there.

It makes sense however to keep the standard error output, as this gives
a actionable suggestion what one should to to fix the issue:

    > error: pathspec 'PKGBUILD' did not match any file(s) known to git
    > Did you forget to 'git add'?

Fixes #281

Signed-off-by: Christian Heusel <christian@heusel.eu>
2025-08-01 11:26:57 +02:00
Daniel M. Capella
c5fe8ff3e6 feat(license): Extend matches for sysusers/tmpfiles configs
Eg. to match:
- sysusers.conf
- $pkgname.sysusers
- $pkgname.sysusers.conf
2025-07-28 23:38:32 -04:00
Jelle van der Waa
a0c0c63a85 PoC: build offline support 2024-10-10 19:35:42 +02:00
6 changed files with 62 additions and 10 deletions

View File

@@ -150,6 +150,7 @@ _pkgctl_cmds=(
db db
diff diff
issue issue
license
release release
repo repo
search search

View File

@@ -155,7 +155,7 @@ if (( ${#needsversioning[*]} )); then
if [[ ! -f "${file}" ]]; then if [[ ! -f "${file}" ]]; then
continue continue
fi fi
if ! git ls-files --error-unmatch "$file"; then if ! git ls-files --error-unmatch "$file" >/dev/null; then
die "%s is not under version control" "$file" die "%s is not under version control" "$file"
fi fi
done done

View File

@@ -55,6 +55,7 @@ pkgctl_build_usage() {
-o, --offload Build on a remote server and transfer artifacts afterwards -o, --offload Build on a remote server and transfer artifacts afterwards
-c, --clean Recreate the chroot before building -c, --clean Recreate the chroot before building
--inspect WHEN Spawn an interactive shell to inspect the chroot (never, always, failure) --inspect WHEN Spawn an interactive shell to inspect the chroot (never, always, failure)
--offline MODE Run a part of the build process offline (build, check)
-w, --worker SLOT Name of the worker slot, useful for concurrent builds (disables automatic names) -w, --worker SLOT Name of the worker slot, useful for concurrent builds (disables automatic names)
--nocheck Do not run the check() function in the PKGBUILD --nocheck Do not run the check() function in the PKGBUILD
@@ -198,6 +199,10 @@ pkgctl_build() {
EDIT=1 EDIT=1
shift shift
;; ;;
--offline)
MAKECHROOT_OPTIONS+=("-o" "$2")
shift 2
;;
-o|--offload) -o|--offload)
OFFLOAD=1 OFFLOAD=1
shift shift

View File

@@ -94,19 +94,19 @@ pkgctl_license_check() {
pushd "${path}" >/dev/null pushd "${path}" >/dev/null
if [[ ! -f PKGBUILD ]]; then if [[ ! -f PKGBUILD ]]; then
msg_error "${BOLD}${path}:${ALL_OFF} no PKGBUILD found" msg_error "${BOLD}${pkgbase}:${ALL_OFF} no PKGBUILD found"
return 1 return 1
fi fi
if [[ ! -f .SRCINFO ]]; then # reset common PKGBUILD variables
msg_error "${BOLD}${path}:${ALL_OFF} no .SRCINFO found" unset pkgbase
return 1
fi
if ! pkgbase=$(grep --max-count=1 --extended-regexp "pkgbase = (.+)" .SRCINFO | awk '{print $3}'); then # shellcheck source=contrib/makepkg/PKGBUILD.proto
msg_error "${BOLD}${path}:${ALL_OFF} pkgbase not found in .SRCINFO" if ! . ./PKGBUILD; then
msg_error "${BOLD}${pkgbase}:${ALL_OFF} failed to source PKGBUILD"
return 1 return 1
fi fi
pkgbase=${pkgbase:-$pkgname}
if [[ ! -e LICENSE ]]; then if [[ ! -e LICENSE ]]; then
msg_error "${BOLD}${pkgbase}:${ALL_OFF} is missing the LICENSE file" msg_error "${BOLD}${pkgbase}:${ALL_OFF} is missing the LICENSE file"

View File

@@ -188,10 +188,13 @@ path = [
"README.md", "README.md",
"keys/**", "keys/**",
".SRCINFO", ".SRCINFO",
".gitignore",
".nvchecker.toml", ".nvchecker.toml",
"*.install", "*.install",
"*.sysusers", "*.sysusers",
"*sysusers.conf",
"*.tmpfiles", "*.tmpfiles",
"*tmpfiles.conf",
"*.logrotate", "*.logrotate",
"*.pam", "*.pam",
"*.service", "*.service",

View File

@@ -40,6 +40,8 @@ bindmounts_ro=()
bindmounts_rw=() bindmounts_rw=()
bindmounts_tmpfs=() bindmounts_tmpfs=()
offline_options=()
copy=$USER copy=$USER
[[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER [[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER
[[ -z "$copy" || $copy = root ]] && copy=copy [[ -z "$copy" || $copy = root ]] && copy=copy
@@ -80,6 +82,7 @@ usage() {
echo ' Useful for maintaining multiple copies' echo ' Useful for maintaining multiple copies'
echo " Default: $copy" echo " Default: $copy"
echo '-n Run namcap on the package' echo '-n Run namcap on the package'
echo '-o Run given step offline'
echo '-C Run checkpkg on the package' echo '-C Run checkpkg on the package'
echo '-T Build in a temporary directory' echo '-T Build in a temporary directory'
echo '-U Run makepkg as a specified user' echo '-U Run makepkg as a specified user'
@@ -203,6 +206,7 @@ EOF
declare -p SOURCE_DATE_EPOCH 2>/dev/null || true declare -p SOURCE_DATE_EPOCH 2>/dev/null || true
declare -p BUILDTOOL 2>/dev/null declare -p BUILDTOOL 2>/dev/null
declare -p BUILDTOOLVER 2>/dev/null declare -p BUILDTOOLVER 2>/dev/null
declare -p offline_options
printf '_chrootbuild "$@" || exit\n' printf '_chrootbuild "$@" || exit\n'
if (( run_namcap )); then if (( run_namcap )); then
@@ -222,14 +226,52 @@ _chrootbuild() {
# shellcheck source=/dev/null # shellcheck source=/dev/null
. /etc/profile . /etc/profile
# for in_array
. /usr/share/makepkg/util.sh
# Beware, there are some stupid arbitrary rules on how you can # Beware, there are some stupid arbitrary rules on how you can
# use "$" in arguments to commands with "sudo -i". ${foo} or # use "$" in arguments to commands with "sudo -i". ${foo} or
# ${1} is OK, but $foo or $1 isn't. # ${1} is OK, but $foo or $1 isn't.
# https://bugzilla.sudo.ws/show_bug.cgi?id=765 # https://bugzilla.sudo.ws/show_bug.cgi?id=765
# Run prepare
sudo --preserve-env=SOURCE_DATE_EPOCH \ sudo --preserve-env=SOURCE_DATE_EPOCH \
--preserve-env=BUILDTOOL \ --preserve-env=BUILDTOOL \
--preserve-env=BUILDTOOLVER \ --preserve-env=BUILDTOOLVER \
-iu builduser bash -c 'cd /startdir; makepkg "$@"' -bash "$@" -iu builduser bash -c 'cd /startdir; makepkg --nobuild "$@"' -bash "$@"
if in_array "build" "${offline_options[@]}"; then
msg "building offline"
# Build offline
unshare -n -- sudo --preserve-env=SOURCE_DATE_EPOCH \
--preserve-env=BUILDTOOL \
--preserve-env=BUILDTOOLVER \
-iu builduser \
bash -c 'cd /startdir; makepkg --noprepare --noextract --nocheck "$@"' -bash "$@"
else
sudo --preserve-env=SOURCE_DATE_EPOCH \
--preserve-env=BUILDTOOL \
--preserve-env=BUILDTOOLVER \
-iu builduser \
bash -c 'cd /startdir; makepkg --noprepare --noextract --nocheck "$@"' -bash "$@"
fi
if in_array "check" "${offline_options[@]}"; then
msg "check offline"
# Run tests online
unshare -n -- sudo --preserve-env=SOURCE_DATE_EPOCH \
--preserve-env=BUILDTOOL \
--preserve-env=BUILDTOOLVER \
-iu builduser \
bash -c 'cd /startdir; makepkg --noprepare --noextract --nobuild "$@"' -bash "$@"
else
sudo --preserve-env=SOURCE_DATE_EPOCH \
--preserve-env=BUILDTOOL \
--preserve-env=BUILDTOOLVER \
-iu builduser \
bash -c 'cd /startdir; makepkg --noprepare --noextract --nobuild "$@"' -bash "$@"
fi
ret=$? ret=$?
case $ret in case $ret in
0|14) 0|14)
@@ -293,7 +335,7 @@ move_products() {
} }
# }}} # }}}
while getopts 'hcur:I:l:nCTD:d:U:x:t:' arg; do while getopts 'hcur:I:l:nCTD:o:d:U:x:t:' arg; do
case "$arg" in case "$arg" in
c) clean_first=1 ;; c) clean_first=1 ;;
D) bindmounts_ro+=("--bind-ro=$OPTARG") ;; D) bindmounts_ro+=("--bind-ro=$OPTARG") ;;
@@ -304,6 +346,7 @@ while getopts 'hcur:I:l:nCTD:d:U:x:t:' arg; do
I) install_pkgs+=("$OPTARG") ;; I) install_pkgs+=("$OPTARG") ;;
l) copy="$OPTARG" ;; l) copy="$OPTARG" ;;
n) run_namcap=1; makepkg_args+=(--install) ;; n) run_namcap=1; makepkg_args+=(--install) ;;
o) offline_options+=("$OPTARG") ;;
C) run_checkpkg=1 ;; C) run_checkpkg=1 ;;
T) temp_chroot=1; copy+="-$$" ;; T) temp_chroot=1; copy+="-$$" ;;
U) makepkg_user="$OPTARG" ;; U) makepkg_user="$OPTARG" ;;