Compare commits

..

8 Commits

Author SHA1 Message Date
Levente Polyak
02bc8bfbc0 chore(release): version v1.0.4 2023-09-27 00:38:17 +02:00
Levente Polyak
f632659563 fix(clone): ssh connection may require user input (key unlocking etc)
Anything that requires user input (such as a key unlock or hostkey
verify) will block the terminal and wait for input which will never
come.

When cloning or configuring a repo via ssh we therefore initially
connect to gitlab to warm the connection.

Afterwards users are expected to either have setup a ssh ControlMaster
or use something like a ssh agent.

Fixes #148

Component: pkgctl repo clone/configure

Co-Authored-by: Christian Heusel <christian@heusel.eu>
Signed-off-by: Christian Heusel <christian@heusel.eu>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-09-26 22:44:58 +02:00
Christian Heusel
7e41adf00b chore: add a config file for git cliff
This is done so that the generated changelog carries more information
(i.e. the scope of the change).

Co-Authored-by: Levente Polyak <anthraxx@archlinux.org>
Signed-off-by: Christian Heusel <christian@heusel.eu>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-09-26 21:13:08 +02:00
Levente Polyak
a316b50f88 fix(makepkg.conf): use breezy for the bzr protocol in makepkg.conf
Pacman does not resolve provides for the protocol packages, hence we
need to switch to the new package name for bzr.

Related-to: https://gitlab.archlinux.org/pacman/pacman/-/merge_requests/78
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-09-19 01:32:22 +02:00
Levente Polyak
547961681a fix(pkgctl): avoid pacman db dependency checks during repo detection
By default the sync operation enables dependency checks during the
preparation of the transaction. This isn't necessary for the print
option, but is done nevertheless, which leads to issues for example
during soname dependency problems. The result is a none functional
automatic repo detection.

Fix this by explicitly disabling dependency version checks. We specify
this option twice to skip all dependency checks.

Fixes #189

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-09-10 00:03:42 +02:00
Jelle van der Waa
8190a22480 feat(release): always generate a .SRCINFO file on release
When releasing a package always generate a .SRCINFO file so we can build
tooling based upon these files instead of having to parse bash in a
non-bash language.

Some tests have shown around 30 seconds or generating the metadata on
packages like thunderbird. The implementation in makepkg becomes semi
slow for some split packages that provide a huge number of individual
packages, but it seems reasonably fast so we can instead have a uniform
state of always providing .SRCINFO files.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2023-09-04 23:41:00 +02:00
Christian Heusel
f31ea3a48e fix(build): fix repo detection for special chars in package name
Currently we used grep -E, in a way that special characters in the
package name such as the '+' in 'ls++' also became part of the regex.

This commit switches this to become a literal string matching using awk.

Signed-off-by: Christian Heusel <christian@heusel.eu>
2023-08-27 17:08:23 +02:00
Christian Heusel
9f7808c26e fix(build): installing packages into the chroot fails for relative links
As the relative links are relative to the pkgctl invocations PWD and not
necessarily relative to the location where makechrootpkg is invoked from
this fails unexpectedly.

This commit fixes this by just using the full path when passing the
location to makechrootpkg.

Fixes https://gitlab.archlinux.org/archlinux/devtools/-/issues/181

Signed-off-by: Christian Heusel <christian@heusel.eu>
2023-08-27 16:55:50 +02:00
13 changed files with 120 additions and 35 deletions

View File

@@ -1,6 +1,6 @@
SHELL=/bin/bash
V=1.0.3
V=1.0.4
BUILDTOOLVER ?= $(V)
PREFIX = /usr/local

View File

@@ -23,6 +23,34 @@ will automatically build the project and proxy all calls to the local build dire
./test/bin/pkgctl --help
```
### Commit messages
All commits must follow [conventional commits](https://www.conventionalcommits.org).
The following groups are allowed:
- chore
- feat
- fix
- doc
- perf
- test
To override the scope for the changelog entry use the `Component:` trailer.
Example:
```
feat(db): yay mega cool feature
Very long and useful description.
Fixes #1
Fixes #2
Component: pkgctl db remove
```
## Releasing
1. bump the version in the Makefile

44
cliff.toml Normal file
View File

@@ -0,0 +1,44 @@
[changelog]
header = "# Changelog\n\n"
body = """
{%- if version -%}
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{%- else -%}
## [unreleased]
{%- endif %}
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits | sort(attribute="message") %}
- {% set component = commit.footers | filter(attribute="token", value="Component") | map(attribute="value") | join %}
{%- if component %}{{ component }}: {% elif commit.scope %}{{ commit.scope }}: {% endif %}
{{- commit.message | upper_first }}
{%- set fixes = commit.footers | filter(attribute="token", value="Fixes") %}
{%- for fix in fixes %}{{ fix.separator }}{{ fix.value }}{% endfor %}
{%- endfor %}
{% endfor %}
"""
footer = ""
# remove the leading and trailing whitespaces from the template
trim = true
[git]
# allow only conventional commits
# https://www.conventionalcommits.org
conventional_commits = true
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^chore\\(release\\): version", skip = true},
{ message = "^feat", group = "Features"},
{ message = "^fix", group = "Bug Fixes"},
{ message = "^doc", group = "Documentation"},
{ message = "^perf", group = "Performance"},
{ message = "^test", group = "Testing"},
{ message = "^chore", group = "Miscellaneous Tasks"},
{ body = ".*security", group = "Security"},
]
# filter out the commits that are not matched by commit parsers
filter_commits = false
# glob pattern for matching git tags
tag_pattern = "*v[0-9]*"

View File

@@ -25,7 +25,7 @@ DLAGENTS=('file::/usr/bin/curl -qgC - -o %o %u'
#-- The package required by makepkg to download VCS sources
# Format: 'protocol::package'
VCSCLIENTS=('bzr::bzr'
VCSCLIENTS=('bzr::breezy'
'fossil::fossil'
'git::git'
'hg::mercurial'

View File

@@ -25,7 +25,7 @@ DLAGENTS=('file::/usr/bin/curl -qgC - -o %o %u'
#-- The package required by makepkg to download VCS sources
# Format: 'protocol::package'
VCSCLIENTS=('bzr::bzr'
VCSCLIENTS=('bzr::breezy'
'fossil::fossil'
'git::git'
'hg::mercurial'

View File

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

View File

@@ -5,10 +5,9 @@
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
# shellcheck source=src/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/srcinfo.sh
check_pkgbuild_validity() {
@@ -72,12 +71,8 @@ if ! repo_spec=$(git config --local devtools.version) || [[ ${repo_spec} != "${G
exit 1
fi
if ! branchname=$(git symbolic-ref --short HEAD); then
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[@]}"
if [[ "$(git symbolic-ref --short HEAD)" != main ]]; then
die 'must be run from the main branch'
fi
source=()
@@ -101,9 +96,6 @@ case "$cmd" in
;;
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 [[ -d keys ]]; then
@@ -186,13 +178,11 @@ done
# check for PKGBUILD standards
check_pkgbuild_validity
# auto generate .SRCINFO if present
if [[ -f .SRCINFO ]]; then
stat_busy 'Generating .SRCINFO'
makepkg --printsrcinfo > .SRCINFO
git add .SRCINFO
stat_done
fi
# auto generate .SRCINFO
stat_busy 'Generating .SRCINFO'
write_srcinfo_content > .SRCINFO
git add --force .SRCINFO
stat_done
if [[ -n $(git status --porcelain --untracked-files=no) ]]; then
stat_busy 'Staging files'

View File

@@ -200,7 +200,7 @@ pkgctl_build() {
;;
-I|--install)
(( $# <= 1 )) && die "missing argument for %s" "$1"
MAKECHROOT_OPTIONS+=("-I" "$2")
MAKECHROOT_OPTIONS+=("-I" "$(realpath "$2")")
warning 'installing packages into the chroot may break reproducible builds, use with caution!'
shift 2
;;

View File

@@ -29,8 +29,6 @@ export GIT_PACKAGING_URL_SSH="git@${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 VALID_RELEASE_BRANCHES=(main unstable)
# check if messages are to be printed using color
if [[ -t 2 && "$TERM" != dumb ]] || [[ ${DEVTOOLS_COLOR} == always ]]; then
colorize

View File

@@ -12,6 +12,8 @@ source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/api/gitlab.sh
# shellcheck source=src/lib/repo/configure.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/repo/configure.sh
# shellcheck source=src/lib/util/git.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/git.sh
source /usr/share/makepkg/util/message.sh
@@ -52,6 +54,7 @@ pkgctl_repo_clone() {
fi
# options
local protocol=ssh
local GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_SSH}
local CLONE_ALL=0
local MAINTAINER=
@@ -72,6 +75,7 @@ pkgctl_repo_clone() {
;;
--protocol=https)
GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_HTTPS}
protocol=https
CONFIGURE_OPTIONS+=("$1")
shift
;;
@@ -82,6 +86,7 @@ pkgctl_repo_clone() {
else
die "unsupported protocol: %s" "$2"
fi
protocol="$2"
CONFIGURE_OPTIONS+=("$1" "$2")
shift 2
;;
@@ -171,6 +176,12 @@ pkgctl_repo_clone() {
if [[ -n "${VERSION}" ]]; then
command+=" --switch '${VERSION}'"
fi
# warm up ssh connection as it may require user input (key unlock, hostkey verification etc)
if [[ ${protocol} == ssh ]]; then
git_warmup_ssh_connection
fi
if ! parallel --bar --jobs "${jobs}" "${command}" ::: "${pkgbases[@]}"; then
die 'Failed to clone some packages, please check the output'
exit 1

View File

@@ -10,6 +10,8 @@ _DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
# shellcheck source=src/lib/api/gitlab.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/api/gitlab.sh
# shellcheck source=src/lib/util/git.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/git.sh
source /usr/share/makepkg/util/config.sh
source /usr/share/makepkg/util/message.sh
@@ -188,6 +190,12 @@ pkgctl_repo_configure() {
if [[ -n ${BOLD} ]]; then
export DEVTOOLS_COLOR=always
fi
# warm up ssh connection as it may require user input (key unlock, hostkey verification etc)
if [[ ${proto} == ssh ]]; then
git_warmup_ssh_connection
fi
if ! parallel --bar --jobs "${jobs}" "${command}" ::: "${paths[@]}"; then
die 'Failed to configure some packages, please check the output'
exit 1

View File

@@ -7,6 +7,9 @@ DEVTOOLS_INCLUDE_UTIL_GIT_SH=1
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
# shellcheck source=src/lib/common.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
git_diff_tree() {
local commit=$1
@@ -23,7 +26,9 @@ git_diff_tree() {
-- "${path}"
}
is_valid_release_branch() {
local branch=$1
in_array "${branch}" "${VALID_RELEASE_BRANCHES[@]}"
git_warmup_ssh_connection() {
msg 'Establishing ssh connection to git@%s' "${GITLAB_HOST}"
if ! ssh -T "git@${GITLAB_HOST}" >/dev/null; then
die 'Failed to establish ssh connection to git@%s' "${GITLAB_HOST}"
fi
}

View File

@@ -39,12 +39,15 @@ get_pacman_repo_from_pkgbuild() {
fi
slock 10 "${_DEVTOOLS_PACMAN_CACHE_DIR}.lock" "Locking pacman database cache"
# query repo of passed pkgname, specify --nodeps twice to skip all dependency checks
mapfile -t repos < <(pacman --config "${_DEVTOOLS_PACMAN_CONF_DIR}/multilib.conf" \
--dbpath "${_DEVTOOLS_PACMAN_CACHE_DIR}" \
-S \
--sync \
--nodeps \
--nodeps \
--print \
--print-format '%n %r' \
"${pkgnames[0]}" | grep -E "^${pkgnames[0]} " | awk '{print $2}'
"${pkgnames[0]}" | awk '$1=="'"${pkgnames[0]}"'"{print $2}'
)
lock_close 10