Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2022-09-12 01:34:08 +0200
committerLevente Polyak <anthraxx@archlinux.org>2023-05-19 22:27:12 +0200
commita8be7423efb287edd5ef80002a75a853fc0c9c1d (patch)
tree327592b654c18c8b66d0919570f7cdc973c65e04
parentd15bd29a9d411dedc0a0682ec54b55e079d4f00f (diff)
pkgctl: add a unified command-line frontend for devtools
This is the first step of a simple and highly structured unified interface to devtools commands in a single wrapper. The split is based on groups like `repo`, `build` and `diff` Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
-rw-r--r--contrib/completion/zsh/_devtools.in42
-rw-r--r--doc/man/devtools.7.asciidoc20
-rw-r--r--doc/man/diffpkg.1.asciidoc4
-rw-r--r--doc/man/pkgctl-diff.1.asciidoc73
-rw-r--r--doc/man/pkgctl-repo-clone.1.asciidoc42
-rw-r--r--doc/man/pkgctl-repo-configure.1.asciidoc32
-rw-r--r--doc/man/pkgctl-repo-web.1.asciidoc24
-rw-r--r--doc/man/pkgctl-repo.1.asciidoc51
-rw-r--r--doc/man/pkgctl.1.asciidoc32
-rw-r--r--src/diffpkg.in11
-rw-r--r--src/pkgctl.in56
-rw-r--r--src/pkgrepo.in7
12 files changed, 365 insertions, 29 deletions
diff --git a/contrib/completion/zsh/_devtools.in b/contrib/completion/zsh/_devtools.in
index d30648a..959497e 100644
--- a/contrib/completion/zsh/_devtools.in
+++ b/contrib/completion/zsh/_devtools.in
@@ -1,4 +1,4 @@
-#compdef archbuild pkgrepo arch-nspawn archrelease commitpkg diffpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild checkpkg sogrep offload-build makerepropkg
+#compdef archbuild pkgrepo arch-nspawn archrelease commitpkg pkgctl diffpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild checkpkg sogrep offload-build makerepropkg
#
# SPDX-License-Identifier: GPL-3.0-or-later
@@ -149,31 +149,47 @@ _devtools_completions_all_packages() {
compadd - "${(@)packages}"
}
-_devtools() {
- local service_func=_${service//-/_}
- local service_cmds=${service_func}_cmds
- if typeset -p ${service_cmds} &> /dev/null; then
+_pkgctl_cmds=(
+ "pkgctl command"
+ "diff[Compare package files using different modes]"
+ "repo[Manage Git packaging repositories and their configuration]"
+)
+
+_pkgctl_diff_args=("${_diffpkg_args[@]}")
+
+_pkgctl_repo_cmds=("${_pkgrepo_cmds[@]}")
+_pkgctl_repo_clone_args=("${_pkgrepo_clone_args[@]}")
+_pkgctl_repo_configure_args=("${_pkgrepo_configure_args[@]}")
+
+_handle_subcommands() {
+ local service_name=${1}
+ if typeset -p ${service_name}_cmds &> /dev/null; then
_arguments -C \
"1: :->cmds" \
'*::arg:->args'
case $state in
cmds)
- local service_cmds_array=${service_cmds}[@]
- _values "${(P)service_cmds_array}"
+ local service_cmds=${service_name}_cmds[@]
+ _values "${(P)service_cmds}"
;;
args)
- local cmd_args_array=${service_func}_$line[1]_args
- if typeset -p ${cmd_args_array} &> /dev/null; then
- local cmd_args=${cmd_args_array}[@]
+ local service_sub=${service_name}_$line[1]
+ if typeset -p ${service_sub}_args &> /dev/null; then
+ local cmd_args=${service_sub}_args[@]
_arguments -s "${(P)cmd_args}"
+ elif typeset -p ${service_sub}_cmds &> /dev/null; then
+ _handle_subcommands "${service_sub}"
fi
;;
esac
- return 0
+ elif typeset -p ${service_name}_args &> /dev/null; then
+ local argname="${service_name}_args[@]"
+ _arguments -s "${(P)argname}"
fi
- local argname="${service_func}_args[@]"
- _arguments -s "${(P)argname}"
+}
+_devtools() {
+ _handle_subcommands _${service//-/_}
}
_devtools
diff --git a/doc/man/devtools.7.asciidoc b/doc/man/devtools.7.asciidoc
index 6b2d0c1..4ed11cf 100644
--- a/doc/man/devtools.7.asciidoc
+++ b/doc/man/devtools.7.asciidoc
@@ -8,16 +8,22 @@ devtools - Developer tools for the Arch Linux distribution
Description
-----------
-Devtools contains tools for package maintenance in Arch Linux. The toolset
-varies from tools for building packages in a clean chroot ('mkarchroot',...),
-packaging related tools for sonames ('sogrep', 'lddd') and tools for
-repository management such as ('pkgrepo')
+Devtools contains tools for package maintenance in Arch Linux. It comes with a
+unified command-line frontend called 'pkgctl' that aids to conveniently
+interact with all the different tools this collection provides.
+
+The toolset varies from tools for building packages in a clean chroot
+('mkarchroot', 'archbuild', ...), packaging related tools ('sogrep', 'diffpkg',
+'lddd') and tools for repository management such as ('pkgrepo').
Programs
--------
The list below gives a short overview; see the respective documentation
for details.
+linkman:pkgctl[1]
+ Unified command-line frontend for devtools
+
linkman:archbuild[1]
Build an Arch Linux package inside a clean chroot
@@ -27,6 +33,12 @@ linkman:arch-nspawn[1]
linkman:checkpkg[1]
Compare the current build package with the repository version
+linkman:diffpkg[1]
+ Compare package files using different modes
+
+linkman:export-pkgbuild-keys[1]
+ Export valid source signing keys from a PKGBUILD
+
linkman:find-libdeps[1]
Find soname dependencies for a package
diff --git a/doc/man/diffpkg.1.asciidoc b/doc/man/diffpkg.1.asciidoc
index bfb2094..2f7c115 100644
--- a/doc/man/diffpkg.1.asciidoc
+++ b/doc/man/diffpkg.1.asciidoc
@@ -30,7 +30,6 @@ Options
*-M, --makepkg-config*::
Set an alternate makepkg configuration file
-
*-P, --pool*='DIR'::
Search diff target in pool dir (default `'/srv/ftp/pool'`)
@@ -71,7 +70,4 @@ Modes
*-b, --buildinfo*::
Activate .BUILDINFO diff mode
-See Also
---------
-
include::include/footer.asciidoc[]
diff --git a/doc/man/pkgctl-diff.1.asciidoc b/doc/man/pkgctl-diff.1.asciidoc
new file mode 100644
index 0000000..7eb9e68
--- /dev/null
+++ b/doc/man/pkgctl-diff.1.asciidoc
@@ -0,0 +1,73 @@
+pkgctl-diff(1)
+==============
+
+Name
+----
+pkgctl-diff - Compare package files using different modes.
+
+Synopsis
+--------
+pkgctl diff [OPTIONS] [MODES] [FILE|PKGNAME...]
+
+Description
+-----------
+
+Searches for a locally built package corresponding to the PKGBUILD, and
+downloads the last version of that package from the Pacman repositories.
+It then compares the package archives using different modes while using
+simple tar content list by default.
+
+When given one package, use it to diff against the locally built one.
+When given two packages, diff both packages against each other.
+
+In either case, a package name will be converted to a filename from the cache
+or pool, and 'pkgctl diff' will proceed as though this filename was initially
+specified.
+
+Options
+-------
+
+*-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
+
+*-h, --help*::
+ 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
+-----
+
+*-l, --list*::
+ Activate tar content list diff mode (default)
+
+*-d, --diffoscope*::
+ Activate diffoscope diff mode
+
+*-p, --pkginfo*::
+ Activate .PKGINFO diff mode
+
+*-b, --buildinfo*::
+ Activate .BUILDINFO diff mode
+
+include::include/footer.asciidoc[]
diff --git a/doc/man/pkgctl-repo-clone.1.asciidoc b/doc/man/pkgctl-repo-clone.1.asciidoc
new file mode 100644
index 0000000..9770ef8
--- /dev/null
+++ b/doc/man/pkgctl-repo-clone.1.asciidoc
@@ -0,0 +1,42 @@
+pkgctl-repo-clone(1)
+======================
+
+Name
+----
+pkgctl-repo-clone - Clone a package repository
+
+Synopsis
+--------
+pkgctl repo clone [OPTIONS] [PKGNAME...]
+
+Description
+-----------
+
+Clone Git packaging repositories from the canonical namespace.
+
+The configure command is subsequently invoked to synchronize the distro
+specs and makepkg.conf settings. The unprivileged option can be used
+for cloning packaging repositories without SSH access using read-only
+HTTPS.
+
+Options
+-------
+
+*-m, --maintainer* 'NAME'::
+ Clone all packages of the named maintainer
+
+*-u, --unprivileged*::
+ Clone package with read-only access and without packager info as Git author
+
+*--universe*::
+ Clone all existing packages, useful for cache warming
+
+*-h, --help*::
+ Show a help text
+
+See Also
+--------
+
+linkman:pkgctl-repo-configure[1]
+
+include::include/footer.asciidoc[]
diff --git a/doc/man/pkgctl-repo-configure.1.asciidoc b/doc/man/pkgctl-repo-configure.1.asciidoc
new file mode 100644
index 0000000..c3a14de
--- /dev/null
+++ b/doc/man/pkgctl-repo-configure.1.asciidoc
@@ -0,0 +1,32 @@
+pkgctl-repo-configure(1)
+========================
+
+Name
+----
+pkgctl-repo-configure - Configure a clone according to distro specs
+
+Synopsis
+--------
+pkgctl repo configure [OPTIONS] [PATH...]
+
+Description
+-----------
+
+Configure Git packaging repositories according to distro specs and
+'makepkg.conf' settings.
+
+Git author information and the used signing key is set up from
+'makepkg.conf' read from any valid location like '/etc' or 'XDG_CONFIG_HOME'.
+The unprivileged option can be used for cloning packaging repositories
+without SSH access using read-only HTTPS.
+
+Options
+-------
+
+*-u, --unprivileged*::
+ Configure read-only repo without packager info as Git author
+
+*-h, --help*::
+ Show a help text
+
+include::include/footer.asciidoc[]
diff --git a/doc/man/pkgctl-repo-web.1.asciidoc b/doc/man/pkgctl-repo-web.1.asciidoc
new file mode 100644
index 0000000..8769be7
--- /dev/null
+++ b/doc/man/pkgctl-repo-web.1.asciidoc
@@ -0,0 +1,24 @@
+pkgctl-repo-web(1)
+==================
+
+Name
+----
+pkgctl-repo-web - Open the packaging repository's website
+
+Synopsis
+--------
+pkgctl repo web [OPTIONS] [PKGBASE...]
+
+Description
+-----------
+
+Open the packaging repository's website via xdg-open. If called with
+no arguments, open the package cloned in the current working directory.
+
+Options
+-------
+
+*-h, --help*::
+ Show a help text
+
+include::include/footer.asciidoc[]
diff --git a/doc/man/pkgctl-repo.1.asciidoc b/doc/man/pkgctl-repo.1.asciidoc
new file mode 100644
index 0000000..564679a
--- /dev/null
+++ b/doc/man/pkgctl-repo.1.asciidoc
@@ -0,0 +1,51 @@
+pkgctl-repo(1)
+================
+
+Name
+----
+pkgctl-repo - Manage Git packaging repositories and their configuration
+
+Synopsis
+--------
+pkgctl repo [OPTIONS] [SUBCOMMAND]
+
+Description
+-----------
+
+Manage Git packaging repositories and helps with their configuration
+according to distro specs.
+
+Git author information and the used signing key is set up from
+'makepkg.conf' read from any valid location like '/etc' or 'XDG_CONFIG_HOME'.
+The configure command can be used to synchronize the distro specs and
+makepkg.conf settings for previously cloned repositories.
+
+The unprivileged option can be used for cloning packaging repositories
+without SSH access using read-only HTTPS.
+
+Options
+-------
+
+*-h, --help*::
+ Show a help text
+
+Subcommands
+-----------
+
+pkgctl repo clone::
+ Clone a package repository
+
+pkgctl repo configure::
+ Configure a clone according to distro specs
+
+pkgctl repo web::
+ Open the packaging repository's website
+
+See Also
+--------
+
+linkman:pkgctl-repo-clone[1]
+linkman:pkgctl-repo-configure[1]
+linkman:pkgctl-repo-web[1]
+
+include::include/footer.asciidoc[]
diff --git a/doc/man/pkgctl.1.asciidoc b/doc/man/pkgctl.1.asciidoc
new file mode 100644
index 0000000..0455074
--- /dev/null
+++ b/doc/man/pkgctl.1.asciidoc
@@ -0,0 +1,32 @@
+pkgctl(1)
+=========
+
+Name
+----
+pkgctl - Unified command-line frontend for devtools
+
+Synopsis
+--------
+pkgctl [SUBCOMMAND] [OPTIONS]
+
+Description
+-----------
+
+TODO
+
+Subcommands
+-----------
+
+pkgctl diff::
+ Compare package files using different modes
+
+pkgctl repo::
+ Manage Git packaging repositories and their configuration
+
+See Also
+--------
+
+linkman:pkgctl-diff[1]
+linkman:pkgctl-repo[1]
+
+include::include/footer.asciidoc[]
diff --git a/src/diffpkg.in b/src/diffpkg.in
index 6d07419..4856e44 100644
--- a/src/diffpkg.in
+++ b/src/diffpkg.in
@@ -5,8 +5,9 @@
m4_include(lib/common.sh)
usage() {
- cat <<- _EOF_
- Usage: ${BASH_SOURCE[0]##*/} [OPTIONS] [MODES] [FILE|PKGNAME...]
+ local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
+ cat <<- _EOF_
+ Usage: ${COMMAND} [OPTIONS] [MODES] [FILE|PKGNAME...]
Searches for a locally built package corresponding to the PKGBUILD, and
downloads the last version of that package from the Pacman repositories.
@@ -17,8 +18,8 @@ usage() {
When given two packages, diff both packages against each other.
In either case, a package name will be converted to a filename from the
- cache, and diffpkg will proceed as though this filename was initially
- specified.
+ cache, and '${COMMAND}' will proceed as though this filename was
+ initially specified.
OPTIONS
-M, --makepkg-config Set an alternate makepkg configuration file
@@ -300,7 +301,7 @@ shopt -u extglob
if (( $# < 2 )); then
if [[ ! -f PKGBUILD ]]; then
- die "This must be run in the directory of a built package.\nTry '$(basename "$0") --help' for more information."
+ die "This must be run in the directory of a built package.\nTry '${COMMAND} --help' for more information."
fi
# shellcheck source=contrib/makepkg/PKGBUILD.proto
diff --git a/src/pkgctl.in b/src/pkgctl.in
new file mode 100644
index 0000000..9b7d89c
--- /dev/null
+++ b/src/pkgctl.in
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+m4_include(lib/common.sh)
+
+set -e
+
+
+usage() {
+ local -r COMMAND=${BASH_SOURCE[0]##*/}
+ cat <<- _EOF_
+ Usage: ${COMMAND} [COMMAND] [OPTIONS]
+
+ Unified command-line frontend for devtools.
+
+ COMMANDS
+ diff Compare package files using different modes
+ repo Manage Git packaging repositories and their configuration
+
+ OPTIONS
+ -h, --help Show this help text
+_EOF_
+}
+
+if (( $# < 1 )); then
+ usage
+ exit 1
+fi
+
+export _DEVTOOLS_COMMAND='pkgctl'
+
+# command checking
+while (( $# )); do
+ case $1 in
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ repo)
+ _DEVTOOLS_COMMAND+=" $1"
+ shift
+ pkgrepo "$@"
+ exit 0
+ ;;
+ diff)
+ _DEVTOOLS_COMMAND+=" $1"
+ shift
+ diffpkg "$@"
+ exit 0
+ ;;
+ *)
+ die "invalid command: %s" "$1"
+ ;;
+ esac
+done
diff --git a/src/pkgrepo.in b/src/pkgrepo.in
index c6f5951..00f46e1 100644
--- a/src/pkgrepo.in
+++ b/src/pkgrepo.in
@@ -9,10 +9,11 @@ source /usr/share/makepkg/util/message.sh
set -e
+COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
usage() {
cat <<- _EOF_
- Usage: ${BASH_SOURCE[0]##*/} [COMMAND] [OPTIONS]
+ Usage: ${COMMAND} [COMMAND] [OPTIONS]
Manage Git packaging repositories and helps with their configuration
according to distro specs.
@@ -37,7 +38,7 @@ _EOF_
usage_clone() {
cat <<- _EOF_
- Usage: ${BASH_SOURCE[0]##*/} clone [OPTIONS] [PKGNAME...]
+ Usage: ${COMMAND} clone [OPTIONS] [PKGNAME...]
Clone Git packaging repositories from the canonical namespace.
@@ -57,7 +58,7 @@ _EOF_
usage_configure() {
cat <<- _EOF_
- Usage: ${BASH_SOURCE[0]##*/} configure [OPTIONS] [PATH...]
+ Usage: ${COMMAND} configure [OPTIONS] [PATH...]
Configure Git packaging repositories according to distro specs and
makepkg.conf settings.