Compare commits

..

9 Commits
0.29 ... 0.29.2

Author SHA1 Message Date
d5d89cf7a4 commitpkg: small msg change 2022-11-04 18:36:55 +01:00
cc8c2fe38e commitpkg: clean up 2022-11-04 15:10:12 +01:00
9bf2bd2671 commitpkg: drop rebuild check, pipeline now supports skipping add/rm stages if rebuild <--> staging moves, both goblins 2022-11-04 12:01:50 +01:00
eb638abdfe patches (#67)
Reviewed-on: artix/artools#67
2022-11-03 23:10:30 +01:00
332cc9751b Merge pull request 'buildtree: use git -C when importing packages' (#65) from Dudemanguy/artools:buildtree-use-path into master
Reviewed-on: artix/artools#65
2022-11-02 18:02:41 +01:00
f86e36c361 buildtree: use git -C when importing packages
This way, the git config credentials that are retrieved correctly match
the actual directory of the package
2022-10-27 13:29:19 -05:00
2edcd2fd54 commitpkg: cp -r on move 2022-07-31 18:23:22 +02:00
80887fba39 commitpkg: cp -r to support keys sub dirs 2022-07-26 18:25:52 +02:00
bd07105192 patches (#64)
Reviewed-on: artix/artools#64
2022-07-21 18:35:47 +02:00
8 changed files with 171 additions and 85 deletions

View File

@@ -112,8 +112,8 @@ update_tree() {
set_maintainer() { set_maintainer() {
local name email path="$1" local name email path="$1"
name=$(git config --get user.name) name=$(git -C $path config --get user.name)
email=$(git config --get user.email) email=$(git -C $path config --get user.email)
sed -e "1s|Maintainer:.*|Maintainer: $name <$email>|" \ sed -e "1s|Maintainer:.*|Maintainer: $name <$email>|" \
-i "$path"/PKGBUILD -i "$path"/PKGBUILD
} }

View File

@@ -15,8 +15,6 @@
m4_include(lib/base/message.sh) m4_include(lib/base/message.sh)
m4_include(lib/pkg/diff.sh) m4_include(lib/pkg/diff.sh)
shopt -s extglob
load_makepkg_config load_makepkg_config
usage() { usage() {

View File

@@ -22,18 +22,6 @@ m4_include(lib/pkg/repo.sh)
#{{{ functions #{{{ functions
check_rebuild(){
if [[ -d "$CARCH"/"${valid_names[10]}" ]] \
&& [[ "${repo_dest}" == "${valid_names[7]}" ]]; then
git rm -r "$CARCH"/"${valid_names[10]}"
git commit -m "switch from ${valid_names[10]} to ${valid_names[7]}"
elif [[ -d "$CARCH"/"${valid_names[7]}" ]] \
&& [[ "${repo_dest}" == "${valid_names[10]}" ]]; then
git rm -r "$CARCH"/"${valid_names[7]}"
git commit -m "switch from ${valid_names[7]} to ${valid_names[10]}"
fi
}
check_team(){ check_team(){
if [[ "${repo_src}" == "${valid_names[0]}" && "${repo_dest}" == "${valid_names[1]}" ]] || \ if [[ "${repo_src}" == "${valid_names[0]}" && "${repo_dest}" == "${valid_names[1]}" ]] || \
[[ "${repo_src}" == "${valid_names[1]}" && "${repo_dest}" == "${valid_names[0]}" ]] || \ [[ "${repo_src}" == "${valid_names[1]}" && "${repo_dest}" == "${valid_names[0]}" ]] || \
@@ -50,11 +38,22 @@ check_team(){
fi fi
} }
path_config() { push_super() {
[[ "${repo_src}" != 'trunk' ]] && pkgbuild="$CARCH/${repo_src}"/PKGBUILD local name="$1"
msg "Update (%s)" "$name"
git push origin master
git prune
[[ "${cmd}" != 'commitpkg' ]] && check_team
}
# shellcheck disable=1090 push_pkg() {
. "$pkgbuild" local name="$1"
if braid push "${package}"; then
braid update "${package}"
push_super "$name"
else
error "'braid push %s' failed.\n" "${package}"
fi
} }
get_repo_commit_msg() { get_repo_commit_msg() {
@@ -72,15 +71,15 @@ commit_pkg() {
commit_msg=$(get_commit_msg) commit_msg=$(get_commit_msg)
msg "Action: %s" "$commit_msg" msg "Action: %s" "$commit_msg"
if [[ "${repo_src}" == 'trunk' ]];then if [[ "${repo_src}" == 'trunk' ]];then
git rm -r trunk git rm -r $package/trunk
else else
git rm -r "$CARCH/${repo_src}" git rm -r "$package/$CARCH/${repo_src}"
fi fi
else else
action='modify' action='modify'
commit_msg=$(get_commit_msg) commit_msg=$(get_commit_msg)
msg "Action: %s" "$commit_msg" msg "Action: %s" "$commit_msg"
git add . git add "$package"
fi fi
git commit -m "$commit_msg" git commit -m "$commit_msg"
} }
@@ -88,60 +87,51 @@ commit_pkg() {
repo_commit_pkg() { repo_commit_pkg() {
local commit_msg local commit_msg
[[ -d "$CARCH/${repo_dest}" ]] && git rm -r "$CARCH/${repo_dest}" [[ -d "$package/$CARCH/${repo_dest}" ]] && git rm -r "$package/$CARCH/${repo_dest}"
[[ ! -d "$CARCH" ]] && mkdir "$CARCH" [[ ! -d "$package/$CARCH" ]] && mkdir "$package/$CARCH"
[[ ! -d "$CARCH/${repo_dest}" ]] && mkdir "$CARCH/${repo_dest}" [[ ! -d "$package/$CARCH/${repo_dest}" ]] && mkdir "$package/$CARCH/${repo_dest}"
if [[ "${repo_src}" == 'trunk' ]]; then if [[ "${repo_src}" == 'trunk' ]]; then
action='add' action='add'
commit_msg=$(get_repo_commit_msg) commit_msg=$(get_repo_commit_msg)
msg "Action: %s" "$commit_msg" msg "Action: %s" "$commit_msg"
check_rebuild cp -r "$package"/trunk/* "$package/$CARCH/${repo_dest}"/
cp trunk/* "$CARCH/${repo_dest}"/
else else
action='move' action='move'
[[ ! -f $pkgbuild ]] && die "%s does not exist!" "$pkgbuild" [[ ! -f $pkgbuild ]] && die "%s does not exist!" "$pkgbuild"
commit_msg=$(get_repo_commit_msg) commit_msg=$(get_repo_commit_msg)
msg "Action: %s" "$commit_msg" msg "Action: %s" "$commit_msg"
cp "$CARCH/${repo_src}"/* "$CARCH/${repo_dest}"/ cp -r "$package/$CARCH/${repo_src}"/* "$package/$CARCH/${repo_dest}"/
git rm -r "$CARCH/${repo_src}" git rm -r "$package/$CARCH/${repo_src}"
fi fi
git add . git add "$package"
git commit -m "$commit_msg" git commit -m "$commit_msg"
} }
run(){ run(){
local artixpath head tree local artixpath head tree tree_name
artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}") artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}")
if [[ -n ${artixpath} ]];then if [[ -n ${artixpath} ]];then
tree=${artixpath%/*} tree=${artixpath%/*}
tree_name=${tree##*/}
cd "$tree" || return cd "$tree" || return
head=$(get_local_head) head=$(get_local_head)
cd "${artixpath}" || return pkgbuild="$package"/trunk/PKGBUILD
if [[ "${repo_src}" != 'trunk' ]]; then
path_config pkgbuild="$package/$CARCH/${repo_src}"/PKGBUILD
if [[ "${cmd}" == 'commitpkg' ]];then
commit_pkg
else
repo_commit_pkg
fi fi
# shellcheck disable=1090
. "$pkgbuild"
cd "$tree" || return case "${cmd}" in
'commitpkg') commit_pkg ;;
*) repo_commit_pkg ;;
esac
msg "Checking (%s) (Artix)" "${tree##*/}" msg "Checking (%s) (Artix)" "$tree_name"
pull_tree "${tree##*/}" "$head" pull_tree "$tree_name" "$head"
push_pkg "$tree_name"
if braid push "${package}"; then
braid update "${package}"
msg "Update (%s)" "${tree##*/}"
git push origin master
git prune
[[ "${cmd}" != 'commitpkg' ]] && check_team
else
warning "'braid push %s' failed.\n" "${package}"
fi
else else
die "Package '%s' does not exist!" "${package}" die "Package '%s' does not exist!" "${package}"
fi fi
@@ -168,8 +158,6 @@ repo_src='trunk'
package='' package=''
remove=false remove=false
pkgbuild=trunk/PKGBUILD
cmd=${0##*/} cmd=${0##*/}
repo_dest=${cmd%pkg} repo_dest=${cmd%pkg}

View File

@@ -2,8 +2,6 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
shopt -s extglob
m4_include(lib/base/message.sh) m4_include(lib/base/message.sh)
m4_include(lib/pkg/diff.sh) m4_include(lib/pkg/diff.sh)
@@ -37,12 +35,19 @@ _EOF_
} }
MAKEPKG_CONF=/etc/makepkg.conf MAKEPKG_CONF=/etc/makepkg.conf
POOLDIR=/srv/pkgpool
VERBOSE=0 VERBOSE=0
TARLIST=0 TARLIST=0
DIFFOSCOPE=0 DIFFOSCOPE=0
PKGINFO=0 PKGINFO=0
BUILDINFO=0 BUILDINFO=0
DIFFMODE=--side-by-side
DIFFCOLOR=--color=auto
DIFFWIDTH=--width=auto
DIFFOPTIONS=(--expand-tabs)
# option checking # option checking
while (( $# )); do while (( $# )); do
case $1 in case $1 in
@@ -51,6 +56,7 @@ while (( $# )); do
exit 0 exit 0
;; ;;
-M|--makepkg-config) -M|--makepkg-config)
(( $# <= 1 )) && die "missing argument for %s" "$1"
MAKEPKG_CONF="$2" MAKEPKG_CONF="$2"
shift 2 shift 2
;; ;;
@@ -74,11 +80,50 @@ while (( $# )); do
VERBOSE=1 VERBOSE=1
shift shift
;; ;;
-u|-U|--unified)
DIFFMODE=--unified
shift
;;
-y|--side-by-side)
DIFFMODE=--side-by-side
shift
;;
--color|--color=*)
if [[ $2 == never || $2 == always || $2 == auto ]]; then
DIFFCOLOR="--color=$2"
shift 2
continue
fi
if [[ $1 == --color ]]; then
DIFFCOLOR="--color=auto"
else
DIFFCOLOR="$1"
fi
shift
;;
-W|--width)
(( $# <= 1 )) && die "missing argument for %s" "$1"
DIFFWIDTH="--width=$2"
shift 2
;;
--width=*)
DIFFWIDTH="$1"
shift
;;
-P|--pool)
(( $# <= 1 )) && die "missing argument for %s" "$1"
POOLDIR="$2"
shift 2
;;
--pool=*)
POOLDIR="${1#*=}"
shift
;;
--) --)
shift shift
break break
;; ;;
-*,--*) -*|--*)
die "invalid argument: %s" "$1" die "invalid argument: %s" "$1"
;; ;;
*) *)
@@ -87,13 +132,29 @@ while (( $# )); do
esac esac
done done
# Set options based on flags or magic values
if (( VERBOSE )); then
if [[ $DIFFMODE == --unified ]]; then
DIFFMODE="--unified=99999"
fi
else
DIFFOPTIONS+=(--suppress-common-lines)
fi
if [[ $DIFFWIDTH == --width=columns ]]; then
DIFFWIDTH="--width=${COLUMNS:-130}"
fi
if [[ $DIFFWIDTH != --width=auto ]]; then
DIFFOPTIONS+=("${DIFFWIDTH}")
fi
DIFFOPTIONS+=("${DIFFMODE}" "${DIFFCOLOR}")
if ! (( DIFFOSCOPE || TARLIST || PKGINFO || BUILDINFO )); then if ! (( DIFFOSCOPE || TARLIST || PKGINFO || BUILDINFO )); then
TARLIST=1 TARLIST=1
fi fi
# Source makepkg.conf; fail if it is not found # Source makepkg.conf; fail if it is not found
if [[ -r "${MAKEPKG_CONF}" ]]; then if [[ -r "${MAKEPKG_CONF}" ]]; then
# shellcheck source=makepkg-x86_64.conf # shellcheck source=config/makepkg/x86_64.conf
source "${MAKEPKG_CONF}" source "${MAKEPKG_CONF}"
else else
die "${MAKEPKG_CONF} not found!" die "${MAKEPKG_CONF} not found!"
@@ -121,6 +182,19 @@ tar_list() {
fi | sort fi | sort
} }
file_line_length() {
path="$1"
wc -L "${path}" | tail -n1 | sed -E 's/^ +//g' | cut -d' ' -f1
}
file_diff_columns() {
file1="$1"
file2="$2"
file1_length=$(file_line_length "$file1")
file2_length=$(file_line_length "$file2")
echo $(( file1_length + file2_length + 3 ))
}
diff_pkgs() { diff_pkgs() {
local oldpkg newpkg local oldpkg newpkg
oldpkg=$(readlink -m "$1") oldpkg=$(readlink -m "$1")
@@ -129,29 +203,40 @@ diff_pkgs() {
[[ -f $oldpkg ]] || die "No such file: %s" "${oldpkg}" [[ -f $oldpkg ]] || die "No such file: %s" "${oldpkg}"
[[ -f $newpkg ]] || die "No such file: %s" "${newpkg}" [[ -f $newpkg ]] || die "No such file: %s" "${newpkg}"
if (( TARLIST )); then DIFFOPTIONS+=(--label "${oldpkg}" --label "${newpkg}")
tar_list "$oldpkg" > "$TMPDIR/filelist-old"
tar_list "$newpkg" > "$TMPDIR/filelist"
sdiff -s "$TMPDIR/filelist-old" "$TMPDIR/filelist" if (( TARLIST )); then
tar_list "$oldpkg" > "$TMPDIR/old"
tar_list "$newpkg" > "$TMPDIR/new"
fi fi
if (( PKGINFO )); then if (( PKGINFO )); then
bsdtar xOqf "$oldpkg" .PKGINFO > "$TMPDIR/pkginfo-old" bsdtar xOqf "$oldpkg" .PKGINFO > "$TMPDIR/old"
bsdtar xOqf "$newpkg" .PKGINFO > "$TMPDIR/pkginfo" bsdtar xOqf "$newpkg" .PKGINFO > "$TMPDIR/new"
sdiff -s "$TMPDIR/pkginfo-old" "$TMPDIR/pkginfo"
fi fi
if (( BUILDINFO )); then if (( BUILDINFO )); then
bsdtar xOqf "$oldpkg" .BUILDINFO > "$TMPDIR/buildinfo-old" bsdtar xOqf "$oldpkg" .BUILDINFO > "$TMPDIR/old"
bsdtar xOqf "$newpkg" .BUILDINFO > "$TMPDIR/buildinfo" bsdtar xOqf "$newpkg" .BUILDINFO > "$TMPDIR/new"
fi
sdiff -s "$TMPDIR/buildinfo-old" "$TMPDIR/buildinfo" if (( TARLIST || PKGINFO || BUILDINFO )); then
# Resolve dynamic auto width one we know the content to diff
if [[ $DIFFWIDTH == --width=auto ]]; then
AUTOLENGTH=$(file_diff_columns "$TMPDIR/old" "$TMPDIR/new")
DIFFOPTIONS+=("--width=${AUTOLENGTH}")
fi
# Print a header for side-by-side view as it lacks labels
if [[ $DIFFMODE == --side-by-side ]]; then
printf -- "--- %s\n+++ %s\n" "${oldpkg}" "${newpkg}"
fi
diff "${DIFFOPTIONS[@]}" "$TMPDIR/old" "$TMPDIR/new"
fi fi
if (( DIFFOSCOPE )); then if (( DIFFOSCOPE )); then
diffoscope "$oldpkg" "$newpkg" diffoscope "${DIFFCOLOR/--color/--text-color}" "$oldpkg" "$newpkg"
fi fi
} }
@@ -165,13 +250,24 @@ fetch_pkg() {
*.pkg.tar*) *.pkg.tar*)
pkgurl=$1 ;; pkgurl=$1 ;;
'') '')
;; ;;
*) *)
pkg=$1 ;; pkg=$1 ;;
esac esac
[[ -n $pkgurl ]] || pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$pkg") || if [[ -z ${pkgurl} ]]; then
die "Couldn't download previous package for %s." "$pkg" # Try to find latest package in pool dir
if [[ -d ${POOLDIR} ]]; then
shopt -s extglob nullglob
pkgurl=$(printf "%s\n" "${POOLDIR}"/*/"${_pkgname}"-!(*-*)-!(*-*)-!(*-*).pkg.tar!(*.sig)|sort -Vr|head -1)
shopt -u extglob nullglob
fi
# Search via pacman database if no pool file exists
if [[ ! -f ${pkgurl} ]]; then
pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$pkg") ||
die "Couldn't download previous package for %s." "$pkg"
fi
fi
pkg=${pkgurl##*/} pkg=${pkgurl##*/}
pkgdest=$(mktemp -t -d "${pkg}-XXXXXX")/${pkg} pkgdest=$(mktemp -t -d "${pkg}-XXXXXX")/${pkg}
@@ -197,7 +293,7 @@ if (( $# < 2 )); 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 '$(basename "$0") --help' for more information."
fi fi
# shellcheck source=PKGBUILD.proto # shellcheck source=contrib/makepkg/PKGBUILD.proto
. ./PKGBUILD . ./PKGBUILD
if [[ ${arch[0]} == 'any' ]]; then if [[ ${arch[0]} == 'any' ]]; then
CARCH='any' CARCH='any'

View File

@@ -15,7 +15,6 @@
m4_include(lib/base/message.sh) m4_include(lib/base/message.sh)
set -e set -e
shopt -s extglob
IGNORE_INTERNAL=0 IGNORE_INTERNAL=0
@@ -53,7 +52,9 @@ fi
process_sofile() { process_sofile() {
# extract the library name: libfoo.so # extract the library name: libfoo.so
shopt -s extglob nullglob
soname="${sofile%.so?(+(.+([0-9])))}".so soname="${sofile%.so?(+(.+([0-9])))}".so
shopt -u extglob nullglob
# extract the major version: 1 # extract the major version: 1
soversion="${sofile##*\.so\.}" soversion="${sofile##*\.so\.}"
if [[ "$soversion" = "$sofile" ]] && ((IGNORE_INTERNAL)); then if [[ "$soversion" = "$sofile" ]] && ((IGNORE_INTERNAL)); then

View File

@@ -329,13 +329,14 @@ fi
# Pass all arguments after -- right to makepkg # Pass all arguments after -- right to makepkg
makepkg_args+=("${@:$OPTIND}") makepkg_args+=("${@:$OPTIND}")
# See if -R or -e was passed to makepkg # See if -R, -e or -A was passed to makepkg
for arg in "${@:$OPTIND}"; do for arg in "${@:$OPTIND}"; do
case ${arg%%=*} in case ${arg%%=*} in
--skip*|--holdver) verifysource_args+=("$arg") ;; --skip*|--holdver|--ignorearch) verifysource_args+=("$arg") ;;
--repackage|--noextract) keepbuilddir=1 ;; --repackage|--noextract) keepbuilddir=1 ;;
--*) ;; --*) ;;
-*R*|-*e*) keepbuilddir=1 ;; -*A*) verifysource_args+=(-A) ;;&
-*R*|-*e*) keepbuilddir=1 ;;&
esac esac
done done

View File

@@ -9,8 +9,6 @@
export LANG=C export LANG=C
shopt -s extglob
if [[ -t 2 && "$TERM" != dumb ]]; then if [[ -t 2 && "$TERM" != dumb ]]; then
colorize colorize
else else

View File

@@ -13,14 +13,18 @@ pkgver_equal() {
} }
find_cached_package() { find_cached_package() {
local searchdirs=("$PKGDEST" "$PWD") results=() local searchdirs=("$PWD" "$PKGDEST") results=()
local targetname=$1 targetver=$2 targetarch=$3 local targetname=$1 targetver=$2 targetarch=$3
local dir pkg pkgbasename name ver rel arch r results local dir pkg packages pkgbasename name ver rel arch r results
for dir in "${searchdirs[@]}"; do for dir in "${searchdirs[@]}"; do
[[ -d $dir ]] || continue [[ -d $dir ]] || continue
for pkg in "$dir"/*.pkg.tar?(.!(sig|*.*)); do shopt -s extglob nullglob
mapfile -t packages < <(printf "%s\n" "$dir"/"${targetname}"-"${targetver}"-*"${targetarch}".pkg.tar?(.!(sig|*.*)))
shopt -u extglob nullglob
for pkg in "${packages[@]}"; do
[[ -f $pkg ]] || continue [[ -f $pkg ]] || continue
# avoid adding duplicates of the same inode # avoid adding duplicates of the same inode