mirror of
https://gitlab.archlinux.org/archlinux/devtools.git
synced 2025-09-13 09:56:18 +02:00
Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
02bc8bfbc0 | ||
![]() |
f632659563 | ||
![]() |
7e41adf00b | ||
![]() |
a316b50f88 | ||
![]() |
547961681a | ||
![]() |
8190a22480 | ||
![]() |
f31ea3a48e | ||
![]() |
9f7808c26e | ||
![]() |
5f4fd52e38 | ||
![]() |
1b25190176 | ||
![]() |
030e6af880 | ||
![]() |
662d6c5274 | ||
![]() |
3de03e8b1f | ||
![]() |
720b7c9b05 | ||
![]() |
0ea7e9e0e5 | ||
![]() |
be5f54c95c | ||
![]() |
5c6e13a672 |
4
Makefile
4
Makefile
@@ -1,6 +1,6 @@
|
||||
SHELL=/bin/bash
|
||||
|
||||
V=1.0.2
|
||||
V=1.0.4
|
||||
BUILDTOOLVER ?= $(V)
|
||||
|
||||
PREFIX = /usr/local
|
||||
@@ -153,7 +153,7 @@ tag:
|
||||
git tag --sign --message "Version v$$VERSION" v$$VERSION
|
||||
|
||||
release: dist
|
||||
glab release create v$(RELEASE) devtools-$(RELEASE).tar.gz*
|
||||
glab release create v$(V) devtools-$(V).tar.gz*
|
||||
|
||||
dist:
|
||||
git archive --format=tar --prefix=devtools-$(V)/ v$(V) | gzip > devtools-$(V).tar.gz
|
||||
|
29
README.md
29
README.md
@@ -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
|
||||
@@ -42,6 +70,7 @@ will automatically build the project and proxy all calls to the local build dire
|
||||
- binutils
|
||||
- coreutils
|
||||
- diffutils
|
||||
- fakeroot
|
||||
- findutils
|
||||
- grep
|
||||
- jq
|
||||
|
44
cliff.toml
Normal file
44
cliff.toml
Normal 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]*"
|
@@ -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'
|
||||
|
@@ -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'
|
||||
|
@@ -241,7 +241,7 @@ _pkgctl_cmds=(
|
||||
"pkgctl command"
|
||||
"auth[Authenticate with services like GitLab]"
|
||||
"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]"
|
||||
"release[Release step to commit, tag and upload build artifacts]"
|
||||
"repo[Manage Git packaging repositories and their configuration]"
|
||||
|
@@ -33,7 +33,7 @@ pkgctl build::
|
||||
Build packages inside a clean chroot
|
||||
|
||||
pkgctl db::
|
||||
Pacman database modification for packge update, move etc
|
||||
Pacman database modification for package update, move etc
|
||||
|
||||
pkgctl diff::
|
||||
Compare package files using different modes
|
||||
|
@@ -16,7 +16,6 @@ umask 0022
|
||||
working_dir=''
|
||||
|
||||
files=()
|
||||
mount_args=()
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]"
|
||||
@@ -56,6 +55,16 @@ shift 1
|
||||
|
||||
[[ -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
|
||||
mapfile -t cache_dirs < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" CacheDir)
|
||||
fi
|
||||
@@ -83,10 +92,10 @@ while read -r line; do
|
||||
done
|
||||
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
|
||||
mount_args+=("--bind-ro=${cache_dir//:/\\:}")
|
||||
nspawn_args+=(--bind-ro="${cache_dir//:/\\:}")
|
||||
done
|
||||
|
||||
# {{{ functions
|
||||
@@ -129,9 +138,4 @@ else
|
||||
set_arch="${CARCH}"
|
||||
fi
|
||||
|
||||
exec ${CARCH:+setarch "$set_arch"} systemd-nspawn -q \
|
||||
-D "$working_dir" \
|
||||
-E "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin" \
|
||||
--register=no --keep-unit --as-pid2 \
|
||||
"${mount_args[@]}" \
|
||||
"$@"
|
||||
exec ${CARCH:+setarch "$set_arch"} systemd-nspawn "${nspawn_args[@]}" "$@"
|
||||
|
@@ -7,6 +7,7 @@ _DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
||||
|
||||
source /usr/share/makepkg/util/util.sh
|
||||
source /usr/share/makepkg/srcinfo.sh
|
||||
|
||||
|
||||
check_pkgbuild_validity() {
|
||||
@@ -111,7 +112,7 @@ if (( ${#validpgpkeys[@]} != 0 )); then
|
||||
fi
|
||||
|
||||
# find files which should be under source control
|
||||
needsversioning=()
|
||||
needsversioning=(PKGBUILD)
|
||||
for s in "${source[@]}"; do
|
||||
[[ $s != *://* ]] && needsversioning+=("$s")
|
||||
done
|
||||
@@ -177,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'
|
||||
|
@@ -129,7 +129,7 @@ pkgctl_build() {
|
||||
local WORKER_SLOT=
|
||||
|
||||
# variables
|
||||
local path pkgbase pkgrepo source
|
||||
local loop_arch path pkgbase pkgrepo source
|
||||
|
||||
while (( $# )); do
|
||||
case $1 in
|
||||
@@ -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
|
||||
;;
|
||||
@@ -318,7 +318,13 @@ pkgctl_build() {
|
||||
if in_array any "${arch[@]}"; then
|
||||
BUILD_ARCH=("${_arch[0]}")
|
||||
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
|
||||
|
||||
@@ -329,7 +335,7 @@ pkgctl_build() {
|
||||
|
||||
# increment pkgrel on rebuild
|
||||
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
|
||||
old_pkgrel=${pkgrel}
|
||||
fi
|
||||
|
@@ -15,7 +15,7 @@ pkgctl_db_usage() {
|
||||
cat <<- _EOF_
|
||||
Usage: ${COMMAND} [COMMAND] [OPTIONS]
|
||||
|
||||
Pacman database modification for packge update, move etc
|
||||
Pacman database modification for package update, move etc
|
||||
|
||||
COMMANDS
|
||||
move Move packages between pacman repositories
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
@@ -22,3 +25,10 @@ git_diff_tree() {
|
||||
"${commit}" \
|
||||
-- "${path}"
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -21,7 +21,7 @@ usage() {
|
||||
COMMANDS
|
||||
auth Authenticate with services like GitLab
|
||||
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
|
||||
release Release step to commit, tag and upload build artifacts
|
||||
repo Manage Git packaging repositories and their configuration
|
||||
|
Reference in New Issue
Block a user