Compare commits

...

16 Commits

Author SHA1 Message Date
Levente Polyak
d7c7074457 feat(release): allow releasing from unstable branch to unstable repos
This is done in order to properly support the build workflow for gnome-unstable.
If one tries to release from branch "unstable" to a regular repo an error is emitted.

Co-authored-by: Christian Heusel <christian@heusel.eu>
2023-08-09 18:10:35 +02:00
Jan Alexander Steffens (heftig)
5f4fd52e38 feat(arch-nspawn): Use a unique scope name instead of --keep-unit
`--keep-unit` is really only for use in services like
`systemd-nspawn@.service`.

The parameter was added in commit 000ea6c7bb because
systemd-nspawn defaults the name of the machine (and thus the generated
scope) to the name of the working directory, which is not unique. Thus
spawning a container from `archbuild/extra-x86_64/foo` while
`archbuild/testing-x86_64/foo` is already running would fail.

We can avoid the unit conflict by giving the container a unique machine
name. Creating a scope also allows us to place the container in a slice
hierarchy for resource control.
2023-07-21 19:41:22 +02:00
Jan Alexander Steffens (heftig)
1b25190176 chore(arch-nspawn): Simplify args construction for systemd-nspawn 2023-07-21 19:41:22 +02:00
Christian Heusel
030e6af880 chore: fix spelling mistake packge -> package
it seems like the mistake was copied to a few locations, this commit
fixes it.

Signed-off-by: Christian Heusel <christian@heusel.eu>
2023-07-06 15:30:49 +02:00
Levente Polyak
662d6c5274 fix(make): use correct version variable for release target 2023-07-05 18:45:54 +02:00
Levente Polyak
3de03e8b1f chore(release): version v1.0.3 2023-07-05 18:36:07 +02:00
Christian Heusel
720b7c9b05 chore(build): skip invalid architectures on autodetection
This is done so that pkgctl can be better used to build aur packages
which can have arch=(...) settings for which we do not have a clean
chroot builder.

Signed-off-by: Christian Heusel <christian@heusel.eu>
2023-07-05 18:17:32 +02:00
Christian Heusel
0ea7e9e0e5 chore(doc): fix spelling typo in pkgrel detection
Signed-off-by: Christian Heusel <christian@heusel.eu>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-06-18 01:01:11 +02:00
Christian Heusel
be5f54c95c fix(commitpkg): ensure the PKGBUILD is version controlled
Early exit in case the PKGBUILD is not yet properly under version
control, which can happen for freshly initialized repositories.
Furthermore print an appropriate error message including a hint how to
resolve this.

Fixes #154
Fixes #167

Signed-off-by: Christian Heusel <christian@heusel.eu>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-06-17 23:02:36 +02:00
Levente Polyak
5c6e13a672 chore(doc): add missing dependency on fakeroot
We need fakeroot to trick pacman into updating a fresh pacman database
for an unprivileged user.
2023-06-08 00:31:35 +02:00
Levente Polyak
a07df0beea chore(release): version v1.0.2 2023-05-28 01:22:09 +02:00
Levente Polyak
c7d627165f chore(release): adjust Makefile for new release schema
Ask for the next release version and automatically create a signed tag.
Furthermore add a simple release target to call glab for uploading the
required artifacts.
2023-05-28 01:21:40 +02:00
Antonio Rojas
e47035e74d chore(build): improve error wording if no package repo could be detected
Not being in any official repo does not necessarily mean this is a new
package. One could simply be building an AUR or custom local package.
Make the message less confusing in such case.
2023-05-27 22:18:04 +02:00
Daniel M. Capella
9b11b16a7e chore(doc): remove duplicate subcommand from example help text 2023-05-27 21:44:09 +02:00
Levente Polyak
3283b2ca59 fix(commitpkg): only force existing files to be under version control
Before porting commitpkg to Git, the code has checked the SVN status for
none commited files. During the port this has changed by straight
checking for any passed files if they were under version control or not.

In general the whole logic is very brittle as variables are searched by
regex and directly passed to eval while ignoring any function scoping.
This leads to missing files when they reference the $pkgname inside a
package function but also provide wrong ones when eval simply returns
the first $pkgname while ignoring and function scopes.

In the future this should completely be replaces by .SRCINFO processing.

Fixes #145

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-05-27 01:53:45 +02:00
Toolybird
71cb9e97bb fix(archroot): preserve original args for check_root before discarding
arch-nspawn, mkarchroot, makerepropkg all call "shift" after getopts
processing. Save the original args and pass on to check_root to prevent
options being discarded.

Fixes 41d4624879
Fixes #149

Signed-off-by: Toolybird <toolybird@tuta.io>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-05-26 01:06:14 +02:00
16 changed files with 81 additions and 38 deletions

View File

@@ -1,6 +1,6 @@
SHELL=/bin/bash SHELL=/bin/bash
V=1.0.1 V=1.0.3
BUILDTOOLVER ?= $(V) BUILDTOOLVER ?= $(V)
PREFIX = /usr/local PREFIX = /usr/local
@@ -145,19 +145,20 @@ uninstall:
$(DESTDIR)$(DATADIR)/pacman.conf.d \ $(DESTDIR)$(DATADIR)/pacman.conf.d \
$(DESTDIR)$(DATADIR) $(DESTDIR)$(DATADIR)
TODAY=$(shell date +"%Y%m%d")
tag: tag:
@sed -E "s|^V=[0-9]{8}|V=$(TODAY)|" -i Makefile @echo "current version: v$(V)"
@git commit --gpg-sign --message "Version $(TODAY)" Makefile @read -r -p "tag version: v" VERSION && \
@git tag --sign --message "Version $(TODAY)" $(TODAY) sed -E "s|^V=.+|V=$$VERSION|" -i Makefile && \
git commit --gpg-sign --message "chore(release): version v$$VERSION" Makefile && \
git tag --sign --message "Version v$$VERSION" v$$VERSION
release: dist
glab release create v$(V) devtools-$(V).tar.gz*
dist: dist:
git archive --format=tar --prefix=devtools-$(V)/ $(V) | gzip > devtools-$(V).tar.gz git archive --format=tar --prefix=devtools-$(V)/ v$(V) | gzip > devtools-$(V).tar.gz
gpg --detach-sign --use-agent devtools-$(V).tar.gz gpg --detach-sign --use-agent devtools-$(V).tar.gz
upload:
scp devtools-$(V).tar.gz devtools-$(V).tar.gz.sig repos.archlinux.org:/srv/ftp/other/devtools/
check: $(BINPROGS_SRC) $(LIBRARY_SRC) contrib/completion/bash/devtools.in config/makepkg/x86_64.conf contrib/makepkg/PKGBUILD.proto check: $(BINPROGS_SRC) $(LIBRARY_SRC) contrib/completion/bash/devtools.in config/makepkg/x86_64.conf contrib/makepkg/PKGBUILD.proto
shellcheck $^ shellcheck $^

View File

@@ -42,6 +42,7 @@ will automatically build the project and proxy all calls to the local build dire
- binutils - binutils
- coreutils - coreutils
- diffutils - diffutils
- fakeroot
- findutils - findutils
- grep - grep
- jq - jq

View File

@@ -241,7 +241,7 @@ _pkgctl_cmds=(
"pkgctl command" "pkgctl command"
"auth[Authenticate with services like GitLab]" "auth[Authenticate with services like GitLab]"
"build[Build packages inside a clean chroot]" "build[Build packages inside a clean chroot]"
"db[Pacman database modification for packge update, move etc]" "db[Pacman database modification for package update, move etc]"
"diff[Compare package files using different modes]" "diff[Compare package files using different modes]"
"release[Release step to commit, tag and upload build artifacts]" "release[Release step to commit, tag and upload build artifacts]"
"repo[Manage Git packaging repositories and their configuration]" "repo[Manage Git packaging repositories and their configuration]"

View File

@@ -33,7 +33,7 @@ pkgctl build::
Build packages inside a clean chroot Build packages inside a clean chroot
pkgctl db:: pkgctl db::
Pacman database modification for packge update, move etc Pacman database modification for package update, move etc
pkgctl diff:: pkgctl diff::
Compare package files using different modes Compare package files using different modes

View File

@@ -16,7 +16,6 @@ umask 0022
working_dir='' working_dir=''
files=() files=()
mount_args=()
usage() { usage() {
echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]" echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]"
@@ -32,6 +31,9 @@ usage() {
exit 1 exit 1
} }
# save all args for check_root
orig_args=("$@")
while getopts 'hC:M:c:f:s' arg; do while getopts 'hC:M:c:f:s' arg; do
case "$arg" in case "$arg" in
C) pac_conf="$OPTARG" ;; C) pac_conf="$OPTARG" ;;
@@ -46,13 +48,23 @@ done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
(( $# < 1 )) && die 'You must specify a directory.' (( $# < 1 )) && die 'You must specify a directory.'
check_root "" "${BASH_SOURCE[0]}" "$@" check_root "" "${BASH_SOURCE[0]}" "${orig_args[@]}"
working_dir=$(readlink -f "$1") working_dir=$(readlink -f "$1")
shift 1 shift 1
[[ -z $working_dir ]] && die 'Please specify a working directory.' [[ -z $working_dir ]] && die 'Please specify a working directory.'
nspawn_args=(
--quiet
--directory="$working_dir"
--setenv="PATH=/usr/local/sbin:/usr/local/bin:/usr/bin"
--register=no
--slice="devtools-$(systemd-escape "${SUDO_USER:-$USER}")"
--machine="arch-nspawn-$$"
--as-pid2
)
if (( ${#cache_dirs[@]} == 0 )); then if (( ${#cache_dirs[@]} == 0 )); then
mapfile -t cache_dirs < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" CacheDir) mapfile -t cache_dirs < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" CacheDir)
fi fi
@@ -80,10 +92,10 @@ while read -r line; do
done done
done < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" --repo-list) done < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" --repo-list)
mount_args+=("--bind=${cache_dirs[0]//:/\\:}") nspawn_args+=(--bind="${cache_dirs[0]//:/\\:}")
for cache_dir in "${cache_dirs[@]:1}"; do for cache_dir in "${cache_dirs[@]:1}"; do
mount_args+=("--bind-ro=${cache_dir//:/\\:}") nspawn_args+=(--bind-ro="${cache_dir//:/\\:}")
done done
# {{{ functions # {{{ functions
@@ -126,9 +138,4 @@ else
set_arch="${CARCH}" set_arch="${CARCH}"
fi fi
exec ${CARCH:+setarch "$set_arch"} systemd-nspawn -q \ exec ${CARCH:+setarch "$set_arch"} systemd-nspawn "${nspawn_args[@]}" "$@"
-D "$working_dir" \
-E "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin" \
--register=no --keep-unit --as-pid2 \
"${mount_args[@]}" \
"$@"

View File

@@ -7,6 +7,8 @@ _DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
# shellcheck source=src/lib/valid-tags.sh # shellcheck source=src/lib/valid-tags.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-tags.sh source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-tags.sh
# shellcheck source=src/lib/util/git.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/git.sh
set -e set -e
@@ -55,8 +57,8 @@ gittag=$(get_tag_from_pkgver "$pkgver")
if ! branchname=$(git symbolic-ref --short HEAD); then if ! branchname=$(git symbolic-ref --short HEAD); then
die 'not on any branch' die 'not on any branch'
fi fi
if [[ "${branchname}" != main ]]; then if ! is_valid_release_branch "${branchname}"; then
die 'must be run from the main branch' die 'must be run from a valid release branch (%s)' "${VALID_RELEASE_BRANCHES[@]}"
fi fi
# Check if remote origin is setup properly # Check if remote origin is setup properly
@@ -85,10 +87,10 @@ if git tag --verify "$gittag" &> /dev/null; then
if [[ "$cwd_checksum" != "$tag_checksum" ]]; then if [[ "$cwd_checksum" != "$tag_checksum" ]]; then
die "tagged PKGBUILD is not the same as the working dir PKGBUILD" die "tagged PKGBUILD is not the same as the working dir PKGBUILD"
fi fi
git push --tags --set-upstream origin main || abort git push --tags --set-upstream origin "${branchname}" || abort
exit 0 exit 0
fi fi
msg "Releasing package" msg "Releasing package"
git tag --sign --message="Package release ${pkgver}" "$gittag" || abort git tag --sign --message="Package release ${pkgver}" "$gittag" || abort
git push --tags --set-upstream origin main || abort git push --tags --set-upstream origin "${branchname}" || abort

View File

@@ -5,6 +5,8 @@
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@} _DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
# shellcheck source=src/lib/common.sh # shellcheck source=src/lib/common.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
# shellcheck source=src/lib/util/git.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/git.sh
source /usr/share/makepkg/util/util.sh source /usr/share/makepkg/util/util.sh
@@ -70,8 +72,12 @@ if ! repo_spec=$(git config --local devtools.version) || [[ ${repo_spec} != "${G
exit 1 exit 1
fi fi
if [[ "$(git symbolic-ref --short HEAD)" != main ]]; then if ! branchname=$(git symbolic-ref --short HEAD); then
die 'must be run from the main branch' die 'not on any branch'
fi
if ! is_valid_release_branch "${branchname}"; then
die 'must be run from a valid release branch (%s)' "${VALID_RELEASE_BRANCHES[@]}"
fi fi
source=() source=()
@@ -95,6 +101,9 @@ case "$cmd" in
;; ;;
esac esac
if [[ "${branchname}" == "unstable" ]] && [[ "$repo" != *"unstable" ]]; then
die 'Cannot release from unstable branch into non-unstable repo: %s' "${repo}"
fi
if (( ${#validpgpkeys[@]} != 0 )); then if (( ${#validpgpkeys[@]} != 0 )); then
if [[ -d keys ]]; then if [[ -d keys ]]; then
@@ -111,7 +120,7 @@ if (( ${#validpgpkeys[@]} != 0 )); then
fi fi
# find files which should be under source control # find files which should be under source control
needsversioning=() needsversioning=(PKGBUILD)
for s in "${source[@]}"; do for s in "${source[@]}"; do
[[ $s != *://* ]] && needsversioning+=("$s") [[ $s != *://* ]] && needsversioning+=("$s")
done done
@@ -129,6 +138,10 @@ done
# assert that they really are controlled by git # assert that they really are controlled by git
if (( ${#needsversioning[*]} )); then if (( ${#needsversioning[*]} )); then
for file in "${needsversioning[@]}"; do for file in "${needsversioning[@]}"; do
# skip none existing files
if [[ ! -f "${file}" ]]; then
continue
fi
if ! git ls-files --error-unmatch "$file"; then if ! git ls-files --error-unmatch "$file"; then
die "%s is not under version control" "$file" die "%s is not under version control" "$file"
fi fi

View File

@@ -129,7 +129,7 @@ pkgctl_build() {
local WORKER_SLOT= local WORKER_SLOT=
# variables # variables
local path pkgbase pkgrepo source local loop_arch path pkgbase pkgrepo source
while (( $# )); do while (( $# )); do
case $1 in case $1 in
@@ -298,7 +298,7 @@ pkgctl_build() {
die 'failed to get pacman repo' die 'failed to get pacman repo'
fi fi
if [[ -z "${pkgrepo}" ]]; then if [[ -z "${pkgrepo}" ]]; then
die 'unknown repo, please specify --repo for new packages' die 'unknown repo, specify --repo for packages not currently in any official repo'
fi fi
fi fi
@@ -318,7 +318,13 @@ pkgctl_build() {
if in_array any "${arch[@]}"; then if in_array any "${arch[@]}"; then
BUILD_ARCH=("${_arch[0]}") BUILD_ARCH=("${_arch[0]}")
else else
BUILD_ARCH+=("${arch[@]}") for loop_arch in "${arch[@]}"; do
if in_array "${loop_arch}" "${_arch[@]}"; then
BUILD_ARCH+=("$loop_arch")
else
warning 'invalid architecture, not building for: %s' "${loop_arch}"
fi
done
fi fi
fi fi
@@ -329,7 +335,7 @@ pkgctl_build() {
# increment pkgrel on rebuild # increment pkgrel on rebuild
if (( REBUILD )); then if (( REBUILD )); then
# try to figure out of pkgrel has been changed # try to figure out if pkgrel has been changed
if ! old_pkgrel=$(git_diff_tree HEAD PKGBUILD | grep --perl-regexp --only-matching --max-count=1 '^-pkgrel=\K\w+'); then if ! old_pkgrel=$(git_diff_tree HEAD PKGBUILD | grep --perl-regexp --only-matching --max-count=1 '^-pkgrel=\K\w+'); then
old_pkgrel=${pkgrel} old_pkgrel=${pkgrel}
fi fi

View File

@@ -29,6 +29,8 @@ export GIT_PACKAGING_URL_SSH="git@${GITLAB_HOST}:${GIT_PACKAGING_NAMESPACE}"
export GIT_PACKAGING_URL_HTTPS="https://${GITLAB_HOST}/${GIT_PACKAGING_NAMESPACE}" export GIT_PACKAGING_URL_HTTPS="https://${GITLAB_HOST}/${GIT_PACKAGING_NAMESPACE}"
export PACKAGING_REPO_RELEASE_HOST=repos.archlinux.org export PACKAGING_REPO_RELEASE_HOST=repos.archlinux.org
export VALID_RELEASE_BRANCHES=(main unstable)
# check if messages are to be printed using color # check if messages are to be printed using color
if [[ -t 2 && "$TERM" != dumb ]] || [[ ${DEVTOOLS_COLOR} == always ]]; then if [[ -t 2 && "$TERM" != dumb ]] || [[ ${DEVTOOLS_COLOR} == always ]]; then
colorize colorize

View File

@@ -15,7 +15,7 @@ pkgctl_db_usage() {
cat <<- _EOF_ cat <<- _EOF_
Usage: ${COMMAND} [COMMAND] [OPTIONS] Usage: ${COMMAND} [COMMAND] [OPTIONS]
Pacman database modification for packge update, move etc Pacman database modification for package update, move etc
COMMANDS COMMANDS
move Move packages between pacman repositories move Move packages between pacman repositories

View File

@@ -38,7 +38,7 @@ pkgctl_repo_configure_usage() {
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} configure * $ ${COMMAND} *
_EOF_ _EOF_
} }

View File

@@ -26,7 +26,7 @@ pkgctl_repo_web_usage() {
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} web linux $ ${COMMAND} linux
_EOF_ _EOF_
} }

View File

@@ -22,3 +22,8 @@ git_diff_tree() {
"${commit}" \ "${commit}" \
-- "${path}" -- "${path}"
} }
is_valid_release_branch() {
local branch=$1
in_array "${branch}" "${VALID_RELEASE_BRANCHES[@]}"
}

View File

@@ -125,6 +125,9 @@ OPTIONS
__EOF__ __EOF__
} }
# save all args for check_root
orig_args=("$@")
while getopts 'dM:c:l:h' arg; do while getopts 'dM:c:l:h' arg; do
case "$arg" in case "$arg" in
d) diffoscope=1 ;; d) diffoscope=1 ;;
@@ -137,7 +140,7 @@ while getopts 'dM:c:l:h' arg; do
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
check_root "" "${BASH_SOURCE[0]}" "$@" check_root "" "${BASH_SOURCE[0]}" "${orig_args[@]}"
[[ -f PKGBUILD ]] || { error "No PKGBUILD in current directory."; exit 1; } [[ -f PKGBUILD ]] || { error "No PKGBUILD in current directory."; exit 1; }

View File

@@ -32,6 +32,9 @@ usage() {
exit 1 exit 1
} }
# save all args for check_root
orig_args=("$@")
while getopts 'hUC:M:c:f:s' arg; do while getopts 'hUC:M:c:f:s' arg; do
case "$arg" in case "$arg" in
U) umode=U ;; U) umode=U ;;
@@ -52,7 +55,7 @@ shift $((OPTIND - 1))
(( $# < 2 )) && die 'You must specify a directory and one or more packages.' (( $# < 2 )) && die 'You must specify a directory and one or more packages.'
check_root "" "${BASH_SOURCE[0]}" "$@" check_root "" "${BASH_SOURCE[0]}" "${orig_args[@]}"
working_dir="$(readlink -f "$1")" working_dir="$(readlink -f "$1")"
shift 1 shift 1

View File

@@ -21,7 +21,7 @@ usage() {
COMMANDS COMMANDS
auth Authenticate with services like GitLab auth Authenticate with services like GitLab
build Build packages inside a clean chroot build Build packages inside a clean chroot
db Pacman database modification for packge update, move etc db Pacman database modification for package update, move etc
diff Compare package files using different modes diff Compare package files using different modes
release Release step to commit, tag and upload build artifacts release Release step to commit, tag and upload build artifacts
repo Manage Git packaging repositories and their configuration repo Manage Git packaging repositories and their configuration