Compare commits

..

3 Commits
0.17.6 ... 0.18

Author SHA1 Message Date
d333c245c0 next (#28)
deploypkg: fix return codes

deploypkg: only remocve if pkg is in repo

deploypkg: refactor

move unique funcs to script

signpkg: fix typo

minor tweaks
rm commented code

signpkg: load makepkg.conf

buildpkg & deploypkg: add optarg to set repo, proves to be better in pipeline to generate cmd args
add signpkg

start 0.18

deploypkg: add sign check
2020-05-24 11:15:25 +02:00
4a650f00d7 Merge pull request 's6: use database names instead of directory names' (#27) from Dudemanguy/artools:master into master 2020-04-28 17:52:27 +02:00
1a250c2167 s6: use database names instead of directory names
It's possible for a service in s6 to exist but for its name to not
actually be the same as the name of an existing directory (ex: a
pipeline of a logger and service daemon). Instead, rework this function
to detect if a service exists based on whether it is defined in the
s6-rc database.
2020-04-27 16:42:58 -05:00
8 changed files with 141 additions and 146 deletions

View File

@@ -1,4 +1,4 @@
VERSION=0.17 VERSION=0.18
CHROOT_VERSION=0.10 CHROOT_VERSION=0.10
@@ -45,7 +45,8 @@ PKG_BIN = \
bin/pkg/checkpkg \ bin/pkg/checkpkg \
bin/pkg/finddeps \ bin/pkg/finddeps \
bin/pkg/find-libdeps \ bin/pkg/find-libdeps \
bin/pkg/batchpkg bin/pkg/batchpkg \
bin/pkg/signpkg
LN_COMMITPKG = \ LN_COMMITPKG = \
extrapkg \ extrapkg \

View File

@@ -30,6 +30,7 @@ base_devel=('base-devel')
usage() { usage() {
echo "Usage: ${0##*/} [options] -- [mkchrootpkg_args]" echo "Usage: ${0##*/} [options] -- [mkchrootpkg_args]"
echo " -r <dir> Create chroots in this directory" echo " -r <dir> Create chroots in this directory"
echo " -d <dir> Destination repo chroot"
echo ' -c Recreate the chroot before building' echo ' -c Recreate the chroot before building'
echo ' -m Major rebuild' echo ' -m Major rebuild'
echo ' -N Disable check() function' echo ' -N Disable check() function'
@@ -43,11 +44,12 @@ usage() {
orig_argv=("$0" "$@") orig_argv=("$0" "$@")
opts='hcCNmr:' opts='hcCNmr:d:'
while getopts "${opts}" arg; do while getopts "${opts}" arg; do
case "${arg}" in case "${arg}" in
r) CHROOTS_PKG="$OPTARG" ;; r) CHROOTS_PKG="$OPTARG" ;;
d) repo="$OPTARG" ;;
c) create_first=true ;; c) create_first=true ;;
m) rebuild=true ;; m) rebuild=true ;;
C) is_checkpkg=true; mkchrootpkg_args+=(-C) ;; C) is_checkpkg=true; mkchrootpkg_args+=(-C) ;;

View File

@@ -18,6 +18,68 @@ shopt -s extglob
load_makepkg_config load_makepkg_config
pkgver_equal() {
if [[ $1 = *-* && $2 = *-* ]]; then
# if both versions have a pkgrel, then they must be an exact match
[[ $1 = "$2" ]]
else
# otherwise, trim any pkgrel and compare the bare version.
[[ ${1%%-*} = "${2%%-*}" ]]
fi
}
find_cached_package() {
local searchdirs=("$PKGDEST" "$PWD") results=()
local targetname=$1 targetver=$2 targetarch=$3
local dir pkg pkgbasename name ver rel arch r results
for dir in "${searchdirs[@]}"; do
[[ -d $dir ]] || continue
for pkg in "$dir"/*.pkg.tar?(.!(sig|*.*)); do
[[ -f $pkg ]] || continue
# avoid adding duplicates of the same inode
for r in "${results[@]}"; do
[[ $r -ef $pkg ]] && continue 2
done
# split apart package filename into parts
pkgbasename=${pkg##*/}
pkgbasename=${pkgbasename%.pkg.tar*}
arch=${pkgbasename##*-}
pkgbasename=${pkgbasename%-"$arch"}
rel=${pkgbasename##*-}
pkgbasename=${pkgbasename%-"$rel"}
ver=${pkgbasename##*-}
name=${pkgbasename%-"$ver"}
if [[ $targetname = "$name" && $targetarch = "$arch" ]] &&
pkgver_equal "$targetver" "$ver-$rel"; then
results+=("$pkg")
fi
done
done
case ${#results[*]} in
0)
return 1
;;
1)
printf '%s\n' "${results[0]}"
return 0
;;
*)
error 'Multiple packages found:'
printf '\t%s\n' "${results[@]}" >&2
return 1
;;
esac
}
usage() { usage() {
cat <<- _EOF_ cat <<- _EOF_
Usage: ${BASH_SOURCE[0]##*/} [OPTIONS] Usage: ${BASH_SOURCE[0]##*/} [OPTIONS]

View File

@@ -16,35 +16,11 @@
prepare_artools prepare_artools
find_cached_pkgfile() {
local searchdirs=("$PKGDEST" "$PWD") results=()
local pkg="$1"
local search=${pkg%.*}
for dir in "${searchdirs[@]}"; do
[[ -d $dir ]] || continue
results+=$(find "$dir" -type f -name "$search.*" ! -path '*.sig' ! -path '*.log')
done
case ${#results[*]} in
0)
return 1
;;
1)
printf '%s\n' "${results[0]}"
return 0
;;
*)
error 'Multiple packages found:'
printf '\t%s\n' "${results[@]}" >&2
return 1
;;
esac
}
get_pkgbasename(){ get_pkgbasename(){
local pkg="$1" local pkg="$1"
local pkgbasename name ver rel arch local pkgbasename name ver rel arch
pkgbasename=${pkg%.pkg.tar.?z} pkgbasename=${pkg%.pkg.tar*}
arch=${pkgbasename##*-} arch=${pkgbasename##*-}
pkgbasename=${pkgbasename%-"$arch"} pkgbasename=${pkgbasename%-"$arch"}
@@ -57,86 +33,42 @@ get_pkgbasename(){
echo $name echo $name
} }
update_repo2(){ add(){
local repo="$1" packages+=("$pkg")
local repo_path=${REPOS_ROOT}/$repo/os/${ARCH} packages=() if [[ -e "${pkgfile}" ]]; then
action='add'
for name in ${passfiles[@]}; do ln -sf "${pkgfile}"{,.sig} "$repo_path"/
if pkgfile=$(find_cached_pkgfile "$name");then
info "Found: %s" "$name"
if ${add_pkg};then
local action='add'
packages+=("$name")
if ${sign_pkg};then
[[ -e ${pkgfile}.sig ]] && rm ${pkgfile}.sig
signfile ${pkgfile}
fi
ln -sf ${pkgfile}{,.sig} $repo_path/
elif ${del_pkg};then
local action='remove'
packages+=("$(get_pkgbasename "$name")")
[[ -e $repo_path/$name ]] && rm $repo_path/$name
[[ -e $repo_path/$name.sig ]] && rm $repo_path/$name.sig
fi
fi
done
cd $repo_path
if [[ -n $action ]]; then
repo-$action -R $repo.${PKGDBEXT} ${packages[@]}
${linksdb} && links-$action $repo.${LINKSDBEXT} ${packages[@]}
fi fi
return 0
} }
update_repo(){ remove(){
local repo="$1" pkgfile ver packages+=("$(get_pkgbasename "$pkg")")
local repo_path=${REPOS_ROOT}/$repo/os/${ARCH} packages=() if [[ -e "$repo_path"/"$pkg" ]]; then
action='remove'
. PKGBUILD rm "$repo_path"/"$pkg"
local pkgsearch=(${pkgname[@]})
if check_option "debug" "y"; then
pkgbase=${pkgbase:-${pkgname[@]}}
pkgsearch+=("${pkgbase}-debug")
fi fi
[[ -e "$repo_path"/"$pkg".sig ]] && rm "$repo_path"/"$pkg".sig
}
for name in ${pkgsearch[@]}; do repo_action(){
pkgarch=$(get_pkg_arch "$name") local packages=() action= func="$1"
ver=$(get_full_version) for pkg in ${passfiles[@]}; do
if pkgfile=$(find_cached_package "$name" "$ver" "$pkgarch");then if pkgfile=$(find_cached_pkgfile "$pkg");then
local pkg=${pkgfile##*/} msg "Found: %s" "${pkgfile}"
info "Found: %s" "$pkg" "$func"
if ${add_pkg};then
local action='add'
packages+=("$pkg")
if ${sign_pkg};then
[[ -e ${pkgfile}.sig ]] && rm ${pkgfile}.sig
signfile ${pkgfile}
fi
ln -sf ${pkgfile}{,.sig} $repo_path/
elif ${del_pkg};then
local action='remove'
packages+=("$name")
[[ -e $repo_path/$pkg ]] && rm $repo_path/$pkg
[[ -e $repo_path/$pkg.sig ]] && rm $repo_path/$pkg.sig
fi
fi fi
done done
cd $repo_path cd $repo_path
if [[ -n $action ]]; then if [[ -n "$action" ]]; then
repo-$action -R $repo.${PKGDBEXT} ${packages[@]} repo-"$action" -R "${dest_repo}"."${PKGDBEXT}" "${packages[@]}"
${linksdb} && links-$action $repo.${LINKSDBEXT} ${packages[@]} ${linksdb} && links-"$action" "${dest_repo}"."${LINKSDBEXT}" "${packages[@]}"
fi fi
return 0
} }
load_makepkg_config load_makepkg_config
add_pkg=false add_pkg=false
del_pkg=false rm_pkg=false
sign_pkg=false
linksdb=false linksdb=false
cmd=${0##*/} cmd=${0##*/}
@@ -144,24 +76,24 @@ dest_repo=${cmd#*-}
usage() { usage() {
echo "Usage: ${cmd} [options]" echo "Usage: ${cmd} [options]"
echo ' -d <dest> Destination repository'
echo ' -a Add package(s) to repository' echo ' -a Add package(s) to repository'
echo ' -r Remove package(s) from repository' echo ' -r Remove package(s) from repository'
echo ' -l Use links db' echo ' -l Use links db'
echo ' -s Sign package(s)'
echo ' -h This help' echo ' -h This help'
echo '' echo ''
echo '' echo ''
exit $1 exit $1
} }
opts='arlsh' opts='arlhd:'
while getopts "${opts}" arg; do while getopts "${opts}" arg; do
case "${arg}" in case "${arg}" in
a) add_pkg=true; del_pkg=false ;; d) dest_repo="$OPTARG" ;;
r) del_pkg=true; add_pkg=false ;; a) add_pkg=true; rm_pkg=false ;;
r) rm_pkg=true; add_pkg=false ;;
l) linksdb=true ;; l) linksdb=true ;;
s) sign_pkg=true ;;
h|?) usage 0 ;; h|?) usage 0 ;;
*) echo "invalid argument '${arg}'"; usage 1 ;; *) echo "invalid argument '${arg}'"; usage 1 ;;
esac esac
@@ -173,8 +105,13 @@ passfiles="$@"
prepare_dir "${REPOS_ROOT}" prepare_dir "${REPOS_ROOT}"
repo_path=${REPOS_ROOT}/${dest_repo}/os/${ARCH}
if [[ -n ${passfiles[@]} ]]; then if [[ -n ${passfiles[@]} ]]; then
update_repo2 "${dest_repo}" if ${add_pkg}; then
else repo_action add
update_repo "${dest_repo}" fi
if ${rm_pkg}; then
repo_action remove
fi
fi fi

29
bin/pkg/signpkg.in Normal file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
#
# Copyright (C) 2018-19 artoo@artixlinux.org
# Copyright (C) 2018 Artix Linux Developers
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
. @libdir@/artools/util-pkg.sh
prepare_artools
load_makepkg_config
passfiles="$@"
for name in ${passfiles[@]}; do
if pkgfile=$(find_cached_pkgfile "$name");then
msg "Found: %s" "${pkgfile}"
[[ -e ${pkgfile}.sig ]] && rm ${pkgfile}.sig
[[ -e ${pkgfile} ]] && signfile ${pkgfile}
fi
done

View File

@@ -36,7 +36,9 @@ add_svc_runit(){
add_svc_s6(){ add_svc_s6(){
local mnt="$1" names="$2" valid="" rlvl="${3:-default}" local mnt="$1" names="$2" valid="" rlvl="${3:-default}"
for svc in $names; do for svc in $names; do
if [[ -d $mnt/etc/s6/sv/$svc ]]; then error=false
chroot $mnt s6-rc-db -c /etc/s6/rc/compiled type $svc &> /dev/null || error=true
if [ $? == 0 ] && [[ $error == false ]]; then
msg2 "Setting %s ..." "$svc" msg2 "Setting %s ..." "$svc"
valid=${valid:-}${valid:+' '}${svc} valid=${valid:-}${valid:+' '}${svc}
fi fi

View File

@@ -33,7 +33,7 @@ subrepo_init() {
subrepo_push(){ subrepo_push(){
local pkg="$1" local pkg="$1"
msg2 "Subrepo push (%s)" "$pkg" msg2 "Subrepo push (%s)" "$pkg"
git subrepo push "$pkg" git subrepo push "$pkg" || die "%s push failed" "$pkg"
} }
subrepo_clean(){ subrepo_clean(){

View File

@@ -46,52 +46,14 @@ find_pkg(){
echo $result echo $result
} }
pkgver_equal() { find_cached_pkgfile() {
if [[ $1 = *-* && $2 = *-* ]]; then
# if both versions have a pkgrel, then they must be an exact match
[[ $1 = "$2" ]]
else
# otherwise, trim any pkgrel and compare the bare version.
[[ ${1%%-*} = "${2%%-*}" ]]
fi
}
find_cached_package() {
local searchdirs=("$PKGDEST" "$PWD") results=() local searchdirs=("$PKGDEST" "$PWD") results=()
local targetname=$1 targetver=$2 targetarch=$3 local pkg="$1"
local dir pkg pkgbasename name ver rel arch r results
for dir in "${searchdirs[@]}"; do for dir in "${searchdirs[@]}"; do
[[ -d $dir ]] || continue [[ -d $dir ]] || continue
#results+=$(find "$dir" -type f -name "$pkg" ! -path '*.sig' ! -path '*.log')
for pkg in "$dir"/*.pkg.tar?(.!(sig|*.*)); do [[ -e $dir/$pkg ]] && results+=($dir/$pkg)
[[ -f $pkg ]] || continue
# avoid adding duplicates of the same inode
for r in "${results[@]}"; do
[[ $r -ef $pkg ]] && continue 2
done
# split apart package filename into parts
pkgbasename=${pkg##*/}
pkgbasename=${pkgbasename%.pkg.tar*}
arch=${pkgbasename##*-}
pkgbasename=${pkgbasename%-"$arch"}
rel=${pkgbasename##*-}
pkgbasename=${pkgbasename%-"$rel"}
ver=${pkgbasename##*-}
name=${pkgbasename%-"$ver"}
if [[ $targetname = "$name" && $targetarch = "$arch" ]] &&
pkgver_equal "$targetver" "$ver-$rel"; then
results+=("$pkg")
fi
done
done done
case ${#results[*]} in case ${#results[*]} in
0) 0)
return 1 return 1