Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
2edcd2fd54 | |||
80887fba39 | |||
bd07105192 | |||
02edf46d6a | |||
860d2272ba | |||
0d9e54c4e3 | |||
26bd425d55 | |||
c08f82044c | |||
74af21ca25 | |||
e3b8439b04 | |||
e00096d503 | |||
f7ebc6bd11 | |||
b5fa7084b2 | |||
7eabdb0e46 | |||
10c013bf33 | |||
74618d77a5 | |||
196761740b | |||
a814655956 | |||
7b03050ab9 | |||
0b1ff8d060 | |||
f66761aa57 | |||
f33d9bdac1 | |||
f50c66cdd7 | |||
fd1bc87ef0 |
25
Makefile
25
Makefile
@@ -1,4 +1,4 @@
|
|||||||
V=0.27
|
V=0.28
|
||||||
|
|
||||||
TOOLS = artools
|
TOOLS = artools
|
||||||
PREFIX ?= /usr
|
PREFIX ?= /usr
|
||||||
@@ -41,7 +41,11 @@ PKG_BIN = \
|
|||||||
bin/pkg/signpkg \
|
bin/pkg/signpkg \
|
||||||
bin/pkg/checkrepo \
|
bin/pkg/checkrepo \
|
||||||
bin/pkg/gitearepo \
|
bin/pkg/gitearepo \
|
||||||
bin/pkg/tidyarch
|
bin/pkg/tidyarch \
|
||||||
|
bin/pkg/mkdepgraph \
|
||||||
|
bin/pkg/diffpkg \
|
||||||
|
bin/pkg/makerepropkg \
|
||||||
|
bin/pkg/export-pkgbuild-keys
|
||||||
|
|
||||||
LN_COMMITPKG = \
|
LN_COMMITPKG = \
|
||||||
extrapkg \
|
extrapkg \
|
||||||
@@ -72,20 +76,6 @@ LN_BUILDPKG = \
|
|||||||
buildpkg-kde-wobble \
|
buildpkg-kde-wobble \
|
||||||
buildpkg-gnome-wobble
|
buildpkg-gnome-wobble
|
||||||
|
|
||||||
LN_DEPLOYPKG = \
|
|
||||||
deploypkg-system \
|
|
||||||
deploypkg-world \
|
|
||||||
deploypkg-gremlins \
|
|
||||||
deploypkg-goblins \
|
|
||||||
deploypkg-galaxy \
|
|
||||||
deploypkg-galaxy-gremlins \
|
|
||||||
deploypkg-galaxy-goblins \
|
|
||||||
deploypkg-lib32 \
|
|
||||||
deploypkg-lib32-gremlins \
|
|
||||||
deploypkg-lib32-goblins \
|
|
||||||
deploypkg-kde-wobble \
|
|
||||||
deploypkg-gnome-wobble
|
|
||||||
|
|
||||||
PKG_DATA = \
|
PKG_DATA = \
|
||||||
data/pacman/makepkg.conf \
|
data/pacman/makepkg.conf \
|
||||||
data/valid-names.conf
|
data/valid-names.conf
|
||||||
@@ -156,9 +146,6 @@ install_pkg:
|
|||||||
|
|
||||||
for l in $(LN_COMMITPKG); do $(LN) commitpkg $(DESTDIR)$(BINDIR)/$$l; done
|
for l in $(LN_COMMITPKG); do $(LN) commitpkg $(DESTDIR)$(BINDIR)/$$l; done
|
||||||
for l in $(LN_BUILDPKG); do $(LN) buildpkg $(DESTDIR)$(BINDIR)/$$l; done
|
for l in $(LN_BUILDPKG); do $(LN) buildpkg $(DESTDIR)$(BINDIR)/$$l; done
|
||||||
for l in $(LN_DEPLOYPKG); do $(LN) deploypkg $(DESTDIR)$(BINDIR)/$$l; done
|
|
||||||
|
|
||||||
$(LN) artix-chroot $(DESTDIR)$(BINDIR)/artools-chroot
|
|
||||||
|
|
||||||
install $(DIRMODE) $(DESTDIR)$(DATADIR)/$(TOOLS)
|
install $(DIRMODE) $(DESTDIR)$(DATADIR)/$(TOOLS)
|
||||||
install $(FILEMODE) $(PKG_DATA) $(DESTDIR)$(DATADIR)/$(TOOLS)
|
install $(FILEMODE) $(PKG_DATA) $(DESTDIR)$(DATADIR)/$(TOOLS)
|
||||||
|
@@ -23,7 +23,7 @@ artools
|
|||||||
|
|
||||||
- pkg:
|
- pkg:
|
||||||
* namcap
|
* namcap
|
||||||
* git-subrepo
|
* ruby-braid
|
||||||
* rsync
|
* rsync
|
||||||
|
|
||||||
- iso:
|
- iso:
|
||||||
|
@@ -18,112 +18,21 @@ m4_include(lib/base/message.sh)
|
|||||||
m4_include(lib/base/chroot.sh)
|
m4_include(lib/base/chroot.sh)
|
||||||
m4_include(lib/base/mount.sh)
|
m4_include(lib/base/mount.sh)
|
||||||
|
|
||||||
#{{{ functions
|
|
||||||
|
|
||||||
chroot_part_mount() {
|
|
||||||
msg2 "mount: [%s]" "$2"
|
|
||||||
mount "$@" && CHROOT_ACTIVE_PART_MOUNTS=("$2" "${CHROOT_ACTIVE_PART_MOUNTS[@]}")
|
|
||||||
}
|
|
||||||
|
|
||||||
chroot_part_umount() {
|
|
||||||
chroot_api_umount
|
|
||||||
msg2 "umount: [%s]" "${CHROOT_ACTIVE_PART_MOUNTS[@]}"
|
|
||||||
umount "${CHROOT_ACTIVE_PART_MOUNTS[@]}"
|
|
||||||
unset CHROOT_ACTIVE_PART_MOUNTS
|
|
||||||
}
|
|
||||||
|
|
||||||
detect(){
|
|
||||||
local detected
|
|
||||||
detected="$(os-prober | tr ' ' '_' | paste -s -d ' ')"
|
|
||||||
printf "%s\n" "${detected}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# $1: os-prober array
|
|
||||||
get_os_name(){
|
|
||||||
local str=$1
|
|
||||||
str="${str#*:}"
|
|
||||||
str="${str#*:}"
|
|
||||||
str="${str%:*}"
|
|
||||||
printf "%s\n" "$str"
|
|
||||||
}
|
|
||||||
|
|
||||||
mount_os(){
|
|
||||||
CHROOT_ACTIVE_PART_MOUNTS=()
|
|
||||||
CHROOT_ACTIVE_MOUNTS=()
|
|
||||||
|
|
||||||
trap_setup chroot_part_umount
|
|
||||||
|
|
||||||
chroot_part_mount "$2" "$1"
|
|
||||||
|
|
||||||
local mounts
|
|
||||||
mounts=$(perl -ane 'printf("%s:%s\n", @F[0,1]) if $F[0] =~ m#^UUID=#;' "$1"/etc/fstab)
|
|
||||||
|
|
||||||
for entry in ${mounts}; do
|
|
||||||
entry=${entry//UUID=}
|
|
||||||
local dev=${entry%:*} mp=${entry#*:}
|
|
||||||
case "${entry#*:}" in
|
|
||||||
'/'|'swap'|'none') continue ;;
|
|
||||||
*) chroot_part_mount "/dev/disk/by-uuid/${dev}" "$1${mp}" ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
chroot_setup "$1" true
|
|
||||||
chroot_add_resolv_conf "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
select_os(){
|
|
||||||
local os_list=( "$(detect)" ) count=${#os_list[@]}
|
|
||||||
if [[ ${count} -gt 1 ]];then
|
|
||||||
msg "Detected systems:"
|
|
||||||
local i=0
|
|
||||||
for os in "${os_list[@]}"; do
|
|
||||||
local last=${os##*:}
|
|
||||||
case $last in
|
|
||||||
'efi') count=$((count-1)) ;;
|
|
||||||
*) msg2 "$i) $(get_os_name "$os")"; i=$((i+1)) ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
i=0
|
|
||||||
msg "Select system to mount [0-%s] : " "$((count-1))"
|
|
||||||
read -r select
|
|
||||||
else
|
|
||||||
select=0
|
|
||||||
fi
|
|
||||||
local os_str=${os_list[$select]} type
|
|
||||||
type=$os_str
|
|
||||||
root=${os_str%%:*}
|
|
||||||
type=${type##*:}
|
|
||||||
if [[ "${type##*:}" == 'linux' ]];then
|
|
||||||
msg "Mounting (%s) [%s]" "$(get_os_name "$os_str")" "$root"
|
|
||||||
mount_os "$1" "$root"
|
|
||||||
else
|
|
||||||
die "You can't mount %s!" "$select"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#}}}
|
|
||||||
|
|
||||||
automount=false
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
printf 'usage: %s -a [or] %s chroot-dir [command]\n' "${0##*/}" "${0##*/}"
|
printf 'usage: %s chroot-dir [command]\n' "${0##*/}"
|
||||||
printf ' -a Automount detected linux system\n'
|
|
||||||
printf ' -h Print this help message\n'
|
printf ' -h Print this help message\n'
|
||||||
printf '\n'
|
printf '\n'
|
||||||
printf " If 'command' is unspecified, %s will launch /bin/sh.\n" "${0##*/}"
|
printf " If 'command' is unspecified, %s will launch /bin/sh.\n" "${0##*/}"
|
||||||
printf '\n'
|
printf '\n'
|
||||||
printf " If 'automount' is true, %s will launch /bin/bash\n" "${0##*/}"
|
|
||||||
printf ' and %s\n' "${chrootdir}"
|
|
||||||
printf '\n'
|
|
||||||
printf '\n'
|
printf '\n'
|
||||||
exit "$1"
|
exit "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
opts=':ha'
|
opts=':h'
|
||||||
|
|
||||||
while getopts ${opts} arg; do
|
while getopts ${opts} arg; do
|
||||||
case "${arg}" in
|
case "${arg}" in
|
||||||
a) automount=true ;;
|
|
||||||
h|?) usage 0 ;;
|
h|?) usage 0 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -131,20 +40,12 @@ shift $(( OPTIND - 1 ))
|
|||||||
|
|
||||||
check_root
|
check_root
|
||||||
|
|
||||||
if ${automount};then
|
|
||||||
chrootdir=/mnt
|
|
||||||
run_args=(/bin/bash)
|
|
||||||
|
|
||||||
select_os "${chrootdir}"
|
|
||||||
else
|
|
||||||
chrootdir=$1
|
chrootdir=$1
|
||||||
shift
|
shift
|
||||||
run_args=("$@")
|
|
||||||
|
|
||||||
[[ -d ${chrootdir} ]] || die "Can't create chroot on non-directory %s" "${chrootdir}"
|
[[ -d ${chrootdir} ]] || die "Can't create chroot on non-directory %s" "${chrootdir}"
|
||||||
|
|
||||||
chroot_api_mount "${chrootdir}" || die "failed to setup API filesystems in chroot %s" "${chrootdir}"
|
chroot_api_mount "${chrootdir}" || die "failed to setup API filesystems in chroot %s" "${chrootdir}"
|
||||||
chroot_add_resolv_conf "${chrootdir}"
|
chroot_add_resolv_conf "${chrootdir}"
|
||||||
fi
|
|
||||||
|
|
||||||
SHELL=/bin/sh unshare --fork --pid chroot "${chrootdir}" "${run_args[@]}"
|
SHELL=/bin/sh unshare --fork --pid chroot "${chrootdir}" "$@"
|
||||||
|
@@ -90,11 +90,11 @@ for f in "${files[@]}"; do
|
|||||||
cp "$f" "$working_dir$f"
|
cp "$f" "$working_dir$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
basestrap -${umode}Mc ${pacman_conf:+-C "$pacman_conf"} "$working_dir" \
|
unshare --mount basestrap -${umode}Mc ${pacman_conf:+-C "$pacman_conf"} "$working_dir" \
|
||||||
"${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'
|
"${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'
|
||||||
|
|
||||||
printf '%s.UTF-8 UTF-8\n' en_US de_DE > "$working_dir/etc/locale.gen"
|
printf '%s.UTF-8 UTF-8\n' C en_US de_DE > "$working_dir/etc/locale.gen"
|
||||||
printf 'LANG=en_US.UTF-8\n' > "$working_dir/etc/locale.conf"
|
printf 'LANG=C.UTF-8\n' > "$working_dir/etc/locale.conf"
|
||||||
# printf 'KEYMAP=en\n' > "$working_dir/etc/vconsole.conf"
|
# printf 'KEYMAP=en\n' > "$working_dir/etc/vconsole.conf"
|
||||||
printf "%s\n" "${CHROOTVERSION}" > "$working_dir/.artools"
|
printf "%s\n" "${CHROOTVERSION}" > "$working_dir/.artools"
|
||||||
|
|
||||||
|
@@ -28,9 +28,9 @@ batch_move() {
|
|||||||
src=${src#*:}
|
src=${src#*:}
|
||||||
local dest=${entry%%:*}
|
local dest=${entry%%:*}
|
||||||
if ${runlist}; then
|
if ${runlist}; then
|
||||||
"${dest}"pkg -s "${src}" -u -p "${pkg}"
|
"${dest}"pkg -s "${src}" -p "${pkg}"
|
||||||
else
|
else
|
||||||
msg "%s" "${dest}pkg -s ${src} -u -p ${pkg}"
|
msg "%s" "${dest}pkg -s ${src} -p ${pkg}"
|
||||||
fi
|
fi
|
||||||
done < "$pkglist"
|
done < "$pkglist"
|
||||||
}
|
}
|
||||||
@@ -65,10 +65,10 @@ batch_update() {
|
|||||||
local dest=${entry%:*}
|
local dest=${entry%:*}
|
||||||
if ${runlist}; then
|
if ${runlist}; then
|
||||||
buildtree -i -p "${pkg}"
|
buildtree -i -p "${pkg}"
|
||||||
"${dest}"pkg -u -p "${pkg}"
|
"${dest}"pkg -p "${pkg}"
|
||||||
else
|
else
|
||||||
msg "buildtree -i -p ${pkg}"
|
msg "buildtree -i -p ${pkg}"
|
||||||
msg2 "${dest}pkg -u -p ${pkg}"
|
msg2 "${dest}pkg -p ${pkg}"
|
||||||
fi
|
fi
|
||||||
done < "$pkglist"
|
done < "$pkglist"
|
||||||
}
|
}
|
||||||
@@ -78,8 +78,8 @@ batch_update() {
|
|||||||
usage() {
|
usage() {
|
||||||
printf 'Usage: %s [optional listname]\n' "${0##*/}"
|
printf 'Usage: %s [optional listname]\n' "${0##*/}"
|
||||||
printf ' -r Run generated commands\n'
|
printf ' -r Run generated commands\n'
|
||||||
printf ' -c Create subrepos from list\n'
|
printf ' -c Create pkgrepos from list\n'
|
||||||
printf ' -u Update subrepos from list\n'
|
printf ' -u Update pkgrepos from list\n'
|
||||||
printf ' -h This help\n'
|
printf ' -h This help\n'
|
||||||
printf '\n'
|
printf '\n'
|
||||||
printf '\n'
|
printf '\n'
|
||||||
|
@@ -23,23 +23,31 @@ m4_include(lib/pkg/jenkins.sh)
|
|||||||
|
|
||||||
#{{{ new git repo
|
#{{{ new git repo
|
||||||
|
|
||||||
subrepo_new(){
|
pkgrepo_new(){
|
||||||
cd "${TREE_DIR_ARTIX}/${group}" || return
|
cd "${TREE_DIR_ARTIX}/${group}" || return
|
||||||
|
|
||||||
local org gitname
|
local org gitname
|
||||||
org=$(get_pkg_org "${package}")
|
org=$(get_pkg_org "${package}")
|
||||||
gitname=$(get_compliant_name "${package}")
|
gitname=$(get_compliant_name "${package}")
|
||||||
|
|
||||||
|
if [[ ! -d "${package}" ]]; then
|
||||||
gitearepo -cr "$gitname"
|
gitearepo -cr "$gitname"
|
||||||
|
|
||||||
add_team_to_repo "$gitname" "$org" "${team}"
|
add_team_to_repo "$gitname" "$org" "${team}"
|
||||||
|
|
||||||
msg2 "Subrepo clone [%s] from (%s)" "${package}" "$org/$gitname"
|
msg2 "Adding [%s] from (%s)" "${package}" "$org/$gitname"
|
||||||
git subrepo clone "${GIT_SSH}":"$org/$gitname".git "${package}"
|
braid add "${GIT_SSH}":"$org/$gitname".git "${package}"
|
||||||
|
|
||||||
prepare_dir "${TREE_DIR_ARTIX}/${group}/${package}/trunk"
|
prepare_dir "${TREE_DIR_ARTIX}/${group}/${package}/trunk"
|
||||||
|
|
||||||
commit_jenkins_files "${package}"
|
commit_ci "${package}"
|
||||||
|
|
||||||
|
# if braid push "${package}"; then
|
||||||
|
# braid update "${package}"
|
||||||
|
# fi
|
||||||
|
else
|
||||||
|
die "Package %s already exists!" "${package}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#}}}
|
#}}}
|
||||||
@@ -52,7 +60,7 @@ config_tree() {
|
|||||||
Artix)
|
Artix)
|
||||||
if "$vars"; then
|
if "$vars"; then
|
||||||
dist_tree=("${ARTIX_TREE[@]}")
|
dist_tree=("${ARTIX_TREE[@]}")
|
||||||
dist_url="${GIT_SSH}:artixlinux"
|
dist_url="${GIT_SSH}:pkgbuild"
|
||||||
dist_dir=${TREE_DIR_ARTIX}
|
dist_dir=${TREE_DIR_ARTIX}
|
||||||
else
|
else
|
||||||
git config --bool pull.rebase true
|
git config --bool pull.rebase true
|
||||||
@@ -102,11 +110,20 @@ update_tree() {
|
|||||||
|
|
||||||
#{{{ patch
|
#{{{ patch
|
||||||
|
|
||||||
|
set_maintainer() {
|
||||||
|
local name email path="$1"
|
||||||
|
name=$(git config --get user.name)
|
||||||
|
email=$(git config --get user.email)
|
||||||
|
sed -e "1s|Maintainer:.*|Maintainer: $name <$email>|" \
|
||||||
|
-i "$path"/PKGBUILD
|
||||||
|
}
|
||||||
|
|
||||||
patch_pkg(){
|
patch_pkg(){
|
||||||
local pkgpath="$1"
|
local pkgpath="$1"
|
||||||
local pkg=${pkgpath%/*}
|
local pkg=${pkgpath%/*}
|
||||||
pkg=${pkg##*/}
|
pkg=${pkg##*/}
|
||||||
sed -e 's|arch-meson|artix-meson|' -i "$pkgpath"/PKGBUILD
|
sed -e 's|arch-meson|artix-meson|' -i "$pkgpath"/PKGBUILD
|
||||||
|
set_maintainer "$pkgpath"
|
||||||
case $pkg in
|
case $pkg in
|
||||||
glibc)
|
glibc)
|
||||||
msg2 "Patching %s" "$pkg"
|
msg2 "Patching %s" "$pkg"
|
||||||
@@ -188,14 +205,14 @@ from_arch(){
|
|||||||
[[ -z $srcpath ]] && die "Package '%s' does not exist!" "${package}"
|
[[ -z $srcpath ]] && die "Package '%s' does not exist!" "${package}"
|
||||||
|
|
||||||
repo=$(find_repo "$srcpath")
|
repo=$(find_repo "$srcpath")
|
||||||
msg "repo: %s" "${repo#*/}"
|
msg "repo: %s" "$repo"
|
||||||
|
|
||||||
archpath=$srcpath/$repo
|
archpath=$srcpath/repos/$repo
|
||||||
artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}")
|
artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}")
|
||||||
|
|
||||||
show_deps "$archpath"
|
show_deps "$archpath"
|
||||||
|
|
||||||
if [[ -f "$artixpath"/.gitrepo ]]; then
|
if [[ -f "$artixpath"/Jenkinsfile ]]; then
|
||||||
artixpath="$artixpath"/trunk
|
artixpath="$artixpath"/trunk
|
||||||
|
|
||||||
if [[ -d "$artixpath" ]];then
|
if [[ -d "$artixpath" ]];then
|
||||||
@@ -214,7 +231,7 @@ view_build(){
|
|||||||
archpath=$(find_pkg "${TREE_DIR_ARCH}" "${package}")
|
archpath=$(find_pkg "${TREE_DIR_ARCH}" "${package}")
|
||||||
[[ -z $archpath ]] && die "Package '%s' does not exist!" "${package}"
|
[[ -z $archpath ]] && die "Package '%s' does not exist!" "${package}"
|
||||||
repo=$(find_repo "${archpath}")
|
repo=$(find_repo "${archpath}")
|
||||||
archpath=$archpath/$repo
|
archpath=$archpath/repos/$repo
|
||||||
msg "repo: %s" "${repo#*/}"
|
msg "repo: %s" "${repo#*/}"
|
||||||
show_deps "$archpath"
|
show_deps "$archpath"
|
||||||
}
|
}
|
||||||
@@ -269,7 +286,7 @@ usage() {
|
|||||||
printf " -a Don't clone or pull arch repos\n"
|
printf " -a Don't clone or pull arch repos\n"
|
||||||
printf " -b Don't clone or pull artix repos\n"
|
printf " -b Don't clone or pull artix repos\n"
|
||||||
printf ' -i Import a package from arch repos\n'
|
printf ' -i Import a package from arch repos\n'
|
||||||
printf ' -n New remote subrepo and clone it\n'
|
printf ' -n New remote pkgrepo and add it\n'
|
||||||
printf ' -v Check if a package is in the artix tree(s)\n'
|
printf ' -v Check if a package is in the artix tree(s)\n'
|
||||||
printf ' -c View package depends\n'
|
printf ' -c View package depends\n'
|
||||||
printf ' -x Exclude testing (only with -i)\n'
|
printf ' -x Exclude testing (only with -i)\n'
|
||||||
@@ -314,4 +331,4 @@ ${check} && check_tree
|
|||||||
|
|
||||||
${import} && from_arch
|
${import} && from_arch
|
||||||
|
|
||||||
${createnew} && subrepo_new
|
${createnew} && pkgrepo_new
|
||||||
|
@@ -13,77 +13,12 @@
|
|||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
m4_include(lib/base/message.sh)
|
m4_include(lib/base/message.sh)
|
||||||
|
m4_include(lib/pkg/diff.sh)
|
||||||
|
|
||||||
shopt -s extglob
|
shopt -s extglob
|
||||||
|
|
||||||
load_makepkg_config
|
load_makepkg_config
|
||||||
|
|
||||||
#{{{ functions
|
|
||||||
|
|
||||||
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]
|
||||||
|
@@ -22,30 +22,6 @@ m4_include(lib/pkg/repo.sh)
|
|||||||
|
|
||||||
#{{{ functions
|
#{{{ functions
|
||||||
|
|
||||||
push_tree(){
|
|
||||||
local tree="$1"
|
|
||||||
msg "Update (%s)" "${tree}"
|
|
||||||
git push origin master
|
|
||||||
}
|
|
||||||
|
|
||||||
subrepo_push(){
|
|
||||||
local pkg="$1"
|
|
||||||
msg2 "Subrepo push (%s)" "$pkg"
|
|
||||||
git subrepo push "$pkg" || die "%s push failed" "$pkg"
|
|
||||||
}
|
|
||||||
|
|
||||||
subrepo_clean(){
|
|
||||||
local pkg="$1"
|
|
||||||
msg2 "Subrepo clean (%s)" "$pkg"
|
|
||||||
git subrepo clean "$pkg"
|
|
||||||
}
|
|
||||||
|
|
||||||
subrepo_pull(){
|
|
||||||
local pkg="$1"
|
|
||||||
msg2 "Subrepo pull (%s)" "$pkg"
|
|
||||||
git subrepo pull "$pkg"
|
|
||||||
}
|
|
||||||
|
|
||||||
check_rebuild(){
|
check_rebuild(){
|
||||||
if [[ -d "$CARCH"/"${valid_names[10]}" ]] \
|
if [[ -d "$CARCH"/"${valid_names[10]}" ]] \
|
||||||
&& [[ "${repo_dest}" == "${valid_names[7]}" ]]; then
|
&& [[ "${repo_dest}" == "${valid_names[7]}" ]]; then
|
||||||
@@ -121,13 +97,13 @@ repo_commit_pkg() {
|
|||||||
commit_msg=$(get_repo_commit_msg)
|
commit_msg=$(get_repo_commit_msg)
|
||||||
msg "Action: %s" "$commit_msg"
|
msg "Action: %s" "$commit_msg"
|
||||||
check_rebuild
|
check_rebuild
|
||||||
cp trunk/* "$CARCH/${repo_dest}"/
|
cp -r 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 "$CARCH/${repo_src}"/* "$CARCH/${repo_dest}"/
|
||||||
git rm -r "$CARCH/${repo_src}"
|
git rm -r "$CARCH/${repo_src}"
|
||||||
fi
|
fi
|
||||||
git add .
|
git add .
|
||||||
@@ -135,11 +111,11 @@ repo_commit_pkg() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run(){
|
run(){
|
||||||
local artixpath head group
|
local artixpath head tree
|
||||||
artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}")
|
artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}")
|
||||||
if [[ -n ${artixpath} ]];then
|
if [[ -n ${artixpath} ]];then
|
||||||
group=${artixpath%/*}
|
tree=${artixpath%/*}
|
||||||
cd "${group}" || return
|
cd "$tree" || return
|
||||||
head=$(get_local_head)
|
head=$(get_local_head)
|
||||||
|
|
||||||
cd "${artixpath}" || return
|
cd "${artixpath}" || return
|
||||||
@@ -152,21 +128,20 @@ run(){
|
|||||||
repo_commit_pkg
|
repo_commit_pkg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "${group}" || return
|
cd "$tree" || return
|
||||||
|
|
||||||
if ${push}; then
|
msg "Checking (%s) (Artix)" "${tree##*/}"
|
||||||
msg "Checking (%s) (Artix)" "${group##*/}"
|
pull_tree "${tree##*/}" "$head"
|
||||||
pull_tree "${group##*/}" "$head"
|
|
||||||
fi
|
|
||||||
|
|
||||||
subrepo_push "${package}"
|
|
||||||
subrepo_clean "${package}"
|
|
||||||
|
|
||||||
${push} && push_tree "${group##*/}"
|
|
||||||
|
|
||||||
|
if braid push "${package}"; then
|
||||||
|
braid update "${package}"
|
||||||
|
msg "Update (%s)" "${tree##*/}"
|
||||||
|
git push origin master
|
||||||
git prune
|
git prune
|
||||||
|
|
||||||
[[ "${cmd}" != 'commitpkg' ]] && check_team
|
[[ "${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
|
||||||
@@ -192,7 +167,6 @@ load_valid_names
|
|||||||
repo_src='trunk'
|
repo_src='trunk'
|
||||||
package=''
|
package=''
|
||||||
remove=false
|
remove=false
|
||||||
push=false
|
|
||||||
|
|
||||||
pkgbuild=trunk/PKGBUILD
|
pkgbuild=trunk/PKGBUILD
|
||||||
|
|
||||||
@@ -204,21 +178,19 @@ usage() {
|
|||||||
printf " -s <name> Source repository [default: %s]\n" "${repo_src}"
|
printf " -s <name> Source repository [default: %s]\n" "${repo_src}"
|
||||||
printf ' -p <pkg> Package name\n'
|
printf ' -p <pkg> Package name\n'
|
||||||
printf ' -r Delete from repo (commitpkg only)\n'
|
printf ' -r Delete from repo (commitpkg only)\n'
|
||||||
printf ' -u Push\n'
|
|
||||||
printf ' -h This help\n'
|
printf ' -h This help\n'
|
||||||
printf '\n'
|
printf '\n'
|
||||||
printf '\n'
|
printf '\n'
|
||||||
exit "$1"
|
exit "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
opts='p:s:urh'
|
opts='p:s:rh'
|
||||||
|
|
||||||
while getopts "${opts}" arg; do
|
while getopts "${opts}" arg; do
|
||||||
case "${arg}" in
|
case "${arg}" in
|
||||||
s) repo_src="$OPTARG" ;;
|
s) repo_src="$OPTARG" ;;
|
||||||
p) package="$OPTARG" ;;
|
p) package="$OPTARG" ;;
|
||||||
r) remove=true ;;
|
r) remove=true ;;
|
||||||
u) push=true ;;
|
|
||||||
h|?) usage 0 ;;
|
h|?) usage 0 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@@ -31,23 +31,32 @@ write_list(){
|
|||||||
printf "%s\n" "$line" >> "${TREE_DIR_ARTIX}"/"$name".list
|
printf "%s\n" "$line" >> "${TREE_DIR_ARTIX}"/"$name".list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_group() {
|
||||||
|
local group
|
||||||
|
group="${artixpath%/*}"
|
||||||
|
group=${group##*/}
|
||||||
|
printf "%s\n" "${group#*-}"
|
||||||
|
}
|
||||||
|
|
||||||
compare_m(){
|
compare_m(){
|
||||||
case ${artixrepo} in
|
# if [ "$result" -eq 0 ];then
|
||||||
|
case "$artixrepo" in
|
||||||
*testing*|*staging*|*rebuild)
|
*testing*|*staging*|*rebuild)
|
||||||
if [[ "${a}" == "${b}" ]]; then
|
if [[ "${archrepo}" == "${artixrepo}" ]]; then
|
||||||
msg_row "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
msg_row "${table}" "${archrepo}" "${artixrepo}" "$pkg" "$archver" "$artixver" "$(get_group)"
|
||||||
elif [[ "${a}" == 'staging' && "${b}" == 'rebuild' ]]; then
|
elif [[ "${archrepo}" == 'staging' && "${artixrepo}" == 'rebuild' ]]; then
|
||||||
msg_row_yellow "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
msg_row_yellow "${table}" "${archrepo}" "${artixrepo}" "$pkg" "$archver" "$artixver" "$(get_group)"
|
||||||
else
|
else
|
||||||
msg_row_green "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
msg_row_green "${table}" "${archrepo}" "${artixrepo}" "$pkg" "$archver" "$artixver" "$(get_group)"
|
||||||
if [[ -n "$archrepo" ]]; then
|
if [[ -n "${archrepo}" ]]; then
|
||||||
write_list "${a}:${b}:$pkg" pkg_moves
|
write_list "${archrepo}:${artixrepo}:$pkg" pkg_moves
|
||||||
else
|
else
|
||||||
write_list "@repo@:${b}:$pkg" artix
|
write_list "@repo@:${artixrepo}:$pkg" artix
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
# fi
|
||||||
}
|
}
|
||||||
|
|
||||||
compare_u(){
|
compare_u(){
|
||||||
@@ -55,15 +64,15 @@ compare_u(){
|
|||||||
# local arel=${archver##*-} brel=${artixver##*-}
|
# local arel=${archver##*-} brel=${artixver##*-}
|
||||||
# local reldiff
|
# local reldiff
|
||||||
# reldiff=$(( $arel-${brel%.*} ))
|
# reldiff=$(( $arel-${brel%.*} ))
|
||||||
msg_row_red "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
msg_row_red "${table}" "${archrepo}" "${artixrepo}" "$pkg" "$archver" "$artixver" "$(get_group)"
|
||||||
write_list "${a}:$pkg" pkg_upgrades
|
write_list "${archrepo}:$pkg" pkg_upgrades
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
compare_d(){
|
compare_d(){
|
||||||
if [ "$result" -eq 1 ];then
|
if [ "$result" -eq 1 ];then
|
||||||
if [[ -n "$archver" ]] && [[ -n "$archrepo" ]];then
|
if [[ -n "$archver" ]] && [[ -n "${archrepo}" ]];then
|
||||||
msg_row_yellow "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
msg_row_yellow "${table}" "${archrepo}" "${artixrepo}" "$pkg" "$archver" "$artixver" "$(get_group)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -78,27 +87,22 @@ get_archpath(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
pre_compare(){
|
pre_compare(){
|
||||||
local func="$1" pkgpath="$2" result group pkg
|
local artixpath="$1" func="$2" pkg
|
||||||
group="${pkgpath%/*}"
|
pkg=${artixpath##*/}
|
||||||
group=${group##*/}
|
|
||||||
pkg=${pkgpath##*/}
|
|
||||||
|
|
||||||
local artixrepo archrepo pkgbuild artixver archver archpath node a b
|
local artixrepo archrepo pkgbuild artixver archver archpath epoch
|
||||||
artixrepo=$(find_repo "$pkgpath")
|
|
||||||
pkgbuild=$pkgpath/$artixrepo/PKGBUILD
|
|
||||||
|
|
||||||
if [[ -f $pkgbuild ]]; then
|
artixrepo=$(find_repo "$artixpath")
|
||||||
|
pkgbuild=$artixpath/$CARCH/$artixrepo/PKGBUILD
|
||||||
|
|
||||||
|
if [[ -f "$pkgbuild" ]]; then
|
||||||
# shellcheck disable=1090
|
# shellcheck disable=1090
|
||||||
. "$pkgbuild" 2>/dev/null
|
. "$pkgbuild" 2>/dev/null
|
||||||
artixver=$(get_full_version)
|
artixver=$(get_full_version)
|
||||||
archpath=$(get_archpath "$pkg")
|
archpath=$(get_archpath "$pkg")
|
||||||
archrepo=$(find_repo "${archpath}")
|
archrepo=$(find_repo "$archpath")
|
||||||
pkgbuild=$archpath/$archrepo/PKGBUILD
|
pkgbuild=$archpath/repos/$archrepo/PKGBUILD
|
||||||
node=${artixrepo%/*}
|
archrepo="${archrepo%-*}"
|
||||||
a=${archrepo#*/} b=${artixrepo#*/}
|
|
||||||
a="${a%-*}"
|
|
||||||
|
|
||||||
[[ "$node" != "$CARCH" ]] && b=${b%-*}
|
|
||||||
|
|
||||||
if [[ -f "$pkgbuild" ]]; then
|
if [[ -f "$pkgbuild" ]]; then
|
||||||
# shellcheck disable=1090
|
# shellcheck disable=1090
|
||||||
@@ -106,27 +110,26 @@ pre_compare(){
|
|||||||
archver=$(get_full_version)
|
archver=$(get_full_version)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local result
|
||||||
result=$(vercmp "$artixver" "$archver")
|
result=$(vercmp "$artixver" "$archver")
|
||||||
|
|
||||||
"$func"
|
"$func"
|
||||||
|
|
||||||
unset epoch
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
compare_upgrades(){
|
compare_upgrades(){
|
||||||
local pkgpath="${1%/*}"
|
local artixpath="${1%/*}"
|
||||||
pre_compare compare_u "$pkgpath"
|
pre_compare "$artixpath" compare_u
|
||||||
}
|
}
|
||||||
|
|
||||||
compare_downgrades(){
|
compare_downgrades(){
|
||||||
local pkgpath="${1%/*}"
|
local artixpath="${1%/*}"
|
||||||
pre_compare compare_d "$pkgpath"
|
pre_compare "$artixpath" compare_d
|
||||||
}
|
}
|
||||||
|
|
||||||
compare_move(){
|
compare_move(){
|
||||||
local pkgpath="${1%/*}"
|
local artixpath="${1%/*}"
|
||||||
pre_compare compare_m "$pkgpath"
|
pre_compare "$artixpath" compare_m
|
||||||
}
|
}
|
||||||
|
|
||||||
#}}}
|
#}}}
|
||||||
@@ -165,7 +168,7 @@ upgrades=false
|
|||||||
downgrades=false
|
downgrades=false
|
||||||
move=false
|
move=false
|
||||||
|
|
||||||
readonly table="%-18s %-18s %-25s %-27s %-27s %-10s"
|
readonly table="%-18s %-18s %-29s %-27s %-27s %-7s"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
printf 'Usage: %s [options]\n' "${0##*/}"
|
printf 'Usage: %s [options]\n' "${0##*/}"
|
||||||
|
229
bin/pkg/diffpkg.in
Normal file
229
bin/pkg/diffpkg.in
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
|
m4_include(lib/base/message.sh)
|
||||||
|
m4_include(lib/pkg/diff.sh)
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<- _EOF_
|
||||||
|
Usage: ${BASH_SOURCE[0]##*/} [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.
|
||||||
|
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, and diffpkg will proceed as though this filename was initially
|
||||||
|
specified.
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-M, --makepkg-config Set an alternate makepkg configuration file
|
||||||
|
-v, --verbose Provide more detailed/unfiltered output
|
||||||
|
-h, --help Show this help text
|
||||||
|
|
||||||
|
MODES
|
||||||
|
-l, --list Activate content list diff mode (default)
|
||||||
|
-d, --diffoscope Activate diffoscope diff mode
|
||||||
|
-p, --pkginfo Activate .PKGINFO diff mode
|
||||||
|
-b, --buildinfo Activate .BUILDINFO diff mode
|
||||||
|
_EOF_
|
||||||
|
}
|
||||||
|
|
||||||
|
MAKEPKG_CONF=/etc/makepkg.conf
|
||||||
|
VERBOSE=0
|
||||||
|
TARLIST=0
|
||||||
|
DIFFOSCOPE=0
|
||||||
|
PKGINFO=0
|
||||||
|
BUILDINFO=0
|
||||||
|
|
||||||
|
# option checking
|
||||||
|
while (( $# )); do
|
||||||
|
case $1 in
|
||||||
|
-h|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-M|--makepkg-config)
|
||||||
|
MAKEPKG_CONF="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
-l|--list)
|
||||||
|
TARLIST=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-d|--diffoscope)
|
||||||
|
DIFFOSCOPE=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-p|--pkginfo)
|
||||||
|
PKGINFO=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-b|--buildinfo)
|
||||||
|
BUILDINFO=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-v|--verbose)
|
||||||
|
VERBOSE=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
-*,--*)
|
||||||
|
die "invalid argument: %s" "$1"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! (( DIFFOSCOPE || TARLIST || PKGINFO || BUILDINFO )); then
|
||||||
|
TARLIST=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source makepkg.conf; fail if it is not found
|
||||||
|
if [[ -r "${MAKEPKG_CONF}" ]]; then
|
||||||
|
# shellcheck source=makepkg-x86_64.conf
|
||||||
|
source "${MAKEPKG_CONF}"
|
||||||
|
else
|
||||||
|
die "${MAKEPKG_CONF} not found!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source user-specific makepkg.conf overrides
|
||||||
|
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf"
|
||||||
|
elif [[ -r "$HOME/.makepkg.conf" ]]; then
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$HOME/.makepkg.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
STARTDIR=$(pwd)
|
||||||
|
trap 'rm -rf $TMPDIR' EXIT INT TERM QUIT
|
||||||
|
TMPDIR=$(mktemp -d --tmpdir diffpkg-script.XXXXXXXX)
|
||||||
|
export TMPDIR
|
||||||
|
|
||||||
|
tar_list() {
|
||||||
|
bsdtar tf "$*" | if (( VERBOSE )); then
|
||||||
|
cat
|
||||||
|
else
|
||||||
|
sed -E 's|^usr/lib/modules/[0-9][^/]+|usr/lib/modules/[…]|g'
|
||||||
|
fi | sort
|
||||||
|
}
|
||||||
|
|
||||||
|
diff_pkgs() {
|
||||||
|
local oldpkg newpkg
|
||||||
|
oldpkg=$(readlink -m "$1")
|
||||||
|
newpkg=$(readlink -m "$2")
|
||||||
|
|
||||||
|
[[ -f $oldpkg ]] || die "No such file: %s" "${oldpkg}"
|
||||||
|
[[ -f $newpkg ]] || die "No such file: %s" "${newpkg}"
|
||||||
|
|
||||||
|
if (( TARLIST )); then
|
||||||
|
tar_list "$oldpkg" > "$TMPDIR/filelist-old"
|
||||||
|
tar_list "$newpkg" > "$TMPDIR/filelist"
|
||||||
|
|
||||||
|
sdiff -s "$TMPDIR/filelist-old" "$TMPDIR/filelist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( PKGINFO )); then
|
||||||
|
bsdtar xOqf "$oldpkg" .PKGINFO > "$TMPDIR/pkginfo-old"
|
||||||
|
bsdtar xOqf "$newpkg" .PKGINFO > "$TMPDIR/pkginfo"
|
||||||
|
|
||||||
|
sdiff -s "$TMPDIR/pkginfo-old" "$TMPDIR/pkginfo"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( BUILDINFO )); then
|
||||||
|
bsdtar xOqf "$oldpkg" .BUILDINFO > "$TMPDIR/buildinfo-old"
|
||||||
|
bsdtar xOqf "$newpkg" .BUILDINFO > "$TMPDIR/buildinfo"
|
||||||
|
|
||||||
|
sdiff -s "$TMPDIR/buildinfo-old" "$TMPDIR/buildinfo"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( DIFFOSCOPE )); then
|
||||||
|
diffoscope "$oldpkg" "$newpkg"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch_pkg() {
|
||||||
|
local pkg pkgdest pkgurl
|
||||||
|
case $1 in
|
||||||
|
*://*)
|
||||||
|
pkgurl=$1 ;;
|
||||||
|
/*|*/*)
|
||||||
|
pkgurl=$(readlink -m "$1") ;;
|
||||||
|
*.pkg.tar*)
|
||||||
|
pkgurl=$1 ;;
|
||||||
|
'')
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
pkg=$1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[[ -n $pkgurl ]] || pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$pkg") ||
|
||||||
|
die "Couldn't download previous package for %s." "$pkg"
|
||||||
|
|
||||||
|
pkg=${pkgurl##*/}
|
||||||
|
pkgdest=$(mktemp -t -d "${pkg}-XXXXXX")/${pkg}
|
||||||
|
|
||||||
|
if [[ $pkgurl = file://* || ( $pkgurl = /* && -f $pkgurl ) ]]; then
|
||||||
|
ln -sf "${pkgurl#file://}" "$pkgdest"
|
||||||
|
elif [[ -f "$PKGDEST/$pkg" ]]; then
|
||||||
|
ln -sf "$PKGDEST/$pkg" "$pkgdest"
|
||||||
|
elif [[ -f "$STARTDIR/$pkg" ]]; then
|
||||||
|
ln -sf "$STARTDIR/$pkg" "$pkgdest"
|
||||||
|
elif [[ $pkgurl = *://* ]]; then
|
||||||
|
curl -fsLC - --retry 3 --retry-delay 3 -o "$pkgdest" "$pkgurl" || \
|
||||||
|
die "Couldn't download %s" "$pkgurl"
|
||||||
|
else
|
||||||
|
die "File not found: %s" "$pkgurl"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$pkgdest"
|
||||||
|
}
|
||||||
|
|
||||||
|
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."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# shellcheck source=PKGBUILD.proto
|
||||||
|
. ./PKGBUILD
|
||||||
|
if [[ ${arch[0]} == 'any' ]]; then
|
||||||
|
CARCH='any'
|
||||||
|
fi
|
||||||
|
|
||||||
|
for _pkgname in "${pkgname[@]}"; do
|
||||||
|
comparepkg=$_pkgname
|
||||||
|
pkgurl=
|
||||||
|
target_pkgver=$(get_full_version "$_pkgname")
|
||||||
|
if ! pkgfile=$(find_cached_package "$_pkgname" "$target_pkgver" "$CARCH"); then
|
||||||
|
die 'tarball not found for package: %s' "${_pkgname}-$target_pkgver"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ln -s "$pkgfile" "$TMPDIR"
|
||||||
|
|
||||||
|
if (( $# )); then
|
||||||
|
comparepkg="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
oldpkg=$(fetch_pkg "$comparepkg") || exit 1
|
||||||
|
|
||||||
|
diff_pkgs "$oldpkg" "$pkgfile"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
file1=$(fetch_pkg "$1") || exit 1
|
||||||
|
file2=$(fetch_pkg "$2") || exit 1
|
||||||
|
|
||||||
|
diff_pkgs "$file1" "$file2"
|
||||||
|
fi
|
70
bin/pkg/export-pkgbuild-keys.in
Normal file
70
bin/pkg/export-pkgbuild-keys.in
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
m4_include(lib/base/message.sh)
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<- _EOF_
|
||||||
|
Usage: ${BASH_SOURCE[0]##*/}
|
||||||
|
|
||||||
|
Export the PGP keys from a PKGBUILDs validpgpkeys array into the keys/pgp/
|
||||||
|
subdirectory. Useful for distributing packager validated source signing
|
||||||
|
keys alongside PKGBUILDs.
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-h, --help Show this help text
|
||||||
|
_EOF_
|
||||||
|
}
|
||||||
|
|
||||||
|
# option checking
|
||||||
|
while (( $# )); do
|
||||||
|
case $1 in
|
||||||
|
-h|--help) usage; exit 0 ;;
|
||||||
|
*) die "invalid argument: %s" "$1" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ ! -f PKGBUILD ]]; then
|
||||||
|
die "This must be run a directory containing a PKGBUILD."
|
||||||
|
fi
|
||||||
|
|
||||||
|
mapfile -t validpgpkeys < <(
|
||||||
|
# shellcheck source=PKGBUILD.proto
|
||||||
|
. ./PKGBUILD
|
||||||
|
if (( ${#validpgpkeys[@]} )); then
|
||||||
|
printf "%s\n" "${validpgpkeys[@]}"
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
|
||||||
|
msg "Exporting ${#validpgpkeys[@]} PGP keys..."
|
||||||
|
if (( ${#validpgpkeys[@]} == 0 )); then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
trap 'rm -rf $TEMPDIR' EXIT INT TERM QUIT
|
||||||
|
TEMPDIR=$(mktemp -d --tmpdir export-pkgbuild-keys.XXXXXXXXXX)
|
||||||
|
|
||||||
|
mkdir -p keys/pgp
|
||||||
|
error=0
|
||||||
|
|
||||||
|
for key in "${validpgpkeys[@]}"; do
|
||||||
|
gpg --output "$TEMPDIR/$key.asc" --armor --export --export-options export-minimal "$key" 2>/dev/null
|
||||||
|
|
||||||
|
# gpg does not give a non-zero return value if it fails to export...
|
||||||
|
if [[ -f $TEMPDIR/$key.asc ]]; then
|
||||||
|
msg2 "Exported $key"
|
||||||
|
mv "$TEMPDIR/$key.asc" "keys/pgp/$key.asc"
|
||||||
|
else
|
||||||
|
if [[ -f keys/pgp/$key.asc ]]; then
|
||||||
|
warning "Failed to update key: $key"
|
||||||
|
else
|
||||||
|
error "Key unavailable: $key"
|
||||||
|
error=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if (( error )); then
|
||||||
|
die "Failed to export all \'validpgpkeys\' entries."
|
||||||
|
fi
|
271
bin/pkg/makerepropkg.in
Normal file
271
bin/pkg/makerepropkg.in
Normal file
@@ -0,0 +1,271 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# makerepropkg - rebuild a package to see if it is reproducible
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019 by Eli Schwartz <eschwartz@archlinux.org>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
m4_include(lib/util-base.sh)
|
||||||
|
m4_include(lib/base/message.sh)
|
||||||
|
m4_include(lib/base/chroot.sh)
|
||||||
|
m4_include(lib/base/chroot.sh)
|
||||||
|
|
||||||
|
declare -A buildinfo
|
||||||
|
declare -a buildenv buildopts installed installpkgs
|
||||||
|
|
||||||
|
archiveurl='https://archive.artixlinux.org/packages'
|
||||||
|
buildroot="${CHROOTS_DIR}"/reproducible
|
||||||
|
diffoscope=0
|
||||||
|
|
||||||
|
chroot=$USER
|
||||||
|
[[ -n ${SUDO_USER:-} ]] && chroot=$SUDO_USER
|
||||||
|
[[ -z "$chroot" || $chroot = root ]] && chroot=copy
|
||||||
|
|
||||||
|
parse_buildinfo() {
|
||||||
|
local line var val
|
||||||
|
|
||||||
|
while read -r line; do
|
||||||
|
var="${line%% = *}"
|
||||||
|
val="${line#* = }"
|
||||||
|
case ${var} in
|
||||||
|
buildenv)
|
||||||
|
buildenv+=("${val}")
|
||||||
|
;;
|
||||||
|
options)
|
||||||
|
buildopts+=("${val}")
|
||||||
|
;;
|
||||||
|
installed)
|
||||||
|
installed+=("${val}")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
buildinfo["${var}"]="${val}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
get_pkgfile() {
|
||||||
|
local cdir=${cache_dirs[0]}
|
||||||
|
local pkgfilebase=${1}
|
||||||
|
local mode=${2}
|
||||||
|
local pkgname=${pkgfilebase%-*-*-*}
|
||||||
|
local pkgfile ext
|
||||||
|
|
||||||
|
# try without downloading
|
||||||
|
if [[ ${mode} != localonly ]] && get_pkgfile "${pkgfilebase}" localonly; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for ext in .zst .xz ''; do
|
||||||
|
pkgfile=${pkgfilebase}.pkg.tar${ext}
|
||||||
|
|
||||||
|
for c in "${cache_dirs[@]}"; do
|
||||||
|
if [[ -f ${c}/${pkgfile} ]]; then
|
||||||
|
cdir=${c}
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for f in "${pkgfile}" "${pkgfile}.sig"; do
|
||||||
|
if [[ ! -f "${cdir}/${f}" ]]; then
|
||||||
|
if [[ ${mode} = localonly ]]; then
|
||||||
|
continue 2
|
||||||
|
fi
|
||||||
|
msg2 "retrieving '%s'..." "${f}" >&2
|
||||||
|
curl -Llf -# -o "${cdir}/${f}" "${archiveurl}/${pkgname:0:1}/${pkgname}/${f}" || continue 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
printf '%s\n' "file://${cdir}/${pkgfile}"
|
||||||
|
return 0
|
||||||
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
get_makepkg_conf() {
|
||||||
|
local fname=${1}
|
||||||
|
local makepkg_conf="${2}"
|
||||||
|
if ! buildtool_file=$(get_pkgfile "${fname}"); then
|
||||||
|
error "failed to retrieve ${fname}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
msg2 "using makepkg.conf from ${fname}"
|
||||||
|
bsdtar xOqf "${buildtool_file/file:\/\//}" usr/share/artools/makepkg.conf > "${makepkg_conf}"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat << __EOF__
|
||||||
|
usage: ${BASH_SOURCE[0]##*/} [options] <package_file>
|
||||||
|
|
||||||
|
Run this script in a PKGBUILD dir to build a package inside a
|
||||||
|
clean chroot while attempting to reproduce it. The package file
|
||||||
|
will be used to derive metadata needed for reproducing the
|
||||||
|
package, including the .PKGINFO as well as the buildinfo.
|
||||||
|
|
||||||
|
For more details see https://reproducible-builds.org/
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-d Run diffoscope if the package is unreproducible
|
||||||
|
-c <dir> Set pacman cache
|
||||||
|
-M <file> Location of a makepkg config file
|
||||||
|
-l <chroot> The directory name to use as the chroot namespace
|
||||||
|
Useful for maintaining multiple copies
|
||||||
|
Default: $chroot
|
||||||
|
-h Show this usage message
|
||||||
|
__EOF__
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts 'dM:c:l:h' arg; do
|
||||||
|
case "$arg" in
|
||||||
|
d) diffoscope=1 ;;
|
||||||
|
M) artixroot_args+=(-M "$OPTARG") ;;
|
||||||
|
c) cache_dirs+=("$OPTARG") ;;
|
||||||
|
l) chroot="$OPTARG" ;;
|
||||||
|
h) usage; exit 0 ;;
|
||||||
|
*|?) usage; exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
|
check_root
|
||||||
|
|
||||||
|
[[ -f PKGBUILD ]] || { error "No PKGBUILD in current directory."; exit 1; }
|
||||||
|
|
||||||
|
# without arguments, get list of packages from PKGBUILD
|
||||||
|
if [[ -z $1 ]]; then
|
||||||
|
mapfile -t pkgnames < <(source PKGBUILD; pacman -Sddp --print-format '%r/%n' "${pkgname[@]}")
|
||||||
|
wait $! || {
|
||||||
|
error "No package file specified and failed to retrieve package names from './PKGBUILD'."
|
||||||
|
plain "Try '${BASH_SOURCE[0]##*/} -h' for more information." >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
msg "Reproducing all pkgnames listed in ./PKGBUILD"
|
||||||
|
set -- "${pkgnames[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check each package to see if it's a file, and if not, try to download it
|
||||||
|
# using pacman -Sw, and get the filename from there
|
||||||
|
splitpkgs=()
|
||||||
|
for p in "$@"; do
|
||||||
|
if [[ -f ${p} ]]; then
|
||||||
|
splitpkgs+=("${p}")
|
||||||
|
else
|
||||||
|
pkgfile_remote=$(pacman -Sddp "${p}" 2>/dev/null) || { error "package name '%s' not in repos" "${p}"; exit 1; }
|
||||||
|
pkgfile=${pkgfile_remote#file://}
|
||||||
|
if [[ ! -f ${pkgfile} ]]; then
|
||||||
|
msg "Downloading package '%s' into pacman's cache" "${pkgfile}"
|
||||||
|
sudo pacman -Swdd --noconfirm --logfile /dev/null "${p}" || exit 1
|
||||||
|
pkgfile_remote=$(pacman -Sddp "${p}" 2>/dev/null)
|
||||||
|
pkgfile="${pkgfile_remote#file://}"
|
||||||
|
fi
|
||||||
|
splitpkgs+=("${pkgfile}")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for f in "${splitpkgs[@]}"; do
|
||||||
|
if ! bsdtar -tqf "${f}" .BUILDINFO >/dev/null 2>&1; then
|
||||||
|
error "file is not a valid pacman package: '%s'" "${f}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if (( ${#cache_dirs[@]} == 0 )); then
|
||||||
|
mapfile -t cache_dirs < <(pacman-conf CacheDir)
|
||||||
|
fi
|
||||||
|
|
||||||
|
ORIG_HOME=${HOME}
|
||||||
|
IFS=: read -r _ _ _ _ _ HOME _ < <(getent passwd "${SUDO_USER:-$USER}")
|
||||||
|
load_makepkg_config
|
||||||
|
HOME=${ORIG_HOME}
|
||||||
|
[[ -d ${SRCDEST} ]] || SRCDEST=${PWD}
|
||||||
|
|
||||||
|
parse_buildinfo < <(bsdtar -xOqf "${splitpkgs[0]}" .BUILDINFO)
|
||||||
|
export SOURCE_DATE_EPOCH="${buildinfo[builddate]}"
|
||||||
|
PACKAGER="${buildinfo[packager]}"
|
||||||
|
BUILDDIR="${buildinfo[builddir]}"
|
||||||
|
BUILDTOOL="${buildinfo[buildtool]}"
|
||||||
|
BUILDTOOLVER="${buildinfo[buildtoolver]}"
|
||||||
|
PKGEXT=${splitpkgs[0]#${splitpkgs[0]%.pkg.tar*}}
|
||||||
|
|
||||||
|
# nuke and restore reproducible testenv
|
||||||
|
namespace="$buildroot/$chroot"
|
||||||
|
lock 9 "${namespace}.lock" "Locking chroot namespace '%s'" "${namespace}"
|
||||||
|
for copy in "${namespace}"/*/; do
|
||||||
|
[[ -d ${copy} ]] || continue
|
||||||
|
subvolume_delete_recursive "${copy}"
|
||||||
|
done
|
||||||
|
rm -rf --one-file-system "${namespace}"
|
||||||
|
(umask 0022; mkdir -p "${namespace}")
|
||||||
|
|
||||||
|
for fname in "${installed[@]}"; do
|
||||||
|
if ! allpkgfiles+=("$(get_pkgfile "${fname}")"); then
|
||||||
|
error "failed to retrieve ${fname}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
trap 'rm -rf $TEMPDIR' EXIT INT TERM QUIT
|
||||||
|
TEMPDIR=$(mktemp -d --tmpdir makerepropkg.XXXXXXXXXX)
|
||||||
|
|
||||||
|
makepkg_conf="${TEMPDIR}/makepkg.conf"
|
||||||
|
# anything before buildtool support is pinned to the last none buildtool aware release
|
||||||
|
if [[ -z "${BUILDTOOL}" ]]; then
|
||||||
|
get_makepkg_conf "artools-pkg-0.28.2-1-any" "${makepkg_conf}" || exit 1
|
||||||
|
# prefere to assume artools-pkg up until matching makepkg version so repository packages remain reproducible
|
||||||
|
elif [[ "${BUILDTOOL}" = makepkg ]] && (( $(vercmp "${BUILDTOOLVER}" 6.0.1) <= 0 )); then
|
||||||
|
get_makepkg_conf "artools-pkg-0.28.2-1-any" "${makepkg_conf}" || exit 1
|
||||||
|
# all artools-pkg builds
|
||||||
|
elif [[ "${BUILDTOOL}" = artools-pkg ]] && get_makepkg_conf "${BUILDTOOL}-${BUILDTOOLVER}" "${makepkg_conf}"; then
|
||||||
|
true
|
||||||
|
# fallback to current makepkg.conf
|
||||||
|
else
|
||||||
|
warning "Unknown buildtool (${BUILDTOOL}-${BUILDTOOLVER}), using fallback"
|
||||||
|
makepkg_conf="${DATADIR}"/makepkg.conf
|
||||||
|
fi
|
||||||
|
printf '%s\n' "${allpkgfiles[@]}" | mkchroot -M "${makepkg_conf}" -U "${artixroot_args[@]}" "${namespace}/root" - || exit 1
|
||||||
|
|
||||||
|
# use makechrootpkg to prep the build directory
|
||||||
|
mkchrootpkg -r "${namespace}" -l build -- --packagelist || exit 1
|
||||||
|
|
||||||
|
# set detected makepkg.conf options
|
||||||
|
{
|
||||||
|
for var in PACKAGER BUILDDIR BUILDTOOL BUILDTOOLVER PKGEXT; do
|
||||||
|
printf '%s=%s\n' "${var}" "${!var@Q}"
|
||||||
|
done
|
||||||
|
printf 'OPTIONS=(%s)\n' "${buildopts[*]@Q}"
|
||||||
|
printf 'BUILDENV=(%s)\n' "${buildenv[*]@Q}"
|
||||||
|
} >> "${namespace}/build"/etc/makepkg.conf
|
||||||
|
install -d -o "${SUDO_UID:-$UID}" -g "$(id -g "${SUDO_UID:-$UID}")" "${namespace}/build/${BUILDDIR}"
|
||||||
|
|
||||||
|
bindmounts+=("-B:${PWD}:/startdir" "-B:${SRCDEST}:/srcdest")
|
||||||
|
|
||||||
|
# kick off the build
|
||||||
|
chroot-run \
|
||||||
|
-b "${bindmounts[*]}" \
|
||||||
|
"${namespace}/build" \
|
||||||
|
/chrootbuild -C --noconfirm --log --holdver --skipinteg
|
||||||
|
ret=$?
|
||||||
|
|
||||||
|
if (( ${ret} == 0 )); then
|
||||||
|
msg2 "built succeeded! built packages can be found in ${namespace}/build/pkgdest"
|
||||||
|
msg "comparing artifacts..."
|
||||||
|
|
||||||
|
for pkgfile in "${splitpkgs[@]}"; do
|
||||||
|
comparefiles=("${pkgfile}" "${namespace}/build/pkgdest/${pkgfile##*/}")
|
||||||
|
if cmp -s "${comparefiles[@]}"; then
|
||||||
|
msg2 "Package '%s' successfully reproduced!" "${pkgfile}"
|
||||||
|
else
|
||||||
|
ret=1
|
||||||
|
warning "Package '%s' is not reproducible. :(" "${pkgfile}"
|
||||||
|
sha256sum "${comparefiles[@]}"
|
||||||
|
if (( diffoscope )); then
|
||||||
|
diffoscope "${comparefiles[@]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# return failure from chrootbuild, or the reproducibility status
|
||||||
|
exit ${ret}
|
77
bin/pkg/mkdepgraph.in
Normal file
77
bin/pkg/mkdepgraph.in
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
mk_tree_graph(){
|
||||||
|
printf "%s\n" "$(pactree "${tree_args[@]}" "${package}")" \
|
||||||
|
| dot -T "${ext}" > "${graph_dir}/${package}.${ext}"
|
||||||
|
}
|
||||||
|
|
||||||
|
mk_rebuild_graph(){
|
||||||
|
local tmpfile
|
||||||
|
tmpfile=/tmp/rebuild.dot
|
||||||
|
rebuild_args+=(-d "${tmpfile}")
|
||||||
|
artix-rebuild-order "${packages[@]}" "${rebuild_args[@]}"
|
||||||
|
dot -T "${ext}" "${tmpfile}" > "${graph_dir}/rebuild.${ext}"
|
||||||
|
rm -f "${tmpfile}"
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
printf "Usage: %s [options] <package|packages>\n" "${0##*/}"
|
||||||
|
printf " -m <tree|rebuild> default mode: [%s]\n" "$mode"
|
||||||
|
printf " rebuild mode accepts packages input\n"
|
||||||
|
printf " -r list packages that depend on the named package (tree)\n"
|
||||||
|
printf " -u show dependencies with no duplicates (tree)\n"
|
||||||
|
printf " -d <#> limit the depth of recursion (tree)\n"
|
||||||
|
printf " default: [%s]\n" "$depth"
|
||||||
|
printf " -o <#> controls at which depth to stop printing optional deps\n"
|
||||||
|
printf " default: [%s]\n" "$optdepth"
|
||||||
|
printf " (-1 for no limit) (tree)\n"
|
||||||
|
printf " -i only use the pkgnames provided as input (rebuild)\n"
|
||||||
|
printf " -h display this help message\n"
|
||||||
|
exit "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
graph_dir=${XDG_PICTURES_DIR:-$(xdg-user-dir PICTURES)/artix}
|
||||||
|
ext="png"
|
||||||
|
|
||||||
|
mode=tree
|
||||||
|
|
||||||
|
tree_args=(-gs)
|
||||||
|
rebuild_args=()
|
||||||
|
|
||||||
|
depth=0
|
||||||
|
optdepth=-1
|
||||||
|
|
||||||
|
opts=':m:d:o:iruh'
|
||||||
|
|
||||||
|
while getopts "$opts" arg; do
|
||||||
|
case "${arg}" in
|
||||||
|
m) mode="$OPTARG" ;;
|
||||||
|
r) tree_args+=(-r) ;;
|
||||||
|
u) tree_args+=(-ul) ;;
|
||||||
|
d) depth="$OPTARG"; tree_args+=(-d "$depth") ;;
|
||||||
|
o) optdepth="$OPTARG"; tree_args+=(-o"$optdepth") ;;
|
||||||
|
i) rebuild_args+=(--no-reverse-depends) ;;
|
||||||
|
h|?) usage 0 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $(( OPTIND - 1 ))
|
||||||
|
|
||||||
|
[[ -d "${graph_dir}" ]] || mkdir -p "${graph_dir}"
|
||||||
|
|
||||||
|
case "$mode" in
|
||||||
|
tree) package=("$@"); mk_tree_graph ;;
|
||||||
|
rebuild) packages=("$@"); mk_rebuild_graph ;;
|
||||||
|
*) usage 1 ;;
|
||||||
|
esac
|
@@ -7,47 +7,13 @@
|
|||||||
|
|
||||||
# TREE_DIR_ARTIX=${WORKSPACE_DIR}/artixlinux
|
# TREE_DIR_ARTIX=${WORKSPACE_DIR}/artixlinux
|
||||||
|
|
||||||
# customize buildtree; uncomment to include
|
# customize buildtree
|
||||||
# TREE_NAMES_ARTIX=(
|
# ARTIX_TREE=(
|
||||||
# packages-kernel
|
# main
|
||||||
# packages-llvm
|
# initsys
|
||||||
# packages-openrc
|
# desktop
|
||||||
# packages-runit
|
# addons
|
||||||
# packages-s6
|
# lib32
|
||||||
# packages-suite66
|
|
||||||
# packages-dinit
|
|
||||||
# packages-perl
|
|
||||||
# packages-java
|
|
||||||
# packages-ruby
|
|
||||||
# packages-gtk
|
|
||||||
# packages-qt5
|
|
||||||
# packages-qt6
|
|
||||||
# packages-xorg
|
|
||||||
# packages-plasma
|
|
||||||
# kde-utils
|
|
||||||
# kde-devel
|
|
||||||
# kde-media
|
|
||||||
# kde-games
|
|
||||||
# kde-edu
|
|
||||||
# kde-net
|
|
||||||
# kde-pim
|
|
||||||
# packages-gnome
|
|
||||||
# packages-cinnamon
|
|
||||||
# packages-lxqt
|
|
||||||
# packages-lxde
|
|
||||||
# packages-mate
|
|
||||||
# packages-xfce
|
|
||||||
# packages-wm
|
|
||||||
# packages-devel
|
|
||||||
# packages-qt6
|
|
||||||
# packages-office
|
|
||||||
# packages-misc
|
|
||||||
# python-world
|
|
||||||
# python-galaxy
|
|
||||||
# python-galaxy-groups
|
|
||||||
# python-misc
|
|
||||||
# packages-python
|
|
||||||
# packages-lib32
|
|
||||||
# )
|
# )
|
||||||
|
|
||||||
# TREE_DIR_ARCH=${WORKSPACE_DIR}/archlinux
|
# TREE_DIR_ARCH=${WORKSPACE_DIR}/archlinux
|
||||||
|
@@ -45,12 +45,13 @@ CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
|
|||||||
-fstack-clash-protection -fcf-protection"
|
-fstack-clash-protection -fcf-protection"
|
||||||
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
|
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
|
||||||
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
|
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
|
||||||
|
LTOFLAGS="-flto=auto"
|
||||||
#RUSTFLAGS="-C opt-level=2"
|
#RUSTFLAGS="-C opt-level=2"
|
||||||
#-- Make Flags: change this for DistCC/SMP systems
|
#-- Make Flags: change this for DistCC/SMP systems
|
||||||
#MAKEFLAGS="-j2"
|
#MAKEFLAGS="-j2"
|
||||||
#-- Debugging flags
|
#-- Debugging flags
|
||||||
DEBUG_CFLAGS="-g"
|
DEBUG_CFLAGS="-g"
|
||||||
DEBUG_CXXFLAGS="-g"
|
DEBUG_CXXFLAGS="$DEBUG_CFLAGS"
|
||||||
#DEBUG_RUSTFLAGS="-C debuginfo=2"
|
#DEBUG_RUSTFLAGS="-C debuginfo=2"
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
@@ -5,7 +5,8 @@
|
|||||||
get_compliant_name(){
|
get_compliant_name(){
|
||||||
local gitname="$1"
|
local gitname="$1"
|
||||||
case "$gitname" in
|
case "$gitname" in
|
||||||
*+) gitname=${gitname//+/plus}
|
*+) gitname=${gitname//+/plus} ;;
|
||||||
|
*+*) gitname=${gitname//+/-} ;;
|
||||||
esac
|
esac
|
||||||
printf "%s\n" "$gitname"
|
printf "%s\n" "$gitname"
|
||||||
}
|
}
|
||||||
|
67
lib/pkg/diff.sh
Normal file
67
lib/pkg/diff.sh
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/hint/bash
|
||||||
|
|
||||||
|
#{{{ functions
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
#}}}
|
@@ -31,7 +31,7 @@ write_agentyaml(){
|
|||||||
git add "$agent"
|
git add "$agent"
|
||||||
}
|
}
|
||||||
|
|
||||||
commit_jenkins_files(){
|
commit_ci(){
|
||||||
local pkg="$1"
|
local pkg="$1"
|
||||||
|
|
||||||
write_jenkinsfile "$pkg"
|
write_jenkinsfile "$pkg"
|
||||||
|
@@ -25,9 +25,9 @@ set_arch_repos(){
|
|||||||
find_repo(){
|
find_repo(){
|
||||||
local pkg="$1" pkgarch="${2:-${CARCH}}" repo
|
local pkg="$1" pkgarch="${2:-${CARCH}}" repo
|
||||||
for r in "${ARCH_REPOS[@]}"; do
|
for r in "${ARCH_REPOS[@]}"; do
|
||||||
[[ -f $pkg/repos/$r-$pkgarch/PKGBUILD ]] && repo=repos/"$r-$pkgarch"
|
[[ -f $pkg/repos/$r-$pkgarch/PKGBUILD ]] && repo="$r-$pkgarch"
|
||||||
[[ -f $pkg/repos/$r-any/PKGBUILD ]] && repo=repos/"$r"-any
|
[[ -f $pkg/repos/$r-any/PKGBUILD ]] && repo="$r"-any
|
||||||
[[ -f $pkg/$pkgarch/$r/PKGBUILD ]] && repo="$pkgarch/$r"
|
[[ -f $pkg/$pkgarch/$r/PKGBUILD ]] && repo="$r"
|
||||||
done
|
done
|
||||||
printf "%s\n" "$repo"
|
printf "%s\n" "$repo"
|
||||||
}
|
}
|
||||||
@@ -42,8 +42,8 @@ tree_loop(){
|
|||||||
local func="$1" pkgs
|
local func="$1" pkgs
|
||||||
for tree in "${ARTIX_TREE[@]}"; do
|
for tree in "${ARTIX_TREE[@]}"; do
|
||||||
mapfile -t pkgs < <(find "${TREE_DIR_ARTIX}/$tree" -name "$CARCH" | sort)
|
mapfile -t pkgs < <(find "${TREE_DIR_ARTIX}/$tree" -name "$CARCH" | sort)
|
||||||
for _package in "${pkgs[@]}"; do
|
for p in "${pkgs[@]}"; do
|
||||||
"$func" "$_package"
|
"$func" "$p"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@@ -21,35 +21,8 @@ load_pkg_config(){
|
|||||||
|
|
||||||
TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"}
|
TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"}
|
||||||
|
|
||||||
ARTIX_TREE=(
|
[[ -z ${ARTIX_TREE[*]} ]] && \
|
||||||
packages community
|
ARTIX_TREE=(main initsys desktop addons lib32)
|
||||||
packages-{llvm,gfx,media,net}
|
|
||||||
)
|
|
||||||
|
|
||||||
local dev_tree=(
|
|
||||||
packages-{python,perl,java,ruby,misc}
|
|
||||||
python-{world,galaxy,galaxy-groups,misc}
|
|
||||||
)
|
|
||||||
|
|
||||||
local init_tree=(packages-{openrc,runit,s6,suite66,dinit})
|
|
||||||
|
|
||||||
local desktop_tree=(
|
|
||||||
packages-{xorg,gtk,qt5,qt6,kf5,plasma}
|
|
||||||
kde-{utils,devel,net,pim,media,edu,games}
|
|
||||||
packages-{lxqt,gnome,cinnamon,mate,xfce,wm,lxde}
|
|
||||||
)
|
|
||||||
|
|
||||||
[[ -z ${TREE_NAMES_ARTIX[*]} ]] && \
|
|
||||||
TREE_NAMES_ARTIX=(
|
|
||||||
packages-kernel
|
|
||||||
"${init_tree[@]}"
|
|
||||||
"${dev_tree[@]}"
|
|
||||||
"${desktop_tree[@]}"
|
|
||||||
packages-devel
|
|
||||||
packages-lib32
|
|
||||||
)
|
|
||||||
|
|
||||||
ARTIX_TREE+=("${TREE_NAMES_ARTIX[@]}")
|
|
||||||
|
|
||||||
TREE_DIR_ARCH=${TREE_DIR_ARCH:-"${WORKSPACE_DIR}/archlinux"}
|
TREE_DIR_ARCH=${TREE_DIR_ARCH:-"${WORKSPACE_DIR}/archlinux"}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user