Compare commits

...

12 Commits

Author SHA1 Message Date
Levente Polyak
93928f7409 wip: version edit 2024-02-16 22:33:59 +01:00
Orhun Parmaksız
39eaeaa4b2 feat(offload-build): use rsync instead of scp
This commit simply replaces the usage of `scp` with `rsync`
for faster file transfer.

Signed-off-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2024-02-15 22:23:54 +01:00
kpcyrd
c79a993148 feat(makepkg.conf): Increase _FORTIFY_SOURCE level to 3
RFC: https://rfc.archlinux.page/0017-increase-fortification-level/
2024-02-14 02:08:01 +01:00
Levente Polyak
6d0ac6b9a8 chore(release): version v1.1.1 2024-02-14 01:40:16 +01:00
Levente Polyak
66a4357f3e fix(common): ensure TERM is always set with a fallback to dumb
This avoids some corner cases that some applications behave ill when
TERM is completely unset. Instead, ensure we set TERM to dumb as a
fallback, which should serve better than not having any term defined.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2024-02-14 01:28:40 +01:00
Christian Heusel
db2f82bf19 feat(offload-build): preserve the TERM variable
Signed-off-by: Christian Heusel <christian@heusel.eu>
2024-02-14 01:28:34 +01:00
Christian Heusel
e0a84aefc3 fix(common): check before using tput with a fallback for colors
The latest release of devtools has included some pretty printing
capabilities and fancy terminal stuff with the spinner and so on.

It seems like the existing safeguards to disable this for incapable
terminals were not enough though, therefore we saw two types of errors:

- offload-build:
  ```
  ==> Building in chroot for [extra] (x86_64)...
  tput: unknown terminal "unknown"
  tput: unknown terminal "unknown"
  tput: unknown terminal "unknown"
  ```
- repro builders:
  ```
  ==> Successfully switched <package> to version <version>
  tput: No value for $TERM and no -T specified
  ERROR: Failed checkout <package>
  ```

The recently included fail option made this error populate to the
command level and therefore increased its impact from a not so nice
logging message to a more severe problem which made the command abort.

We fix this by checking if tput is supported or else use the raw escape
sequences instead of tput commands.

Fixes: fedfc80 ("feat(term): add terminal utils to handle a dynamic spinner")
Fixes: 66e83c9 ("feat(version): pretty print and group together version check results")
Fixes: d0dc0e1 ("feat(search): add optional plain output formatting")
Signed-off-by: Christian Heusel <christian@heusel.eu>
2024-02-14 01:21:28 +01:00
Jakub Klinkovský
98bd7e3760 fix(build): explicitly add --nosign when building a srcpkg
We should explicitly instruct makepkg to not sign the source package,
even when the BUILDENV array in makepkg.conf contains 'sign'. The
devtools workflow is to always sign separately from building, which is
different from makepkg and it should not depend on its configuration.

Furthermore, this function is currently used only in offload-build to
collect sources that are transferred to the server before the build
itself. Signing this source package does not provide any benefits.
2024-02-11 13:37:49 +01:00
Christian Heusel
3e79cb8f4a doc: add pacman-contrib to optdeps in the README
We are depending on updpkgsums for the --update-checksums option used in
pkgctl build. Document this requirement.

Signed-off-by: Christian Heusel <christian@heusel.eu>
2024-02-10 20:13:15 +01:00
Levente Polyak
1cf402eae9 fix(build): forward target repo options to the release subcommand
The adequate target repo options are not appropriately forwarded to the
release subcommand if the auto-release options is activated. Previously
we did not restrict the --repo option, which the build option has used
as a shortcut. Since last release, this option is restricted to new
packages that are not in any official repository yet.

Fix this issue by forwarding the same target repo options that have been
used during the build command and not forcefully the --repo options.

Fixes #209

Component: pkgctl build
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2024-02-09 20:18:30 +01:00
Levente Polyak
0469d3c902 fix(build): avoid trying to download none existing debug packages
Since last release, offload building now has proper error handling
enabled. This unfortunately lead to a regression for packages, like any
packages, where makepkg claims debug packages are available during
--packagelist while none were actually built. This leads to the scp
command failing when trying to download the none existing packages
which ultimately leads to a termination of the build script.

Fix this by filtering out package files that do not exist before trying
to download them.

Fixes #208

Component: pkgctl build
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2024-02-08 22:08:54 +01:00
Christian Heusel
f6b1b1ba45 doc: add curl to the dependencies in the README
We use curl all over pkgctl, i.e. to do the Gitlab API calls.

Signed-off-by: Christian Heusel <christian@heusel.eu>
2024-02-08 02:01:55 +01:00
10 changed files with 142 additions and 11 deletions

View File

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

View File

@@ -69,6 +69,7 @@ Component: pkgctl db remove
- bash
- binutils
- coreutils
- curl
- diffutils
- fakeroot
- findutils
@@ -90,6 +91,7 @@ Component: pkgctl db remove
- bat (pretty printing)
- nvchecker (version checking)
- pacman-contrib (--update-checksums options for pkgctl build)
### Development Dependencies

View File

@@ -41,7 +41,7 @@ CHOST="x86_64-pc-linux-gnu"
#-- Compiler and Linker Flags
#CPPFLAGS=""
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
-Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security \
-fstack-clash-protection -fcf-protection"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now \

View File

@@ -41,7 +41,7 @@ CHOST="x86_64-pc-linux-gnu"
#-- Compiler and Linker Flags
#CPPFLAGS=""
CFLAGS="-march=x86-64-v3 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
-Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security \
-fstack-clash-protection -fcf-protection"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now \

View File

@@ -154,6 +154,7 @@ pkgctl_build() {
(( $# <= 1 )) && die "missing argument for %s" "$1"
pkgctl_build_check_option_group_repo '--repo' "${REPO}" "${TESTING}" "${STAGING}"
REPO="${2}"
RELEASE_OPTIONS+=("--repo" "${REPO}")
shift 2
;;
--arch)
@@ -204,11 +205,13 @@ pkgctl_build() {
-s|--staging)
pkgctl_build_check_option_group_repo '--staging' "${REPO}" "${TESTING}" "${STAGING}"
STAGING=1
RELEASE_OPTIONS+=("--staging")
shift
;;
-t|--testing)
pkgctl_build_check_option_group_repo '--testing' "${REPO}" "${TESTING}" "${STAGING}"
TESTING=1
RELEASE_OPTIONS+=("--testing")
shift
;;
-c|--clean)
@@ -495,7 +498,7 @@ pkgctl_build() {
# release the build
if (( RELEASE )); then
pkgctl_release --repo "${pkgrepo}" "${RELEASE_OPTIONS[@]}"
pkgctl_release "${RELEASE_OPTIONS[@]}"
fi
# reset common PKGBUILD variables

View File

@@ -31,12 +31,21 @@ export PACKAGING_REPO_RELEASE_HOST=repos.archlinux.org
export PKGBASE_MAINTAINER_URL=https://archlinux.org/packages/pkgbase-maintainer
export AUR_URL_SSH=aur@aur.archlinux.org
# ensure TERM is set with a fallback to dumb
export TERM=${TERM:-dumb}
# check if messages are to be printed using color
if [[ -t 2 && "$TERM" != dumb ]] || [[ ${DEVTOOLS_COLOR} == always ]]; then
colorize
PURPLE="$(tput setaf 5)"
DARK_GREEN="$(tput setaf 2)"
UNDERLINE="$(tput smul)"
if tput setaf 0 &>/dev/null; then
PURPLE="$(tput setaf 5)"
DARK_GREEN="$(tput setaf 2)"
UNDERLINE="$(tput smul)"
else
PURPLE="\e[35m"
DARK_GREEN="\e[32m"
UNDERLINE="\e[4m"
fi
else
# shellcheck disable=2034
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW='' PURPLE='' DARK_GREEN='' UNDERLINE=''
@@ -108,7 +117,9 @@ cleanup() {
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
rm -rf "$WORKDIR"
fi
tput cnorm >&2
if tput setaf 0 &>/dev/null; then
tput cnorm >&2
fi
exit "${1:-0}"
}

View File

@@ -28,7 +28,9 @@ makepkg_source_package() {
export LIBMAKEPKG_SRCINFO_SH=1
write_srcinfo() { print_srcinfo; }
set +e -- -F --source
# explicitly instruct makepkg to not sign the source package, even when
# the BUILDENV array in makepkg.conf contains 'sign'
set +e -- -F --source --nosign
# shellcheck source=/usr/bin/makepkg
source "$(command -v makepkg)"
)

View File

@@ -49,6 +49,14 @@ pkgctl_version() {
pkgctl_version_check "$@"
exit $?
;;
edit)
_DEVTOOLS_COMMAND+=" $1"
shift
# shellcheck source=src/lib/version/edit.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/version/edit.sh
pkgctl_version_edit "$@"
exit $?
;;
upgrade)
_DEVTOOLS_COMMAND+=" $1"
shift

101
src/lib/version/edit.sh Normal file
View File

@@ -0,0 +1,101 @@
#!/bin/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
[[ -z ${DEVTOOLS_INCLUDE_VERSION_CHECK_SH:-} ]] || return 0
DEVTOOLS_INCLUDE_VERSION_CHECK_SH=1
_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/term.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/term.sh
source /usr/share/makepkg/util/message.sh
set -eo pipefail
pkgctl_version_edit_usage() {
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
cat <<- _EOF_
Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
Compares the versions of packages in the local packaging repository against
their latest upstream versions.
Upon execution, it generates a grouped list that provides detailed insights
into each package's status. For each package, it displays the current local
version alongside the latest version available upstream.
Outputs a summary of up-to-date packages, out-of-date packages, and any
check failures.
OPTIONS
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} neovim vim
_EOF_
}
pkgctl_version_edit() {
local pkgbases=()
local path pkgbase
while (( $# )); do
case $1 in
-h|--help)
pkgctl_version_edit_usage
exit 0
;;
--)
shift
break
;;
-*)
die "invalid argument: %s" "$1"
;;
*)
pkgbases=("$@")
break
;;
esac
done
# Check if used without pkgbases in a packaging directory
if (( ${#pkgbases[@]} == 0 )); then
if [[ -f PKGBUILD ]]; then
pkgbases=(".")
else
pkgctl_version_check_usage
exit 1
fi
fi
# Check if EDITOR or xdg-open are present
if [[ -z ${EDITOR} ]] && ! command -v xdg-open &>/dev/null; then
die "The version edit command requires either \$EDITOR or 'xdg-open'"
fi
for path in "${pkgbases[@]}"; do
pushd "${path}" >/dev/null
if [[ ! -f "PKGBUILD" ]]; then
die "No PKGBUILD found for ${path}"
fi
if [[ ! -f .nvchecker.toml ]]; then
touch .nvchecker.toml
fi
if [[ -n ${EDITOR} ]]; then
"${EDITOR}" .nvchecker.toml
else
xdg-open .nvchecker.toml
fi
popd >/dev/null
done
}

View File

@@ -23,6 +23,7 @@ fi
repo=extra
arch=x86_64
server=build.archlinux.org
rsyncopts=(-e ssh -c -h -L --progress --partial -y)
usage() {
cat <<- _EOF_
@@ -99,6 +100,7 @@ mapfile -t files < <(
# shellcheck disable=SC2145
cat "$SRCPKGDEST"/*"$SRCEXT" |
ssh $server '
export TERM="'"${TERM}"'"
temp="${XDG_CACHE_HOME:-$HOME/.cache}/offload-build" &&
mkdir -p "$temp" &&
temp=$(mktemp -d -p "$temp") &&
@@ -114,14 +116,16 @@ mapfile -t files < <(
if [[ -f /usr/share/devtools/makepkg.conf.d/'"${repo}"'-'"${arch}"'.conf ]]; then
makepkg_config="/usr/share/devtools/makepkg.conf.d/'"${repo}"'-'"${arch}"'.conf"
fi &&
makepkg --config <(cat "${makepkg_user_config}" "${makepkg_config}" 2>/dev/null) --packagelist &&
while read -r file; do
[[ -f "${file}" ]] && printf "%s\n" "${file}" ||:
done < <(makepkg --config <(cat "${makepkg_user_config}" "${makepkg_config}" 2>/dev/null) --packagelist) &&
printf "%s\n" "${temp}/PKGBUILD"
')
if (( ${#files[@]} )); then
printf '%s\n' '' '-> copying files...'
scp "${files[@]/#/$server:}" "${TEMPDIR}/"
rsync "${rsyncopts[@]}" "${files[@]/#/$server:}" "${TEMPDIR}/" || die
mv "${TEMPDIR}"/*.pkg.tar* "${PKGDEST:-${PWD}}/"
mv "${TEMPDIR}/PKGBUILD" "${PWD}/"
else