artools: add patch
This commit is contained in:
parent
bed1815484
commit
6779605b66
194 changed files with 28049 additions and 17 deletions
8
artools/0.26.1/artools/.gitignore
vendored
Normal file
8
artools/0.26.1/artools/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
*~
|
||||
*.tar.gz
|
||||
*.tar.xz
|
||||
.kateproject.d
|
||||
data/schemas/*.conf
|
||||
.project
|
||||
iso-profiles
|
||||
live-services
|
179
artools/0.26.1/artools/Makefile
Normal file
179
artools/0.26.1/artools/Makefile
Normal file
|
@ -0,0 +1,179 @@
|
|||
V=0.26
|
||||
|
||||
TOOLS = artools
|
||||
PREFIX ?= /usr
|
||||
SYSCONFDIR = /etc
|
||||
BINDIR = $(PREFIX)/bin
|
||||
DATADIR = $(PREFIX)/share
|
||||
|
||||
BASE_CONF = \
|
||||
data/conf/artools-base.conf
|
||||
|
||||
BASE_BIN = \
|
||||
bin/base/chroot-run \
|
||||
bin/base/mkchroot \
|
||||
bin/base/basestrap \
|
||||
bin/base/artix-chroot \
|
||||
bin/base/fstabgen
|
||||
|
||||
BASE_DATA = \
|
||||
$(wildcard data/pacman/pacman*.conf)
|
||||
|
||||
PKG_CONF = \
|
||||
data/conf/artools-pkg.conf
|
||||
|
||||
SETARCH_ALIASES = \
|
||||
|
||||
PKG_BIN = \
|
||||
bin/pkg/buildpkg \
|
||||
bin/pkg/deploypkg \
|
||||
bin/pkg/commitpkg \
|
||||
bin/pkg/comparepkg \
|
||||
bin/pkg/mkchrootpkg \
|
||||
bin/pkg/pkg2yaml \
|
||||
bin/pkg/buildtree \
|
||||
bin/pkg/lddd \
|
||||
bin/pkg/links-add \
|
||||
bin/pkg/checkpkg \
|
||||
bin/pkg/finddeps \
|
||||
bin/pkg/find-libdeps \
|
||||
bin/pkg/batchpkg \
|
||||
bin/pkg/signpkg \
|
||||
bin/pkg/checkrepo \
|
||||
bin/pkg/gitearepo
|
||||
|
||||
LN_COMMITPKG = \
|
||||
extrapkg \
|
||||
corepkg \
|
||||
testingpkg \
|
||||
stagingpkg \
|
||||
communitypkg \
|
||||
community-testingpkg \
|
||||
community-stagingpkg \
|
||||
multilibpkg \
|
||||
multilib-testingpkg \
|
||||
multilib-stagingpkg \
|
||||
kde-unstablepkg \
|
||||
gnome-unstablepkg \
|
||||
rebuildpkg
|
||||
|
||||
LN_BUILDPKG = \
|
||||
buildpkg-system \
|
||||
buildpkg-world \
|
||||
buildpkg-gremlins \
|
||||
buildpkg-goblins \
|
||||
buildpkg-galaxy \
|
||||
buildpkg-galaxy-gremlins \
|
||||
buildpkg-galaxy-goblins \
|
||||
buildpkg-lib32 \
|
||||
buildpkg-lib32-gremlins \
|
||||
buildpkg-lib32-goblins \
|
||||
buildpkg-kde-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 = \
|
||||
data/pacman/makepkg.conf \
|
||||
data/valid-names.conf
|
||||
|
||||
PATCHES = \
|
||||
$(wildcard data/patches/*.patch)
|
||||
|
||||
ISO_CONF = \
|
||||
data/conf/artools-iso.conf
|
||||
|
||||
ISO_BIN = \
|
||||
bin/iso/buildiso
|
||||
|
||||
LN_BUILDISO = \
|
||||
buildiso-gremlins \
|
||||
buildiso-goblins
|
||||
|
||||
DIRMODE = -dm0755
|
||||
FILEMODE = -m0644
|
||||
MODE = -m0755
|
||||
LN = ln -sf
|
||||
RM = rm -f
|
||||
M4 = m4 -P --define=m4_artools_pkg_version=$V
|
||||
CHMODAW = chmod a-w
|
||||
CHMODX = chmod +x
|
||||
|
||||
BIN = $(BASE_BIN) $(PKG_BIN) $(ISO_BIN)
|
||||
|
||||
all: $(BIN)
|
||||
|
||||
EDIT = sed -e "s|@datadir[@]|$(DATADIR)|g" \
|
||||
-e "s|@sysconfdir[@]|$(SYSCONFDIR)|g"
|
||||
|
||||
%: %.in Makefile lib/util-base.sh
|
||||
@echo "GEN $@"
|
||||
@$(RM) "$@"
|
||||
@{ echo -n 'm4_changequote([[[,]]])'; cat $@.in; } | $(M4) | $(EDIT) >$@
|
||||
@$(CHMODAW) "$@"
|
||||
@$(CHMODX) "$@"
|
||||
@bash -O extglob -n "$@"
|
||||
|
||||
clean:
|
||||
$(RM) $(BIN)
|
||||
|
||||
install_base:
|
||||
install $(DIRMODE) $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)
|
||||
install $(FILEMODE) $(BASE_CONF) $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)
|
||||
|
||||
install $(DIRMODE) $(DESTDIR)$(BINDIR)
|
||||
install $(MODE) $(BASE_BIN) $(DESTDIR)$(BINDIR)
|
||||
|
||||
install $(DIRMODE) $(DESTDIR)$(DATADIR)/$(TOOLS)
|
||||
install $(FILEMODE) $(BASE_DATA) $(DESTDIR)$(DATADIR)/$(TOOLS)
|
||||
|
||||
install $(DIRMODE) $(DESTDIR)$(DATADIR)/$(TOOLS)/setarch-aliases.d
|
||||
for a in ${SETARCH_ALIASES}; do install $(FILEMODE) setarch-aliases.d/$$a $(DESTDIR)$(DATADIR)/$(TOOLS)/setarch-aliases.d; done
|
||||
|
||||
install_pkg:
|
||||
install $(DIRMODE) $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)
|
||||
install $(FILEMODE) $(PKG_CONF) $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)
|
||||
|
||||
install $(DIRMODE) $(DESTDIR)$(BINDIR)
|
||||
install $(MODE) $(PKG_BIN) $(DESTDIR)$(BINDIR)
|
||||
|
||||
$(LN) find-libdeps $(DESTDIR)$(BINDIR)/find-libprovides
|
||||
|
||||
$(LN) links-add $(DESTDIR)$(BINDIR)/links-remove
|
||||
|
||||
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_DEPLOYPKG); do $(LN) deploypkg $(DESTDIR)$(BINDIR)/$$l; done
|
||||
|
||||
$(LN) artix-chroot $(DESTDIR)$(BINDIR)/artools-chroot
|
||||
|
||||
install $(DIRMODE) $(DESTDIR)$(DATADIR)/$(TOOLS)
|
||||
install $(FILEMODE) $(PKG_DATA) $(DESTDIR)$(DATADIR)/$(TOOLS)
|
||||
|
||||
install $(DIRMODE) $(DESTDIR)$(DATADIR)/$(TOOLS)/patches
|
||||
install $(FILEMODE) $(PATCHES) $(DESTDIR)$(DATADIR)/$(TOOLS)/patches
|
||||
|
||||
install_iso:
|
||||
install $(DIRMODE) $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)
|
||||
install $(FILEMODE) $(ISO_CONF) $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)
|
||||
|
||||
install $(DIRMODE) $(DESTDIR)$(BINDIR)
|
||||
install $(MODE) $(ISO_BIN) $(DESTDIR)$(BINDIR)
|
||||
|
||||
for l in $(LN_BUILDISO); do $(LN) buildiso $(DESTDIR)$(BINDIR)/$$l; done
|
||||
|
||||
install: install_base install_pkg install_iso
|
||||
|
||||
.PHONY: all clean install install_base install_pkg install_iso
|
69
artools/0.26.1/artools/README.md
Normal file
69
artools/0.26.1/artools/README.md
Normal file
|
@ -0,0 +1,69 @@
|
|||
artools
|
||||
=============
|
||||
|
||||
#### Make flags
|
||||
|
||||
|
||||
* PREFIX=/usr
|
||||
* SYSCONFDIR=/etc
|
||||
|
||||
#### Dependencies
|
||||
|
||||
##### Buildtime:
|
||||
|
||||
* make
|
||||
* git
|
||||
* m4
|
||||
|
||||
##### Runtime:
|
||||
|
||||
- base:
|
||||
* os-prober
|
||||
* pacman
|
||||
|
||||
- pkg:
|
||||
* namcap
|
||||
* git-subrepo
|
||||
* rsync
|
||||
|
||||
- iso:
|
||||
* dosfstools
|
||||
* libisoburn
|
||||
* squashfs-tools
|
||||
* grub
|
||||
|
||||
#### Configuration
|
||||
|
||||
artools-{base,pkg,iso}.conf are the configuration files for artools.
|
||||
By default, the config files are installed in
|
||||
|
||||
```bash
|
||||
/etc/artools/artools-{base,pkg,iso}.conf
|
||||
```
|
||||
|
||||
A user artools-{base,pkg,iso}.conf can be placed in
|
||||
|
||||
```bash
|
||||
$HOME/.config/artools/artools-{base,pkg,iso}.conf
|
||||
```
|
||||
|
||||
If the userconfig is present, artools will load the userconfig values, however, if variables have been set in the systemwide
|
||||
|
||||
These values take precedence over the userconfig.
|
||||
Best practise is to leave systemwide file untouched.
|
||||
By default it is commented and shows just initialization values done in code.
|
||||
|
||||
Tools configuration is done in artools-{base,pkg,iso}.conf or by args.
|
||||
Specifying args will override artools-{base,pkg,iso}.conf settings.
|
||||
|
||||
Both, pacman.conf and makepkg.conf for chroots are loaded from
|
||||
|
||||
```bash
|
||||
usr/share/artools/{makepkg,pacman-*}.conf
|
||||
```
|
||||
|
||||
and can be overridden dropping them in
|
||||
|
||||
```bash
|
||||
$HOME/.config/artools/
|
||||
```
|
381
artools/0.26.1/artools/bin/base/artix-chroot
Executable file
381
artools/0.26.1/artools/bin/base/artix-chroot
Executable file
|
@ -0,0 +1,381 @@
|
|||
#!/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.
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ chroot
|
||||
|
||||
orig_argv=("$0" "$@")
|
||||
check_root() {
|
||||
local keepenv="$1"
|
||||
|
||||
(( EUID == 0 )) && return
|
||||
if type -P sudo >/dev/null; then
|
||||
# shellcheck disable=2154
|
||||
exec sudo --preserve-env="$keepenv" -- "${orig_argv[@]}"
|
||||
else
|
||||
# shellcheck disable=2154
|
||||
exec su root -c "$(printf ' %q' "${orig_argv[@]}")"
|
||||
fi
|
||||
}
|
||||
|
||||
is_btrfs() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]]
|
||||
}
|
||||
|
||||
is_subvolume() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs && "$(stat -c %i "$1")" == 256 ]]
|
||||
}
|
||||
|
||||
# is_same_fs() {
|
||||
# [[ "$(stat -c %d "$1")" == "$(stat -c %d "$2")" ]]
|
||||
# }
|
||||
|
||||
subvolume_delete_recursive() {
|
||||
local subvol
|
||||
|
||||
is_subvolume "$1" || return 0
|
||||
|
||||
while IFS= read -d $'\0' -r subvol; do
|
||||
if ! subvolume_delete_recursive "$subvol"; then
|
||||
return 1
|
||||
fi
|
||||
done < <(find "$1" -mindepth 1 -xdev -depth -inum 256 -print0)
|
||||
if ! btrfs subvolume delete "$1" &>/dev/null; then
|
||||
error "Unable to delete subvolume %s" "$subvol"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ mount
|
||||
|
||||
ignore_error() {
|
||||
"$@" 2>/dev/null
|
||||
return 0
|
||||
}
|
||||
|
||||
trap_setup(){
|
||||
[[ $(trap -p EXIT) ]] && die 'Error! Attempting to overwrite existing EXIT trap'
|
||||
trap "$1" EXIT
|
||||
}
|
||||
|
||||
chroot_mount() {
|
||||
# msg2 "mount: [%s]" "$2"
|
||||
mount "$@" && CHROOT_ACTIVE_MOUNTS=("$2" "${CHROOT_ACTIVE_MOUNTS[@]}")
|
||||
}
|
||||
|
||||
chroot_add_resolv_conf() {
|
||||
local chrootdir=$1 resolv_conf=$1/etc/resolv.conf
|
||||
|
||||
[[ -e /etc/resolv.conf ]] || return 0
|
||||
|
||||
# Handle resolv.conf as a symlink to somewhere else.
|
||||
if [[ -L $chrootdir/etc/resolv.conf ]]; then
|
||||
# readlink(1) should always give us *something* since we know at this point
|
||||
# it's a symlink. For simplicity, ignore the case of nested symlinks.
|
||||
resolv_conf=$(readlink "$chrootdir/etc/resolv.conf")
|
||||
if [[ $resolv_conf = /* ]]; then
|
||||
resolv_conf=$chrootdir$resolv_conf
|
||||
else
|
||||
resolv_conf=$chrootdir/etc/$resolv_conf
|
||||
fi
|
||||
|
||||
# ensure file exists to bind mount over
|
||||
if [[ ! -f $resolv_conf ]]; then
|
||||
install -Dm644 /dev/null "$resolv_conf" || return 1
|
||||
fi
|
||||
elif [[ ! -e $chrootdir/etc/resolv.conf ]]; then
|
||||
# The chroot might not have a resolv.conf.
|
||||
return 0
|
||||
fi
|
||||
|
||||
chroot_mount /etc/resolv.conf "$resolv_conf" --bind
|
||||
}
|
||||
|
||||
chroot_mount_conditional() {
|
||||
local cond=$1; shift
|
||||
if eval "$cond"; then
|
||||
chroot_mount "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
chroot_setup(){
|
||||
local mnt="$1" os="$2" args='-t tmpfs -o nosuid,nodev,mode=0755'
|
||||
$os && args='--bind'
|
||||
chroot_mount_conditional "! mountpoint -q '$mnt'" "$mnt" "$mnt" --bind &&
|
||||
chroot_mount proc "$mnt/proc" -t proc -o nosuid,noexec,nodev &&
|
||||
chroot_mount sys "$mnt/sys" -t sysfs -o nosuid,noexec,nodev,ro &&
|
||||
ignore_error chroot_mount_conditional "[[ -d '$mnt/sys/firmware/efi/efivars' ]]" \
|
||||
efivarfs "$mnt/sys/firmware/efi/efivars" -t efivarfs -o nosuid,noexec,nodev &&
|
||||
chroot_mount udev "$mnt/dev" -t devtmpfs -o mode=0755,nosuid &&
|
||||
chroot_mount devpts "$mnt/dev/pts" -t devpts -o mode=0620,gid=5,nosuid,noexec &&
|
||||
chroot_mount shm "$mnt/dev/shm" -t tmpfs -o mode=1777,nosuid,nodev &&
|
||||
chroot_mount /run "$mnt/run" ${args} &&
|
||||
chroot_mount tmp "$mnt/tmp" -t tmpfs -o mode=1777,strictatime,nodev,nosuid
|
||||
}
|
||||
|
||||
chroot_api_mount() {
|
||||
CHROOT_ACTIVE_MOUNTS=()
|
||||
trap_setup chroot_api_umount
|
||||
chroot_setup "$1" false
|
||||
}
|
||||
|
||||
chroot_api_umount() {
|
||||
if (( ${#CHROOT_ACTIVE_MOUNTS[@]} )); then
|
||||
# msg2 "umount: [%s]" "${CHROOT_ACTIVE_MOUNTS[@]}"
|
||||
umount "${CHROOT_ACTIVE_MOUNTS[@]}"
|
||||
fi
|
||||
unset CHROOT_ACTIVE_MOUNTS
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
|
||||
#{{{ 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 ' ')"
|
||||
echo "${detected}"
|
||||
}
|
||||
|
||||
# $1: os-prober array
|
||||
get_os_name(){
|
||||
local str=$1
|
||||
str="${str#*:}"
|
||||
str="${str#*:}"
|
||||
str="${str%:*}"
|
||||
echo "$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() {
|
||||
echo "usage: ${0##*/} -a [or] ${0##*/} chroot-dir [command]"
|
||||
echo ' -a Automount detected linux system'
|
||||
echo ' -h Print this help message'
|
||||
echo ''
|
||||
echo " If 'command' is unspecified, ${0##*/} will launch /bin/sh."
|
||||
echo ''
|
||||
echo " If 'automount' is true, ${0##*/} will launch /bin/bash"
|
||||
echo " and ${chrootdir}."
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts=':ha'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
a) automount=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument ${arg}"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
check_root
|
||||
|
||||
if ${automount};then
|
||||
chrootdir=/mnt
|
||||
run_args=(/bin/bash)
|
||||
|
||||
select_os "${chrootdir}"
|
||||
else
|
||||
chrootdir=$1
|
||||
shift
|
||||
run_args=("$@")
|
||||
|
||||
[[ -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_add_resolv_conf "${chrootdir}"
|
||||
fi
|
||||
|
||||
SHELL=/bin/sh unshare --fork --pid chroot "${chrootdir}" "${run_args[@]}"
|
151
artools/0.26.1/artools/bin/base/artix-chroot.in
Normal file
151
artools/0.26.1/artools/bin/base/artix-chroot.in
Normal file
|
@ -0,0 +1,151 @@
|
|||
#!/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.
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
m4_include(lib/base/message.sh)
|
||||
m4_include(lib/base/chroot.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 ' ')"
|
||||
echo "${detected}"
|
||||
}
|
||||
|
||||
# $1: os-prober array
|
||||
get_os_name(){
|
||||
local str=$1
|
||||
str="${str#*:}"
|
||||
str="${str#*:}"
|
||||
str="${str%:*}"
|
||||
echo "$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() {
|
||||
echo "usage: ${0##*/} -a [or] ${0##*/} chroot-dir [command]"
|
||||
echo ' -a Automount detected linux system'
|
||||
echo ' -h Print this help message'
|
||||
echo ''
|
||||
echo " If 'command' is unspecified, ${0##*/} will launch /bin/sh."
|
||||
echo ''
|
||||
echo " If 'automount' is true, ${0##*/} will launch /bin/bash"
|
||||
echo " and ${chrootdir}."
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts=':ha'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
a) automount=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument ${arg}"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
check_root
|
||||
|
||||
if ${automount};then
|
||||
chrootdir=/mnt
|
||||
run_args=(/bin/bash)
|
||||
|
||||
select_os "${chrootdir}"
|
||||
else
|
||||
chrootdir=$1
|
||||
shift
|
||||
run_args=("$@")
|
||||
|
||||
[[ -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_add_resolv_conf "${chrootdir}"
|
||||
fi
|
||||
|
||||
SHELL=/bin/sh unshare --fork --pid chroot "${chrootdir}" "${run_args[@]}"
|
356
artools/0.26.1/artools/bin/base/basestrap
Executable file
356
artools/0.26.1/artools/bin/base/basestrap
Executable file
|
@ -0,0 +1,356 @@
|
|||
#!/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.
|
||||
|
||||
#
|
||||
# Assumptions:
|
||||
# 1) User has partitioned, formatted, and mounted partitions on /mnt
|
||||
# 2) Network is functional
|
||||
# 3) Arguments passed to the script are valid pacman targets
|
||||
# 4) A valid mirror appears in /etc/pacman.d/mirrorlist
|
||||
#
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ mount
|
||||
|
||||
ignore_error() {
|
||||
"$@" 2>/dev/null
|
||||
return 0
|
||||
}
|
||||
|
||||
trap_setup(){
|
||||
[[ $(trap -p EXIT) ]] && die 'Error! Attempting to overwrite existing EXIT trap'
|
||||
trap "$1" EXIT
|
||||
}
|
||||
|
||||
chroot_mount() {
|
||||
# msg2 "mount: [%s]" "$2"
|
||||
mount "$@" && CHROOT_ACTIVE_MOUNTS=("$2" "${CHROOT_ACTIVE_MOUNTS[@]}")
|
||||
}
|
||||
|
||||
chroot_add_resolv_conf() {
|
||||
local chrootdir=$1 resolv_conf=$1/etc/resolv.conf
|
||||
|
||||
[[ -e /etc/resolv.conf ]] || return 0
|
||||
|
||||
# Handle resolv.conf as a symlink to somewhere else.
|
||||
if [[ -L $chrootdir/etc/resolv.conf ]]; then
|
||||
# readlink(1) should always give us *something* since we know at this point
|
||||
# it's a symlink. For simplicity, ignore the case of nested symlinks.
|
||||
resolv_conf=$(readlink "$chrootdir/etc/resolv.conf")
|
||||
if [[ $resolv_conf = /* ]]; then
|
||||
resolv_conf=$chrootdir$resolv_conf
|
||||
else
|
||||
resolv_conf=$chrootdir/etc/$resolv_conf
|
||||
fi
|
||||
|
||||
# ensure file exists to bind mount over
|
||||
if [[ ! -f $resolv_conf ]]; then
|
||||
install -Dm644 /dev/null "$resolv_conf" || return 1
|
||||
fi
|
||||
elif [[ ! -e $chrootdir/etc/resolv.conf ]]; then
|
||||
# The chroot might not have a resolv.conf.
|
||||
return 0
|
||||
fi
|
||||
|
||||
chroot_mount /etc/resolv.conf "$resolv_conf" --bind
|
||||
}
|
||||
|
||||
chroot_mount_conditional() {
|
||||
local cond=$1; shift
|
||||
if eval "$cond"; then
|
||||
chroot_mount "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
chroot_setup(){
|
||||
local mnt="$1" os="$2" args='-t tmpfs -o nosuid,nodev,mode=0755'
|
||||
$os && args='--bind'
|
||||
chroot_mount_conditional "! mountpoint -q '$mnt'" "$mnt" "$mnt" --bind &&
|
||||
chroot_mount proc "$mnt/proc" -t proc -o nosuid,noexec,nodev &&
|
||||
chroot_mount sys "$mnt/sys" -t sysfs -o nosuid,noexec,nodev,ro &&
|
||||
ignore_error chroot_mount_conditional "[[ -d '$mnt/sys/firmware/efi/efivars' ]]" \
|
||||
efivarfs "$mnt/sys/firmware/efi/efivars" -t efivarfs -o nosuid,noexec,nodev &&
|
||||
chroot_mount udev "$mnt/dev" -t devtmpfs -o mode=0755,nosuid &&
|
||||
chroot_mount devpts "$mnt/dev/pts" -t devpts -o mode=0620,gid=5,nosuid,noexec &&
|
||||
chroot_mount shm "$mnt/dev/shm" -t tmpfs -o mode=1777,nosuid,nodev &&
|
||||
chroot_mount /run "$mnt/run" ${args} &&
|
||||
chroot_mount tmp "$mnt/tmp" -t tmpfs -o mode=1777,strictatime,nodev,nosuid
|
||||
}
|
||||
|
||||
chroot_api_mount() {
|
||||
CHROOT_ACTIVE_MOUNTS=()
|
||||
trap_setup chroot_api_umount
|
||||
chroot_setup "$1" false
|
||||
}
|
||||
|
||||
chroot_api_umount() {
|
||||
if (( ${#CHROOT_ACTIVE_MOUNTS[@]} )); then
|
||||
# msg2 "umount: [%s]" "${CHROOT_ACTIVE_MOUNTS[@]}"
|
||||
umount "${CHROOT_ACTIVE_MOUNTS[@]}"
|
||||
fi
|
||||
unset CHROOT_ACTIVE_MOUNTS
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ chroot
|
||||
|
||||
orig_argv=("$0" "$@")
|
||||
check_root() {
|
||||
local keepenv="$1"
|
||||
|
||||
(( EUID == 0 )) && return
|
||||
if type -P sudo >/dev/null; then
|
||||
# shellcheck disable=2154
|
||||
exec sudo --preserve-env="$keepenv" -- "${orig_argv[@]}"
|
||||
else
|
||||
# shellcheck disable=2154
|
||||
exec su root -c "$(printf ' %q' "${orig_argv[@]}")"
|
||||
fi
|
||||
}
|
||||
|
||||
is_btrfs() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]]
|
||||
}
|
||||
|
||||
is_subvolume() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs && "$(stat -c %i "$1")" == 256 ]]
|
||||
}
|
||||
|
||||
# is_same_fs() {
|
||||
# [[ "$(stat -c %d "$1")" == "$(stat -c %d "$2")" ]]
|
||||
# }
|
||||
|
||||
subvolume_delete_recursive() {
|
||||
local subvol
|
||||
|
||||
is_subvolume "$1" || return 0
|
||||
|
||||
while IFS= read -d $'\0' -r subvol; do
|
||||
if ! subvolume_delete_recursive "$subvol"; then
|
||||
return 1
|
||||
fi
|
||||
done < <(find "$1" -mindepth 1 -xdev -depth -inum 256 -print0)
|
||||
if ! btrfs subvolume delete "$1" &>/dev/null; then
|
||||
error "Unable to delete subvolume %s" "$subvol"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
||||
|
||||
#{{{ functions
|
||||
|
||||
copy_mirrorlist(){
|
||||
cp -a /etc/pacman.d/mirrorlist "$1/etc/pacman.d/"
|
||||
}
|
||||
|
||||
copy_keyring(){
|
||||
if [[ -d /etc/pacman.d/gnupg ]] && [[ ! -d $1/etc/pacman.d/gnupg ]]; then
|
||||
cp -a /etc/pacman.d/gnupg "$1/etc/pacman.d/"
|
||||
fi
|
||||
}
|
||||
|
||||
create_min_fs(){
|
||||
msg "Creating install root at %s" "$1"
|
||||
mkdir -m 0755 -p "$1"/var/{cache/pacman/pkg,lib/pacman,log} "$1"/{dev,run,etc/pacman.d}
|
||||
mkdir -m 1777 -p "$1"/tmp
|
||||
mkdir -m 0555 -p "$1"/{sys,proc}
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
newroot=/mnt
|
||||
|
||||
hostcache=0
|
||||
copykeyring=1
|
||||
copymirrorlist=1
|
||||
pacmode=-Sy
|
||||
|
||||
usage() {
|
||||
echo "usage: ${0##*/} [options] root [packages...]"
|
||||
echo " -C <config> Use an alternate config file for pacman"
|
||||
echo " -c Use the package cache on the host, rather than the target"
|
||||
echo " -G Avoid copying the host's pacman keyring to the target"
|
||||
echo " -i Avoid auto-confirmation of package selections"
|
||||
echo " -M Avoid copying the host's mirrorlist to the target"
|
||||
echo ' -U Use pacman -U to install packages'
|
||||
echo " -h Print this help message"
|
||||
echo ''
|
||||
echo ' basestrap installs packages to the specified new root directory.'
|
||||
echo ' If no packages are given, basestrap defaults to the "base" group.'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts=':C:cGiMU'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
C) pacman_conf=$OPTARG ;;
|
||||
c) hostcache=1 ;;
|
||||
i) interactive=1 ;;
|
||||
G) copykeyring=0 ;;
|
||||
M) copymirrorlist=0 ;;
|
||||
U) pacmode=-U ;;
|
||||
:) echo "invalid argument ${arg}:$OPTARG"; usage 1;;
|
||||
?) usage 0 ;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
check_root
|
||||
|
||||
(( $# )) || die "No root directory specified"
|
||||
newroot=$1; shift
|
||||
pacman_args=("${@:-base}")
|
||||
|
||||
if (( ! hostcache ));then
|
||||
pacman_args+=(--cachedir="$newroot/var/cache/pacman/pkg")
|
||||
fi
|
||||
|
||||
if (( ! interactive )); then
|
||||
pacman_args+=(--noconfirm)
|
||||
fi
|
||||
|
||||
[[ -n $pacman_conf ]] && pacman_args+=(--config="$pacman_conf")
|
||||
|
||||
[[ -d $newroot ]] || die "%s is not a directory" "$newroot"
|
||||
|
||||
# create obligatory directories
|
||||
create_min_fs "$newroot"
|
||||
|
||||
# mount API filesystems
|
||||
chroot_api_mount "$newroot" || die "failed to setup API filesystems in new root"
|
||||
|
||||
if (( copykeyring ));then
|
||||
copy_keyring "$newroot"
|
||||
fi
|
||||
|
||||
msg2 'Installing packages to %s' "$newroot"
|
||||
if ! unshare --fork --pid pacman -r "$newroot" $pacmode "${pacman_args[@]}"; then
|
||||
die 'Failed to install packages to new root'
|
||||
fi
|
||||
|
||||
|
||||
if (( copymirrorlist ));then
|
||||
copy_mirrorlist "$newroot"
|
||||
fi
|
126
artools/0.26.1/artools/bin/base/basestrap.in
Normal file
126
artools/0.26.1/artools/bin/base/basestrap.in
Normal file
|
@ -0,0 +1,126 @@
|
|||
#!/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.
|
||||
|
||||
#
|
||||
# Assumptions:
|
||||
# 1) User has partitioned, formatted, and mounted partitions on /mnt
|
||||
# 2) Network is functional
|
||||
# 3) Arguments passed to the script are valid pacman targets
|
||||
# 4) A valid mirror appears in /etc/pacman.d/mirrorlist
|
||||
#
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
m4_include(lib/base/message.sh)
|
||||
m4_include(lib/base/mount.sh)
|
||||
m4_include(lib/base/chroot.sh)
|
||||
|
||||
#{{{ functions
|
||||
|
||||
copy_mirrorlist(){
|
||||
cp -a /etc/pacman.d/mirrorlist "$1/etc/pacman.d/"
|
||||
}
|
||||
|
||||
copy_keyring(){
|
||||
if [[ -d /etc/pacman.d/gnupg ]] && [[ ! -d $1/etc/pacman.d/gnupg ]]; then
|
||||
cp -a /etc/pacman.d/gnupg "$1/etc/pacman.d/"
|
||||
fi
|
||||
}
|
||||
|
||||
create_min_fs(){
|
||||
msg "Creating install root at %s" "$1"
|
||||
mkdir -m 0755 -p "$1"/var/{cache/pacman/pkg,lib/pacman,log} "$1"/{dev,run,etc/pacman.d}
|
||||
mkdir -m 1777 -p "$1"/tmp
|
||||
mkdir -m 0555 -p "$1"/{sys,proc}
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
newroot=/mnt
|
||||
|
||||
hostcache=0
|
||||
copykeyring=1
|
||||
copymirrorlist=1
|
||||
pacmode=-Sy
|
||||
|
||||
usage() {
|
||||
echo "usage: ${0##*/} [options] root [packages...]"
|
||||
echo " -C <config> Use an alternate config file for pacman"
|
||||
echo " -c Use the package cache on the host, rather than the target"
|
||||
echo " -G Avoid copying the host's pacman keyring to the target"
|
||||
echo " -i Avoid auto-confirmation of package selections"
|
||||
echo " -M Avoid copying the host's mirrorlist to the target"
|
||||
echo ' -U Use pacman -U to install packages'
|
||||
echo " -h Print this help message"
|
||||
echo ''
|
||||
echo ' basestrap installs packages to the specified new root directory.'
|
||||
echo ' If no packages are given, basestrap defaults to the "base" group.'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts=':C:cGiMU'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
C) pacman_conf=$OPTARG ;;
|
||||
c) hostcache=1 ;;
|
||||
i) interactive=1 ;;
|
||||
G) copykeyring=0 ;;
|
||||
M) copymirrorlist=0 ;;
|
||||
U) pacmode=-U ;;
|
||||
:) echo "invalid argument ${arg}:$OPTARG"; usage 1;;
|
||||
?) usage 0 ;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
check_root
|
||||
|
||||
(( $# )) || die "No root directory specified"
|
||||
newroot=$1; shift
|
||||
pacman_args=("${@:-base}")
|
||||
|
||||
if (( ! hostcache ));then
|
||||
pacman_args+=(--cachedir="$newroot/var/cache/pacman/pkg")
|
||||
fi
|
||||
|
||||
if (( ! interactive )); then
|
||||
pacman_args+=(--noconfirm)
|
||||
fi
|
||||
|
||||
[[ -n $pacman_conf ]] && pacman_args+=(--config="$pacman_conf")
|
||||
|
||||
[[ -d $newroot ]] || die "%s is not a directory" "$newroot"
|
||||
|
||||
# create obligatory directories
|
||||
create_min_fs "$newroot"
|
||||
|
||||
# mount API filesystems
|
||||
chroot_api_mount "$newroot" || die "failed to setup API filesystems in new root"
|
||||
|
||||
if (( copykeyring ));then
|
||||
copy_keyring "$newroot"
|
||||
fi
|
||||
|
||||
msg2 'Installing packages to %s' "$newroot"
|
||||
if ! unshare --fork --pid pacman -r "$newroot" $pacmode "${pacman_args[@]}"; then
|
||||
die 'Failed to install packages to new root'
|
||||
fi
|
||||
|
||||
|
||||
if (( copymirrorlist ));then
|
||||
copy_mirrorlist "$newroot"
|
||||
fi
|
414
artools/0.26.1/artools/bin/base/chroot-run
Executable file
414
artools/0.26.1/artools/bin/base/chroot-run
Executable file
|
@ -0,0 +1,414 @@
|
|||
#!/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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ mount
|
||||
|
||||
ignore_error() {
|
||||
"$@" 2>/dev/null
|
||||
return 0
|
||||
}
|
||||
|
||||
trap_setup(){
|
||||
[[ $(trap -p EXIT) ]] && die 'Error! Attempting to overwrite existing EXIT trap'
|
||||
trap "$1" EXIT
|
||||
}
|
||||
|
||||
chroot_mount() {
|
||||
# msg2 "mount: [%s]" "$2"
|
||||
mount "$@" && CHROOT_ACTIVE_MOUNTS=("$2" "${CHROOT_ACTIVE_MOUNTS[@]}")
|
||||
}
|
||||
|
||||
chroot_add_resolv_conf() {
|
||||
local chrootdir=$1 resolv_conf=$1/etc/resolv.conf
|
||||
|
||||
[[ -e /etc/resolv.conf ]] || return 0
|
||||
|
||||
# Handle resolv.conf as a symlink to somewhere else.
|
||||
if [[ -L $chrootdir/etc/resolv.conf ]]; then
|
||||
# readlink(1) should always give us *something* since we know at this point
|
||||
# it's a symlink. For simplicity, ignore the case of nested symlinks.
|
||||
resolv_conf=$(readlink "$chrootdir/etc/resolv.conf")
|
||||
if [[ $resolv_conf = /* ]]; then
|
||||
resolv_conf=$chrootdir$resolv_conf
|
||||
else
|
||||
resolv_conf=$chrootdir/etc/$resolv_conf
|
||||
fi
|
||||
|
||||
# ensure file exists to bind mount over
|
||||
if [[ ! -f $resolv_conf ]]; then
|
||||
install -Dm644 /dev/null "$resolv_conf" || return 1
|
||||
fi
|
||||
elif [[ ! -e $chrootdir/etc/resolv.conf ]]; then
|
||||
# The chroot might not have a resolv.conf.
|
||||
return 0
|
||||
fi
|
||||
|
||||
chroot_mount /etc/resolv.conf "$resolv_conf" --bind
|
||||
}
|
||||
|
||||
chroot_mount_conditional() {
|
||||
local cond=$1; shift
|
||||
if eval "$cond"; then
|
||||
chroot_mount "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
chroot_setup(){
|
||||
local mnt="$1" os="$2" args='-t tmpfs -o nosuid,nodev,mode=0755'
|
||||
$os && args='--bind'
|
||||
chroot_mount_conditional "! mountpoint -q '$mnt'" "$mnt" "$mnt" --bind &&
|
||||
chroot_mount proc "$mnt/proc" -t proc -o nosuid,noexec,nodev &&
|
||||
chroot_mount sys "$mnt/sys" -t sysfs -o nosuid,noexec,nodev,ro &&
|
||||
ignore_error chroot_mount_conditional "[[ -d '$mnt/sys/firmware/efi/efivars' ]]" \
|
||||
efivarfs "$mnt/sys/firmware/efi/efivars" -t efivarfs -o nosuid,noexec,nodev &&
|
||||
chroot_mount udev "$mnt/dev" -t devtmpfs -o mode=0755,nosuid &&
|
||||
chroot_mount devpts "$mnt/dev/pts" -t devpts -o mode=0620,gid=5,nosuid,noexec &&
|
||||
chroot_mount shm "$mnt/dev/shm" -t tmpfs -o mode=1777,nosuid,nodev &&
|
||||
chroot_mount /run "$mnt/run" ${args} &&
|
||||
chroot_mount tmp "$mnt/tmp" -t tmpfs -o mode=1777,strictatime,nodev,nosuid
|
||||
}
|
||||
|
||||
chroot_api_mount() {
|
||||
CHROOT_ACTIVE_MOUNTS=()
|
||||
trap_setup chroot_api_umount
|
||||
chroot_setup "$1" false
|
||||
}
|
||||
|
||||
chroot_api_umount() {
|
||||
if (( ${#CHROOT_ACTIVE_MOUNTS[@]} )); then
|
||||
# msg2 "umount: [%s]" "${CHROOT_ACTIVE_MOUNTS[@]}"
|
||||
umount "${CHROOT_ACTIVE_MOUNTS[@]}"
|
||||
fi
|
||||
unset CHROOT_ACTIVE_MOUNTS
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ chroot
|
||||
|
||||
orig_argv=("$0" "$@")
|
||||
check_root() {
|
||||
local keepenv="$1"
|
||||
|
||||
(( EUID == 0 )) && return
|
||||
if type -P sudo >/dev/null; then
|
||||
# shellcheck disable=2154
|
||||
exec sudo --preserve-env="$keepenv" -- "${orig_argv[@]}"
|
||||
else
|
||||
# shellcheck disable=2154
|
||||
exec su root -c "$(printf ' %q' "${orig_argv[@]}")"
|
||||
fi
|
||||
}
|
||||
|
||||
is_btrfs() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]]
|
||||
}
|
||||
|
||||
is_subvolume() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs && "$(stat -c %i "$1")" == 256 ]]
|
||||
}
|
||||
|
||||
# is_same_fs() {
|
||||
# [[ "$(stat -c %d "$1")" == "$(stat -c %d "$2")" ]]
|
||||
# }
|
||||
|
||||
subvolume_delete_recursive() {
|
||||
local subvol
|
||||
|
||||
is_subvolume "$1" || return 0
|
||||
|
||||
while IFS= read -d $'\0' -r subvol; do
|
||||
if ! subvolume_delete_recursive "$subvol"; then
|
||||
return 1
|
||||
fi
|
||||
done < <(find "$1" -mindepth 1 -xdev -depth -inum 256 -print0)
|
||||
if ! btrfs subvolume delete "$1" &>/dev/null; then
|
||||
error "Unable to delete subvolume %s" "$subvol"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
CHROOTVERSION=0.10
|
||||
|
||||
|
||||
# $1: chroot
|
||||
kill_chroot_process(){
|
||||
local prefix="$1" flink pid name
|
||||
for root_dir in /proc/*/root; do
|
||||
flink=$(readlink "$root_dir")
|
||||
if [ "x$flink" != "x" ]; then
|
||||
if [ "x${flink:0:${#prefix}}" = "x$prefix" ]; then
|
||||
# this process is in the chroot...
|
||||
pid=$(basename "$(dirname "$root_dir")")
|
||||
name=$(ps -p "$pid" -o comm=)
|
||||
msg2 "Killing chroot process: %s (%s)" "$name" "$pid"
|
||||
kill -9 "$pid"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
sleep 1
|
||||
}
|
||||
|
||||
# umask might have been changed in /etc/profile
|
||||
# ensure that sane default is set again
|
||||
umask 0022
|
||||
|
||||
working_dir=''
|
||||
files=()
|
||||
|
||||
mount_args=("-B:/etc/hosts:/etc/hosts")
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] working-dir [run arguments]"
|
||||
echo "A wrapper around chroot. Provides support for pacman."
|
||||
echo
|
||||
echo ' options:'
|
||||
echo ' -C <file> Location of a pacman config file'
|
||||
echo ' -M <file> Location of a makepkg config file'
|
||||
echo ' -c <dir> Set pacman cache'
|
||||
echo ' -f <file> Copy file from the host to the chroot'
|
||||
echo ' -s Do not run setarch'
|
||||
echo ' -b <list> Bind mountargs'
|
||||
echo ' List format [mntarg1:src1:dest1 ... mntargN:srcN:destN]'
|
||||
echo ' -h This message'
|
||||
exit 1
|
||||
}
|
||||
|
||||
opts='hC:M:c:b:f:s'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
C) pacman_conf="$OPTARG" ;;
|
||||
M) makepkg_conf="$OPTARG" ;;
|
||||
c) cache_dirs+=("$OPTARG") ;;
|
||||
f) files+=("$OPTARG") ;;
|
||||
s) nosetarch=1 ;;
|
||||
b) bindmounts+=("$OPTARG"); mount_args+=(${bindmounts[@]}) ;;
|
||||
h|?) usage ;;
|
||||
*) error "invalid argument '$arg'"; usage ;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
(( $# < 1 )) && die 'You must specify a directory.'
|
||||
|
||||
check_root
|
||||
|
||||
working_dir=$(readlink -f "$1")
|
||||
shift 1
|
||||
|
||||
[[ -z $working_dir ]] && die 'Please specify a working directory.'
|
||||
|
||||
if (( ${#cache_dirs[@]} == 0 )); then
|
||||
mapfile -t cache_dirs < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" CacheDir)
|
||||
fi
|
||||
|
||||
# shellcheck disable=2016
|
||||
host_mirrors=($(pacman-conf --repo world Server 2> /dev/null | sed -r 's#(.*/)world/os/.*#\1$repo/os/$arch#'))
|
||||
|
||||
for host_mirror in "${host_mirrors[@]}"; do
|
||||
if [[ $host_mirror == *file://* ]]; then
|
||||
# shellcheck disable=2016
|
||||
host_mirror=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g')
|
||||
in_array "$host_mirror" "${cache_dirs[@]}" || cache_dirs+=("$host_mirror")
|
||||
fi
|
||||
done
|
||||
|
||||
while read -r line; do
|
||||
# shellcheck disable=2016
|
||||
mapfile -t lines < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" \
|
||||
--repo "$line" Server | sed -r 's#(.*/)[^/]+/os/.+#\1#')
|
||||
for line in "${lines[@]}"; do
|
||||
if [[ $line = file://* ]]; then
|
||||
line=${line#file://}
|
||||
in_array "$line" "${cache_dirs[@]}" || cache_dirs+=("$line")
|
||||
fi
|
||||
done
|
||||
done < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" --repo-list)
|
||||
|
||||
copy_hostconf () {
|
||||
unshare --fork --pid gpg --homedir "$working_dir"/etc/pacman.d/gnupg/ --no-permission-warning --quiet --batch --import --import-options import-local-sigs "$(pacman-conf GpgDir)"/pubring.gpg >/dev/null 2>&1
|
||||
pacman-key --gpgdir "$working_dir"/etc/pacman.d/gnupg/ --import-trustdb "$(pacman-conf GpgDir)" >/dev/null 2>&1
|
||||
|
||||
printf 'Server = %s\n' "${host_mirrors[@]}" >"$working_dir/etc/pacman.d/mirrorlist"
|
||||
|
||||
[[ -n $pacman_conf ]] && cp "$pacman_conf" "${working_dir}/etc/pacman.conf"
|
||||
|
||||
[[ -n $makepkg_conf ]] && cp "$makepkg_conf" "${working_dir}/etc/makepkg.conf"
|
||||
|
||||
local file
|
||||
for file in "${files[@]}"; do
|
||||
mkdir -p "$(dirname "$working_dir$file")"
|
||||
cp -T "$file" "$working_dir$file"
|
||||
done
|
||||
|
||||
sed -r "s|^#?\\s*CacheDir.+|CacheDir = ${cache_dirs[*]}|g" -i "${working_dir}/etc/pacman.conf"
|
||||
}
|
||||
|
||||
mount_args+=("-B:${cache_dirs[0]//:/\\:}:${cache_dirs[0]//:/\\:}")
|
||||
|
||||
for cache_dir in "${cache_dirs[@]:1}"; do
|
||||
mount_args+=("-Br:${cache_dir//:/\\:}:${cache_dir//:/\\:}")
|
||||
done
|
||||
|
||||
chroot_extra_mount() {
|
||||
chroot_add_resolv_conf "${working_dir}"
|
||||
|
||||
for arg in "${mount_args[@]}"; do
|
||||
local flag=${arg%%:*} dest=${arg##*:} src=${arg%:*}
|
||||
src=${src#*:}
|
||||
chroot_mount "${src}" "${working_dir}${dest}" "${flag}"
|
||||
done
|
||||
}
|
||||
|
||||
umask 0022
|
||||
|
||||
# Sanity check
|
||||
if [[ ! -f "$working_dir/.artools" ]]; then
|
||||
die "'%s' does not appear to be an artix chroot." "$working_dir"
|
||||
elif [[ $(cat "$working_dir/.artools") != "${CHROOTVERSION}" ]]; then
|
||||
die "chroot '%s' is not at version %s. Please rebuild." "$working_dir" "${CHROOTVERSION}"
|
||||
fi
|
||||
|
||||
chroot_api_mount "${working_dir}" || die "failed to setup API filesystems in chroot %s" "${working_dir}"
|
||||
|
||||
chroot_extra_mount
|
||||
|
||||
copy_hostconf
|
||||
|
||||
eval "$(grep '^CARCH=' "$working_dir/etc/makepkg.conf")"
|
||||
|
||||
[[ -z $nosetarch ]] || unset CARCH
|
||||
|
||||
if [[ -f "/usr/share/artools/setarch-aliases.d/${CARCH}" ]]; then
|
||||
read -r set_arch < "/usr/share/artools/setarch-aliases.d/${CARCH}"
|
||||
else
|
||||
set_arch="${CARCH}"
|
||||
fi
|
||||
|
||||
${CARCH:+setarch "${set_arch}"} chroot "${working_dir}" "$@"
|
||||
|
||||
ret=$?
|
||||
|
||||
kill_chroot_process "${working_dir}"
|
||||
|
||||
exit $ret
|
181
artools/0.26.1/artools/bin/base/chroot-run.in
Normal file
181
artools/0.26.1/artools/bin/base/chroot-run.in
Normal file
|
@ -0,0 +1,181 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/base/message.sh)
|
||||
m4_include(lib/base/mount.sh)
|
||||
m4_include(lib/base/chroot.sh)
|
||||
m4_include(lib/base/chroot-version.sh)
|
||||
|
||||
# $1: chroot
|
||||
kill_chroot_process(){
|
||||
local prefix="$1" flink pid name
|
||||
for root_dir in /proc/*/root; do
|
||||
flink=$(readlink "$root_dir")
|
||||
if [ "x$flink" != "x" ]; then
|
||||
if [ "x${flink:0:${#prefix}}" = "x$prefix" ]; then
|
||||
# this process is in the chroot...
|
||||
pid=$(basename "$(dirname "$root_dir")")
|
||||
name=$(ps -p "$pid" -o comm=)
|
||||
msg2 "Killing chroot process: %s (%s)" "$name" "$pid"
|
||||
kill -9 "$pid"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
sleep 1
|
||||
}
|
||||
|
||||
# umask might have been changed in /etc/profile
|
||||
# ensure that sane default is set again
|
||||
umask 0022
|
||||
|
||||
working_dir=''
|
||||
files=()
|
||||
|
||||
mount_args=("-B:/etc/hosts:/etc/hosts")
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] working-dir [run arguments]"
|
||||
echo "A wrapper around chroot. Provides support for pacman."
|
||||
echo
|
||||
echo ' options:'
|
||||
echo ' -C <file> Location of a pacman config file'
|
||||
echo ' -M <file> Location of a makepkg config file'
|
||||
echo ' -c <dir> Set pacman cache'
|
||||
echo ' -f <file> Copy file from the host to the chroot'
|
||||
echo ' -s Do not run setarch'
|
||||
echo ' -b <list> Bind mountargs'
|
||||
echo ' List format [mntarg1:src1:dest1 ... mntargN:srcN:destN]'
|
||||
echo ' -h This message'
|
||||
exit 1
|
||||
}
|
||||
|
||||
opts='hC:M:c:b:f:s'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
C) pacman_conf="$OPTARG" ;;
|
||||
M) makepkg_conf="$OPTARG" ;;
|
||||
c) cache_dirs+=("$OPTARG") ;;
|
||||
f) files+=("$OPTARG") ;;
|
||||
s) nosetarch=1 ;;
|
||||
b) bindmounts+=("$OPTARG"); mount_args+=(${bindmounts[@]}) ;;
|
||||
h|?) usage ;;
|
||||
*) error "invalid argument '$arg'"; usage ;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
(( $# < 1 )) && die 'You must specify a directory.'
|
||||
|
||||
check_root
|
||||
|
||||
working_dir=$(readlink -f "$1")
|
||||
shift 1
|
||||
|
||||
[[ -z $working_dir ]] && die 'Please specify a working directory.'
|
||||
|
||||
if (( ${#cache_dirs[@]} == 0 )); then
|
||||
mapfile -t cache_dirs < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" CacheDir)
|
||||
fi
|
||||
|
||||
# shellcheck disable=2016
|
||||
host_mirrors=($(pacman-conf --repo world Server 2> /dev/null | sed -r 's#(.*/)world/os/.*#\1$repo/os/$arch#'))
|
||||
|
||||
for host_mirror in "${host_mirrors[@]}"; do
|
||||
if [[ $host_mirror == *file://* ]]; then
|
||||
# shellcheck disable=2016
|
||||
host_mirror=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g')
|
||||
in_array "$host_mirror" "${cache_dirs[@]}" || cache_dirs+=("$host_mirror")
|
||||
fi
|
||||
done
|
||||
|
||||
while read -r line; do
|
||||
# shellcheck disable=2016
|
||||
mapfile -t lines < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" \
|
||||
--repo "$line" Server | sed -r 's#(.*/)[^/]+/os/.+#\1#')
|
||||
for line in "${lines[@]}"; do
|
||||
if [[ $line = file://* ]]; then
|
||||
line=${line#file://}
|
||||
in_array "$line" "${cache_dirs[@]}" || cache_dirs+=("$line")
|
||||
fi
|
||||
done
|
||||
done < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" --repo-list)
|
||||
|
||||
copy_hostconf () {
|
||||
unshare --fork --pid gpg --homedir "$working_dir"/etc/pacman.d/gnupg/ --no-permission-warning --quiet --batch --import --import-options import-local-sigs "$(pacman-conf GpgDir)"/pubring.gpg >/dev/null 2>&1
|
||||
pacman-key --gpgdir "$working_dir"/etc/pacman.d/gnupg/ --import-trustdb "$(pacman-conf GpgDir)" >/dev/null 2>&1
|
||||
|
||||
printf 'Server = %s\n' "${host_mirrors[@]}" >"$working_dir/etc/pacman.d/mirrorlist"
|
||||
|
||||
[[ -n $pacman_conf ]] && cp "$pacman_conf" "${working_dir}/etc/pacman.conf"
|
||||
|
||||
[[ -n $makepkg_conf ]] && cp "$makepkg_conf" "${working_dir}/etc/makepkg.conf"
|
||||
|
||||
local file
|
||||
for file in "${files[@]}"; do
|
||||
mkdir -p "$(dirname "$working_dir$file")"
|
||||
cp -T "$file" "$working_dir$file"
|
||||
done
|
||||
|
||||
sed -r "s|^#?\\s*CacheDir.+|CacheDir = ${cache_dirs[*]}|g" -i "${working_dir}/etc/pacman.conf"
|
||||
}
|
||||
|
||||
mount_args+=("-B:${cache_dirs[0]//:/\\:}:${cache_dirs[0]//:/\\:}")
|
||||
|
||||
for cache_dir in "${cache_dirs[@]:1}"; do
|
||||
mount_args+=("-Br:${cache_dir//:/\\:}:${cache_dir//:/\\:}")
|
||||
done
|
||||
|
||||
chroot_extra_mount() {
|
||||
chroot_add_resolv_conf "${working_dir}"
|
||||
|
||||
for arg in "${mount_args[@]}"; do
|
||||
local flag=${arg%%:*} dest=${arg##*:} src=${arg%:*}
|
||||
src=${src#*:}
|
||||
chroot_mount "${src}" "${working_dir}${dest}" "${flag}"
|
||||
done
|
||||
}
|
||||
|
||||
umask 0022
|
||||
|
||||
# Sanity check
|
||||
if [[ ! -f "$working_dir/.artools" ]]; then
|
||||
die "'%s' does not appear to be an artix chroot." "$working_dir"
|
||||
elif [[ $(cat "$working_dir/.artools") != "${CHROOTVERSION}" ]]; then
|
||||
die "chroot '%s' is not at version %s. Please rebuild." "$working_dir" "${CHROOTVERSION}"
|
||||
fi
|
||||
|
||||
chroot_api_mount "${working_dir}" || die "failed to setup API filesystems in chroot %s" "${working_dir}"
|
||||
|
||||
chroot_extra_mount
|
||||
|
||||
copy_hostconf
|
||||
|
||||
eval "$(grep '^CARCH=' "$working_dir/etc/makepkg.conf")"
|
||||
|
||||
[[ -z $nosetarch ]] || unset CARCH
|
||||
|
||||
if [[ -f "@datadir@/artools/setarch-aliases.d/${CARCH}" ]]; then
|
||||
read -r set_arch < "@datadir@/artools/setarch-aliases.d/${CARCH}"
|
||||
else
|
||||
set_arch="${CARCH}"
|
||||
fi
|
||||
|
||||
${CARCH:+setarch "${set_arch}"} chroot "${working_dir}" "$@"
|
||||
|
||||
ret=$?
|
||||
|
||||
kill_chroot_process "${working_dir}"
|
||||
|
||||
exit $ret
|
529
artools/0.26.1/artools/bin/base/fstabgen
Executable file
529
artools/0.26.1/artools/bin/base/fstabgen
Executable file
|
@ -0,0 +1,529 @@
|
|||
#!/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.
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
|
||||
#{{{ filesystems
|
||||
|
||||
declare -A pseudofs_types=([anon_inodefs]=1
|
||||
[autofs]=1
|
||||
[bdev]=1
|
||||
[bpf]=1
|
||||
[binfmt_misc]=1
|
||||
[cgroup]=1
|
||||
[cgroup2]=1
|
||||
[configfs]=1
|
||||
[cpuset]=1
|
||||
[debugfs]=1
|
||||
[devfs]=1
|
||||
[devpts]=1
|
||||
[devtmpfs]=1
|
||||
[dlmfs]=1
|
||||
[efivarfs]=1
|
||||
[fuse.gvfs-fuse-daemon]=1
|
||||
[fusectl]=1
|
||||
[hugetlbfs]=1
|
||||
[mqueue]=1
|
||||
[nfsd]=1
|
||||
[none]=1
|
||||
[pipefs]=1
|
||||
[proc]=1
|
||||
[pstore]=1
|
||||
[ramfs]=1
|
||||
[rootfs]=1
|
||||
[rpc_pipefs]=1
|
||||
[securityfs]=1
|
||||
[sockfs]=1
|
||||
[spufs]=1
|
||||
[sysfs]=1
|
||||
[tmpfs]=1)
|
||||
|
||||
declare -A fsck_types=([cramfs]=1
|
||||
[exfat]=1
|
||||
[ext2]=1
|
||||
[ext3]=1
|
||||
[ext4]=1
|
||||
[ext4dev]=1
|
||||
[jfs]=1
|
||||
[minix]=1
|
||||
[msdos]=1
|
||||
[reiserfs]=1
|
||||
[vfat]=1
|
||||
[xfs]=1)
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ functions
|
||||
|
||||
fstype_is_pseudofs() {
|
||||
(( pseudofs_types["$1"] ))
|
||||
}
|
||||
|
||||
fstype_has_fsck() {
|
||||
(( fsck_types["$1"] ))
|
||||
}
|
||||
|
||||
valid_number_of_base() {
|
||||
local base=$1 len=${#2} i
|
||||
|
||||
for (( i = 0; i < len; i++ )); do
|
||||
{ _=$(( $base#${2:i:1} )) || return 1; } 2>/dev/null
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
mangle() {
|
||||
local i chr out
|
||||
|
||||
local {a..f}= {A..F}=
|
||||
|
||||
for (( i = 0; i < ${#1}; i++ )); do
|
||||
chr=${1:i:1}
|
||||
case $chr in
|
||||
[[:space:]\\])
|
||||
printf -v chr '%03o' "'$chr"
|
||||
out+=\\
|
||||
;;
|
||||
esac
|
||||
out+=$chr
|
||||
done
|
||||
|
||||
printf '%s' "$out"
|
||||
}
|
||||
|
||||
unmangle() {
|
||||
local i chr out len=$(( ${#1} - 4 ))
|
||||
|
||||
local {a..f}= {A..F}=
|
||||
|
||||
for (( i = 0; i < len; i++ )); do
|
||||
chr=${1:i:1}
|
||||
case $chr in
|
||||
\\)
|
||||
if valid_number_of_base 8 "${1:i+1:3}" ||
|
||||
valid_number_of_base 16 "${1:i+1:3}"; then
|
||||
printf -v chr '%b' "${1:i:4}"
|
||||
(( i += 3 ))
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
out+=$chr
|
||||
done
|
||||
|
||||
printf '%s' "$out${1:i}"
|
||||
}
|
||||
|
||||
dm_name_for_devnode() {
|
||||
read -r dm_name <"/sys/class/block/${1#/dev/}/dm/name"
|
||||
if [[ $dm_name ]]; then
|
||||
printf '/dev/mapper/%s' "$dm_name"
|
||||
else
|
||||
# don't leave the caller hanging, just print the original name
|
||||
# along with the failure.
|
||||
print '%s' "$1"
|
||||
error 'Failed to resolve device mapper name for: %s' "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
optstring_match_option() {
|
||||
local candidate pat patterns
|
||||
|
||||
IFS=, read -ra patterns <<<"$1"
|
||||
for pat in "${patterns[@]}"; do
|
||||
if [[ $pat = *=* ]]; then
|
||||
# "key=val" will only ever match "key=val"
|
||||
candidate=$2
|
||||
else
|
||||
# "key" will match "key", but also "key=anyval"
|
||||
candidate=${2%%=*}
|
||||
fi
|
||||
|
||||
[[ $pat = "$candidate" ]] && return 0
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
optstring_remove_option() {
|
||||
local o options_ remove=$2 IFS=,
|
||||
|
||||
read -ra options_ <<<"${!1}"
|
||||
|
||||
for o in "${!options_[@]}"; do
|
||||
optstring_match_option "$remove" "${options_[o]}" && unset 'options_[o]'
|
||||
done
|
||||
|
||||
declare -g "$1=${options_[*]}"
|
||||
}
|
||||
|
||||
optstring_normalize() {
|
||||
local o options_ norm IFS=,
|
||||
|
||||
read -ra options_ <<<"${!1}"
|
||||
|
||||
# remove empty fields
|
||||
for o in "${options_[@]}"; do
|
||||
[[ $o ]] && norm+=("$o")
|
||||
done
|
||||
|
||||
# avoid empty strings, reset to "defaults"
|
||||
declare -g "$1=${norm[*]:-defaults}"
|
||||
}
|
||||
|
||||
optstring_append_option() {
|
||||
if ! optstring_has_option "$1" "$2"; then
|
||||
declare -g "$1=${!1},$2"
|
||||
fi
|
||||
|
||||
optstring_normalize "$1"
|
||||
}
|
||||
|
||||
optstring_prepend_option() {
|
||||
if ! optstring_has_option "$1" "$2"; then
|
||||
declare -g "$1=$2,${!1}"
|
||||
fi
|
||||
|
||||
optstring_normalize "$1"
|
||||
}
|
||||
|
||||
optstring_get_option() {
|
||||
local opts o
|
||||
|
||||
IFS=, read -ra opts <<<"${!1}"
|
||||
for o in "${opts[@]}"; do
|
||||
if optstring_match_option "$2" "$o"; then
|
||||
declare -g "$o"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
optstring_has_option() {
|
||||
local "${2%%=*}"
|
||||
|
||||
optstring_get_option "$1" "$2"
|
||||
}
|
||||
|
||||
write_source() {
|
||||
local src=$1 spec label uuid comment=()
|
||||
|
||||
label=$(lsblk -rno LABEL "$1" 2>/dev/null)
|
||||
uuid=$(lsblk -rno UUID "$1" 2>/dev/null)
|
||||
|
||||
# bind mounts do not have a UUID!
|
||||
|
||||
case $bytag in
|
||||
'')
|
||||
[[ $uuid ]] && comment=("UUID=$uuid")
|
||||
[[ $label ]] && comment+=("LABEL=$(mangle "$label")")
|
||||
;;
|
||||
LABEL)
|
||||
spec=$label
|
||||
[[ $uuid ]] && comment=("$src" "UUID=$uuid")
|
||||
;;
|
||||
UUID)
|
||||
spec=$uuid
|
||||
comment=("$src")
|
||||
[[ $label ]] && comment+=("LABEL=$(mangle "$label")")
|
||||
;;
|
||||
*)
|
||||
[[ $uuid ]] && comment=("$1" "UUID=$uuid")
|
||||
[[ $label ]] && comment+=("LABEL=$(mangle "$label")")
|
||||
[[ $bytag ]] && spec=$(lsblk -rno "$bytag" "$1" 2>/dev/null)
|
||||
;;
|
||||
esac
|
||||
|
||||
[[ -n "${comment[*]}" ]] && printf '# %s\n' "${comment[*]}"
|
||||
|
||||
if [[ $spec ]]; then
|
||||
printf '%-20s' "$bytag=$(mangle "$spec")"
|
||||
else
|
||||
printf '%-20s' "$(mangle "$src")"
|
||||
fi
|
||||
}
|
||||
|
||||
optstring_apply_quirks() {
|
||||
local varname="$1" fstype="$2"
|
||||
|
||||
# SELinux displays a 'seclabel' option in /proc/self/mountinfo. We can't know
|
||||
# if the system we're generating the fstab for has any support for SELinux (as
|
||||
# one might install Arch from a Fedora environment), so let's remove it.
|
||||
optstring_remove_option "$varname" seclabel
|
||||
|
||||
# Prune 'relatime' option for any pseudofs. This seems to be a rampant
|
||||
# default which the kernel often exports even if the underlying filesystem
|
||||
# doesn't support it. Example: https://bugs.archlinux.org/task/54554.
|
||||
if awk -v fstype="$fstype" '$1 == fstype { exit 1 }' /proc/filesystems; then
|
||||
optstring_remove_option "$varname" relatime
|
||||
fi
|
||||
|
||||
case $fstype in
|
||||
f2fs)
|
||||
# These are Kconfig options for f2fs. Kernels supporting the options will
|
||||
# only provide the negative versions of these (e.g. noacl), and vice versa
|
||||
# for kernels without support.
|
||||
optstring_remove_option "$varname" noacl,acl,nouser_xattr,user_xattr
|
||||
;;
|
||||
vfat)
|
||||
# Before Linux v3.8, "cp" is prepended to the value of the codepage.
|
||||
if optstring_get_option "$varname" codepage && [[ "$codepage" = cp* ]]; then
|
||||
optstring_remove_option "$varname" codepage
|
||||
optstring_append_option "$varname" "codepage=${codepage#cp}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
usage: ${0##*/} [options] root
|
||||
|
||||
Options:
|
||||
-f FILTER Restrict output to mountpoints matching the prefix FILTER
|
||||
-L Use labels for source identifiers (shortcut for -t LABEL)
|
||||
-p Exclude pseudofs mounts (default behavior)
|
||||
-P Include printing mounts
|
||||
-t TAG Use TAG for source identifiers
|
||||
-U Use UUIDs for source identifiers (shortcut for -t UUID)
|
||||
|
||||
-h Print this help message
|
||||
|
||||
fstabgen generates output suitable for addition to an fstab file based on the
|
||||
devices mounted under the mountpoint specified by the given root.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ -z $1 || $1 = @(-h|--help) ]]; then
|
||||
usage
|
||||
exit $(( $# ? 0 : 1 ))
|
||||
fi
|
||||
|
||||
while getopts ':f:LPpt:U' flag; do
|
||||
case $flag in
|
||||
L) bytag=LABEL ;;
|
||||
U) bytag=UUID ;;
|
||||
f) prefixfilter=$OPTARG ;;
|
||||
P) pseudofs=1 ;;
|
||||
p) pseudofs=0 ;;
|
||||
t) bytag=${OPTARG^^} ;;
|
||||
:) die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG" ;;
|
||||
?) die '%s: invalid option -- '\''%s'\' "${0##*/}" "$OPTARG" ;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
(( $# )) || die "No root directory specified"
|
||||
root=$(realpath -mL "$1"); shift
|
||||
|
||||
if ! mountpoint -q "$root"; then
|
||||
die "$root is not a mountpoint"
|
||||
fi
|
||||
|
||||
# handle block devices
|
||||
findmnt -Recvruno SOURCE,TARGET,FSTYPE,OPTIONS,FSROOT "$root" |
|
||||
while read -r src target fstype opts fsroot; do
|
||||
if (( !pseudofs )) && fstype_is_pseudofs "$fstype"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
[[ $target = "$prefixfilter"* ]] || continue
|
||||
|
||||
# default 5th and 6th columns
|
||||
dump=0 pass=2
|
||||
|
||||
src=$(unmangle "$src")
|
||||
target=$(unmangle "$target")
|
||||
target=${target#$root}
|
||||
|
||||
if (( !foundroot )) && findmnt "$src" "$root" >/dev/null; then
|
||||
# this is root. we can't possibly have more than one...
|
||||
pass=1 foundroot=1
|
||||
fi
|
||||
|
||||
# if there's no fsck tool available, then only pass=0 makes sense.
|
||||
if ! fstype_has_fsck "$fstype"; then
|
||||
pass=0
|
||||
fi
|
||||
|
||||
if [[ $fsroot != / && $fstype != btrfs ]]; then
|
||||
# it's a bind mount
|
||||
src=$(findmnt -funcevo TARGET "$src")$fsroot
|
||||
if [[ $src -ef $target ]]; then
|
||||
# hrmm, this is weird. we're probably looking at a file or directory
|
||||
# that was bound into a chroot from the host machine. Ignore it,
|
||||
# because this won't actually be a valid mount. Worst case, the user
|
||||
# just re-adds it.
|
||||
continue
|
||||
fi
|
||||
fstype=none
|
||||
opts+=,bind
|
||||
pass=0
|
||||
fi
|
||||
|
||||
# filesystem quirks
|
||||
case $fstype in
|
||||
fuseblk)
|
||||
# well-behaved FUSE filesystems will report themselves as fuse.$fstype.
|
||||
# this is probably NTFS-3g, but let's just make sure.
|
||||
if ! newtype=$(lsblk -no FSTYPE "$src") || [[ -z $newtype ]]; then
|
||||
# avoid blanking out fstype, leading to an invalid fstab
|
||||
error 'Failed to derive real filesystem type for FUSE device on %s' "$target"
|
||||
else
|
||||
fstype=$newtype
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
optstring_apply_quirks "opts" "$fstype"
|
||||
|
||||
# write one line
|
||||
write_source "$src"
|
||||
printf '\t%-10s' "/$(mangle "${target#/}")" "$fstype" "$opts"
|
||||
printf '\t%s %s' "$dump" "$pass"
|
||||
printf '\n\n'
|
||||
done
|
||||
|
||||
# handle swaps devices
|
||||
{
|
||||
# ignore header
|
||||
read -r
|
||||
|
||||
while read -r device type _ _ prio; do
|
||||
options=defaults
|
||||
if (( prio >= 0 )); then
|
||||
options+=,pri=$prio
|
||||
fi
|
||||
|
||||
# skip files marked deleted by the kernel
|
||||
[[ $device = *'\040(deleted)' ]] && continue
|
||||
|
||||
if [[ $type = file ]]; then
|
||||
printf '%-20s' "${device#${root%/}}"
|
||||
elif [[ $device = /dev/dm-+([0-9]) ]]; then
|
||||
# device mapper doesn't allow characters we need to worry
|
||||
# about being mangled, and it does the escaping of dashes
|
||||
# for us in sysfs.
|
||||
write_source "$(dm_name_for_devnode "$device")"
|
||||
else
|
||||
write_source "$(unmangle "$device")"
|
||||
fi
|
||||
|
||||
printf '\t%-10s\t%-10s\t%-10s\t0 0\n\n' 'none' 'swap' "$options"
|
||||
done
|
||||
} </proc/swaps
|
432
artools/0.26.1/artools/bin/base/fstabgen.in
Normal file
432
artools/0.26.1/artools/bin/base/fstabgen.in
Normal file
|
@ -0,0 +1,432 @@
|
|||
#!/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.
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
m4_include(lib/base/message.sh)
|
||||
|
||||
#{{{ filesystems
|
||||
|
||||
declare -A pseudofs_types=([anon_inodefs]=1
|
||||
[autofs]=1
|
||||
[bdev]=1
|
||||
[bpf]=1
|
||||
[binfmt_misc]=1
|
||||
[cgroup]=1
|
||||
[cgroup2]=1
|
||||
[configfs]=1
|
||||
[cpuset]=1
|
||||
[debugfs]=1
|
||||
[devfs]=1
|
||||
[devpts]=1
|
||||
[devtmpfs]=1
|
||||
[dlmfs]=1
|
||||
[efivarfs]=1
|
||||
[fuse.gvfs-fuse-daemon]=1
|
||||
[fusectl]=1
|
||||
[hugetlbfs]=1
|
||||
[mqueue]=1
|
||||
[nfsd]=1
|
||||
[none]=1
|
||||
[pipefs]=1
|
||||
[proc]=1
|
||||
[pstore]=1
|
||||
[ramfs]=1
|
||||
[rootfs]=1
|
||||
[rpc_pipefs]=1
|
||||
[securityfs]=1
|
||||
[sockfs]=1
|
||||
[spufs]=1
|
||||
[sysfs]=1
|
||||
[tmpfs]=1)
|
||||
|
||||
declare -A fsck_types=([cramfs]=1
|
||||
[exfat]=1
|
||||
[ext2]=1
|
||||
[ext3]=1
|
||||
[ext4]=1
|
||||
[ext4dev]=1
|
||||
[jfs]=1
|
||||
[minix]=1
|
||||
[msdos]=1
|
||||
[reiserfs]=1
|
||||
[vfat]=1
|
||||
[xfs]=1)
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ functions
|
||||
|
||||
fstype_is_pseudofs() {
|
||||
(( pseudofs_types["$1"] ))
|
||||
}
|
||||
|
||||
fstype_has_fsck() {
|
||||
(( fsck_types["$1"] ))
|
||||
}
|
||||
|
||||
valid_number_of_base() {
|
||||
local base=$1 len=${#2} i
|
||||
|
||||
for (( i = 0; i < len; i++ )); do
|
||||
{ _=$(( $base#${2:i:1} )) || return 1; } 2>/dev/null
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
mangle() {
|
||||
local i chr out
|
||||
|
||||
local {a..f}= {A..F}=
|
||||
|
||||
for (( i = 0; i < ${#1}; i++ )); do
|
||||
chr=${1:i:1}
|
||||
case $chr in
|
||||
[[:space:]\\])
|
||||
printf -v chr '%03o' "'$chr"
|
||||
out+=\\
|
||||
;;
|
||||
esac
|
||||
out+=$chr
|
||||
done
|
||||
|
||||
printf '%s' "$out"
|
||||
}
|
||||
|
||||
unmangle() {
|
||||
local i chr out len=$(( ${#1} - 4 ))
|
||||
|
||||
local {a..f}= {A..F}=
|
||||
|
||||
for (( i = 0; i < len; i++ )); do
|
||||
chr=${1:i:1}
|
||||
case $chr in
|
||||
\\)
|
||||
if valid_number_of_base 8 "${1:i+1:3}" ||
|
||||
valid_number_of_base 16 "${1:i+1:3}"; then
|
||||
printf -v chr '%b' "${1:i:4}"
|
||||
(( i += 3 ))
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
out+=$chr
|
||||
done
|
||||
|
||||
printf '%s' "$out${1:i}"
|
||||
}
|
||||
|
||||
dm_name_for_devnode() {
|
||||
read -r dm_name <"/sys/class/block/${1#/dev/}/dm/name"
|
||||
if [[ $dm_name ]]; then
|
||||
printf '/dev/mapper/%s' "$dm_name"
|
||||
else
|
||||
# don't leave the caller hanging, just print the original name
|
||||
# along with the failure.
|
||||
print '%s' "$1"
|
||||
error 'Failed to resolve device mapper name for: %s' "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
optstring_match_option() {
|
||||
local candidate pat patterns
|
||||
|
||||
IFS=, read -ra patterns <<<"$1"
|
||||
for pat in "${patterns[@]}"; do
|
||||
if [[ $pat = *=* ]]; then
|
||||
# "key=val" will only ever match "key=val"
|
||||
candidate=$2
|
||||
else
|
||||
# "key" will match "key", but also "key=anyval"
|
||||
candidate=${2%%=*}
|
||||
fi
|
||||
|
||||
[[ $pat = "$candidate" ]] && return 0
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
optstring_remove_option() {
|
||||
local o options_ remove=$2 IFS=,
|
||||
|
||||
read -ra options_ <<<"${!1}"
|
||||
|
||||
for o in "${!options_[@]}"; do
|
||||
optstring_match_option "$remove" "${options_[o]}" && unset 'options_[o]'
|
||||
done
|
||||
|
||||
declare -g "$1=${options_[*]}"
|
||||
}
|
||||
|
||||
optstring_normalize() {
|
||||
local o options_ norm IFS=,
|
||||
|
||||
read -ra options_ <<<"${!1}"
|
||||
|
||||
# remove empty fields
|
||||
for o in "${options_[@]}"; do
|
||||
[[ $o ]] && norm+=("$o")
|
||||
done
|
||||
|
||||
# avoid empty strings, reset to "defaults"
|
||||
declare -g "$1=${norm[*]:-defaults}"
|
||||
}
|
||||
|
||||
optstring_append_option() {
|
||||
if ! optstring_has_option "$1" "$2"; then
|
||||
declare -g "$1=${!1},$2"
|
||||
fi
|
||||
|
||||
optstring_normalize "$1"
|
||||
}
|
||||
|
||||
optstring_prepend_option() {
|
||||
if ! optstring_has_option "$1" "$2"; then
|
||||
declare -g "$1=$2,${!1}"
|
||||
fi
|
||||
|
||||
optstring_normalize "$1"
|
||||
}
|
||||
|
||||
optstring_get_option() {
|
||||
local opts o
|
||||
|
||||
IFS=, read -ra opts <<<"${!1}"
|
||||
for o in "${opts[@]}"; do
|
||||
if optstring_match_option "$2" "$o"; then
|
||||
declare -g "$o"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
optstring_has_option() {
|
||||
local "${2%%=*}"
|
||||
|
||||
optstring_get_option "$1" "$2"
|
||||
}
|
||||
|
||||
write_source() {
|
||||
local src=$1 spec label uuid comment=()
|
||||
|
||||
label=$(lsblk -rno LABEL "$1" 2>/dev/null)
|
||||
uuid=$(lsblk -rno UUID "$1" 2>/dev/null)
|
||||
|
||||
# bind mounts do not have a UUID!
|
||||
|
||||
case $bytag in
|
||||
'')
|
||||
[[ $uuid ]] && comment=("UUID=$uuid")
|
||||
[[ $label ]] && comment+=("LABEL=$(mangle "$label")")
|
||||
;;
|
||||
LABEL)
|
||||
spec=$label
|
||||
[[ $uuid ]] && comment=("$src" "UUID=$uuid")
|
||||
;;
|
||||
UUID)
|
||||
spec=$uuid
|
||||
comment=("$src")
|
||||
[[ $label ]] && comment+=("LABEL=$(mangle "$label")")
|
||||
;;
|
||||
*)
|
||||
[[ $uuid ]] && comment=("$1" "UUID=$uuid")
|
||||
[[ $label ]] && comment+=("LABEL=$(mangle "$label")")
|
||||
[[ $bytag ]] && spec=$(lsblk -rno "$bytag" "$1" 2>/dev/null)
|
||||
;;
|
||||
esac
|
||||
|
||||
[[ -n "${comment[*]}" ]] && printf '# %s\n' "${comment[*]}"
|
||||
|
||||
if [[ $spec ]]; then
|
||||
printf '%-20s' "$bytag=$(mangle "$spec")"
|
||||
else
|
||||
printf '%-20s' "$(mangle "$src")"
|
||||
fi
|
||||
}
|
||||
|
||||
optstring_apply_quirks() {
|
||||
local varname="$1" fstype="$2"
|
||||
|
||||
# SELinux displays a 'seclabel' option in /proc/self/mountinfo. We can't know
|
||||
# if the system we're generating the fstab for has any support for SELinux (as
|
||||
# one might install Arch from a Fedora environment), so let's remove it.
|
||||
optstring_remove_option "$varname" seclabel
|
||||
|
||||
# Prune 'relatime' option for any pseudofs. This seems to be a rampant
|
||||
# default which the kernel often exports even if the underlying filesystem
|
||||
# doesn't support it. Example: https://bugs.archlinux.org/task/54554.
|
||||
if awk -v fstype="$fstype" '$1 == fstype { exit 1 }' /proc/filesystems; then
|
||||
optstring_remove_option "$varname" relatime
|
||||
fi
|
||||
|
||||
case $fstype in
|
||||
f2fs)
|
||||
# These are Kconfig options for f2fs. Kernels supporting the options will
|
||||
# only provide the negative versions of these (e.g. noacl), and vice versa
|
||||
# for kernels without support.
|
||||
optstring_remove_option "$varname" noacl,acl,nouser_xattr,user_xattr
|
||||
;;
|
||||
vfat)
|
||||
# Before Linux v3.8, "cp" is prepended to the value of the codepage.
|
||||
if optstring_get_option "$varname" codepage && [[ "$codepage" = cp* ]]; then
|
||||
optstring_remove_option "$varname" codepage
|
||||
optstring_append_option "$varname" "codepage=${codepage#cp}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
usage: ${0##*/} [options] root
|
||||
|
||||
Options:
|
||||
-f FILTER Restrict output to mountpoints matching the prefix FILTER
|
||||
-L Use labels for source identifiers (shortcut for -t LABEL)
|
||||
-p Exclude pseudofs mounts (default behavior)
|
||||
-P Include printing mounts
|
||||
-t TAG Use TAG for source identifiers
|
||||
-U Use UUIDs for source identifiers (shortcut for -t UUID)
|
||||
|
||||
-h Print this help message
|
||||
|
||||
fstabgen generates output suitable for addition to an fstab file based on the
|
||||
devices mounted under the mountpoint specified by the given root.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ -z $1 || $1 = @(-h|--help) ]]; then
|
||||
usage
|
||||
exit $(( $# ? 0 : 1 ))
|
||||
fi
|
||||
|
||||
while getopts ':f:LPpt:U' flag; do
|
||||
case $flag in
|
||||
L) bytag=LABEL ;;
|
||||
U) bytag=UUID ;;
|
||||
f) prefixfilter=$OPTARG ;;
|
||||
P) pseudofs=1 ;;
|
||||
p) pseudofs=0 ;;
|
||||
t) bytag=${OPTARG^^} ;;
|
||||
:) die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG" ;;
|
||||
?) die '%s: invalid option -- '\''%s'\' "${0##*/}" "$OPTARG" ;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
(( $# )) || die "No root directory specified"
|
||||
root=$(realpath -mL "$1"); shift
|
||||
|
||||
if ! mountpoint -q "$root"; then
|
||||
die "$root is not a mountpoint"
|
||||
fi
|
||||
|
||||
# handle block devices
|
||||
findmnt -Recvruno SOURCE,TARGET,FSTYPE,OPTIONS,FSROOT "$root" |
|
||||
while read -r src target fstype opts fsroot; do
|
||||
if (( !pseudofs )) && fstype_is_pseudofs "$fstype"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
[[ $target = "$prefixfilter"* ]] || continue
|
||||
|
||||
# default 5th and 6th columns
|
||||
dump=0 pass=2
|
||||
|
||||
src=$(unmangle "$src")
|
||||
target=$(unmangle "$target")
|
||||
target=${target#$root}
|
||||
|
||||
if (( !foundroot )) && findmnt "$src" "$root" >/dev/null; then
|
||||
# this is root. we can't possibly have more than one...
|
||||
pass=1 foundroot=1
|
||||
fi
|
||||
|
||||
# if there's no fsck tool available, then only pass=0 makes sense.
|
||||
if ! fstype_has_fsck "$fstype"; then
|
||||
pass=0
|
||||
fi
|
||||
|
||||
if [[ $fsroot != / && $fstype != btrfs ]]; then
|
||||
# it's a bind mount
|
||||
src=$(findmnt -funcevo TARGET "$src")$fsroot
|
||||
if [[ $src -ef $target ]]; then
|
||||
# hrmm, this is weird. we're probably looking at a file or directory
|
||||
# that was bound into a chroot from the host machine. Ignore it,
|
||||
# because this won't actually be a valid mount. Worst case, the user
|
||||
# just re-adds it.
|
||||
continue
|
||||
fi
|
||||
fstype=none
|
||||
opts+=,bind
|
||||
pass=0
|
||||
fi
|
||||
|
||||
# filesystem quirks
|
||||
case $fstype in
|
||||
fuseblk)
|
||||
# well-behaved FUSE filesystems will report themselves as fuse.$fstype.
|
||||
# this is probably NTFS-3g, but let's just make sure.
|
||||
if ! newtype=$(lsblk -no FSTYPE "$src") || [[ -z $newtype ]]; then
|
||||
# avoid blanking out fstype, leading to an invalid fstab
|
||||
error 'Failed to derive real filesystem type for FUSE device on %s' "$target"
|
||||
else
|
||||
fstype=$newtype
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
optstring_apply_quirks "opts" "$fstype"
|
||||
|
||||
# write one line
|
||||
write_source "$src"
|
||||
printf '\t%-10s' "/$(mangle "${target#/}")" "$fstype" "$opts"
|
||||
printf '\t%s %s' "$dump" "$pass"
|
||||
printf '\n\n'
|
||||
done
|
||||
|
||||
# handle swaps devices
|
||||
{
|
||||
# ignore header
|
||||
read -r
|
||||
|
||||
while read -r device type _ _ prio; do
|
||||
options=defaults
|
||||
if (( prio >= 0 )); then
|
||||
options+=,pri=$prio
|
||||
fi
|
||||
|
||||
# skip files marked deleted by the kernel
|
||||
[[ $device = *'\040(deleted)' ]] && continue
|
||||
|
||||
if [[ $type = file ]]; then
|
||||
printf '%-20s' "${device#${root%/}}"
|
||||
elif [[ $device = /dev/dm-+([0-9]) ]]; then
|
||||
# device mapper doesn't allow characters we need to worry
|
||||
# about being mangled, and it does the escaping of dashes
|
||||
# for us in sysfs.
|
||||
write_source "$(dm_name_for_devnode "$device")"
|
||||
else
|
||||
write_source "$(unmangle "$device")"
|
||||
fi
|
||||
|
||||
printf '\t%-10s\t%-10s\t%-10s\t0 0\n\n' 'none' 'swap' "$options"
|
||||
done
|
||||
} </proc/swaps
|
255
artools/0.26.1/artools/bin/base/mkchroot
Executable file
255
artools/0.26.1/artools/bin/base/mkchroot
Executable file
|
@ -0,0 +1,255 @@
|
|||
#!/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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ chroot
|
||||
|
||||
orig_argv=("$0" "$@")
|
||||
check_root() {
|
||||
local keepenv="$1"
|
||||
|
||||
(( EUID == 0 )) && return
|
||||
if type -P sudo >/dev/null; then
|
||||
# shellcheck disable=2154
|
||||
exec sudo --preserve-env="$keepenv" -- "${orig_argv[@]}"
|
||||
else
|
||||
# shellcheck disable=2154
|
||||
exec su root -c "$(printf ' %q' "${orig_argv[@]}")"
|
||||
fi
|
||||
}
|
||||
|
||||
is_btrfs() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]]
|
||||
}
|
||||
|
||||
is_subvolume() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs && "$(stat -c %i "$1")" == 256 ]]
|
||||
}
|
||||
|
||||
# is_same_fs() {
|
||||
# [[ "$(stat -c %d "$1")" == "$(stat -c %d "$2")" ]]
|
||||
# }
|
||||
|
||||
subvolume_delete_recursive() {
|
||||
local subvol
|
||||
|
||||
is_subvolume "$1" || return 0
|
||||
|
||||
while IFS= read -d $'\0' -r subvol; do
|
||||
if ! subvolume_delete_recursive "$subvol"; then
|
||||
return 1
|
||||
fi
|
||||
done < <(find "$1" -mindepth 1 -xdev -depth -inum 256 -print0)
|
||||
if ! btrfs subvolume delete "$1" &>/dev/null; then
|
||||
error "Unable to delete subvolume %s" "$subvol"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
CHROOTVERSION=0.10
|
||||
|
||||
|
||||
working_dir=''
|
||||
umode=''
|
||||
|
||||
files=()
|
||||
chroot_args=()
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] working-dir package-list..."
|
||||
echo ' options:'
|
||||
echo ' -U Use pacman -U to install packages'
|
||||
echo ' -C <file> Location of a pacman config file'
|
||||
echo ' -M <file> Location of a makepkg config file'
|
||||
echo ' -c <dir> Set pacman cache'
|
||||
echo ' -f <file> Copy file from the host to the chroot'
|
||||
echo ' -s Do not run setarch'
|
||||
echo ' -h This message'
|
||||
exit 1
|
||||
}
|
||||
|
||||
opts='hUC:M:c:f:s'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
U) umode=U ;;
|
||||
C) pacman_conf="$OPTARG" ;;
|
||||
M) makepkg_conf="$OPTARG" ;;
|
||||
c) cache_dir="$OPTARG" ;;
|
||||
f) files+=("$OPTARG") ;;
|
||||
s) nosetarch=1 ;;
|
||||
h|?) usage ;;
|
||||
*) error "invalid argument '%s'" "$arg"; usage ;;
|
||||
esac
|
||||
if [[ $arg != U ]]; then
|
||||
chroot_args+=("-$arg")
|
||||
[[ -v OPTARG ]] && chroot_args+=("$OPTARG")
|
||||
fi
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
(( $# < 2 )) && die 'You must specify a directory and one or more packages.'
|
||||
|
||||
check_root
|
||||
|
||||
working_dir="$(readlink -f "$1")"
|
||||
shift 1
|
||||
|
||||
[[ -z $working_dir ]] && die 'Please specify a working directory.'
|
||||
|
||||
if (( ${#cache_dirs[@]} == 0 )); then
|
||||
mapfile -t cache_dirs < <(pacman-conf CacheDir)
|
||||
fi
|
||||
|
||||
umask 0022
|
||||
|
||||
[[ -e $working_dir ]] && die "Working directory '%s' already exists" "$working_dir"
|
||||
|
||||
mkdir -p "$working_dir"
|
||||
|
||||
[[ ! -d $working_dir ]] && mkdir -p "$working_dir"
|
||||
|
||||
lock 9 "${working_dir}.lock" "Locking chroot"
|
||||
|
||||
if is_btrfs "$working_dir"; then
|
||||
rmdir "$working_dir"
|
||||
if ! btrfs subvolume create "$working_dir"; then
|
||||
die "Couldn't create subvolume for '%s'" "$working_dir"
|
||||
fi
|
||||
chmod 0755 "$working_dir"
|
||||
fi
|
||||
|
||||
for f in "${files[@]}"; do
|
||||
mkdir -p "$(dirname "$working_dir$f")"
|
||||
cp "$f" "$working_dir$f"
|
||||
done
|
||||
|
||||
basestrap -${umode}Mc ${pacman_conf:+-C "$pacman_conf"} "$working_dir" \
|
||||
"${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"
|
||||
echo 'LANG=en_US.UTF-8' > "$working_dir/etc/locale.conf"
|
||||
# echo 'KEYMAP=en' > "$working_dir/etc/vconsole.conf"
|
||||
echo "${CHROOTVERSION}" > "$working_dir/.artools"
|
||||
|
||||
dbus-uuidgen --ensure="$working_dir"/etc/machine-id
|
||||
|
||||
exec chroot-run \
|
||||
"${chroot_args[@]}" \
|
||||
"$working_dir" locale-gen
|
106
artools/0.26.1/artools/bin/base/mkchroot.in
Normal file
106
artools/0.26.1/artools/bin/base/mkchroot.in
Normal file
|
@ -0,0 +1,106 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/base/message.sh)
|
||||
m4_include(lib/base/chroot.sh)
|
||||
m4_include(lib/base/chroot-version.sh)
|
||||
|
||||
working_dir=''
|
||||
umode=''
|
||||
|
||||
files=()
|
||||
chroot_args=()
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] working-dir package-list..."
|
||||
echo ' options:'
|
||||
echo ' -U Use pacman -U to install packages'
|
||||
echo ' -C <file> Location of a pacman config file'
|
||||
echo ' -M <file> Location of a makepkg config file'
|
||||
echo ' -c <dir> Set pacman cache'
|
||||
echo ' -f <file> Copy file from the host to the chroot'
|
||||
echo ' -s Do not run setarch'
|
||||
echo ' -h This message'
|
||||
exit 1
|
||||
}
|
||||
|
||||
opts='hUC:M:c:f:s'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
U) umode=U ;;
|
||||
C) pacman_conf="$OPTARG" ;;
|
||||
M) makepkg_conf="$OPTARG" ;;
|
||||
c) cache_dir="$OPTARG" ;;
|
||||
f) files+=("$OPTARG") ;;
|
||||
s) nosetarch=1 ;;
|
||||
h|?) usage ;;
|
||||
*) error "invalid argument '%s'" "$arg"; usage ;;
|
||||
esac
|
||||
if [[ $arg != U ]]; then
|
||||
chroot_args+=("-$arg")
|
||||
[[ -v OPTARG ]] && chroot_args+=("$OPTARG")
|
||||
fi
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
(( $# < 2 )) && die 'You must specify a directory and one or more packages.'
|
||||
|
||||
check_root
|
||||
|
||||
working_dir="$(readlink -f "$1")"
|
||||
shift 1
|
||||
|
||||
[[ -z $working_dir ]] && die 'Please specify a working directory.'
|
||||
|
||||
if (( ${#cache_dirs[@]} == 0 )); then
|
||||
mapfile -t cache_dirs < <(pacman-conf CacheDir)
|
||||
fi
|
||||
|
||||
umask 0022
|
||||
|
||||
[[ -e $working_dir ]] && die "Working directory '%s' already exists" "$working_dir"
|
||||
|
||||
mkdir -p "$working_dir"
|
||||
|
||||
[[ ! -d $working_dir ]] && mkdir -p "$working_dir"
|
||||
|
||||
lock 9 "${working_dir}.lock" "Locking chroot"
|
||||
|
||||
if is_btrfs "$working_dir"; then
|
||||
rmdir "$working_dir"
|
||||
if ! btrfs subvolume create "$working_dir"; then
|
||||
die "Couldn't create subvolume for '%s'" "$working_dir"
|
||||
fi
|
||||
chmod 0755 "$working_dir"
|
||||
fi
|
||||
|
||||
for f in "${files[@]}"; do
|
||||
mkdir -p "$(dirname "$working_dir$f")"
|
||||
cp "$f" "$working_dir$f"
|
||||
done
|
||||
|
||||
basestrap -${umode}Mc ${pacman_conf:+-C "$pacman_conf"} "$working_dir" \
|
||||
"${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"
|
||||
echo 'LANG=en_US.UTF-8' > "$working_dir/etc/locale.conf"
|
||||
# echo 'KEYMAP=en' > "$working_dir/etc/vconsole.conf"
|
||||
echo "${CHROOTVERSION}" > "$working_dir/.artools"
|
||||
|
||||
dbus-uuidgen --ensure="$working_dir"/etc/machine-id
|
||||
|
||||
exec chroot-run \
|
||||
"${chroot_args[@]}" \
|
||||
"$working_dir" locale-gen
|
1327
artools/0.26.1/artools/bin/iso/buildiso
Executable file
1327
artools/0.26.1/artools/bin/iso/buildiso
Executable file
File diff suppressed because it is too large
Load diff
389
artools/0.26.1/artools/bin/iso/buildiso.in
Executable file
389
artools/0.26.1/artools/bin/iso/buildiso.in
Executable file
|
@ -0,0 +1,389 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/util-base.sh)
|
||||
m4_include(lib/util-iso.sh)
|
||||
m4_include(lib/base/message.sh)
|
||||
m4_include(lib/base/common.sh)
|
||||
m4_include(lib/base/chroot.sh)
|
||||
m4_include(lib/iso/mount.sh)
|
||||
m4_include(lib/iso/services.sh)
|
||||
m4_include(lib/base/yaml.sh)
|
||||
m4_include(lib/iso/calamares.sh)
|
||||
m4_include(lib/iso/config.sh)
|
||||
m4_include(lib/iso/firmware.sh)
|
||||
m4_include(lib/iso/dracut.sh)
|
||||
m4_include(lib/iso/initcpio.sh)
|
||||
m4_include(lib/iso/grub.sh)
|
||||
m4_include(lib/iso/squash.sh)
|
||||
m4_include(lib/iso/iso.sh)
|
||||
m4_include(lib/iso/profile.sh)
|
||||
m4_include(lib/iso/trap.sh)
|
||||
|
||||
clean_up_chroot(){
|
||||
local path mnt="$1"
|
||||
msg2 "Cleaning [%s]" "${mnt##*/}"
|
||||
|
||||
path=$mnt/boot
|
||||
if [[ -d "$path" ]]; then
|
||||
find "$path" -name 'initramfs*.img' -delete &> /dev/null
|
||||
fi
|
||||
path=$mnt/var/lib/pacman/sync
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -type f -delete &> /dev/null
|
||||
fi
|
||||
path=$mnt/var/cache/pacman/pkg
|
||||
if [[ -d $path ]]; then
|
||||
find "$path" -type f -delete &> /dev/null
|
||||
fi
|
||||
path=$mnt/var/log
|
||||
if [[ -d $path ]]; then
|
||||
find "$path" -type f -delete &> /dev/null
|
||||
fi
|
||||
path=$mnt/var/tmp
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -mindepth 1 -delete &> /dev/null
|
||||
fi
|
||||
path=$mnt/tmp
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -mindepth 1 -delete &> /dev/null
|
||||
fi
|
||||
# shellcheck disable=2035
|
||||
find "$mnt" -name *.pacnew -name *.pacsave -name *.pacorig -delete
|
||||
if [[ -f "$mnt/boot/grub/grub.cfg" ]]; then
|
||||
rm "$mnt"/boot/grub/grub.cfg
|
||||
fi
|
||||
if [[ -f "$mnt/etc/machine-id" ]]; then
|
||||
rm "$mnt"/etc/machine-id
|
||||
fi
|
||||
}
|
||||
|
||||
copy_overlay(){
|
||||
local src="$1" dest="$2"
|
||||
if [[ -e "$src" ]];then
|
||||
msg2 "Copying [%s] ..." "${src##*/}"
|
||||
cp -LR "$src"/* "$dest"
|
||||
fi
|
||||
}
|
||||
|
||||
make_rootfs() {
|
||||
if [[ ! -e "${work_dir}"/rootfs.lock ]]; then
|
||||
msg "Prepare [Base installation] (rootfs)"
|
||||
local rootfs="${work_dir}/rootfs"
|
||||
|
||||
prepare_dir "${rootfs}"
|
||||
|
||||
basestrap "${basestrap_args[@]}" "${rootfs}" "${packages[@]}"
|
||||
|
||||
copy_overlay "${root_overlay}" "${rootfs}"
|
||||
|
||||
[[ -z ${live_list} ]] && configure_chroot "${rootfs}"
|
||||
|
||||
clean_up_chroot "${rootfs}"
|
||||
|
||||
: > "${work_dir}"/rootfs.lock
|
||||
|
||||
msg "Done [Base installation] (rootfs)"
|
||||
fi
|
||||
}
|
||||
|
||||
make_livefs() {
|
||||
if [[ ! -e ${work_dir}/livefs.lock ]]; then
|
||||
msg "Prepare [Live installation] (livefs)"
|
||||
local livefs="${work_dir}/livefs"
|
||||
|
||||
prepare_dir "${livefs}"
|
||||
|
||||
mount_overlayfs "${livefs}" "${work_dir}"
|
||||
|
||||
basestrap "${basestrap_args[@]}" "${livefs}" "${packages[@]}"
|
||||
|
||||
copy_overlay "${live_overlay}" "${livefs}"
|
||||
|
||||
configure_chroot "${livefs}"
|
||||
|
||||
umount_overlayfs
|
||||
|
||||
clean_up_chroot "${livefs}"
|
||||
|
||||
: > "${work_dir}"/livefs.lock
|
||||
|
||||
msg "Done [Live installation] (livefs)"
|
||||
fi
|
||||
}
|
||||
|
||||
make_bootfs() {
|
||||
if [[ ! -e ${work_dir}/bootfs.lock ]]; then
|
||||
msg "Prepare [/iso/boot]"
|
||||
|
||||
prepare_dir "${iso_root}/boot"
|
||||
|
||||
cp "${work_dir}"/rootfs/boot/vmlinuz* "${iso_root}"/boot/vmlinuz-"${arch}"
|
||||
|
||||
local bootfs="${work_dir}/bootfs"
|
||||
|
||||
mount_overlayfs "${bootfs}" "${work_dir}"
|
||||
|
||||
if "${use_dracut}"; then
|
||||
prepare_initramfs_dracut "${bootfs}"
|
||||
else
|
||||
prepare_initramfs_mkinitcpio "${bootfs}"
|
||||
fi
|
||||
|
||||
umount_overlayfs
|
||||
|
||||
rm -R "${bootfs}"
|
||||
: > "${work_dir}"/bootfs.lock
|
||||
msg "Done [/iso/boot]"
|
||||
fi
|
||||
}
|
||||
|
||||
make_grub(){
|
||||
if [[ ! -e ${work_dir}/grub.lock ]]; then
|
||||
msg "Prepare [/iso/boot/grub]"
|
||||
|
||||
local layer=${work_dir}/rootfs
|
||||
[[ -n ${live_list} ]] && layer=${work_dir}/livefs
|
||||
|
||||
prepare_grub "${work_dir}/rootfs" "$layer"
|
||||
|
||||
if ${use_dracut}; then
|
||||
configure_grub_dracut
|
||||
else
|
||||
configure_grub_mkinitcpio
|
||||
fi
|
||||
|
||||
: > "${work_dir}"/grub.lock
|
||||
msg "Done [/iso/boot/grub]"
|
||||
fi
|
||||
}
|
||||
|
||||
gen_iso_fn(){
|
||||
local vars=("artix") name
|
||||
vars+=("${profile}")
|
||||
vars+=("${INITSYS}")
|
||||
case "${repo}" in
|
||||
'gremlins'|'goblins') vars+=("${repo}") ;;
|
||||
esac
|
||||
vars+=("${ISO_VERSION}")
|
||||
vars+=("${arch}")
|
||||
for n in "${vars[@]}"; do
|
||||
name=${name:-}${name:+-}${n}
|
||||
done
|
||||
echo "$name"
|
||||
}
|
||||
|
||||
prepare_build(){
|
||||
load_profile
|
||||
|
||||
case "${repo}" in
|
||||
'gremlins'|'goblins') repo="${repo}" ;;
|
||||
*) repo=default ;;
|
||||
esac
|
||||
|
||||
get_pacman_conf "${repo}"
|
||||
|
||||
iso_file=$(gen_iso_fn).iso
|
||||
|
||||
iso_label="ARTIX_$(date +%Y%m)"
|
||||
|
||||
basestrap_args+=(-C "${pacman_conf}")
|
||||
work_dir=${chroots_iso}/${profile}/artix
|
||||
|
||||
iso_dir="${ISO_POOL}/${profile}"
|
||||
|
||||
iso_root=${chroots_iso}/${profile}/iso
|
||||
live_dir=/LiveOS
|
||||
|
||||
mnt_dir=${chroots_iso}/${profile}/mnt
|
||||
|
||||
if [[ -n "${GPG_KEY}" ]]; then
|
||||
${use_dracut} || export_gpg_publickey
|
||||
fi
|
||||
}
|
||||
|
||||
display_settings(){
|
||||
msg "OPTIONS:"
|
||||
msg2 "profile: %s" "${profile}"
|
||||
msg2 "INITSYS: %s" "${INITSYS}"
|
||||
[[ -n ${GPG_KEY} ]] && msg2 "GPG_KEY: %s" "${GPG_KEY}"
|
||||
|
||||
msg "ISO SETTINGS:"
|
||||
msg2 "ISO_VERSION: %s" "${ISO_VERSION}"
|
||||
msg2 "COMPRESSION: %s" "${COMPRESSION}"
|
||||
[[ "${COMPRESSION}" == 'zstd' ]] && msg2 "COMPRESSION_LEVEL: %s" "${COMPRESSION_LEVEL}"
|
||||
|
||||
msg "BUILD:"
|
||||
show_profile
|
||||
}
|
||||
|
||||
mk_squash(){
|
||||
make_sfs "${work_dir}/rootfs"
|
||||
if [[ -d "${work_dir}/livefs" ]]; then
|
||||
make_sfs "${work_dir}/livefs"
|
||||
fi
|
||||
}
|
||||
|
||||
mk_iso(){
|
||||
touch "${iso_root}/.artix"
|
||||
msg "Making bootable image"
|
||||
# Sanity checks
|
||||
[[ ! -d "${iso_root}" ]] && return 1
|
||||
if [[ -f "${iso_dir}/${iso_file}" ]]; then
|
||||
msg2 "Removing existing bootable image..."
|
||||
rm -rf "${iso_dir}/${iso_file}"
|
||||
fi
|
||||
assemble_iso
|
||||
chown -R "${owner}:$(id --group "${owner}")" "${iso_dir}"
|
||||
}
|
||||
|
||||
mk_boot(){
|
||||
run_safe "make_bootfs"
|
||||
run_safe "make_grub"
|
||||
}
|
||||
|
||||
mk_chroots(){
|
||||
load_pkgs "${root_list}"
|
||||
run_safe "make_rootfs"
|
||||
if [[ -n ${live_list} ]]; then
|
||||
load_pkgs "${live_list}"
|
||||
run_safe "make_livefs"
|
||||
fi
|
||||
}
|
||||
|
||||
build(){
|
||||
msg "Start building [%s]" "${profile}"
|
||||
if ${clean_first};then
|
||||
for copy in "${work_dir}"/*; do
|
||||
[[ -d $copy ]] || continue
|
||||
msg2 "Deleting chroot copy '%s'..." "$(basename "${copy}")"
|
||||
|
||||
lock 9 "$copy.lock" "Locking chroot copy '%s'" "$copy"
|
||||
|
||||
subvolume_delete_recursive "${copy}"
|
||||
rm -rf --one-file-system "${copy}"
|
||||
done
|
||||
lock_close 9
|
||||
|
||||
rm -rf --one-file-system "${work_dir}"
|
||||
|
||||
msg "Deleting isoroot [%s] ..." "${iso_root##*/}"
|
||||
rm -rf --one-file-system "${iso_root}"
|
||||
fi
|
||||
|
||||
if ${chroot_only}; then
|
||||
mk_chroots
|
||||
warning "Continue squash: %s -p %s -sc ..." "${cmd}" "${profile}"
|
||||
exit 1
|
||||
elif ${boot_only}; then
|
||||
mk_boot
|
||||
warning "Continue iso: %s -p %s -zc ..." "${cmd}" "${profile}"
|
||||
exit 1
|
||||
elif ${squash_only}; then
|
||||
mk_squash
|
||||
warning "Continue boot: %s -p %s -bc ..." "${cmd}" "${profile}"
|
||||
exit 1
|
||||
elif ${iso_only}; then
|
||||
[[ ! -d ${work_dir} ]] && die "Create chroot: %s -p %s -x" "${cmd}" "${profile}"
|
||||
mk_iso
|
||||
else
|
||||
mk_chroots
|
||||
mk_boot
|
||||
mk_squash
|
||||
mk_iso
|
||||
fi
|
||||
msg "Finished building [%s]" "${profile}"
|
||||
}
|
||||
|
||||
clean_first=true
|
||||
pretend=false
|
||||
chroot_only=false
|
||||
iso_only=false
|
||||
persist=false
|
||||
use_dracut=false
|
||||
squash_only=false
|
||||
boot_only=false
|
||||
|
||||
basestrap_args=(-GMc)
|
||||
cmd=${0##*/}
|
||||
|
||||
repo=${cmd##*-}
|
||||
owner=${SUDO_USER:-$USER}
|
||||
profile='base'
|
||||
chroots_iso="${CHROOTS_DIR}/buildiso"
|
||||
arch=$(uname -m)
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${cmd} [options]"
|
||||
echo " -p <profile> Profile [default: ${profile}]"
|
||||
echo ' -r <dir> Chroots directory'
|
||||
echo " [default: ${chroots_iso}]"
|
||||
echo ' -t <dir> Target directory'
|
||||
echo " [default: ${ISO_POOL}]"
|
||||
echo ' -i <name> Init system to use'
|
||||
echo " [default: ${INITSYS}]"
|
||||
echo ' -g <key> The gpg key for img signing'
|
||||
echo " [default: none]"
|
||||
echo ' -m Set SquashFS image mode to persistence'
|
||||
echo ' -c Disable clean work dir'
|
||||
echo ' -x Build chroot only'
|
||||
echo ' -s Squash chroot only'
|
||||
echo ' -b Generate iso boot only'
|
||||
echo ' -z Generate iso only'
|
||||
echo ' Requires pre built images (-x)'
|
||||
echo ' -d Use dracut instead of mkinitcpio for iso initramfs'
|
||||
echo ' -q Query settings and pretend build'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='p:r:t:i:g:czsbxmdqh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
p) profile="$OPTARG" ;;
|
||||
r) chroots_iso="$OPTARG" ;;
|
||||
t) ISO_POOL="$OPTARG" ;;
|
||||
i) INITSYS="$OPTARG" ;;
|
||||
g) GPG_KEY="$OPTARG" ;;
|
||||
c) clean_first=false ;;
|
||||
x) chroot_only=true ;;
|
||||
z) iso_only=true ;;
|
||||
s) squash_only=true ;;
|
||||
b) boot_only=true ;;
|
||||
m) persist=true ;;
|
||||
d) use_dracut=true ;;
|
||||
q) pretend=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
prepare_build
|
||||
|
||||
${pretend} && display_settings && exit 1
|
||||
|
||||
check_root
|
||||
|
||||
prepare_dir "${mnt_dir}"
|
||||
prepare_dir "${iso_dir}"
|
||||
prepare_dir "${iso_root}"
|
||||
|
||||
prepare_traps
|
||||
|
||||
build
|
328
artools/0.26.1/artools/bin/pkg/batchpkg
Executable file
328
artools/0.26.1/artools/bin/pkg/batchpkg
Executable file
|
@ -0,0 +1,328 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2018-20 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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ base conf
|
||||
|
||||
DATADIR=${DATADIR:-'/usr/share/artools'}
|
||||
SYSCONFDIR=${SYSCONFDIR:-'/etc/artools'}
|
||||
|
||||
if [[ -n $SUDO_USER ]]; then
|
||||
eval "USER_HOME=~$SUDO_USER"
|
||||
else
|
||||
USER_HOME=$HOME
|
||||
fi
|
||||
|
||||
USER_CONF_DIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/artools"
|
||||
|
||||
prepare_dir(){
|
||||
[[ ! -d $1 ]] && mkdir -p "$1"
|
||||
}
|
||||
|
||||
load_base_config(){
|
||||
|
||||
local conf="$1/artools-base.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-base.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
CHROOTS_DIR=${CHROOTS_DIR:-'/var/lib/artools'}
|
||||
|
||||
WORKSPACE_DIR=${WORKSPACE_DIR:-"${USER_HOME}/artools-workspace"}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_base_config "${USER_CONF_DIR}" || load_base_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${WORKSPACE_DIR}"
|
||||
prepare_dir "${USER_CONF_DIR}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ pkg conf
|
||||
|
||||
load_pkg_config(){
|
||||
|
||||
local conf="$1/artools-pkg.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-pkg.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
local git_domain="gitea.artixlinux.org"
|
||||
|
||||
GIT_URL=${GIT_URL:-"https://${git_domain}"}
|
||||
|
||||
GIT_SSH=${GIT_SSH:-"gitea@${git_domain}"}
|
||||
|
||||
GIT_TOKEN=${GIT_TOKEN:-''}
|
||||
|
||||
TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"}
|
||||
|
||||
ARTIX_TREE=(
|
||||
packages community
|
||||
packages-{gfx,media,net}
|
||||
)
|
||||
|
||||
local dev_tree=(
|
||||
packages-{llvm,python,perl,java,ruby,misc}
|
||||
python-{world,galaxy,galaxy-groups,misc}
|
||||
)
|
||||
|
||||
local init_tree=(packages-{openrc,runit,s6,suite66,dinit})
|
||||
|
||||
local desktop_tree=(
|
||||
packages-{kf5,plasma,kde,qt5,qt6,xorg,gtk}
|
||||
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"}
|
||||
|
||||
[[ -z ${ARCH_TREE[*]} ]] && \
|
||||
ARCH_TREE=(svntogit-{packages,community})
|
||||
|
||||
REPOS_ROOT=${REPOS_ROOT:-"${WORKSPACE_DIR}/repos"}
|
||||
|
||||
REPOS_MIRROR=${REPOS_MIRROR:-'http://mirror1.artixlinux.org/repos'}
|
||||
|
||||
HOST_TREE_ARCH=${HOST_TREE_ARCH:-'https://github.com/archlinux'}
|
||||
|
||||
DBEXT=${DBEXT:-'gz'}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_pkg_config "${USER_CONF_DIR}" || load_pkg_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${REPOS_ROOT}"
|
||||
prepare_dir "${TREE_DIR_ARTIX}"
|
||||
prepare_dir "${TREE_DIR_ARCH}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
|
||||
#{{{ functions
|
||||
|
||||
batch_move() {
|
||||
local name="${1:-pkg_moves}"
|
||||
local pkglist="${TREE_DIR_ARTIX}"/"$name".list
|
||||
[[ -f $pkglist ]] || die "%s does not exist!" "$pkglist"
|
||||
while read -r entry; do
|
||||
local pkg=${entry##*:}
|
||||
local src=${entry%:*}
|
||||
src=${src#*:}
|
||||
local dest=${entry%%:*}
|
||||
if ${runlist}; then
|
||||
"${dest}"pkg -s "${src}" -u -p "${pkg}"
|
||||
else
|
||||
msg "%s" "${dest}pkg -s ${src} -u -p ${pkg}"
|
||||
fi
|
||||
done < "$pkglist"
|
||||
}
|
||||
|
||||
batch_create() {
|
||||
local name="${1:-pkg_create}"
|
||||
local pkglist="${TREE_DIR_ARTIX}"/"$name".list
|
||||
[[ -f $pkglist ]] || die "%s does not exist!" "$pkglist"
|
||||
while read -r entry; do
|
||||
local pkg=${entry##*:}
|
||||
local group=${entry%:*}
|
||||
group=${group#*:}
|
||||
local team=${entry%%:*}
|
||||
if ${runlist}; then
|
||||
buildtree -n -p "${pkg}" -t "${team}" -g "${group}"
|
||||
buildtree -i -p "${pkg}"
|
||||
commitpkg -p "${pkg}"
|
||||
else
|
||||
msg "%s" "buildtree -n -p ${pkg} -t ${team} -g ${group}"
|
||||
msg2 "%s" "buildtree -i -p ${pkg}"
|
||||
msg2 "%s" "commitpkg -p ${pkg}"
|
||||
fi
|
||||
done < "$pkglist"
|
||||
}
|
||||
|
||||
batch_update() {
|
||||
local name="${1:-pkg_upgrades}"
|
||||
local pkglist=${TREE_DIR_ARTIX}/$name.list
|
||||
[[ -f $pkglist ]] || die "%s does not exist!" "$pkglist"
|
||||
while read -r entry; do
|
||||
local pkg=${entry#*:}
|
||||
local dest=${entry%:*}
|
||||
if ${runlist}; then
|
||||
buildtree -i -p "${pkg}"
|
||||
"${dest}"pkg -u -p "${pkg}"
|
||||
else
|
||||
msg "buildtree -i -p ${pkg}"
|
||||
msg2 "${dest}pkg -u -p ${pkg}"
|
||||
fi
|
||||
done < "$pkglist"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [optional listname]"
|
||||
echo ' -r Run generated commands'
|
||||
echo ' -c Create subrepos from list'
|
||||
echo ' -u Update subrepos from list'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
runlist=false
|
||||
create=false
|
||||
update=false
|
||||
|
||||
opts='rcuh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
r) runlist=true ;;
|
||||
c) create=true ;;
|
||||
u) update=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
listname="$1"; shift
|
||||
|
||||
if ${create}; then
|
||||
batch_create "${listname}"
|
||||
elif ${update}; then
|
||||
batch_update "${listname}"
|
||||
else
|
||||
batch_move "${listname}"
|
||||
fi
|
115
artools/0.26.1/artools/bin/pkg/batchpkg.in
Normal file
115
artools/0.26.1/artools/bin/pkg/batchpkg.in
Normal file
|
@ -0,0 +1,115 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2018-20 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.
|
||||
|
||||
m4_include(lib/util-base.sh)
|
||||
m4_include(lib/util-pkg.sh)
|
||||
m4_include(lib/base/message.sh)
|
||||
|
||||
#{{{ functions
|
||||
|
||||
batch_move() {
|
||||
local name="${1:-pkg_moves}"
|
||||
local pkglist="${TREE_DIR_ARTIX}"/"$name".list
|
||||
[[ -f $pkglist ]] || die "%s does not exist!" "$pkglist"
|
||||
while read -r entry; do
|
||||
local pkg=${entry##*:}
|
||||
local src=${entry%:*}
|
||||
src=${src#*:}
|
||||
local dest=${entry%%:*}
|
||||
if ${runlist}; then
|
||||
"${dest}"pkg -s "${src}" -u -p "${pkg}"
|
||||
else
|
||||
msg "%s" "${dest}pkg -s ${src} -u -p ${pkg}"
|
||||
fi
|
||||
done < "$pkglist"
|
||||
}
|
||||
|
||||
batch_create() {
|
||||
local name="${1:-pkg_create}"
|
||||
local pkglist="${TREE_DIR_ARTIX}"/"$name".list
|
||||
[[ -f $pkglist ]] || die "%s does not exist!" "$pkglist"
|
||||
while read -r entry; do
|
||||
local pkg=${entry##*:}
|
||||
local group=${entry%:*}
|
||||
group=${group#*:}
|
||||
local team=${entry%%:*}
|
||||
if ${runlist}; then
|
||||
buildtree -n -p "${pkg}" -t "${team}" -g "${group}"
|
||||
buildtree -i -p "${pkg}"
|
||||
commitpkg -p "${pkg}"
|
||||
else
|
||||
msg "%s" "buildtree -n -p ${pkg} -t ${team} -g ${group}"
|
||||
msg2 "%s" "buildtree -i -p ${pkg}"
|
||||
msg2 "%s" "commitpkg -p ${pkg}"
|
||||
fi
|
||||
done < "$pkglist"
|
||||
}
|
||||
|
||||
batch_update() {
|
||||
local name="${1:-pkg_upgrades}"
|
||||
local pkglist=${TREE_DIR_ARTIX}/$name.list
|
||||
[[ -f $pkglist ]] || die "%s does not exist!" "$pkglist"
|
||||
while read -r entry; do
|
||||
local pkg=${entry#*:}
|
||||
local dest=${entry%:*}
|
||||
if ${runlist}; then
|
||||
buildtree -i -p "${pkg}"
|
||||
"${dest}"pkg -u -p "${pkg}"
|
||||
else
|
||||
msg "buildtree -i -p ${pkg}"
|
||||
msg2 "${dest}pkg -u -p ${pkg}"
|
||||
fi
|
||||
done < "$pkglist"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [optional listname]"
|
||||
echo ' -r Run generated commands'
|
||||
echo ' -c Create subrepos from list'
|
||||
echo ' -u Update subrepos from list'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
runlist=false
|
||||
create=false
|
||||
update=false
|
||||
|
||||
opts='rcuh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
r) runlist=true ;;
|
||||
c) create=true ;;
|
||||
u) update=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
listname="$1"; shift
|
||||
|
||||
if ${create}; then
|
||||
batch_create "${listname}"
|
||||
elif ${update}; then
|
||||
batch_update "${listname}"
|
||||
else
|
||||
batch_move "${listname}"
|
||||
fi
|
324
artools/0.26.1/artools/bin/pkg/buildpkg
Executable file
324
artools/0.26.1/artools/bin/pkg/buildpkg
Executable file
|
@ -0,0 +1,324 @@
|
|||
#!/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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ base conf
|
||||
|
||||
DATADIR=${DATADIR:-'/usr/share/artools'}
|
||||
SYSCONFDIR=${SYSCONFDIR:-'/etc/artools'}
|
||||
|
||||
if [[ -n $SUDO_USER ]]; then
|
||||
eval "USER_HOME=~$SUDO_USER"
|
||||
else
|
||||
USER_HOME=$HOME
|
||||
fi
|
||||
|
||||
USER_CONF_DIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/artools"
|
||||
|
||||
prepare_dir(){
|
||||
[[ ! -d $1 ]] && mkdir -p "$1"
|
||||
}
|
||||
|
||||
load_base_config(){
|
||||
|
||||
local conf="$1/artools-base.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-base.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
CHROOTS_DIR=${CHROOTS_DIR:-'/var/lib/artools'}
|
||||
|
||||
WORKSPACE_DIR=${WORKSPACE_DIR:-"${USER_HOME}/artools-workspace"}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_base_config "${USER_CONF_DIR}" || load_base_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${WORKSPACE_DIR}"
|
||||
prepare_dir "${USER_CONF_DIR}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ common
|
||||
|
||||
get_makepkg_conf() {
|
||||
makepkg_conf="${DATADIR}/makepkg.conf"
|
||||
[[ -f ${USER_CONF_DIR}/makepkg.conf ]] && makepkg_conf="${USER_CONF_DIR}/makepkg.conf"
|
||||
}
|
||||
|
||||
get_pacman_conf() {
|
||||
local repo="$1"
|
||||
pacman_conf="${DATADIR}/pacman-${repo}.conf"
|
||||
[[ -f "${USER_CONF_DIR}/pacman-${repo}.conf" ]] && pacman_conf="${USER_CONF_DIR}/pacman-${repo}.conf"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ chroot
|
||||
|
||||
orig_argv=("$0" "$@")
|
||||
check_root() {
|
||||
local keepenv="$1"
|
||||
|
||||
(( EUID == 0 )) && return
|
||||
if type -P sudo >/dev/null; then
|
||||
# shellcheck disable=2154
|
||||
exec sudo --preserve-env="$keepenv" -- "${orig_argv[@]}"
|
||||
else
|
||||
# shellcheck disable=2154
|
||||
exec su root -c "$(printf ' %q' "${orig_argv[@]}")"
|
||||
fi
|
||||
}
|
||||
|
||||
is_btrfs() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]]
|
||||
}
|
||||
|
||||
is_subvolume() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs && "$(stat -c %i "$1")" == 256 ]]
|
||||
}
|
||||
|
||||
# is_same_fs() {
|
||||
# [[ "$(stat -c %d "$1")" == "$(stat -c %d "$2")" ]]
|
||||
# }
|
||||
|
||||
subvolume_delete_recursive() {
|
||||
local subvol
|
||||
|
||||
is_subvolume "$1" || return 0
|
||||
|
||||
while IFS= read -d $'\0' -r subvol; do
|
||||
if ! subvolume_delete_recursive "$subvol"; then
|
||||
return 1
|
||||
fi
|
||||
done < <(find "$1" -mindepth 1 -xdev -depth -inum 256 -print0)
|
||||
if ! btrfs subvolume delete "$1" &>/dev/null; then
|
||||
error "Unable to delete subvolume %s" "$subvol"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
||||
|
||||
create_first=false
|
||||
rebuild=false
|
||||
|
||||
mkchrootpkg_args=(-c -n)
|
||||
|
||||
cmd=${0##*/}
|
||||
repo=${cmd#*-}
|
||||
base_devel=('base-devel')
|
||||
chroots_pkg="${CHROOTS_DIR}/buildpkg"
|
||||
arch=$(uname -m)
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] -- [mkchrootpkg_args]"
|
||||
echo " -r <dir> Create chroots in this directory"
|
||||
echo " -d <dir> Destination repo chroot"
|
||||
echo ' -c Recreate the chroot before building'
|
||||
echo ' -m Major rebuild'
|
||||
echo ' -N Disable check() function'
|
||||
echo ' -C Run checkpkg after built'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo "Default mkchrootpkg_args args: ${mkchrootpkg_args[*]}"
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='hcCNmr:d:'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
r) chroots_pkg="$OPTARG" ;;
|
||||
d) repo="$OPTARG" ;;
|
||||
c) create_first=true ;;
|
||||
m) rebuild=true ;;
|
||||
C) mkchrootpkg_args+=(-C) ;;
|
||||
N) mkchrootpkg_args+=(-N) ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '%s'" "${arg}"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if ${rebuild};then
|
||||
repo='default'
|
||||
else
|
||||
case ${repo} in
|
||||
system|world|galaxy) repo='default' ;;
|
||||
lib32*) base_devel+=('multilib-devel') ;;
|
||||
galaxy-gremlins|galaxy-goblins) repo=${repo#*-} ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
get_pacman_conf "${repo}"
|
||||
|
||||
get_makepkg_conf
|
||||
|
||||
if [[ -f "${DATADIR}/setarch-aliases.d/${arch}" ]]; then
|
||||
read -r set_arch < "${DATADIR}/setarch-aliases.d/${arch}"
|
||||
else
|
||||
set_arch="${arch}"
|
||||
fi
|
||||
|
||||
check_root SOURCE_DATE_EPOCH,SRCDEST,SRCPKGDEST,PKGDEST,LOGDEST,MAKEFLAGS,PACKAGER,GNUPGHOME
|
||||
|
||||
mkchrootpkg_args+=("${@:$OPTIND}")
|
||||
|
||||
if ${create_first} || [[ ! -d "${chroots_pkg}/${repo}-${arch}" ]];then
|
||||
msg "Creating chroot for [%s] (%s)..." "${repo}" "${arch}"
|
||||
|
||||
for copy in "${chroots_pkg}/${repo}-${arch}"/*; do
|
||||
[[ -d $copy ]] || continue
|
||||
msg2 "Deleting chroot copy '%s'..." "$(basename "${copy}")"
|
||||
|
||||
lock 9 "$copy.lock" "Locking chroot copy '%s'" "$copy"
|
||||
|
||||
subvolume_delete_recursive "${copy}"
|
||||
rm -rf --one-file-system "${copy}"
|
||||
done
|
||||
lock_close 9
|
||||
|
||||
rm -rf --one-file-system "${chroots_pkg}/${repo}-${arch}"
|
||||
(umask 0022; mkdir -p "${chroots_pkg}/${repo}-${arch}")
|
||||
setarch "${set_arch}" mkchroot \
|
||||
-C "${pacman_conf}" \
|
||||
-M "${makepkg_conf}" \
|
||||
"${chroots_pkg}/${repo}-${arch}/root" \
|
||||
"${base_devel[@]}" || abort
|
||||
else
|
||||
lock 9 "${chroots_pkg}/${repo}-${arch}/root.lock" "Locking clean chroot"
|
||||
chroot-run \
|
||||
-C "${pacman_conf}" \
|
||||
-M "${makepkg_conf}" \
|
||||
"${chroots_pkg}/${repo}-${arch}/root" \
|
||||
pacman -Syuu --noconfirm || abort
|
||||
fi
|
||||
|
||||
# Always build official packages reproducibly
|
||||
if [[ ! -v SOURCE_DATE_EPOCH ]]; then
|
||||
export SOURCE_DATE_EPOCH=$(date +%s)
|
||||
fi
|
||||
|
||||
msg "Building in chroot for [%s] (%s)..." "${repo}" "${arch}"
|
||||
exec mkchrootpkg -r "${chroots_pkg}/${repo}-${arch}" "${mkchrootpkg_args[@]}"
|
121
artools/0.26.1/artools/bin/pkg/buildpkg.in
Normal file
121
artools/0.26.1/artools/bin/pkg/buildpkg.in
Normal file
|
@ -0,0 +1,121 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/util-base.sh)
|
||||
m4_include(lib/base/message.sh)
|
||||
m4_include(lib/base/common.sh)
|
||||
m4_include(lib/base/chroot.sh)
|
||||
|
||||
create_first=false
|
||||
rebuild=false
|
||||
|
||||
mkchrootpkg_args=(-c -n)
|
||||
|
||||
cmd=${0##*/}
|
||||
repo=${cmd#*-}
|
||||
base_devel=('base-devel')
|
||||
chroots_pkg="${CHROOTS_DIR}/buildpkg"
|
||||
arch=$(uname -m)
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] -- [mkchrootpkg_args]"
|
||||
echo " -r <dir> Create chroots in this directory"
|
||||
echo " -d <dir> Destination repo chroot"
|
||||
echo ' -c Recreate the chroot before building'
|
||||
echo ' -m Major rebuild'
|
||||
echo ' -N Disable check() function'
|
||||
echo ' -C Run checkpkg after built'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo "Default mkchrootpkg_args args: ${mkchrootpkg_args[*]}"
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='hcCNmr:d:'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
r) chroots_pkg="$OPTARG" ;;
|
||||
d) repo="$OPTARG" ;;
|
||||
c) create_first=true ;;
|
||||
m) rebuild=true ;;
|
||||
C) mkchrootpkg_args+=(-C) ;;
|
||||
N) mkchrootpkg_args+=(-N) ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '%s'" "${arg}"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if ${rebuild};then
|
||||
repo='default'
|
||||
else
|
||||
case ${repo} in
|
||||
system|world|galaxy) repo='default' ;;
|
||||
lib32*) base_devel+=('multilib-devel') ;;
|
||||
galaxy-gremlins|galaxy-goblins) repo=${repo#*-} ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
get_pacman_conf "${repo}"
|
||||
|
||||
get_makepkg_conf
|
||||
|
||||
if [[ -f "${DATADIR}/setarch-aliases.d/${arch}" ]]; then
|
||||
read -r set_arch < "${DATADIR}/setarch-aliases.d/${arch}"
|
||||
else
|
||||
set_arch="${arch}"
|
||||
fi
|
||||
|
||||
check_root SOURCE_DATE_EPOCH,SRCDEST,SRCPKGDEST,PKGDEST,LOGDEST,MAKEFLAGS,PACKAGER,GNUPGHOME
|
||||
|
||||
mkchrootpkg_args+=("${@:$OPTIND}")
|
||||
|
||||
if ${create_first} || [[ ! -d "${chroots_pkg}/${repo}-${arch}" ]];then
|
||||
msg "Creating chroot for [%s] (%s)..." "${repo}" "${arch}"
|
||||
|
||||
for copy in "${chroots_pkg}/${repo}-${arch}"/*; do
|
||||
[[ -d $copy ]] || continue
|
||||
msg2 "Deleting chroot copy '%s'..." "$(basename "${copy}")"
|
||||
|
||||
lock 9 "$copy.lock" "Locking chroot copy '%s'" "$copy"
|
||||
|
||||
subvolume_delete_recursive "${copy}"
|
||||
rm -rf --one-file-system "${copy}"
|
||||
done
|
||||
lock_close 9
|
||||
|
||||
rm -rf --one-file-system "${chroots_pkg}/${repo}-${arch}"
|
||||
(umask 0022; mkdir -p "${chroots_pkg}/${repo}-${arch}")
|
||||
setarch "${set_arch}" mkchroot \
|
||||
-C "${pacman_conf}" \
|
||||
-M "${makepkg_conf}" \
|
||||
"${chroots_pkg}/${repo}-${arch}/root" \
|
||||
"${base_devel[@]}" || abort
|
||||
else
|
||||
lock 9 "${chroots_pkg}/${repo}-${arch}/root.lock" "Locking clean chroot"
|
||||
chroot-run \
|
||||
-C "${pacman_conf}" \
|
||||
-M "${makepkg_conf}" \
|
||||
"${chroots_pkg}/${repo}-${arch}/root" \
|
||||
pacman -Syuu --noconfirm || abort
|
||||
fi
|
||||
|
||||
# Always build official packages reproducibly
|
||||
if [[ ! -v SOURCE_DATE_EPOCH ]]; then
|
||||
export SOURCE_DATE_EPOCH=$(date +%s)
|
||||
fi
|
||||
|
||||
msg "Building in chroot for [%s] (%s)..." "${repo}" "${arch}"
|
||||
exec mkchrootpkg -r "${chroots_pkg}/${repo}-${arch}" "${mkchrootpkg_args[@]}"
|
741
artools/0.26.1/artools/bin/pkg/buildtree
Executable file
741
artools/0.26.1/artools/bin/pkg/buildtree
Executable file
|
@ -0,0 +1,741 @@
|
|||
#!/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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ base conf
|
||||
|
||||
DATADIR=${DATADIR:-'/usr/share/artools'}
|
||||
SYSCONFDIR=${SYSCONFDIR:-'/etc/artools'}
|
||||
|
||||
if [[ -n $SUDO_USER ]]; then
|
||||
eval "USER_HOME=~$SUDO_USER"
|
||||
else
|
||||
USER_HOME=$HOME
|
||||
fi
|
||||
|
||||
USER_CONF_DIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/artools"
|
||||
|
||||
prepare_dir(){
|
||||
[[ ! -d $1 ]] && mkdir -p "$1"
|
||||
}
|
||||
|
||||
load_base_config(){
|
||||
|
||||
local conf="$1/artools-base.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-base.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
CHROOTS_DIR=${CHROOTS_DIR:-'/var/lib/artools'}
|
||||
|
||||
WORKSPACE_DIR=${WORKSPACE_DIR:-"${USER_HOME}/artools-workspace"}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_base_config "${USER_CONF_DIR}" || load_base_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${WORKSPACE_DIR}"
|
||||
prepare_dir "${USER_CONF_DIR}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ pkg conf
|
||||
|
||||
load_pkg_config(){
|
||||
|
||||
local conf="$1/artools-pkg.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-pkg.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
local git_domain="gitea.artixlinux.org"
|
||||
|
||||
GIT_URL=${GIT_URL:-"https://${git_domain}"}
|
||||
|
||||
GIT_SSH=${GIT_SSH:-"gitea@${git_domain}"}
|
||||
|
||||
GIT_TOKEN=${GIT_TOKEN:-''}
|
||||
|
||||
TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"}
|
||||
|
||||
ARTIX_TREE=(
|
||||
packages community
|
||||
packages-{gfx,media,net}
|
||||
)
|
||||
|
||||
local dev_tree=(
|
||||
packages-{llvm,python,perl,java,ruby,misc}
|
||||
python-{world,galaxy,galaxy-groups,misc}
|
||||
)
|
||||
|
||||
local init_tree=(packages-{openrc,runit,s6,suite66,dinit})
|
||||
|
||||
local desktop_tree=(
|
||||
packages-{kf5,plasma,kde,qt5,qt6,xorg,gtk}
|
||||
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"}
|
||||
|
||||
[[ -z ${ARCH_TREE[*]} ]] && \
|
||||
ARCH_TREE=(svntogit-{packages,community})
|
||||
|
||||
REPOS_ROOT=${REPOS_ROOT:-"${WORKSPACE_DIR}/repos"}
|
||||
|
||||
REPOS_MIRROR=${REPOS_MIRROR:-'http://mirror1.artixlinux.org/repos'}
|
||||
|
||||
HOST_TREE_ARCH=${HOST_TREE_ARCH:-'https://github.com/archlinux'}
|
||||
|
||||
DBEXT=${DBEXT:-'gz'}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_pkg_config "${USER_CONF_DIR}" || load_pkg_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${REPOS_ROOT}"
|
||||
prepare_dir "${TREE_DIR_ARTIX}"
|
||||
prepare_dir "${TREE_DIR_ARCH}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ common functions
|
||||
|
||||
get_compliant_name(){
|
||||
local gitname="$1"
|
||||
case "$gitname" in
|
||||
*+) gitname=${gitname//+/plus}
|
||||
esac
|
||||
echo "$gitname"
|
||||
}
|
||||
|
||||
get_pkg_org(){
|
||||
local pkg="$1" org sub
|
||||
case ${pkg} in
|
||||
ruby-*) org="packagesRuby" ;;
|
||||
perl-*) org="packagesPerl" ;;
|
||||
python-*|python2-*) org="packagesPython" ;;
|
||||
*) sub=${pkg:0:1}; org="packages${sub^^}" ;;
|
||||
esac
|
||||
echo "$org"
|
||||
}
|
||||
|
||||
api_put() {
|
||||
curl -s -X PUT "$@"
|
||||
}
|
||||
|
||||
api_delete() {
|
||||
curl -s -X DELETE "$@"
|
||||
}
|
||||
|
||||
api_post() {
|
||||
curl -s -X POST "$@"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ git
|
||||
|
||||
get_local_head(){
|
||||
git log --pretty=%H ...refs/heads/master^ | head -n 1
|
||||
}
|
||||
|
||||
get_remote_head(){
|
||||
git ls-remote origin -h refs/heads/master | cut -f1
|
||||
}
|
||||
|
||||
has_changeset(){
|
||||
local head_l="$1" head_r="$2"
|
||||
if [[ "$head_l" == "$head_r" ]]; then
|
||||
msg2 "remote changes: no"
|
||||
return 1
|
||||
else
|
||||
msg2 "remote changes: yes"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
pull_tree(){
|
||||
local tree="$1" local_head="$2" os="${3:-Artix}"
|
||||
local remote_head
|
||||
remote_head=$(get_remote_head)
|
||||
|
||||
msg "Checking (%s) (%s)" "${tree}" "$os"
|
||||
if has_changeset "${local_head}" "${remote_head}";then
|
||||
git pull origin master
|
||||
fi
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ gitea api
|
||||
|
||||
add_team_to_repo() {
|
||||
local name="$1"
|
||||
local org="$2"
|
||||
local team="$3"
|
||||
local url
|
||||
|
||||
url="${GIT_URL}/api/v1/repos/$org/$name/teams/$team?access_token=${GIT_TOKEN}"
|
||||
|
||||
msg2 "Adding team (%s) to package repo [%s]" "$team" "$name"
|
||||
|
||||
api_put "$url" -H "accept: application/json"
|
||||
}
|
||||
|
||||
remove_team_from_repo() {
|
||||
local name="$1"
|
||||
local org="$2"
|
||||
local team="$3"
|
||||
local url
|
||||
|
||||
url="${GIT_URL}/api/v1/repos/$org/$name/teams/$team?access_token=${GIT_TOKEN}"
|
||||
|
||||
msg2 "Removing team (%s) from package repo [%s]" "$team" "$name"
|
||||
|
||||
api_delete "$url" -H "accept: application/json"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
##{{{ repo
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
load_valid_names(){
|
||||
local conf
|
||||
conf="${DATADIR}"/valid-names.conf
|
||||
[[ -f "$conf" ]] || return 1
|
||||
# shellcheck source=/usr/share/artools/valid-names.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
return 0
|
||||
}
|
||||
|
||||
set_arch_repos(){
|
||||
local _testing="$1" _staging="$2" _unstable="$3"
|
||||
[[ -z ${valid_names[*]} ]] && load_valid_names
|
||||
ARCH_REPOS=("${stable[@]}")
|
||||
$_testing && ARCH_REPOS+=("${gremlins[@]}")
|
||||
$_staging && ARCH_REPOS+=("${goblins[@]}")
|
||||
$_unstable && ARCH_REPOS+=("${wobble[@]}")
|
||||
}
|
||||
|
||||
find_repo(){
|
||||
local pkg="$1" pkgarch="${2:-${CARCH}}" repo
|
||||
for r in "${ARCH_REPOS[@]}"; do
|
||||
[[ -f $pkg/repos/$r-$pkgarch/PKGBUILD ]] && repo=repos/"$r-$pkgarch"
|
||||
[[ -f $pkg/repos/$r-any/PKGBUILD ]] && repo=repos/"$r"-any
|
||||
[[ -f $pkg/$pkgarch/$r/PKGBUILD ]] && repo="$pkgarch/$r"
|
||||
done
|
||||
echo "$repo"
|
||||
}
|
||||
|
||||
find_pkg(){
|
||||
local searchdir="$1" pkg="$2" result
|
||||
result=$(find "$searchdir" -mindepth 2 -maxdepth 2 -type d -name "$pkg")
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
tree_loop(){
|
||||
local func="$1" pkgs
|
||||
for tree in "${ARTIX_TREE[@]}"; do
|
||||
pkgs=$(find "${TREE_DIR_ARTIX}/$tree" -name "$CARCH" | sort)
|
||||
for _package in ${pkgs}; do
|
||||
"$func" "$_package"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ jenkins
|
||||
|
||||
write_jenkinsfile(){
|
||||
local pkg="$1"
|
||||
local jenkins=$pkg/Jenkinsfile
|
||||
|
||||
echo "@Library('artix-ci') import org.artixlinux.RepoPackage" > "$jenkins"
|
||||
{
|
||||
echo ''
|
||||
echo 'PackagePipeline(new RepoPackage(this))'
|
||||
echo ''
|
||||
} >> "$jenkins"
|
||||
|
||||
git add "$jenkins"
|
||||
}
|
||||
|
||||
write_agentyaml(){
|
||||
local pkg="$1"
|
||||
local agent="$pkg"/.artixlinux/agent.yaml label='master'
|
||||
[[ -d $pkg/.artixlinux ]] || mkdir "$pkg"/.artixlinux
|
||||
|
||||
echo '---' > "$agent"
|
||||
{
|
||||
echo ''
|
||||
echo "label: $label"
|
||||
echo ''
|
||||
} >> "$agent"
|
||||
|
||||
git add "$agent"
|
||||
}
|
||||
|
||||
commit_jenkins_files(){
|
||||
local pkg="$1"
|
||||
|
||||
write_jenkinsfile "$pkg"
|
||||
write_agentyaml "$pkg"
|
||||
|
||||
git commit -m "initial commit"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
|
||||
#{{{ new git repo
|
||||
|
||||
subrepo_clone(){
|
||||
local pkg="$1"
|
||||
local org="$2"
|
||||
local name="$3"
|
||||
|
||||
msg2 "Subrepo clone [%s] from (%s)" "$pkg" "$org/$name"
|
||||
git subrepo clone "${GIT_SSH}":"$org"/"$name".git "$pkg"
|
||||
}
|
||||
|
||||
subrepo_new(){
|
||||
cd "${TREE_DIR_ARTIX}/${group}" || return
|
||||
|
||||
local org gitname
|
||||
org=$(get_pkg_org "${package}")
|
||||
gitname=$(get_compliant_name "${package}")
|
||||
|
||||
gitearepo -cr "$gitname"
|
||||
|
||||
add_team_to_repo "$gitname" "$org" "${team}"
|
||||
|
||||
subrepo_clone "${package}" "$org" "$gitname"
|
||||
|
||||
mkdir -p "${TREE_DIR_ARTIX}/${group}/${package}/trunk"
|
||||
|
||||
commit_jenkins_files "${package}"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ pull
|
||||
|
||||
clone_tree(){
|
||||
local url="$1" tree="$2" os="${3:-Artix}"
|
||||
|
||||
msg "Cloning %s (%s) ..." "$tree" "$os"
|
||||
|
||||
git clone "$url/$tree".git
|
||||
}
|
||||
|
||||
pull_tree_arch(){
|
||||
cd "${TREE_DIR_ARCH}" || return
|
||||
for tree in "${ARCH_TREE[@]}";do
|
||||
if [[ -d "${tree}" ]];then
|
||||
( cd "${tree}" || return
|
||||
pull_tree "${tree}" "$(get_local_head)" "Arch"
|
||||
)
|
||||
else
|
||||
clone_tree "${HOST_TREE_ARCH}" "${tree}" "Arch"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
config_tree(){
|
||||
local tree="$1"
|
||||
cd "$tree" || return
|
||||
git config --bool pull.rebase true
|
||||
git config commit.gpgsign true
|
||||
if [[ -n "${GPGKEY}" ]];then
|
||||
git config user.signingkey "${GPGKEY}"
|
||||
else
|
||||
warning "No GPGKEY configured in makepkg.conf!"
|
||||
fi
|
||||
cd ..
|
||||
}
|
||||
|
||||
pull_tree_artix(){
|
||||
local repos=()
|
||||
if ${sync_group}; then
|
||||
repos=("${group}")
|
||||
else
|
||||
repos=("${ARTIX_TREE[@]}")
|
||||
fi
|
||||
cd "${TREE_DIR_ARTIX}" || return
|
||||
for tree in "${repos[@]}"; do
|
||||
if [[ -d "${tree}" ]];then
|
||||
config_tree "${tree}"
|
||||
( cd "${tree}" || return
|
||||
pull_tree "${tree}" "$(get_local_head)"
|
||||
)
|
||||
else
|
||||
clone_tree "${host_tree_artix}" "${tree}"
|
||||
config_tree "${tree}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ patch
|
||||
|
||||
patch_pkg(){
|
||||
local pkgpath="$1"
|
||||
local pkg=${pkgpath%/*}
|
||||
pkg=${pkg##*/}
|
||||
sed -e 's|arch-meson|artix-meson|' -i "$pkgpath"/PKGBUILD
|
||||
case $pkg in
|
||||
glibc)
|
||||
msg2 "Patching %s" "$pkg"
|
||||
sed -e 's|{locale,systemd/system,tmpfiles.d}|{locale,tmpfiles.d}|' \
|
||||
-e '/nscd.service/d' \
|
||||
-i "$pkgpath"/PKGBUILD
|
||||
;;
|
||||
linux|linux-lts)
|
||||
msg2 "Patching %s" "$pkg"
|
||||
sed -e 's|KBUILD_BUILD_HOST=.*|KBUILD_BUILD_HOST=artixlinux|' -i "$pkgpath"/PKGBUILD
|
||||
sed -e 's|CONFIG_DEFAULT_HOSTNAME=.*|CONFIG_DEFAULT_HOSTNAME="artixlinux"|' \
|
||||
-i "$pkgpath"/config
|
||||
;;
|
||||
bash)
|
||||
msg2 "Patching %s" "$pkg"
|
||||
# shellcheck disable=2016
|
||||
sed -e 's|system.bash_logout)|system.bash_logout artix.bashrc)|' \
|
||||
-e "s|etc/bash.|etc/bash/|g" \
|
||||
-e 's|"$pkgdir/etc/skel/.bash_logout"|"$pkgdir/etc/skel/.bash_logout"\n install -Dm644 artix.bashrc $pkgdir/etc/bash/bashrc.d/artix.bashrc|' \
|
||||
-i "$pkgpath"/PKGBUILD
|
||||
( cd "$pkgpath" || return
|
||||
patch -Np 1 -i "${DATADIR}"/patches/artix-bash.patch
|
||||
updpkgsums
|
||||
)
|
||||
;;
|
||||
gstreamer|gst-plugins-*|licenses)
|
||||
msg2 "Patching %s" "$pkg"
|
||||
sed -e 's|https://www.archlinux.org/|https://www.artixlinux.org/|' \
|
||||
-e 's|(Arch Linux)|(Artix Linux)|' \
|
||||
-i "$pkgpath"/PKGBUILD
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ pkgbuild import
|
||||
|
||||
sync_pkg(){
|
||||
local rsync_args=(-aWxvci --progress --delete-before --no-R --no-implied-dirs)
|
||||
local src="$1" dest="$2"
|
||||
msg "Sync from Arch [%s] to Artix [%s]" "${src##*archlinux/}" "${dest##*artixlinux/}"
|
||||
rsync "${rsync_args[@]}" "$src"/ "$dest"/
|
||||
}
|
||||
|
||||
show_deps(){
|
||||
local src="$1" archver
|
||||
|
||||
# shellcheck disable=1090
|
||||
. "$src"/PKGBUILD 2>/dev/null
|
||||
|
||||
archver=$(get_full_version)
|
||||
|
||||
# shellcheck disable=2154
|
||||
[[ -n ${pkgbase} ]] && msg2 "pkgbase: %s" "${pkgbase}"
|
||||
# shellcheck disable=2154
|
||||
msg2 "pkgname: %s" "${pkgname[*]}"
|
||||
# shellcheck disable=2154
|
||||
[[ -n "${pkgdesc}" ]] && msg2 "pkgdesc: %s" "${pkgdesc}"
|
||||
# shellcheck disable=2154
|
||||
msg2 "Arch Version: %s" "$archver"
|
||||
# shellcheck disable=2154
|
||||
msg2 "arch: %s" "$arch"
|
||||
# shellcheck disable=2154
|
||||
[[ -n ${makedepends[*]} ]] && msg2 "makedepends: %s" "${makedepends[*]}"
|
||||
# shellcheck disable=2154
|
||||
[[ -n ${checkdepends[*]} ]] && msg2 "checkdepends: %s" "${checkdepends[*]}"
|
||||
# shellcheck disable=2154
|
||||
[[ -n ${depends[*]} ]] && msg2 "depends: %s" "${depends[*]}"
|
||||
# shellcheck disable=2154
|
||||
[[ -n ${optdepends[*]} ]] && msg2 "optdepends: %s" "${optdepends[@]}"
|
||||
}
|
||||
|
||||
from_arch(){
|
||||
cd "${TREE_DIR_ARTIX}" || return
|
||||
|
||||
local srcpath repo archpath artixpath
|
||||
srcpath=$(find_pkg "${TREE_DIR_ARCH}" "${package}")
|
||||
[[ -z $srcpath ]] && die "Package '%s' does not exist!" "${package}"
|
||||
|
||||
repo=$(find_repo "$srcpath")
|
||||
msg "repo: %s" "${repo#*/}"
|
||||
|
||||
archpath=$srcpath/$repo
|
||||
artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}")
|
||||
|
||||
show_deps "$archpath"
|
||||
|
||||
if [[ -f "$artixpath"/.gitrepo ]]; then
|
||||
artixpath="$artixpath"/trunk
|
||||
|
||||
if [[ -d "$artixpath" ]];then
|
||||
sync_pkg "$archpath" "$artixpath"
|
||||
patch_pkg "$artixpath"
|
||||
fi
|
||||
else
|
||||
die "Package '%s' does not exist!" "${package}"
|
||||
fi
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
view_build(){
|
||||
local archpath repo
|
||||
archpath=$(find_pkg "${TREE_DIR_ARCH}" "${package}")
|
||||
[[ -z $archpath ]] && die "Package '%s' does not exist!" "${package}"
|
||||
repo=$(find_repo "${archpath}")
|
||||
archpath=$archpath/$repo
|
||||
msg "repo: %s" "${repo#*/}"
|
||||
show_deps "$archpath"
|
||||
}
|
||||
|
||||
check_tree(){
|
||||
local archpath artixpath group
|
||||
archpath=$(find_pkg "${TREE_DIR_ARCH}" "${package}")
|
||||
[[ -z $archpath ]] && die "Package '%s' does not exist!" "${package}"
|
||||
artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}")
|
||||
group=${artixpath%/*}
|
||||
msg "group: %s" "${group##*/}"
|
||||
|
||||
[[ -z $artixpath ]] && msg2 "exists: %s" "no"
|
||||
[[ -n $artixpath ]] && msg2 "exists: %s" "yes"
|
||||
}
|
||||
|
||||
sync_repos(){
|
||||
${sync_arch} && pull_tree_arch
|
||||
${sync_artix} && pull_tree_artix
|
||||
}
|
||||
|
||||
load_makepkg_config
|
||||
|
||||
load_valid_names
|
||||
|
||||
testing=true
|
||||
staging=true
|
||||
unstable=false
|
||||
|
||||
sync=false
|
||||
sync_arch=true
|
||||
sync_artix=true
|
||||
import=false
|
||||
view=false
|
||||
createnew=false
|
||||
sync_group=false
|
||||
check=false
|
||||
|
||||
package=''
|
||||
|
||||
team='community'
|
||||
group="${ARTIX_TREE[0]}"
|
||||
|
||||
host_tree_artix="${GIT_SSH}:artixlinux"
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options]"
|
||||
echo ' -p <pkg> Package name'
|
||||
echo ' -t <team> Team name (only with -n)'
|
||||
echo ' Possible values: core,extra,community,multilib'
|
||||
echo " [default: ${team}]"
|
||||
echo ' -g <group> Group name, the superrepo (only with -n or -s)'
|
||||
echo " [default: ${group}]"
|
||||
echo " -s Clone or pull repos"
|
||||
echo " -a Don't clone or pull arch repos"
|
||||
echo " -b Don't clone or pull artix repos"
|
||||
echo ' -i Import a package from arch repos'
|
||||
echo ' -n New remote subrepo and clone it'
|
||||
echo ' -v Check if a package is in the artix tree(s)'
|
||||
echo ' -c View package depends'
|
||||
echo ' -x Exclude testing (only with -i)'
|
||||
echo ' -y Exclude staging (only with -i)'
|
||||
echo ' -z Include kde & gnome unstable (only with -i)'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='p:t:g:sinabcvxyzh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
p) package="$OPTARG" ;;
|
||||
t) team="$OPTARG" ;;
|
||||
g) group="$OPTARG"; sync_group=true ;;
|
||||
s) sync=true ;;
|
||||
a) sync_arch=false ;;
|
||||
b) sync_artix=false ;;
|
||||
i) import=true ;;
|
||||
n) createnew=true ;;
|
||||
c) check=true ;;
|
||||
v) view=true ;;
|
||||
x) testing=false ;;
|
||||
y) staging=false ;;
|
||||
z) unstable=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
set_arch_repos "$testing" "$staging" "$unstable"
|
||||
|
||||
${sync} && sync_repos
|
||||
|
||||
${view} && view_build
|
||||
|
||||
${check} && check_tree
|
||||
|
||||
${import} && from_arch
|
||||
|
||||
${createnew} && subrepo_new
|
332
artools/0.26.1/artools/bin/pkg/buildtree.in
Normal file
332
artools/0.26.1/artools/bin/pkg/buildtree.in
Normal file
|
@ -0,0 +1,332 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/util-base.sh)
|
||||
m4_include(lib/util-pkg.sh)
|
||||
m4_include(lib/base/message.sh)
|
||||
m4_include(lib/pkg/common.sh)
|
||||
m4_include(lib/pkg/git.sh)
|
||||
m4_include(lib/pkg/gitea.sh)
|
||||
m4_include(lib/pkg/repo.sh)
|
||||
m4_include(lib/pkg/jenkins.sh)
|
||||
|
||||
#{{{ new git repo
|
||||
|
||||
subrepo_clone(){
|
||||
local pkg="$1"
|
||||
local org="$2"
|
||||
local name="$3"
|
||||
|
||||
msg2 "Subrepo clone [%s] from (%s)" "$pkg" "$org/$name"
|
||||
git subrepo clone "${GIT_SSH}":"$org"/"$name".git "$pkg"
|
||||
}
|
||||
|
||||
subrepo_new(){
|
||||
cd "${TREE_DIR_ARTIX}/${group}" || return
|
||||
|
||||
local org gitname
|
||||
org=$(get_pkg_org "${package}")
|
||||
gitname=$(get_compliant_name "${package}")
|
||||
|
||||
gitearepo -cr "$gitname"
|
||||
|
||||
add_team_to_repo "$gitname" "$org" "${team}"
|
||||
|
||||
subrepo_clone "${package}" "$org" "$gitname"
|
||||
|
||||
mkdir -p "${TREE_DIR_ARTIX}/${group}/${package}/trunk"
|
||||
|
||||
commit_jenkins_files "${package}"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ pull
|
||||
|
||||
clone_tree(){
|
||||
local url="$1" tree="$2" os="${3:-Artix}"
|
||||
|
||||
msg "Cloning %s (%s) ..." "$tree" "$os"
|
||||
|
||||
git clone "$url/$tree".git
|
||||
}
|
||||
|
||||
pull_tree_arch(){
|
||||
cd "${TREE_DIR_ARCH}" || return
|
||||
for tree in "${ARCH_TREE[@]}";do
|
||||
if [[ -d "${tree}" ]];then
|
||||
( cd "${tree}" || return
|
||||
pull_tree "${tree}" "$(get_local_head)" "Arch"
|
||||
)
|
||||
else
|
||||
clone_tree "${HOST_TREE_ARCH}" "${tree}" "Arch"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
config_tree(){
|
||||
local tree="$1"
|
||||
cd "$tree" || return
|
||||
git config --bool pull.rebase true
|
||||
git config commit.gpgsign true
|
||||
if [[ -n "${GPGKEY}" ]];then
|
||||
git config user.signingkey "${GPGKEY}"
|
||||
else
|
||||
warning "No GPGKEY configured in makepkg.conf!"
|
||||
fi
|
||||
cd ..
|
||||
}
|
||||
|
||||
pull_tree_artix(){
|
||||
local repos=()
|
||||
if ${sync_group}; then
|
||||
repos=("${group}")
|
||||
else
|
||||
repos=("${ARTIX_TREE[@]}")
|
||||
fi
|
||||
cd "${TREE_DIR_ARTIX}" || return
|
||||
for tree in "${repos[@]}"; do
|
||||
if [[ -d "${tree}" ]];then
|
||||
config_tree "${tree}"
|
||||
( cd "${tree}" || return
|
||||
pull_tree "${tree}" "$(get_local_head)"
|
||||
)
|
||||
else
|
||||
clone_tree "${host_tree_artix}" "${tree}"
|
||||
config_tree "${tree}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ patch
|
||||
|
||||
patch_pkg(){
|
||||
local pkgpath="$1"
|
||||
local pkg=${pkgpath%/*}
|
||||
pkg=${pkg##*/}
|
||||
sed -e 's|arch-meson|artix-meson|' -i "$pkgpath"/PKGBUILD
|
||||
case $pkg in
|
||||
glibc)
|
||||
msg2 "Patching %s" "$pkg"
|
||||
sed -e 's|{locale,systemd/system,tmpfiles.d}|{locale,tmpfiles.d}|' \
|
||||
-e '/nscd.service/d' \
|
||||
-i "$pkgpath"/PKGBUILD
|
||||
;;
|
||||
linux|linux-lts)
|
||||
msg2 "Patching %s" "$pkg"
|
||||
sed -e 's|KBUILD_BUILD_HOST=.*|KBUILD_BUILD_HOST=artixlinux|' -i "$pkgpath"/PKGBUILD
|
||||
sed -e 's|CONFIG_DEFAULT_HOSTNAME=.*|CONFIG_DEFAULT_HOSTNAME="artixlinux"|' \
|
||||
-i "$pkgpath"/config
|
||||
;;
|
||||
bash)
|
||||
msg2 "Patching %s" "$pkg"
|
||||
# shellcheck disable=2016
|
||||
sed -e 's|system.bash_logout)|system.bash_logout artix.bashrc)|' \
|
||||
-e "s|etc/bash.|etc/bash/|g" \
|
||||
-e 's|"$pkgdir/etc/skel/.bash_logout"|"$pkgdir/etc/skel/.bash_logout"\n install -Dm644 artix.bashrc $pkgdir/etc/bash/bashrc.d/artix.bashrc|' \
|
||||
-i "$pkgpath"/PKGBUILD
|
||||
( cd "$pkgpath" || return
|
||||
patch -Np 1 -i "${DATADIR}"/patches/artix-bash.patch
|
||||
updpkgsums
|
||||
)
|
||||
;;
|
||||
gstreamer|gst-plugins-*|licenses)
|
||||
msg2 "Patching %s" "$pkg"
|
||||
sed -e 's|https://www.archlinux.org/|https://www.artixlinux.org/|' \
|
||||
-e 's|(Arch Linux)|(Artix Linux)|' \
|
||||
-i "$pkgpath"/PKGBUILD
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ pkgbuild import
|
||||
|
||||
sync_pkg(){
|
||||
local rsync_args=(-aWxvci --progress --delete-before --no-R --no-implied-dirs)
|
||||
local src="$1" dest="$2"
|
||||
msg "Sync from Arch [%s] to Artix [%s]" "${src##*archlinux/}" "${dest##*artixlinux/}"
|
||||
rsync "${rsync_args[@]}" "$src"/ "$dest"/
|
||||
}
|
||||
|
||||
show_deps(){
|
||||
local src="$1" archver
|
||||
|
||||
# shellcheck disable=1090
|
||||
. "$src"/PKGBUILD 2>/dev/null
|
||||
|
||||
archver=$(get_full_version)
|
||||
|
||||
# shellcheck disable=2154
|
||||
[[ -n ${pkgbase} ]] && msg2 "pkgbase: %s" "${pkgbase}"
|
||||
# shellcheck disable=2154
|
||||
msg2 "pkgname: %s" "${pkgname[*]}"
|
||||
# shellcheck disable=2154
|
||||
[[ -n "${pkgdesc}" ]] && msg2 "pkgdesc: %s" "${pkgdesc}"
|
||||
# shellcheck disable=2154
|
||||
msg2 "Arch Version: %s" "$archver"
|
||||
# shellcheck disable=2154
|
||||
msg2 "arch: %s" "$arch"
|
||||
# shellcheck disable=2154
|
||||
[[ -n ${makedepends[*]} ]] && msg2 "makedepends: %s" "${makedepends[*]}"
|
||||
# shellcheck disable=2154
|
||||
[[ -n ${checkdepends[*]} ]] && msg2 "checkdepends: %s" "${checkdepends[*]}"
|
||||
# shellcheck disable=2154
|
||||
[[ -n ${depends[*]} ]] && msg2 "depends: %s" "${depends[*]}"
|
||||
# shellcheck disable=2154
|
||||
[[ -n ${optdepends[*]} ]] && msg2 "optdepends: %s" "${optdepends[@]}"
|
||||
}
|
||||
|
||||
from_arch(){
|
||||
cd "${TREE_DIR_ARTIX}" || return
|
||||
|
||||
local srcpath repo archpath artixpath
|
||||
srcpath=$(find_pkg "${TREE_DIR_ARCH}" "${package}")
|
||||
[[ -z $srcpath ]] && die "Package '%s' does not exist!" "${package}"
|
||||
|
||||
repo=$(find_repo "$srcpath")
|
||||
msg "repo: %s" "${repo#*/}"
|
||||
|
||||
archpath=$srcpath/$repo
|
||||
artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}")
|
||||
|
||||
show_deps "$archpath"
|
||||
|
||||
if [[ -f "$artixpath"/.gitrepo ]]; then
|
||||
artixpath="$artixpath"/trunk
|
||||
|
||||
if [[ -d "$artixpath" ]];then
|
||||
sync_pkg "$archpath" "$artixpath"
|
||||
patch_pkg "$artixpath"
|
||||
fi
|
||||
else
|
||||
die "Package '%s' does not exist!" "${package}"
|
||||
fi
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
view_build(){
|
||||
local archpath repo
|
||||
archpath=$(find_pkg "${TREE_DIR_ARCH}" "${package}")
|
||||
[[ -z $archpath ]] && die "Package '%s' does not exist!" "${package}"
|
||||
repo=$(find_repo "${archpath}")
|
||||
archpath=$archpath/$repo
|
||||
msg "repo: %s" "${repo#*/}"
|
||||
show_deps "$archpath"
|
||||
}
|
||||
|
||||
check_tree(){
|
||||
local archpath artixpath group
|
||||
archpath=$(find_pkg "${TREE_DIR_ARCH}" "${package}")
|
||||
[[ -z $archpath ]] && die "Package '%s' does not exist!" "${package}"
|
||||
artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}")
|
||||
group=${artixpath%/*}
|
||||
msg "group: %s" "${group##*/}"
|
||||
|
||||
[[ -z $artixpath ]] && msg2 "exists: %s" "no"
|
||||
[[ -n $artixpath ]] && msg2 "exists: %s" "yes"
|
||||
}
|
||||
|
||||
sync_repos(){
|
||||
${sync_arch} && pull_tree_arch
|
||||
${sync_artix} && pull_tree_artix
|
||||
}
|
||||
|
||||
load_makepkg_config
|
||||
|
||||
load_valid_names
|
||||
|
||||
testing=true
|
||||
staging=true
|
||||
unstable=false
|
||||
|
||||
sync=false
|
||||
sync_arch=true
|
||||
sync_artix=true
|
||||
import=false
|
||||
view=false
|
||||
createnew=false
|
||||
sync_group=false
|
||||
check=false
|
||||
|
||||
package=''
|
||||
|
||||
team='community'
|
||||
group="${ARTIX_TREE[0]}"
|
||||
|
||||
host_tree_artix="${GIT_SSH}:artixlinux"
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options]"
|
||||
echo ' -p <pkg> Package name'
|
||||
echo ' -t <team> Team name (only with -n)'
|
||||
echo ' Possible values: core,extra,community,multilib'
|
||||
echo " [default: ${team}]"
|
||||
echo ' -g <group> Group name, the superrepo (only with -n or -s)'
|
||||
echo " [default: ${group}]"
|
||||
echo " -s Clone or pull repos"
|
||||
echo " -a Don't clone or pull arch repos"
|
||||
echo " -b Don't clone or pull artix repos"
|
||||
echo ' -i Import a package from arch repos'
|
||||
echo ' -n New remote subrepo and clone it'
|
||||
echo ' -v Check if a package is in the artix tree(s)'
|
||||
echo ' -c View package depends'
|
||||
echo ' -x Exclude testing (only with -i)'
|
||||
echo ' -y Exclude staging (only with -i)'
|
||||
echo ' -z Include kde & gnome unstable (only with -i)'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='p:t:g:sinabcvxyzh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
p) package="$OPTARG" ;;
|
||||
t) team="$OPTARG" ;;
|
||||
g) group="$OPTARG"; sync_group=true ;;
|
||||
s) sync=true ;;
|
||||
a) sync_arch=false ;;
|
||||
b) sync_artix=false ;;
|
||||
i) import=true ;;
|
||||
n) createnew=true ;;
|
||||
c) check=true ;;
|
||||
v) view=true ;;
|
||||
x) testing=false ;;
|
||||
y) staging=false ;;
|
||||
z) unstable=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
set_arch_repos "$testing" "$staging" "$unstable"
|
||||
|
||||
${sync} && sync_repos
|
||||
|
||||
${view} && view_build
|
||||
|
||||
${check} && check_tree
|
||||
|
||||
${import} && from_arch
|
||||
|
||||
${createnew} && subrepo_new
|
303
artools/0.26.1/artools/bin/pkg/checkpkg
Executable file
303
artools/0.26.1/artools/bin/pkg/checkpkg
Executable file
|
@ -0,0 +1,303 @@
|
|||
#!/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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
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() {
|
||||
cat <<- _EOF_
|
||||
Usage: ${BASH_SOURCE[0]##*/} [OPTIONS]
|
||||
|
||||
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 list of .so files provided by each version of the
|
||||
package and outputs if there are soname differences for the new package.
|
||||
A directory is also created using mktemp with files containing a file
|
||||
list for both packages and a library list for both packages.
|
||||
|
||||
OPTIONS
|
||||
-r, --rmdir Remove the temporary directory
|
||||
-w, --warn Print a warning in case of differences
|
||||
-h, --help Show this help text
|
||||
_EOF_
|
||||
}
|
||||
|
||||
RMDIR=0
|
||||
WARN=0
|
||||
|
||||
OPT_SHORT='rwh'
|
||||
OPT_LONG=('rmdir' 'warn' 'help')
|
||||
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
|
||||
exit 1
|
||||
fi
|
||||
set -- "${OPTRET[@]}"
|
||||
|
||||
while :; do
|
||||
case $1 in
|
||||
-r|--rmdir)
|
||||
RMDIR=1
|
||||
;;
|
||||
-w|--warn)
|
||||
WARN=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
shift; break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ ! -f PKGBUILD ]]; then
|
||||
die 'This must be run in the directory of a built package.'
|
||||
fi
|
||||
|
||||
# shellcheck source=PKGBUILD.proto
|
||||
. ./PKGBUILD
|
||||
if [[ ${arch[0]} == 'any' ]]; then
|
||||
CARCH='any'
|
||||
fi
|
||||
|
||||
STARTDIR=$(pwd)
|
||||
(( RMDIR )) && trap 'rm -rf $TEMPDIR' EXIT INT TERM QUIT
|
||||
TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX)
|
||||
|
||||
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" "$TEMPDIR"
|
||||
|
||||
if (( $# )); then
|
||||
case $1 in
|
||||
/*|*/*)
|
||||
pkgurl=file://$(readlink -m "$1") ;;
|
||||
*.pkg.tar*)
|
||||
pkgurl=$1 ;;
|
||||
'')
|
||||
;;
|
||||
*)
|
||||
comparepkg=$1 ;;
|
||||
esac
|
||||
shift
|
||||
fi
|
||||
[[ -n $pkgurl ]] || pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$comparepkg") ||
|
||||
die "Couldn't download previous package for %s." "$comparepkg"
|
||||
|
||||
oldpkg=${pkgurl##*/}
|
||||
|
||||
if [[ ${oldpkg} = "${pkgfile##*/}" ]]; then
|
||||
die "The built package (%s) is the one in the repo right now!" "$_pkgname"
|
||||
fi
|
||||
|
||||
if [[ $pkgurl = file://* || ( $pkgurl = /* && -f $pkgurl ) ]]; then
|
||||
ln -s "${pkgurl#file://}" "$TEMPDIR/$oldpkg"
|
||||
elif [[ -f "$PKGDEST/$oldpkg" ]]; then
|
||||
ln -s "$PKGDEST/$oldpkg" "$TEMPDIR/$oldpkg"
|
||||
elif [[ -f "$STARTDIR/$oldpkg" ]]; then
|
||||
ln -s "$STARTDIR/$oldpkg" "$TEMPDIR/$oldpkg"
|
||||
else
|
||||
curl -fsLC - --retry 3 --retry-delay 3 -o "$TEMPDIR/$oldpkg" "$pkgurl"
|
||||
fi
|
||||
|
||||
bsdtar tf "$TEMPDIR/$oldpkg" | sort > "$TEMPDIR/filelist-$_pkgname-old"
|
||||
bsdtar tf "$pkgfile" | sort > "$TEMPDIR/filelist-$_pkgname"
|
||||
|
||||
sdiff -s "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname"
|
||||
|
||||
find-libprovides "$TEMPDIR/$oldpkg" 2>/dev/null | sort > "$TEMPDIR/libraries-$_pkgname-old"
|
||||
find-libprovides "$pkgfile" 2>/dev/null | sort > "$TEMPDIR/libraries-$_pkgname"
|
||||
if ! diff_output="$(sdiff -s "$TEMPDIR/libraries-$_pkgname-old" "$TEMPDIR/libraries-$_pkgname")"; then
|
||||
message="Sonames differ in $_pkgname!"
|
||||
(( WARN )) && warning "$message" || msg "$message"
|
||||
echo "$diff_output"
|
||||
else
|
||||
msg "No soname differences for %s." "$_pkgname"
|
||||
fi
|
||||
done
|
||||
|
||||
(( RMDIR )) || msg "Files saved to %s" "$TEMPDIR"
|
206
artools/0.26.1/artools/bin/pkg/checkpkg.in
Normal file
206
artools/0.26.1/artools/bin/pkg/checkpkg.in
Normal file
|
@ -0,0 +1,206 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/base/message.sh)
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
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() {
|
||||
cat <<- _EOF_
|
||||
Usage: ${BASH_SOURCE[0]##*/} [OPTIONS]
|
||||
|
||||
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 list of .so files provided by each version of the
|
||||
package and outputs if there are soname differences for the new package.
|
||||
A directory is also created using mktemp with files containing a file
|
||||
list for both packages and a library list for both packages.
|
||||
|
||||
OPTIONS
|
||||
-r, --rmdir Remove the temporary directory
|
||||
-w, --warn Print a warning in case of differences
|
||||
-h, --help Show this help text
|
||||
_EOF_
|
||||
}
|
||||
|
||||
RMDIR=0
|
||||
WARN=0
|
||||
|
||||
OPT_SHORT='rwh'
|
||||
OPT_LONG=('rmdir' 'warn' 'help')
|
||||
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
|
||||
exit 1
|
||||
fi
|
||||
set -- "${OPTRET[@]}"
|
||||
|
||||
while :; do
|
||||
case $1 in
|
||||
-r|--rmdir)
|
||||
RMDIR=1
|
||||
;;
|
||||
-w|--warn)
|
||||
WARN=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
shift; break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ ! -f PKGBUILD ]]; then
|
||||
die 'This must be run in the directory of a built package.'
|
||||
fi
|
||||
|
||||
# shellcheck source=PKGBUILD.proto
|
||||
. ./PKGBUILD
|
||||
if [[ ${arch[0]} == 'any' ]]; then
|
||||
CARCH='any'
|
||||
fi
|
||||
|
||||
STARTDIR=$(pwd)
|
||||
(( RMDIR )) && trap 'rm -rf $TEMPDIR' EXIT INT TERM QUIT
|
||||
TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX)
|
||||
|
||||
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" "$TEMPDIR"
|
||||
|
||||
if (( $# )); then
|
||||
case $1 in
|
||||
/*|*/*)
|
||||
pkgurl=file://$(readlink -m "$1") ;;
|
||||
*.pkg.tar*)
|
||||
pkgurl=$1 ;;
|
||||
'')
|
||||
;;
|
||||
*)
|
||||
comparepkg=$1 ;;
|
||||
esac
|
||||
shift
|
||||
fi
|
||||
[[ -n $pkgurl ]] || pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$comparepkg") ||
|
||||
die "Couldn't download previous package for %s." "$comparepkg"
|
||||
|
||||
oldpkg=${pkgurl##*/}
|
||||
|
||||
if [[ ${oldpkg} = "${pkgfile##*/}" ]]; then
|
||||
die "The built package (%s) is the one in the repo right now!" "$_pkgname"
|
||||
fi
|
||||
|
||||
if [[ $pkgurl = file://* || ( $pkgurl = /* && -f $pkgurl ) ]]; then
|
||||
ln -s "${pkgurl#file://}" "$TEMPDIR/$oldpkg"
|
||||
elif [[ -f "$PKGDEST/$oldpkg" ]]; then
|
||||
ln -s "$PKGDEST/$oldpkg" "$TEMPDIR/$oldpkg"
|
||||
elif [[ -f "$STARTDIR/$oldpkg" ]]; then
|
||||
ln -s "$STARTDIR/$oldpkg" "$TEMPDIR/$oldpkg"
|
||||
else
|
||||
curl -fsLC - --retry 3 --retry-delay 3 -o "$TEMPDIR/$oldpkg" "$pkgurl"
|
||||
fi
|
||||
|
||||
bsdtar tf "$TEMPDIR/$oldpkg" | sort > "$TEMPDIR/filelist-$_pkgname-old"
|
||||
bsdtar tf "$pkgfile" | sort > "$TEMPDIR/filelist-$_pkgname"
|
||||
|
||||
sdiff -s "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname"
|
||||
|
||||
find-libprovides "$TEMPDIR/$oldpkg" 2>/dev/null | sort > "$TEMPDIR/libraries-$_pkgname-old"
|
||||
find-libprovides "$pkgfile" 2>/dev/null | sort > "$TEMPDIR/libraries-$_pkgname"
|
||||
if ! diff_output="$(sdiff -s "$TEMPDIR/libraries-$_pkgname-old" "$TEMPDIR/libraries-$_pkgname")"; then
|
||||
message="Sonames differ in $_pkgname!"
|
||||
(( WARN )) && warning "$message" || msg "$message"
|
||||
echo "$diff_output"
|
||||
else
|
||||
msg "No soname differences for %s." "$_pkgname"
|
||||
fi
|
||||
done
|
||||
|
||||
(( RMDIR )) || msg "Files saved to %s" "$TEMPDIR"
|
550
artools/0.26.1/artools/bin/pkg/checkrepo
Executable file
550
artools/0.26.1/artools/bin/pkg/checkrepo
Executable file
|
@ -0,0 +1,550 @@
|
|||
#!/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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ base conf
|
||||
|
||||
DATADIR=${DATADIR:-'/usr/share/artools'}
|
||||
SYSCONFDIR=${SYSCONFDIR:-'/etc/artools'}
|
||||
|
||||
if [[ -n $SUDO_USER ]]; then
|
||||
eval "USER_HOME=~$SUDO_USER"
|
||||
else
|
||||
USER_HOME=$HOME
|
||||
fi
|
||||
|
||||
USER_CONF_DIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/artools"
|
||||
|
||||
prepare_dir(){
|
||||
[[ ! -d $1 ]] && mkdir -p "$1"
|
||||
}
|
||||
|
||||
load_base_config(){
|
||||
|
||||
local conf="$1/artools-base.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-base.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
CHROOTS_DIR=${CHROOTS_DIR:-'/var/lib/artools'}
|
||||
|
||||
WORKSPACE_DIR=${WORKSPACE_DIR:-"${USER_HOME}/artools-workspace"}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_base_config "${USER_CONF_DIR}" || load_base_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${WORKSPACE_DIR}"
|
||||
prepare_dir "${USER_CONF_DIR}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ pkg conf
|
||||
|
||||
load_pkg_config(){
|
||||
|
||||
local conf="$1/artools-pkg.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-pkg.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
local git_domain="gitea.artixlinux.org"
|
||||
|
||||
GIT_URL=${GIT_URL:-"https://${git_domain}"}
|
||||
|
||||
GIT_SSH=${GIT_SSH:-"gitea@${git_domain}"}
|
||||
|
||||
GIT_TOKEN=${GIT_TOKEN:-''}
|
||||
|
||||
TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"}
|
||||
|
||||
ARTIX_TREE=(
|
||||
packages community
|
||||
packages-{gfx,media,net}
|
||||
)
|
||||
|
||||
local dev_tree=(
|
||||
packages-{llvm,python,perl,java,ruby,misc}
|
||||
python-{world,galaxy,galaxy-groups,misc}
|
||||
)
|
||||
|
||||
local init_tree=(packages-{openrc,runit,s6,suite66,dinit})
|
||||
|
||||
local desktop_tree=(
|
||||
packages-{kf5,plasma,kde,qt5,qt6,xorg,gtk}
|
||||
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"}
|
||||
|
||||
[[ -z ${ARCH_TREE[*]} ]] && \
|
||||
ARCH_TREE=(svntogit-{packages,community})
|
||||
|
||||
REPOS_ROOT=${REPOS_ROOT:-"${WORKSPACE_DIR}/repos"}
|
||||
|
||||
REPOS_MIRROR=${REPOS_MIRROR:-'http://mirror1.artixlinux.org/repos'}
|
||||
|
||||
HOST_TREE_ARCH=${HOST_TREE_ARCH:-'https://github.com/archlinux'}
|
||||
|
||||
DBEXT=${DBEXT:-'gz'}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_pkg_config "${USER_CONF_DIR}" || load_pkg_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${REPOS_ROOT}"
|
||||
prepare_dir "${TREE_DIR_ARTIX}"
|
||||
prepare_dir "${TREE_DIR_ARCH}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
##{{{ repo
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
load_valid_names(){
|
||||
local conf
|
||||
conf="${DATADIR}"/valid-names.conf
|
||||
[[ -f "$conf" ]] || return 1
|
||||
# shellcheck source=/usr/share/artools/valid-names.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
return 0
|
||||
}
|
||||
|
||||
set_arch_repos(){
|
||||
local _testing="$1" _staging="$2" _unstable="$3"
|
||||
[[ -z ${valid_names[*]} ]] && load_valid_names
|
||||
ARCH_REPOS=("${stable[@]}")
|
||||
$_testing && ARCH_REPOS+=("${gremlins[@]}")
|
||||
$_staging && ARCH_REPOS+=("${goblins[@]}")
|
||||
$_unstable && ARCH_REPOS+=("${wobble[@]}")
|
||||
}
|
||||
|
||||
find_repo(){
|
||||
local pkg="$1" pkgarch="${2:-${CARCH}}" repo
|
||||
for r in "${ARCH_REPOS[@]}"; do
|
||||
[[ -f $pkg/repos/$r-$pkgarch/PKGBUILD ]] && repo=repos/"$r-$pkgarch"
|
||||
[[ -f $pkg/repos/$r-any/PKGBUILD ]] && repo=repos/"$r"-any
|
||||
[[ -f $pkg/$pkgarch/$r/PKGBUILD ]] && repo="$pkgarch/$r"
|
||||
done
|
||||
echo "$repo"
|
||||
}
|
||||
|
||||
find_pkg(){
|
||||
local searchdir="$1" pkg="$2" result
|
||||
result=$(find "$searchdir" -mindepth 2 -maxdepth 2 -type d -name "$pkg")
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
tree_loop(){
|
||||
local func="$1" pkgs
|
||||
for tree in "${ARTIX_TREE[@]}"; do
|
||||
pkgs=$(find "${TREE_DIR_ARTIX}/$tree" -name "$CARCH" | sort)
|
||||
for _package in ${pkgs}; do
|
||||
"$func" "$_package"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ table
|
||||
|
||||
msg_table_header(){
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${BLUE} ${mesg} ${ALL_OFF}\n" "$@"
|
||||
}
|
||||
|
||||
msg_row_yellow(){
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${YELLOW} ${mesg}${ALL_OFF}\n" "$@"
|
||||
}
|
||||
|
||||
msg_row_green(){
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN} ${mesg}${ALL_OFF}\n" "$@"
|
||||
}
|
||||
|
||||
msg_row(){
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${WHITE} ${mesg}${ALL_OFF}\n" "$@"
|
||||
}
|
||||
|
||||
msg_row_red(){
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${RED} ${mesg} ${ALL_OFF}\n" "$@"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
|
||||
#{{{ db libs
|
||||
|
||||
extract_db() {
|
||||
local u="$1" cdir="$2"
|
||||
rm -rf "$cdir"
|
||||
mkdir -p "$cdir"
|
||||
msg2 "%s" "${cdir##*/}"
|
||||
curl -L -s "$u" | bsdtar -xf - -C "$cdir"
|
||||
}
|
||||
|
||||
update_db_cache(){
|
||||
msg "Updating database cache ..."
|
||||
local cachedir url
|
||||
for repo in "${searchrepos[@]}"; do
|
||||
cachedir=${db_cache_dir}/linksdb/$repo
|
||||
url=${REPOS_MIRROR}/$repo/os/${CARCH}/$repo.${linksdb_ext}
|
||||
extract_db "$url" "$cachedir"
|
||||
done
|
||||
msg "Done"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ sogrep
|
||||
|
||||
query_db() {
|
||||
for repo in "${searchrepos[@]}"; do
|
||||
local db
|
||||
db=${db_cache_dir}/linksdb/$repo/
|
||||
if [[ -d ${db} ]]; then
|
||||
while read -rd '' pkg; do
|
||||
read -r match
|
||||
pkg=${pkg#${db}}
|
||||
pkg="${pkg%/*}"
|
||||
msg_row "${tableQ}" "$repo" "$pkg" "${match}"
|
||||
done < <(grep -rZ "$library" "$db") | sort -u
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ check db
|
||||
|
||||
is_db_entry() {
|
||||
local pkgname="$1" repo="${REPOS[$2]}" entry
|
||||
entry=${db_cache_dir}/linksdb/$repo/$pkgname
|
||||
|
||||
if [[ -d "$entry" ]];then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
check_db(){
|
||||
local pkgpath="${1}"
|
||||
|
||||
for repo in "${!REPOS[@]}"; do
|
||||
|
||||
local pkgbuild artixver
|
||||
if [[ -f $pkgpath/$repo/PKGBUILD ]]; then
|
||||
pkgbuild=$pkgpath/$repo/PKGBUILD
|
||||
|
||||
# shellcheck disable=1090
|
||||
. "$pkgbuild" 2>/dev/null
|
||||
artixver=$(get_full_version)
|
||||
for name in "${pkgname[@]}"; do
|
||||
if ! is_db_entry "$name-$artixver" "$repo"; then
|
||||
msg_row_red "${tableU}" "$repo" "$name" "$artixver" "false"
|
||||
else
|
||||
${all_db} && msg_row "${tableU}" "$repo" "$name" "$artixver" "true"
|
||||
fi
|
||||
done
|
||||
unset artixver pkgbuild pkgver epoch pkgname pkgbase
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
# {{{ check obsolete
|
||||
|
||||
show_obsolete_table() {
|
||||
local arch_mirror='https://mirror.f4st.host/archlinux'
|
||||
|
||||
local arch_repo artix_repo artix_db arch_db url
|
||||
arch_repo="${searchrepos[@]}"
|
||||
artix_repo="${REPOS[$arch_repo]}"
|
||||
|
||||
artix_db="${db_cache_dir}/artixdb/${artix_repo}"
|
||||
arch_db="${db_cache_dir}/archdb/${arch_repo}"
|
||||
|
||||
msg "Updating database cache ..."
|
||||
url=${REPOS_MIRROR}/${artix_repo}/os/$CARCH/${artix_repo}.${db_ext}
|
||||
extract_db "$url" "${artix_db}"
|
||||
|
||||
url=${arch_mirror}/${arch_repo}/os/$CARCH/${arch_repo}.${db_ext}
|
||||
extract_db "$url" "${arch_db}"
|
||||
msg "Done"
|
||||
|
||||
msg_table_header "${tableQ}" "Repo" "Package" "Obsolete"
|
||||
for p in "${artix_db}"/*; do
|
||||
local pkg rel
|
||||
pkg=${p##*/}
|
||||
rel=${pkg##*-}
|
||||
rel=${rel%.*}
|
||||
pkg=${pkg%-*}
|
||||
local p="$pkg-$rel"
|
||||
|
||||
if [[ "$p" != *openrc* ]] && [[ "$p" != *runit* ]] \
|
||||
&& [[ "$p" != *s6* ]] && [[ "$p" != *suite66* ]] \
|
||||
&& [[ "$p" != *eudev* ]] && [[ "$p" != *elogind* ]] \
|
||||
&& [[ "$p" != *sysusers* ]] && [[ "$p" != *tmpfiles* ]] \
|
||||
&& [[ "$p" != *execline* ]] && [[ "$p" != *skalibs* ]] \
|
||||
&& [[ "$p" != *netifrc* ]] && [[ "$p" != *bootlogd* ]] \
|
||||
&& [[ "$p" != *pam_rundir* ]] && [[ "$p" != *artools* ]] \
|
||||
&& [[ "$p" != *archlinux* ]] && [[ "$p" != *iso-profiles* ]] \
|
||||
&& [[ "$p" != *calamares* ]] && [[ "$p" != *iso-initcpio* ]] \
|
||||
&& [[ "$p" != *dinit* ]] && [[ "$p" != *artix* ]]; then
|
||||
if [[ ! -d "${arch_db}/$p" ]]; then
|
||||
msg_row "${tableQ}" "${artix_repo}" "$p" "true"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
show_lib_table() {
|
||||
msg_table_header "${tableQ}" "Repo" "Package" "Library"
|
||||
query_db
|
||||
}
|
||||
|
||||
show_db_table(){
|
||||
msg_table_header "${tableU}" "Repo" "Package" "Version" "Database"
|
||||
tree_loop check_db
|
||||
}
|
||||
|
||||
db_cache_dir="${XDG_CACHE_HOME:-$USER_HOME/.cache}/artools"
|
||||
|
||||
linksdb_ext="links.tar.${DBEXT}"
|
||||
db_ext="db.tar.${DBEXT}"
|
||||
|
||||
load_makepkg_config
|
||||
|
||||
sync=false
|
||||
check=false
|
||||
query=false
|
||||
all_db=false
|
||||
obsolete=false
|
||||
|
||||
readonly tableU="%-20s %-35s %-30s %-10s"
|
||||
readonly tableQ="%-20s %-55s %s"
|
||||
|
||||
load_valid_names
|
||||
|
||||
#{{{ repo names arrays
|
||||
|
||||
declare -A REPOS=(
|
||||
[${valid_names[0]}]=system
|
||||
[${valid_names[1]}]=world
|
||||
[${valid_names[2]}]=galaxy
|
||||
[${valid_names[3]}]=lib32
|
||||
[${valid_names[4]}]=gremlins
|
||||
[${valid_names[5]}]=galaxy-gremlins
|
||||
[${valid_names[6]}]=lib32-gremlins
|
||||
[${valid_names[7]}]=goblins
|
||||
[${valid_names[8]}]=galaxy-goblins
|
||||
[${valid_names[9]}]=lib32-goblins
|
||||
[${valid_names[11]}]=kde-wobble
|
||||
[${valid_names[12]}]=gnome-wobble
|
||||
)
|
||||
|
||||
searchrepos=(
|
||||
"${REPOS[${valid_names[11]}]}"
|
||||
"${REPOS[${valid_names[12]}]}"
|
||||
"${REPOS[${valid_names[7]}]}"
|
||||
"${REPOS[${valid_names[8]}]}"
|
||||
"${REPOS[${valid_names[9]}]}"
|
||||
"${REPOS[${valid_names[4]}]}"
|
||||
"${REPOS[${valid_names[5]}]}"
|
||||
"${REPOS[${valid_names[6]}]}"
|
||||
"${REPOS[${valid_names[0]}]}"
|
||||
"${REPOS[${valid_names[1]}]}"
|
||||
"${REPOS[${valid_names[2]}]}"
|
||||
"${REPOS[${valid_names[3]}]}"
|
||||
)
|
||||
|
||||
#}}}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] (with -q [libname])"
|
||||
echo ' -r <repo> Repo name to query'
|
||||
echo ' [default: all]'
|
||||
echo " -s Sync repo databases"
|
||||
echo ' -c Check repos'
|
||||
echo ' -a Show repo db (-c)'
|
||||
echo ' -o Check for obsolete packages'
|
||||
echo " -q Query repo databases for so libs"
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='r:qcsaoh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
r) searchrepos=("$OPTARG") ;;
|
||||
s) sync=true ;;
|
||||
c) check=true ;;
|
||||
a) all_db=true ;;
|
||||
q) query=true ;;
|
||||
o) obsolete=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
library="$1"; shift
|
||||
|
||||
${sync} && update_db_cache
|
||||
|
||||
${check} && show_db_table
|
||||
|
||||
${query} && show_lib_table
|
||||
|
||||
${obsolete} && show_obsolete_table
|
251
artools/0.26.1/artools/bin/pkg/checkrepo.in
Normal file
251
artools/0.26.1/artools/bin/pkg/checkrepo.in
Normal file
|
@ -0,0 +1,251 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/util-base.sh)
|
||||
m4_include(lib/util-pkg.sh)
|
||||
m4_include(lib/base/message.sh)
|
||||
m4_include(lib/pkg/repo.sh)
|
||||
m4_include(lib/pkg/table.sh)
|
||||
|
||||
#{{{ db libs
|
||||
|
||||
extract_db() {
|
||||
local u="$1" cdir="$2"
|
||||
rm -rf "$cdir"
|
||||
mkdir -p "$cdir"
|
||||
msg2 "%s" "${cdir##*/}"
|
||||
curl -L -s "$u" | bsdtar -xf - -C "$cdir"
|
||||
}
|
||||
|
||||
update_db_cache(){
|
||||
msg "Updating database cache ..."
|
||||
local cachedir url
|
||||
for repo in "${searchrepos[@]}"; do
|
||||
cachedir=${db_cache_dir}/linksdb/$repo
|
||||
url=${REPOS_MIRROR}/$repo/os/${CARCH}/$repo.${linksdb_ext}
|
||||
extract_db "$url" "$cachedir"
|
||||
done
|
||||
msg "Done"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ sogrep
|
||||
|
||||
query_db() {
|
||||
for repo in "${searchrepos[@]}"; do
|
||||
local db
|
||||
db=${db_cache_dir}/linksdb/$repo/
|
||||
if [[ -d ${db} ]]; then
|
||||
while read -rd '' pkg; do
|
||||
read -r match
|
||||
pkg=${pkg#${db}}
|
||||
pkg="${pkg%/*}"
|
||||
msg_row "${tableQ}" "$repo" "$pkg" "${match}"
|
||||
done < <(grep -rZ "$library" "$db") | sort -u
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#{{{ check db
|
||||
|
||||
is_db_entry() {
|
||||
local pkgname="$1" repo="${REPOS[$2]}" entry
|
||||
entry=${db_cache_dir}/linksdb/$repo/$pkgname
|
||||
|
||||
if [[ -d "$entry" ]];then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
check_db(){
|
||||
local pkgpath="${1}"
|
||||
|
||||
for repo in "${!REPOS[@]}"; do
|
||||
|
||||
local pkgbuild artixver
|
||||
if [[ -f $pkgpath/$repo/PKGBUILD ]]; then
|
||||
pkgbuild=$pkgpath/$repo/PKGBUILD
|
||||
|
||||
# shellcheck disable=1090
|
||||
. "$pkgbuild" 2>/dev/null
|
||||
artixver=$(get_full_version)
|
||||
for name in "${pkgname[@]}"; do
|
||||
if ! is_db_entry "$name-$artixver" "$repo"; then
|
||||
msg_row_red "${tableU}" "$repo" "$name" "$artixver" "false"
|
||||
else
|
||||
${all_db} && msg_row "${tableU}" "$repo" "$name" "$artixver" "true"
|
||||
fi
|
||||
done
|
||||
unset artixver pkgbuild pkgver epoch pkgname pkgbase
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
# {{{ check obsolete
|
||||
|
||||
show_obsolete_table() {
|
||||
local arch_mirror='https://mirror.f4st.host/archlinux'
|
||||
|
||||
local arch_repo artix_repo artix_db arch_db url
|
||||
arch_repo="${searchrepos[@]}"
|
||||
artix_repo="${REPOS[$arch_repo]}"
|
||||
|
||||
artix_db="${db_cache_dir}/artixdb/${artix_repo}"
|
||||
arch_db="${db_cache_dir}/archdb/${arch_repo}"
|
||||
|
||||
msg "Updating database cache ..."
|
||||
url=${REPOS_MIRROR}/${artix_repo}/os/$CARCH/${artix_repo}.${db_ext}
|
||||
extract_db "$url" "${artix_db}"
|
||||
|
||||
url=${arch_mirror}/${arch_repo}/os/$CARCH/${arch_repo}.${db_ext}
|
||||
extract_db "$url" "${arch_db}"
|
||||
msg "Done"
|
||||
|
||||
msg_table_header "${tableQ}" "Repo" "Package" "Obsolete"
|
||||
for p in "${artix_db}"/*; do
|
||||
local pkg rel
|
||||
pkg=${p##*/}
|
||||
rel=${pkg##*-}
|
||||
rel=${rel%.*}
|
||||
pkg=${pkg%-*}
|
||||
local p="$pkg-$rel"
|
||||
|
||||
if [[ "$p" != *openrc* ]] && [[ "$p" != *runit* ]] \
|
||||
&& [[ "$p" != *s6* ]] && [[ "$p" != *suite66* ]] \
|
||||
&& [[ "$p" != *eudev* ]] && [[ "$p" != *elogind* ]] \
|
||||
&& [[ "$p" != *sysusers* ]] && [[ "$p" != *tmpfiles* ]] \
|
||||
&& [[ "$p" != *execline* ]] && [[ "$p" != *skalibs* ]] \
|
||||
&& [[ "$p" != *netifrc* ]] && [[ "$p" != *bootlogd* ]] \
|
||||
&& [[ "$p" != *pam_rundir* ]] && [[ "$p" != *artools* ]] \
|
||||
&& [[ "$p" != *archlinux* ]] && [[ "$p" != *iso-profiles* ]] \
|
||||
&& [[ "$p" != *calamares* ]] && [[ "$p" != *iso-initcpio* ]] \
|
||||
&& [[ "$p" != *dinit* ]] && [[ "$p" != *artix* ]]; then
|
||||
if [[ ! -d "${arch_db}/$p" ]]; then
|
||||
msg_row "${tableQ}" "${artix_repo}" "$p" "true"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
show_lib_table() {
|
||||
msg_table_header "${tableQ}" "Repo" "Package" "Library"
|
||||
query_db
|
||||
}
|
||||
|
||||
show_db_table(){
|
||||
msg_table_header "${tableU}" "Repo" "Package" "Version" "Database"
|
||||
tree_loop check_db
|
||||
}
|
||||
|
||||
db_cache_dir="${XDG_CACHE_HOME:-$USER_HOME/.cache}/artools"
|
||||
|
||||
linksdb_ext="links.tar.${DBEXT}"
|
||||
db_ext="db.tar.${DBEXT}"
|
||||
|
||||
load_makepkg_config
|
||||
|
||||
sync=false
|
||||
check=false
|
||||
query=false
|
||||
all_db=false
|
||||
obsolete=false
|
||||
|
||||
readonly tableU="%-20s %-35s %-30s %-10s"
|
||||
readonly tableQ="%-20s %-55s %s"
|
||||
|
||||
load_valid_names
|
||||
|
||||
#{{{ repo names arrays
|
||||
|
||||
declare -A REPOS=(
|
||||
[${valid_names[0]}]=system
|
||||
[${valid_names[1]}]=world
|
||||
[${valid_names[2]}]=galaxy
|
||||
[${valid_names[3]}]=lib32
|
||||
[${valid_names[4]}]=gremlins
|
||||
[${valid_names[5]}]=galaxy-gremlins
|
||||
[${valid_names[6]}]=lib32-gremlins
|
||||
[${valid_names[7]}]=goblins
|
||||
[${valid_names[8]}]=galaxy-goblins
|
||||
[${valid_names[9]}]=lib32-goblins
|
||||
[${valid_names[11]}]=kde-wobble
|
||||
[${valid_names[12]}]=gnome-wobble
|
||||
)
|
||||
|
||||
searchrepos=(
|
||||
"${REPOS[${valid_names[11]}]}"
|
||||
"${REPOS[${valid_names[12]}]}"
|
||||
"${REPOS[${valid_names[7]}]}"
|
||||
"${REPOS[${valid_names[8]}]}"
|
||||
"${REPOS[${valid_names[9]}]}"
|
||||
"${REPOS[${valid_names[4]}]}"
|
||||
"${REPOS[${valid_names[5]}]}"
|
||||
"${REPOS[${valid_names[6]}]}"
|
||||
"${REPOS[${valid_names[0]}]}"
|
||||
"${REPOS[${valid_names[1]}]}"
|
||||
"${REPOS[${valid_names[2]}]}"
|
||||
"${REPOS[${valid_names[3]}]}"
|
||||
)
|
||||
|
||||
#}}}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] (with -q [libname])"
|
||||
echo ' -r <repo> Repo name to query'
|
||||
echo ' [default: all]'
|
||||
echo " -s Sync repo databases"
|
||||
echo ' -c Check repos'
|
||||
echo ' -a Show repo db (-c)'
|
||||
echo ' -o Check for obsolete packages'
|
||||
echo " -q Query repo databases for so libs"
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='r:qcsaoh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
r) searchrepos=("$OPTARG") ;;
|
||||
s) sync=true ;;
|
||||
c) check=true ;;
|
||||
a) all_db=true ;;
|
||||
q) query=true ;;
|
||||
o) obsolete=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
library="$1"; shift
|
||||
|
||||
${sync} && update_db_cache
|
||||
|
||||
${check} && show_db_table
|
||||
|
||||
${query} && show_lib_table
|
||||
|
||||
${obsolete} && show_obsolete_table
|
596
artools/0.26.1/artools/bin/pkg/commitpkg
Executable file
596
artools/0.26.1/artools/bin/pkg/commitpkg
Executable file
|
@ -0,0 +1,596 @@
|
|||
#!/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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ base conf
|
||||
|
||||
DATADIR=${DATADIR:-'/usr/share/artools'}
|
||||
SYSCONFDIR=${SYSCONFDIR:-'/etc/artools'}
|
||||
|
||||
if [[ -n $SUDO_USER ]]; then
|
||||
eval "USER_HOME=~$SUDO_USER"
|
||||
else
|
||||
USER_HOME=$HOME
|
||||
fi
|
||||
|
||||
USER_CONF_DIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/artools"
|
||||
|
||||
prepare_dir(){
|
||||
[[ ! -d $1 ]] && mkdir -p "$1"
|
||||
}
|
||||
|
||||
load_base_config(){
|
||||
|
||||
local conf="$1/artools-base.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-base.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
CHROOTS_DIR=${CHROOTS_DIR:-'/var/lib/artools'}
|
||||
|
||||
WORKSPACE_DIR=${WORKSPACE_DIR:-"${USER_HOME}/artools-workspace"}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_base_config "${USER_CONF_DIR}" || load_base_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${WORKSPACE_DIR}"
|
||||
prepare_dir "${USER_CONF_DIR}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ pkg conf
|
||||
|
||||
load_pkg_config(){
|
||||
|
||||
local conf="$1/artools-pkg.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-pkg.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
local git_domain="gitea.artixlinux.org"
|
||||
|
||||
GIT_URL=${GIT_URL:-"https://${git_domain}"}
|
||||
|
||||
GIT_SSH=${GIT_SSH:-"gitea@${git_domain}"}
|
||||
|
||||
GIT_TOKEN=${GIT_TOKEN:-''}
|
||||
|
||||
TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"}
|
||||
|
||||
ARTIX_TREE=(
|
||||
packages community
|
||||
packages-{gfx,media,net}
|
||||
)
|
||||
|
||||
local dev_tree=(
|
||||
packages-{llvm,python,perl,java,ruby,misc}
|
||||
python-{world,galaxy,galaxy-groups,misc}
|
||||
)
|
||||
|
||||
local init_tree=(packages-{openrc,runit,s6,suite66,dinit})
|
||||
|
||||
local desktop_tree=(
|
||||
packages-{kf5,plasma,kde,qt5,qt6,xorg,gtk}
|
||||
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"}
|
||||
|
||||
[[ -z ${ARCH_TREE[*]} ]] && \
|
||||
ARCH_TREE=(svntogit-{packages,community})
|
||||
|
||||
REPOS_ROOT=${REPOS_ROOT:-"${WORKSPACE_DIR}/repos"}
|
||||
|
||||
REPOS_MIRROR=${REPOS_MIRROR:-'http://mirror1.artixlinux.org/repos'}
|
||||
|
||||
HOST_TREE_ARCH=${HOST_TREE_ARCH:-'https://github.com/archlinux'}
|
||||
|
||||
DBEXT=${DBEXT:-'gz'}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_pkg_config "${USER_CONF_DIR}" || load_pkg_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${REPOS_ROOT}"
|
||||
prepare_dir "${TREE_DIR_ARTIX}"
|
||||
prepare_dir "${TREE_DIR_ARCH}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ common functions
|
||||
|
||||
get_compliant_name(){
|
||||
local gitname="$1"
|
||||
case "$gitname" in
|
||||
*+) gitname=${gitname//+/plus}
|
||||
esac
|
||||
echo "$gitname"
|
||||
}
|
||||
|
||||
get_pkg_org(){
|
||||
local pkg="$1" org sub
|
||||
case ${pkg} in
|
||||
ruby-*) org="packagesRuby" ;;
|
||||
perl-*) org="packagesPerl" ;;
|
||||
python-*|python2-*) org="packagesPython" ;;
|
||||
*) sub=${pkg:0:1}; org="packages${sub^^}" ;;
|
||||
esac
|
||||
echo "$org"
|
||||
}
|
||||
|
||||
api_put() {
|
||||
curl -s -X PUT "$@"
|
||||
}
|
||||
|
||||
api_delete() {
|
||||
curl -s -X DELETE "$@"
|
||||
}
|
||||
|
||||
api_post() {
|
||||
curl -s -X POST "$@"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ git
|
||||
|
||||
get_local_head(){
|
||||
git log --pretty=%H ...refs/heads/master^ | head -n 1
|
||||
}
|
||||
|
||||
get_remote_head(){
|
||||
git ls-remote origin -h refs/heads/master | cut -f1
|
||||
}
|
||||
|
||||
has_changeset(){
|
||||
local head_l="$1" head_r="$2"
|
||||
if [[ "$head_l" == "$head_r" ]]; then
|
||||
msg2 "remote changes: no"
|
||||
return 1
|
||||
else
|
||||
msg2 "remote changes: yes"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
pull_tree(){
|
||||
local tree="$1" local_head="$2" os="${3:-Artix}"
|
||||
local remote_head
|
||||
remote_head=$(get_remote_head)
|
||||
|
||||
msg "Checking (%s) (%s)" "${tree}" "$os"
|
||||
if has_changeset "${local_head}" "${remote_head}";then
|
||||
git pull origin master
|
||||
fi
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ gitea api
|
||||
|
||||
add_team_to_repo() {
|
||||
local name="$1"
|
||||
local org="$2"
|
||||
local team="$3"
|
||||
local url
|
||||
|
||||
url="${GIT_URL}/api/v1/repos/$org/$name/teams/$team?access_token=${GIT_TOKEN}"
|
||||
|
||||
msg2 "Adding team (%s) to package repo [%s]" "$team" "$name"
|
||||
|
||||
api_put "$url" -H "accept: application/json"
|
||||
}
|
||||
|
||||
remove_team_from_repo() {
|
||||
local name="$1"
|
||||
local org="$2"
|
||||
local team="$3"
|
||||
local url
|
||||
|
||||
url="${GIT_URL}/api/v1/repos/$org/$name/teams/$team?access_token=${GIT_TOKEN}"
|
||||
|
||||
msg2 "Removing team (%s) from package repo [%s]" "$team" "$name"
|
||||
|
||||
api_delete "$url" -H "accept: application/json"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
##{{{ repo
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
load_valid_names(){
|
||||
local conf
|
||||
conf="${DATADIR}"/valid-names.conf
|
||||
[[ -f "$conf" ]] || return 1
|
||||
# shellcheck source=/usr/share/artools/valid-names.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
return 0
|
||||
}
|
||||
|
||||
set_arch_repos(){
|
||||
local _testing="$1" _staging="$2" _unstable="$3"
|
||||
[[ -z ${valid_names[*]} ]] && load_valid_names
|
||||
ARCH_REPOS=("${stable[@]}")
|
||||
$_testing && ARCH_REPOS+=("${gremlins[@]}")
|
||||
$_staging && ARCH_REPOS+=("${goblins[@]}")
|
||||
$_unstable && ARCH_REPOS+=("${wobble[@]}")
|
||||
}
|
||||
|
||||
find_repo(){
|
||||
local pkg="$1" pkgarch="${2:-${CARCH}}" repo
|
||||
for r in "${ARCH_REPOS[@]}"; do
|
||||
[[ -f $pkg/repos/$r-$pkgarch/PKGBUILD ]] && repo=repos/"$r-$pkgarch"
|
||||
[[ -f $pkg/repos/$r-any/PKGBUILD ]] && repo=repos/"$r"-any
|
||||
[[ -f $pkg/$pkgarch/$r/PKGBUILD ]] && repo="$pkgarch/$r"
|
||||
done
|
||||
echo "$repo"
|
||||
}
|
||||
|
||||
find_pkg(){
|
||||
local searchdir="$1" pkg="$2" result
|
||||
result=$(find "$searchdir" -mindepth 2 -maxdepth 2 -type d -name "$pkg")
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
tree_loop(){
|
||||
local func="$1" pkgs
|
||||
for tree in "${ARTIX_TREE[@]}"; do
|
||||
pkgs=$(find "${TREE_DIR_ARTIX}/$tree" -name "$CARCH" | sort)
|
||||
for _package in ${pkgs}; do
|
||||
"$func" "$_package"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
|
||||
#{{{ 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(){
|
||||
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(){
|
||||
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[2]}" ]] || \
|
||||
[[ "${repo_src}" == "${valid_names[2]}" && "${repo_dest}" == "${valid_names[1]}" ]] || \
|
||||
[[ "${repo_src}" == "${valid_names[0]}" && "${repo_dest}" == "${valid_names[2]}" ]] || \
|
||||
[[ "${repo_src}" == "${valid_names[2]}" && "${repo_dest}" == "${valid_names[0]}" ]]; then
|
||||
|
||||
local org gitname
|
||||
org=$(get_pkg_org "${package}")
|
||||
gitname=$(get_compliant_name "${package}")
|
||||
add_team_to_repo "$gitname" "${org}" "${repo_dest}"
|
||||
remove_team_from_repo "$gitname" "${org}" "${repo_src}"
|
||||
fi
|
||||
}
|
||||
|
||||
path_config() {
|
||||
[[ "${repo_src}" != 'trunk' ]] && pkgbuild="$CARCH/${repo_src}"/PKGBUILD
|
||||
|
||||
# shellcheck disable=1090
|
||||
. "$pkgbuild"
|
||||
}
|
||||
|
||||
get_repo_commit_msg() {
|
||||
echo "[${repo_src}] -> [${repo_dest}] '${package}-$(get_full_version)' ${action}"
|
||||
}
|
||||
|
||||
get_commit_msg() {
|
||||
echo "[${repo_src}] '${package}-$(get_full_version)' ${action}"
|
||||
}
|
||||
|
||||
commit_pkg() {
|
||||
local commit_msg pkg
|
||||
if ${remove}; then
|
||||
action='remove'
|
||||
commit_msg=$(get_commit_msg)
|
||||
msg "Action: %s" "$commit_msg"
|
||||
if [[ "${repo_src}" == 'trunk' ]];then
|
||||
git rm -r trunk
|
||||
else
|
||||
git rm -r "$CARCH/${repo_src}"
|
||||
fi
|
||||
else
|
||||
action='modify'
|
||||
commit_msg=$(get_commit_msg)
|
||||
msg "Action: %s" "$commit_msg"
|
||||
git add .
|
||||
fi
|
||||
git commit -m "$commit_msg"
|
||||
}
|
||||
|
||||
repo_commit_pkg() {
|
||||
local commit_msg
|
||||
|
||||
[[ -d "$CARCH/${repo_dest}" ]] && git rm -r "$CARCH/${repo_dest}"
|
||||
[[ ! -d "$CARCH" ]] && mkdir "$CARCH"
|
||||
[[ ! -d "$CARCH/${repo_dest}" ]] && mkdir "$CARCH/${repo_dest}"
|
||||
|
||||
if [[ "${repo_src}" == 'trunk' ]]; then
|
||||
action='add'
|
||||
commit_msg=$(get_repo_commit_msg)
|
||||
msg "Action: %s" "$commit_msg"
|
||||
check_rebuild
|
||||
cp trunk/* "$CARCH/${repo_dest}"/
|
||||
else
|
||||
action='move'
|
||||
[[ ! -f $pkgbuild ]] && die "%s does not exist!" "$pkgbuild"
|
||||
commit_msg=$(get_repo_commit_msg)
|
||||
msg "Action: %s" "$commit_msg"
|
||||
cp "$CARCH/${repo_src}"/* "$CARCH/${repo_dest}"/
|
||||
git rm -r "$CARCH/${repo_src}"
|
||||
fi
|
||||
git add .
|
||||
git commit -m "$commit_msg"
|
||||
}
|
||||
|
||||
run(){
|
||||
local artixpath head group
|
||||
artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}")
|
||||
if [[ -n ${artixpath} ]];then
|
||||
group=${artixpath%/*}
|
||||
cd "${group}" || return
|
||||
head=$(get_local_head)
|
||||
|
||||
cd "${artixpath}" || return
|
||||
|
||||
path_config
|
||||
|
||||
if [[ "${cmd}" == 'commitpkg' ]];then
|
||||
commit_pkg
|
||||
else
|
||||
repo_commit_pkg
|
||||
fi
|
||||
|
||||
cd "${group}" || return
|
||||
|
||||
${push} && pull_tree "${group##*/}" "$head"
|
||||
# subrepo_pull "${package}"
|
||||
subrepo_push "${package}"
|
||||
subrepo_clean "${package}"
|
||||
|
||||
${push} && push_tree "${group##*/}"
|
||||
|
||||
git prune
|
||||
|
||||
[[ "${cmd}" != 'commitpkg' ]] && check_team
|
||||
else
|
||||
die "Package '%s' does not exist!" "${package}"
|
||||
fi
|
||||
}
|
||||
|
||||
is_valid_repo(){
|
||||
local _valid=trunk
|
||||
for repo in "${valid_names[@]}"; do
|
||||
_valid=${repo:-}${repo:+|}$_valid
|
||||
done
|
||||
eval "case ${repo_src} in
|
||||
${_valid}) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_makepkg_config
|
||||
|
||||
load_valid_names
|
||||
|
||||
repo_src='trunk'
|
||||
package=''
|
||||
remove=false
|
||||
push=false
|
||||
|
||||
pkgbuild=trunk/PKGBUILD
|
||||
|
||||
cmd=${0##*/}
|
||||
repo_dest=${cmd%pkg}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options]"
|
||||
echo " -s <name> Source repository [default:${repo_src}]"
|
||||
echo ' -p <pkg> Package name'
|
||||
echo ' -r Delete from repo (commitpkg only)'
|
||||
echo ' -u Push'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='p:s:urh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
s) repo_src="$OPTARG" ;;
|
||||
p) package="$OPTARG" ;;
|
||||
r) remove=true ;;
|
||||
u) push=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
if is_valid_repo;then
|
||||
run
|
||||
else
|
||||
die "source repository '%s' is not valid!" "${repo_src}"
|
||||
fi
|
230
artools/0.26.1/artools/bin/pkg/commitpkg.in
Normal file
230
artools/0.26.1/artools/bin/pkg/commitpkg.in
Normal file
|
@ -0,0 +1,230 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/util-base.sh)
|
||||
m4_include(lib/util-pkg.sh)
|
||||
m4_include(lib/base/message.sh)
|
||||
m4_include(lib/pkg/common.sh)
|
||||
m4_include(lib/pkg/git.sh)
|
||||
m4_include(lib/pkg/gitea.sh)
|
||||
m4_include(lib/pkg/repo.sh)
|
||||
|
||||
#{{{ 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(){
|
||||
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(){
|
||||
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[2]}" ]] || \
|
||||
[[ "${repo_src}" == "${valid_names[2]}" && "${repo_dest}" == "${valid_names[1]}" ]] || \
|
||||
[[ "${repo_src}" == "${valid_names[0]}" && "${repo_dest}" == "${valid_names[2]}" ]] || \
|
||||
[[ "${repo_src}" == "${valid_names[2]}" && "${repo_dest}" == "${valid_names[0]}" ]]; then
|
||||
|
||||
local org gitname
|
||||
org=$(get_pkg_org "${package}")
|
||||
gitname=$(get_compliant_name "${package}")
|
||||
add_team_to_repo "$gitname" "${org}" "${repo_dest}"
|
||||
remove_team_from_repo "$gitname" "${org}" "${repo_src}"
|
||||
fi
|
||||
}
|
||||
|
||||
path_config() {
|
||||
[[ "${repo_src}" != 'trunk' ]] && pkgbuild="$CARCH/${repo_src}"/PKGBUILD
|
||||
|
||||
# shellcheck disable=1090
|
||||
. "$pkgbuild"
|
||||
}
|
||||
|
||||
get_repo_commit_msg() {
|
||||
echo "[${repo_src}] -> [${repo_dest}] '${package}-$(get_full_version)' ${action}"
|
||||
}
|
||||
|
||||
get_commit_msg() {
|
||||
echo "[${repo_src}] '${package}-$(get_full_version)' ${action}"
|
||||
}
|
||||
|
||||
commit_pkg() {
|
||||
local commit_msg pkg
|
||||
if ${remove}; then
|
||||
action='remove'
|
||||
commit_msg=$(get_commit_msg)
|
||||
msg "Action: %s" "$commit_msg"
|
||||
if [[ "${repo_src}" == 'trunk' ]];then
|
||||
git rm -r trunk
|
||||
else
|
||||
git rm -r "$CARCH/${repo_src}"
|
||||
fi
|
||||
else
|
||||
action='modify'
|
||||
commit_msg=$(get_commit_msg)
|
||||
msg "Action: %s" "$commit_msg"
|
||||
git add .
|
||||
fi
|
||||
git commit -m "$commit_msg"
|
||||
}
|
||||
|
||||
repo_commit_pkg() {
|
||||
local commit_msg
|
||||
|
||||
[[ -d "$CARCH/${repo_dest}" ]] && git rm -r "$CARCH/${repo_dest}"
|
||||
[[ ! -d "$CARCH" ]] && mkdir "$CARCH"
|
||||
[[ ! -d "$CARCH/${repo_dest}" ]] && mkdir "$CARCH/${repo_dest}"
|
||||
|
||||
if [[ "${repo_src}" == 'trunk' ]]; then
|
||||
action='add'
|
||||
commit_msg=$(get_repo_commit_msg)
|
||||
msg "Action: %s" "$commit_msg"
|
||||
check_rebuild
|
||||
cp trunk/* "$CARCH/${repo_dest}"/
|
||||
else
|
||||
action='move'
|
||||
[[ ! -f $pkgbuild ]] && die "%s does not exist!" "$pkgbuild"
|
||||
commit_msg=$(get_repo_commit_msg)
|
||||
msg "Action: %s" "$commit_msg"
|
||||
cp "$CARCH/${repo_src}"/* "$CARCH/${repo_dest}"/
|
||||
git rm -r "$CARCH/${repo_src}"
|
||||
fi
|
||||
git add .
|
||||
git commit -m "$commit_msg"
|
||||
}
|
||||
|
||||
run(){
|
||||
local artixpath head group
|
||||
artixpath=$(find_pkg "${TREE_DIR_ARTIX}" "${package}")
|
||||
if [[ -n ${artixpath} ]];then
|
||||
group=${artixpath%/*}
|
||||
cd "${group}" || return
|
||||
head=$(get_local_head)
|
||||
|
||||
cd "${artixpath}" || return
|
||||
|
||||
path_config
|
||||
|
||||
if [[ "${cmd}" == 'commitpkg' ]];then
|
||||
commit_pkg
|
||||
else
|
||||
repo_commit_pkg
|
||||
fi
|
||||
|
||||
cd "${group}" || return
|
||||
|
||||
${push} && pull_tree "${group##*/}" "$head"
|
||||
# subrepo_pull "${package}"
|
||||
subrepo_push "${package}"
|
||||
subrepo_clean "${package}"
|
||||
|
||||
${push} && push_tree "${group##*/}"
|
||||
|
||||
git prune
|
||||
|
||||
[[ "${cmd}" != 'commitpkg' ]] && check_team
|
||||
else
|
||||
die "Package '%s' does not exist!" "${package}"
|
||||
fi
|
||||
}
|
||||
|
||||
is_valid_repo(){
|
||||
local _valid=trunk
|
||||
for repo in "${valid_names[@]}"; do
|
||||
_valid=${repo:-}${repo:+|}$_valid
|
||||
done
|
||||
eval "case ${repo_src} in
|
||||
${_valid}) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_makepkg_config
|
||||
|
||||
load_valid_names
|
||||
|
||||
repo_src='trunk'
|
||||
package=''
|
||||
remove=false
|
||||
push=false
|
||||
|
||||
pkgbuild=trunk/PKGBUILD
|
||||
|
||||
cmd=${0##*/}
|
||||
repo_dest=${cmd%pkg}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options]"
|
||||
echo " -s <name> Source repository [default:${repo_src}]"
|
||||
echo ' -p <pkg> Package name'
|
||||
echo ' -r Delete from repo (commitpkg only)'
|
||||
echo ' -u Push'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='p:s:urh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
s) repo_src="$OPTARG" ;;
|
||||
p) package="$OPTARG" ;;
|
||||
r) remove=true ;;
|
||||
u) push=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
if is_valid_repo;then
|
||||
run
|
||||
else
|
||||
die "source repository '%s' is not valid!" "${repo_src}"
|
||||
fi
|
506
artools/0.26.1/artools/bin/pkg/comparepkg
Executable file
506
artools/0.26.1/artools/bin/pkg/comparepkg
Executable file
|
@ -0,0 +1,506 @@
|
|||
#!/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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ base conf
|
||||
|
||||
DATADIR=${DATADIR:-'/usr/share/artools'}
|
||||
SYSCONFDIR=${SYSCONFDIR:-'/etc/artools'}
|
||||
|
||||
if [[ -n $SUDO_USER ]]; then
|
||||
eval "USER_HOME=~$SUDO_USER"
|
||||
else
|
||||
USER_HOME=$HOME
|
||||
fi
|
||||
|
||||
USER_CONF_DIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/artools"
|
||||
|
||||
prepare_dir(){
|
||||
[[ ! -d $1 ]] && mkdir -p "$1"
|
||||
}
|
||||
|
||||
load_base_config(){
|
||||
|
||||
local conf="$1/artools-base.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-base.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
CHROOTS_DIR=${CHROOTS_DIR:-'/var/lib/artools'}
|
||||
|
||||
WORKSPACE_DIR=${WORKSPACE_DIR:-"${USER_HOME}/artools-workspace"}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_base_config "${USER_CONF_DIR}" || load_base_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${WORKSPACE_DIR}"
|
||||
prepare_dir "${USER_CONF_DIR}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ pkg conf
|
||||
|
||||
load_pkg_config(){
|
||||
|
||||
local conf="$1/artools-pkg.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-pkg.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
local git_domain="gitea.artixlinux.org"
|
||||
|
||||
GIT_URL=${GIT_URL:-"https://${git_domain}"}
|
||||
|
||||
GIT_SSH=${GIT_SSH:-"gitea@${git_domain}"}
|
||||
|
||||
GIT_TOKEN=${GIT_TOKEN:-''}
|
||||
|
||||
TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"}
|
||||
|
||||
ARTIX_TREE=(
|
||||
packages community
|
||||
packages-{gfx,media,net}
|
||||
)
|
||||
|
||||
local dev_tree=(
|
||||
packages-{llvm,python,perl,java,ruby,misc}
|
||||
python-{world,galaxy,galaxy-groups,misc}
|
||||
)
|
||||
|
||||
local init_tree=(packages-{openrc,runit,s6,suite66,dinit})
|
||||
|
||||
local desktop_tree=(
|
||||
packages-{kf5,plasma,kde,qt5,qt6,xorg,gtk}
|
||||
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"}
|
||||
|
||||
[[ -z ${ARCH_TREE[*]} ]] && \
|
||||
ARCH_TREE=(svntogit-{packages,community})
|
||||
|
||||
REPOS_ROOT=${REPOS_ROOT:-"${WORKSPACE_DIR}/repos"}
|
||||
|
||||
REPOS_MIRROR=${REPOS_MIRROR:-'http://mirror1.artixlinux.org/repos'}
|
||||
|
||||
HOST_TREE_ARCH=${HOST_TREE_ARCH:-'https://github.com/archlinux'}
|
||||
|
||||
DBEXT=${DBEXT:-'gz'}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_pkg_config "${USER_CONF_DIR}" || load_pkg_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${REPOS_ROOT}"
|
||||
prepare_dir "${TREE_DIR_ARTIX}"
|
||||
prepare_dir "${TREE_DIR_ARCH}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
##{{{ repo
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
load_valid_names(){
|
||||
local conf
|
||||
conf="${DATADIR}"/valid-names.conf
|
||||
[[ -f "$conf" ]] || return 1
|
||||
# shellcheck source=/usr/share/artools/valid-names.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
return 0
|
||||
}
|
||||
|
||||
set_arch_repos(){
|
||||
local _testing="$1" _staging="$2" _unstable="$3"
|
||||
[[ -z ${valid_names[*]} ]] && load_valid_names
|
||||
ARCH_REPOS=("${stable[@]}")
|
||||
$_testing && ARCH_REPOS+=("${gremlins[@]}")
|
||||
$_staging && ARCH_REPOS+=("${goblins[@]}")
|
||||
$_unstable && ARCH_REPOS+=("${wobble[@]}")
|
||||
}
|
||||
|
||||
find_repo(){
|
||||
local pkg="$1" pkgarch="${2:-${CARCH}}" repo
|
||||
for r in "${ARCH_REPOS[@]}"; do
|
||||
[[ -f $pkg/repos/$r-$pkgarch/PKGBUILD ]] && repo=repos/"$r-$pkgarch"
|
||||
[[ -f $pkg/repos/$r-any/PKGBUILD ]] && repo=repos/"$r"-any
|
||||
[[ -f $pkg/$pkgarch/$r/PKGBUILD ]] && repo="$pkgarch/$r"
|
||||
done
|
||||
echo "$repo"
|
||||
}
|
||||
|
||||
find_pkg(){
|
||||
local searchdir="$1" pkg="$2" result
|
||||
result=$(find "$searchdir" -mindepth 2 -maxdepth 2 -type d -name "$pkg")
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
tree_loop(){
|
||||
local func="$1" pkgs
|
||||
for tree in "${ARTIX_TREE[@]}"; do
|
||||
pkgs=$(find "${TREE_DIR_ARTIX}/$tree" -name "$CARCH" | sort)
|
||||
for _package in ${pkgs}; do
|
||||
"$func" "$_package"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ table
|
||||
|
||||
msg_table_header(){
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${BLUE} ${mesg} ${ALL_OFF}\n" "$@"
|
||||
}
|
||||
|
||||
msg_row_yellow(){
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${YELLOW} ${mesg}${ALL_OFF}\n" "$@"
|
||||
}
|
||||
|
||||
msg_row_green(){
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN} ${mesg}${ALL_OFF}\n" "$@"
|
||||
}
|
||||
|
||||
msg_row(){
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${WHITE} ${mesg}${ALL_OFF}\n" "$@"
|
||||
}
|
||||
|
||||
msg_row_red(){
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${RED} ${mesg} ${ALL_OFF}\n" "$@"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
|
||||
|
||||
#{{{ upgrades, downgrades, moves
|
||||
|
||||
remove_list(){
|
||||
local name="$1"
|
||||
[[ -f "${TREE_DIR_ARTIX}"/$name.list ]] && rm "${TREE_DIR_ARTIX}"/"$name".list
|
||||
}
|
||||
|
||||
write_list(){
|
||||
local line="$1" name="$2"
|
||||
printf "%s\n" "$line" >> "${TREE_DIR_ARTIX}"/"$name".list
|
||||
}
|
||||
|
||||
compare_m(){
|
||||
case ${artixrepo} in
|
||||
*testing*|*staging*|*rebuild)
|
||||
if [[ "${a}" == "${b}" ]]; then
|
||||
msg_row "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
||||
elif [[ "${a}" == 'staging' && "${b}" == 'rebuild' ]]; then
|
||||
msg_row_yellow "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
||||
else
|
||||
msg_row_green "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
||||
if [[ -n "$archrepo" ]]; then
|
||||
write_list "${a}:${b}:$pkg" pkg_moves
|
||||
else
|
||||
write_list "@repo@:${b}:$pkg" artix
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
compare_u(){
|
||||
if [ "$result" -eq -1 ];then
|
||||
# local arel=${archver##*-} brel=${artixver##*-}
|
||||
# local reldiff
|
||||
# reldiff=$(( $arel-${brel%.*} ))
|
||||
msg_row_red "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
||||
write_list "${a}:$pkg" pkg_upgrades
|
||||
fi
|
||||
}
|
||||
|
||||
compare_d(){
|
||||
if [ "$result" -eq 1 ];then
|
||||
if [[ -n "$archver" ]] && [[ -n "$archrepo" ]];then
|
||||
msg_row_yellow "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_archpath(){
|
||||
local pkg="$1" archpath
|
||||
|
||||
for tree in "${ARCH_TREE[@]}"; do
|
||||
[[ -d ${TREE_DIR_ARCH}/$tree/$pkg/repos ]] && archpath=${TREE_DIR_ARCH}/$tree/$pkg
|
||||
done
|
||||
echo "$archpath"
|
||||
}
|
||||
|
||||
pre_compare(){
|
||||
local func="$1" pkgpath="$2" result group pkg
|
||||
group="${pkgpath%/*}"
|
||||
group=${group##*/}
|
||||
pkg=${pkgpath##*/}
|
||||
|
||||
local artixrepo archrepo pkgbuild artixver archver archpath node a b
|
||||
artixrepo=$(find_repo "$pkgpath")
|
||||
pkgbuild=$pkgpath/$artixrepo/PKGBUILD
|
||||
|
||||
if [[ -f $pkgbuild ]]; then
|
||||
# shellcheck disable=1090
|
||||
. "$pkgbuild" 2>/dev/null
|
||||
artixver=$(get_full_version)
|
||||
archpath=$(get_archpath "$pkg")
|
||||
archrepo=$(find_repo "${archpath}")
|
||||
pkgbuild=$archpath/$archrepo/PKGBUILD
|
||||
node=${artixrepo%/*}
|
||||
a=${archrepo#*/} b=${artixrepo#*/}
|
||||
a="${a%-*}"
|
||||
|
||||
[[ "$node" != "$CARCH" ]] && b=${b%-*}
|
||||
|
||||
if [[ -f "$pkgbuild" ]]; then
|
||||
# shellcheck disable=1090
|
||||
. "$pkgbuild" 2>/dev/null
|
||||
archver=$(get_full_version)
|
||||
fi
|
||||
|
||||
result=$(vercmp "$artixver" "$archver")
|
||||
|
||||
"$func"
|
||||
|
||||
unset epoch
|
||||
fi
|
||||
}
|
||||
|
||||
compare_upgrades(){
|
||||
local pkgpath="${1%/*}"
|
||||
pre_compare compare_u "$pkgpath"
|
||||
}
|
||||
|
||||
compare_downgrades(){
|
||||
local pkgpath="${1%/*}"
|
||||
pre_compare compare_d "$pkgpath"
|
||||
}
|
||||
|
||||
compare_move(){
|
||||
local pkgpath="${1%/*}"
|
||||
pre_compare compare_m "$pkgpath"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
show_compare_header(){
|
||||
msg_table_header "${table}" "Arch Repo" "Artix Repo" "Package" "Arch version" "Artix version" "Group"
|
||||
}
|
||||
|
||||
show_upgrades_table(){
|
||||
show_compare_header
|
||||
remove_list pkg_upgrades
|
||||
tree_loop compare_upgrades
|
||||
}
|
||||
|
||||
show_downgrades_table(){
|
||||
show_compare_header
|
||||
tree_loop compare_downgrades
|
||||
}
|
||||
|
||||
show_move_table(){
|
||||
show_compare_header
|
||||
remove_list pkg_moves
|
||||
remove_list artix
|
||||
tree_loop compare_move
|
||||
}
|
||||
|
||||
load_makepkg_config
|
||||
|
||||
load_valid_names
|
||||
|
||||
testing=true
|
||||
staging=true
|
||||
unstable=false
|
||||
|
||||
upgrades=false
|
||||
downgrades=false
|
||||
move=false
|
||||
|
||||
readonly table="%-18s %-18s %-25s %-27s %-27s %-10s"
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options]"
|
||||
echo ' -u Show upgrade packages'
|
||||
echo ' -d Show downgrade packages'
|
||||
echo ' -m Show packages to move'
|
||||
echo " -x Don't inlcude testing packages"
|
||||
echo " -y Don't inlcude staging packages"
|
||||
echo ' -z Include unstable kde and gnome'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='udmxyzh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
u) upgrades=true ;;
|
||||
d) downgrades=true ;;
|
||||
m) move=true ;;
|
||||
x) testing=false ;;
|
||||
y) staging=false ;;
|
||||
z) unstable=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
set_arch_repos "$testing" "$staging" "$unstable"
|
||||
|
||||
${move} && show_move_table
|
||||
|
||||
${upgrades} && show_upgrades_table
|
||||
|
||||
${downgrades} && show_downgrades_table
|
207
artools/0.26.1/artools/bin/pkg/comparepkg.in
Normal file
207
artools/0.26.1/artools/bin/pkg/comparepkg.in
Normal file
|
@ -0,0 +1,207 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/util-base.sh)
|
||||
m4_include(lib/util-pkg.sh)
|
||||
m4_include(lib/base/message.sh)
|
||||
m4_include(lib/pkg/repo.sh)
|
||||
m4_include(lib/pkg/table.sh)
|
||||
|
||||
|
||||
#{{{ upgrades, downgrades, moves
|
||||
|
||||
remove_list(){
|
||||
local name="$1"
|
||||
[[ -f "${TREE_DIR_ARTIX}"/$name.list ]] && rm "${TREE_DIR_ARTIX}"/"$name".list
|
||||
}
|
||||
|
||||
write_list(){
|
||||
local line="$1" name="$2"
|
||||
printf "%s\n" "$line" >> "${TREE_DIR_ARTIX}"/"$name".list
|
||||
}
|
||||
|
||||
compare_m(){
|
||||
case ${artixrepo} in
|
||||
*testing*|*staging*|*rebuild)
|
||||
if [[ "${a}" == "${b}" ]]; then
|
||||
msg_row "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
||||
elif [[ "${a}" == 'staging' && "${b}" == 'rebuild' ]]; then
|
||||
msg_row_yellow "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
||||
else
|
||||
msg_row_green "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
||||
if [[ -n "$archrepo" ]]; then
|
||||
write_list "${a}:${b}:$pkg" pkg_moves
|
||||
else
|
||||
write_list "@repo@:${b}:$pkg" artix
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
compare_u(){
|
||||
if [ "$result" -eq -1 ];then
|
||||
# local arel=${archver##*-} brel=${artixver##*-}
|
||||
# local reldiff
|
||||
reldiff=$(( $arel-${brel%.*} ))
|
||||
msg_row_red "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
||||
write_list "${a}:$pkg" pkg_upgrades
|
||||
fi
|
||||
}
|
||||
|
||||
compare_d(){
|
||||
if [ "$result" -eq 1 ];then
|
||||
if [[ -n "$archver" ]] && [[ -n "$archrepo" ]];then
|
||||
msg_row_yellow "${table}" "${a}" "${b}" "$pkg" "$archver" "$artixver" "${group#*-}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_archpath(){
|
||||
local pkg="$1" archpath
|
||||
|
||||
for tree in "${ARCH_TREE[@]}"; do
|
||||
[[ -d ${TREE_DIR_ARCH}/$tree/$pkg/repos ]] && archpath=${TREE_DIR_ARCH}/$tree/$pkg
|
||||
done
|
||||
echo "$archpath"
|
||||
}
|
||||
|
||||
pre_compare(){
|
||||
local func="$1" pkgpath="$2" result group pkg
|
||||
group="${pkgpath%/*}"
|
||||
group=${group##*/}
|
||||
pkg=${pkgpath##*/}
|
||||
|
||||
local artixrepo archrepo pkgbuild artixver archver archpath node a b
|
||||
artixrepo=$(find_repo "$pkgpath")
|
||||
pkgbuild=$pkgpath/$artixrepo/PKGBUILD
|
||||
|
||||
if [[ -f $pkgbuild ]]; then
|
||||
# shellcheck disable=1090
|
||||
. "$pkgbuild" 2>/dev/null
|
||||
artixver=$(get_full_version)
|
||||
archpath=$(get_archpath "$pkg")
|
||||
archrepo=$(find_repo "${archpath}")
|
||||
pkgbuild=$archpath/$archrepo/PKGBUILD
|
||||
node=${artixrepo%/*}
|
||||
a=${archrepo#*/} b=${artixrepo#*/}
|
||||
a="${a%-*}"
|
||||
|
||||
[[ "$node" != "$CARCH" ]] && b=${b%-*}
|
||||
|
||||
if [[ -f "$pkgbuild" ]]; then
|
||||
# shellcheck disable=1090
|
||||
. "$pkgbuild" 2>/dev/null
|
||||
archver=$(get_full_version)
|
||||
fi
|
||||
|
||||
result=$(vercmp "$artixver" "$archver")
|
||||
|
||||
"$func"
|
||||
|
||||
unset epoch
|
||||
fi
|
||||
}
|
||||
|
||||
compare_upgrades(){
|
||||
local pkgpath="${1%/*}"
|
||||
pre_compare compare_u "$pkgpath"
|
||||
}
|
||||
|
||||
compare_downgrades(){
|
||||
local pkgpath="${1%/*}"
|
||||
pre_compare compare_d "$pkgpath"
|
||||
}
|
||||
|
||||
compare_move(){
|
||||
local pkgpath="${1%/*}"
|
||||
pre_compare compare_m "$pkgpath"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
show_compare_header(){
|
||||
msg_table_header "${table}" "Arch Repo" "Artix Repo" "Package" "Arch version" "Artix version" "Group"
|
||||
}
|
||||
|
||||
show_upgrades_table(){
|
||||
show_compare_header
|
||||
remove_list pkg_upgrades
|
||||
tree_loop compare_upgrades
|
||||
}
|
||||
|
||||
show_downgrades_table(){
|
||||
show_compare_header
|
||||
tree_loop compare_downgrades
|
||||
}
|
||||
|
||||
show_move_table(){
|
||||
show_compare_header
|
||||
remove_list pkg_moves
|
||||
remove_list artix
|
||||
tree_loop compare_move
|
||||
}
|
||||
|
||||
load_makepkg_config
|
||||
|
||||
load_valid_names
|
||||
|
||||
testing=true
|
||||
staging=true
|
||||
unstable=false
|
||||
|
||||
upgrades=false
|
||||
downgrades=false
|
||||
move=false
|
||||
|
||||
readonly table="%-18s %-18s %-25s %-27s %-27s %-10s"
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options]"
|
||||
echo ' -u Show upgrade packages'
|
||||
echo ' -d Show downgrade packages'
|
||||
echo ' -m Show packages to move'
|
||||
echo " -x Don't inlcude testing packages"
|
||||
echo " -y Don't inlcude staging packages"
|
||||
echo ' -z Include unstable kde and gnome'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='udmxyzh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
u) upgrades=true ;;
|
||||
d) downgrades=true ;;
|
||||
m) move=true ;;
|
||||
x) testing=false ;;
|
||||
y) staging=false ;;
|
||||
z) unstable=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
set_arch_repos "$testing" "$staging" "$unstable"
|
||||
|
||||
${move} && show_move_table
|
||||
|
||||
${upgrades} && show_upgrades_table
|
||||
|
||||
${downgrades} && show_downgrades_table
|
351
artools/0.26.1/artools/bin/pkg/deploypkg
Executable file
351
artools/0.26.1/artools/bin/pkg/deploypkg
Executable file
|
@ -0,0 +1,351 @@
|
|||
#!/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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ base conf
|
||||
|
||||
DATADIR=${DATADIR:-'/usr/share/artools'}
|
||||
SYSCONFDIR=${SYSCONFDIR:-'/etc/artools'}
|
||||
|
||||
if [[ -n $SUDO_USER ]]; then
|
||||
eval "USER_HOME=~$SUDO_USER"
|
||||
else
|
||||
USER_HOME=$HOME
|
||||
fi
|
||||
|
||||
USER_CONF_DIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/artools"
|
||||
|
||||
prepare_dir(){
|
||||
[[ ! -d $1 ]] && mkdir -p "$1"
|
||||
}
|
||||
|
||||
load_base_config(){
|
||||
|
||||
local conf="$1/artools-base.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-base.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
CHROOTS_DIR=${CHROOTS_DIR:-'/var/lib/artools'}
|
||||
|
||||
WORKSPACE_DIR=${WORKSPACE_DIR:-"${USER_HOME}/artools-workspace"}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_base_config "${USER_CONF_DIR}" || load_base_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${WORKSPACE_DIR}"
|
||||
prepare_dir "${USER_CONF_DIR}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ pkg conf
|
||||
|
||||
load_pkg_config(){
|
||||
|
||||
local conf="$1/artools-pkg.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-pkg.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
local git_domain="gitea.artixlinux.org"
|
||||
|
||||
GIT_URL=${GIT_URL:-"https://${git_domain}"}
|
||||
|
||||
GIT_SSH=${GIT_SSH:-"gitea@${git_domain}"}
|
||||
|
||||
GIT_TOKEN=${GIT_TOKEN:-''}
|
||||
|
||||
TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"}
|
||||
|
||||
ARTIX_TREE=(
|
||||
packages community
|
||||
packages-{gfx,media,net}
|
||||
)
|
||||
|
||||
local dev_tree=(
|
||||
packages-{llvm,python,perl,java,ruby,misc}
|
||||
python-{world,galaxy,galaxy-groups,misc}
|
||||
)
|
||||
|
||||
local init_tree=(packages-{openrc,runit,s6,suite66,dinit})
|
||||
|
||||
local desktop_tree=(
|
||||
packages-{kf5,plasma,kde,qt5,qt6,xorg,gtk}
|
||||
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"}
|
||||
|
||||
[[ -z ${ARCH_TREE[*]} ]] && \
|
||||
ARCH_TREE=(svntogit-{packages,community})
|
||||
|
||||
REPOS_ROOT=${REPOS_ROOT:-"${WORKSPACE_DIR}/repos"}
|
||||
|
||||
REPOS_MIRROR=${REPOS_MIRROR:-'http://mirror1.artixlinux.org/repos'}
|
||||
|
||||
HOST_TREE_ARCH=${HOST_TREE_ARCH:-'https://github.com/archlinux'}
|
||||
|
||||
DBEXT=${DBEXT:-'gz'}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_pkg_config "${USER_CONF_DIR}" || load_pkg_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${REPOS_ROOT}"
|
||||
prepare_dir "${TREE_DIR_ARTIX}"
|
||||
prepare_dir "${TREE_DIR_ARCH}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ functions
|
||||
|
||||
find_cached_pkgfile() {
|
||||
local searchdirs=("$PKGDEST" "$PWD") results=()
|
||||
local pkg="$1"
|
||||
for dir in "${searchdirs[@]}"; do
|
||||
[[ -d "$dir" ]] || continue
|
||||
[[ -e "$dir/$pkg" ]] && results+=("$dir/$pkg")
|
||||
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() {
|
||||
local name="$1"
|
||||
local rm_pkg=${name%.pkg.tar*}
|
||||
rm_pkg=${rm_pkg%-*}
|
||||
rm_pkg=${rm_pkg%-*}
|
||||
rm_pkg=${rm_pkg%-*}
|
||||
echo "$rm_pkg"
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
|
||||
#{{{ deploy
|
||||
|
||||
add(){
|
||||
if pkgfile=$(find_cached_pkgfile "${pkgname}"); then
|
||||
msg "Found: %s" "${pkgfile}"
|
||||
packages+=("${pkgname}")
|
||||
action='add'
|
||||
ln -sfv "${pkgfile}"{,.sig} "$repo_path"/
|
||||
fi
|
||||
}
|
||||
|
||||
remove(){
|
||||
packages+=("$(get_pkgbasename "${pkgname}")")
|
||||
action='remove'
|
||||
rm -v "$repo_path"/"${pkgname}"{,.sig}
|
||||
}
|
||||
|
||||
repo_action(){
|
||||
local packages=() action func="$1"
|
||||
for pkgname in "${passfiles[@]}"; do
|
||||
"$func"
|
||||
done
|
||||
cd "$repo_path" || return
|
||||
if [[ -n "${action}" ]]; then
|
||||
repo-"${action}" -R "${dest_repo}"."${pkgdb_ext}" "${packages[@]}"
|
||||
${linksdb} && links-"${action}" "${dest_repo}"."${linksdb_ext}" "${packages[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_makepkg_config
|
||||
|
||||
pkgdb_ext="db.tar.${DBEXT}"
|
||||
linksdb_ext="links.tar.${DBEXT}"
|
||||
|
||||
add_pkg=false
|
||||
rm_pkg=false
|
||||
linksdb=false
|
||||
|
||||
cmd=${0##*/}
|
||||
dest_repo=${cmd#*-}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${cmd} [options]"
|
||||
echo ' -d <dest> Destination repository'
|
||||
echo ' -a Add package(s) to repository'
|
||||
echo ' -r Remove package(s) from repository'
|
||||
echo ' -l Use links db'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='arlhd:'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
d) dest_repo="$OPTARG" ;;
|
||||
a) add_pkg=true; rm_pkg=false ;;
|
||||
r) rm_pkg=true; add_pkg=false ;;
|
||||
l) linksdb=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
passfiles=("$@")
|
||||
|
||||
repo_path=${REPOS_ROOT}/${dest_repo}/os/${CARCH}
|
||||
|
||||
if [[ -n "${passfiles[*]}" ]]; then
|
||||
if ${add_pkg}; then
|
||||
repo_action add
|
||||
fi
|
||||
if ${rm_pkg}; then
|
||||
repo_action remove
|
||||
fi
|
||||
fi
|
101
artools/0.26.1/artools/bin/pkg/deploypkg.in
Normal file
101
artools/0.26.1/artools/bin/pkg/deploypkg.in
Normal file
|
@ -0,0 +1,101 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/util-base.sh)
|
||||
m4_include(lib/util-pkg.sh)
|
||||
m4_include(lib/base/message.sh)
|
||||
m4_include(lib/pkg/deploy.sh)
|
||||
|
||||
#{{{ deploy
|
||||
|
||||
add(){
|
||||
if pkgfile=$(find_cached_pkgfile "${pkgname}"); then
|
||||
msg "Found: %s" "${pkgfile}"
|
||||
packages+=("${pkgname}")
|
||||
action='add'
|
||||
ln -sfv "${pkgfile}"{,.sig} "$repo_path"/
|
||||
fi
|
||||
}
|
||||
|
||||
remove(){
|
||||
packages+=("$(get_pkgbasename "${pkgname}")")
|
||||
action='remove'
|
||||
rm -v "$repo_path"/"${pkgname}"{,.sig}
|
||||
}
|
||||
|
||||
repo_action(){
|
||||
local packages=() action func="$1"
|
||||
for pkgname in "${passfiles[@]}"; do
|
||||
"$func"
|
||||
done
|
||||
cd "$repo_path" || return
|
||||
if [[ -n "${action}" ]]; then
|
||||
repo-"${action}" -R "${dest_repo}"."${pkgdb_ext}" "${packages[@]}"
|
||||
${linksdb} && links-"${action}" "${dest_repo}"."${linksdb_ext}" "${packages[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_makepkg_config
|
||||
|
||||
pkgdb_ext="db.tar.${DBEXT}"
|
||||
linksdb_ext="links.tar.${DBEXT}"
|
||||
|
||||
add_pkg=false
|
||||
rm_pkg=false
|
||||
linksdb=false
|
||||
|
||||
cmd=${0##*/}
|
||||
dest_repo=${cmd#*-}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${cmd} [options]"
|
||||
echo ' -d <dest> Destination repository'
|
||||
echo ' -a Add package(s) to repository'
|
||||
echo ' -r Remove package(s) from repository'
|
||||
echo ' -l Use links db'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
opts='arlhd:'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
d) dest_repo="$OPTARG" ;;
|
||||
a) add_pkg=true; rm_pkg=false ;;
|
||||
r) rm_pkg=true; add_pkg=false ;;
|
||||
l) linksdb=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
passfiles=("$@")
|
||||
|
||||
repo_path=${REPOS_ROOT}/${dest_repo}/os/${CARCH}
|
||||
|
||||
if [[ -n "${passfiles[*]}" ]]; then
|
||||
if ${add_pkg}; then
|
||||
repo_action add
|
||||
fi
|
||||
if ${rm_pkg}; then
|
||||
repo_action remove
|
||||
fi
|
||||
fi
|
196
artools/0.26.1/artools/bin/pkg/find-libdeps
Executable file
196
artools/0.26.1/artools/bin/pkg/find-libdeps
Executable file
|
@ -0,0 +1,196 @@
|
|||
#!/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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
|
||||
set -e
|
||||
shopt -s extglob
|
||||
|
||||
IGNORE_INTERNAL=0
|
||||
|
||||
if [[ $1 = "--ignore-internal" ]]; then
|
||||
IGNORE_INTERNAL=1
|
||||
shift
|
||||
fi
|
||||
|
||||
script_mode=${BASH_SOURCE[0]##*/find-lib}
|
||||
|
||||
case $script_mode in
|
||||
deps|provides) true;;
|
||||
*) die "Unknown mode %s" "$script_mode" ;;
|
||||
esac
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo "${0##*/} [options] <package file|extracted package dir>"
|
||||
echo "Options:"
|
||||
echo " --ignore-internal ignore internal libraries"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -d $1 ]]; then
|
||||
pushd "$1" >/dev/null
|
||||
else
|
||||
setup_workdir
|
||||
|
||||
case ${script_mode} in
|
||||
deps) bsdtar -C "$WORKDIR" -xf "$1";;
|
||||
provides) bsdtar -C "$WORKDIR" -xf "$1" --include="*.so*";;
|
||||
esac
|
||||
|
||||
pushd "$WORKDIR" >/dev/null
|
||||
fi
|
||||
|
||||
process_sofile() {
|
||||
# extract the library name: libfoo.so
|
||||
soname="${sofile%.so?(+(.+([0-9])))}".so
|
||||
# extract the major version: 1
|
||||
soversion="${sofile##*\.so\.}"
|
||||
if [[ "$soversion" = "$sofile" ]] && ((IGNORE_INTERNAL)); then
|
||||
return
|
||||
fi
|
||||
if ! in_array "${soname}=${soversion}-${soarch}" "${soobjects[@]}"; then
|
||||
# libfoo.so=1-64
|
||||
echo "${soname}=${soversion}-${soarch}"
|
||||
soobjects+=("${soname}=${soversion}-${soarch}")
|
||||
fi
|
||||
}
|
||||
|
||||
case $script_mode in
|
||||
deps) find_args=(-perm -u+x);;
|
||||
provides) find_args=(-name '*.so*');;
|
||||
esac
|
||||
|
||||
find . -type f "${find_args[@]}" | while read -r filename; do
|
||||
if [[ $script_mode = "provides" ]]; then
|
||||
# ignore if we don't have a shared object
|
||||
if ! LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
# get architecture of the file; if soarch is empty it's not an ELF binary
|
||||
soarch=$(LC_ALL=C readelf -h "$filename" 2>/dev/null | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
|
||||
[[ -n $soarch ]] || continue
|
||||
|
||||
if [[ $script_mode = "provides" ]]; then
|
||||
# get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1
|
||||
sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
|
||||
[[ -z $sofile ]] && sofile="${filename##*/}"
|
||||
process_sofile
|
||||
elif [[ $script_mode = "deps" ]]; then
|
||||
# process all libraries needed by the binary
|
||||
for sofile in $(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p'); do
|
||||
process_sofile
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
popd >/dev/null
|
99
artools/0.26.1/artools/bin/pkg/find-libdeps.in
Normal file
99
artools/0.26.1/artools/bin/pkg/find-libdeps.in
Normal file
|
@ -0,0 +1,99 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/base/message.sh)
|
||||
|
||||
set -e
|
||||
shopt -s extglob
|
||||
|
||||
IGNORE_INTERNAL=0
|
||||
|
||||
if [[ $1 = "--ignore-internal" ]]; then
|
||||
IGNORE_INTERNAL=1
|
||||
shift
|
||||
fi
|
||||
|
||||
script_mode=${BASH_SOURCE[0]##*/find-lib}
|
||||
|
||||
case $script_mode in
|
||||
deps|provides) true;;
|
||||
*) die "Unknown mode %s" "$script_mode" ;;
|
||||
esac
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo "${0##*/} [options] <package file|extracted package dir>"
|
||||
echo "Options:"
|
||||
echo " --ignore-internal ignore internal libraries"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -d $1 ]]; then
|
||||
pushd "$1" >/dev/null
|
||||
else
|
||||
setup_workdir
|
||||
|
||||
case ${script_mode} in
|
||||
deps) bsdtar -C "$WORKDIR" -xf "$1";;
|
||||
provides) bsdtar -C "$WORKDIR" -xf "$1" --include="*.so*";;
|
||||
esac
|
||||
|
||||
pushd "$WORKDIR" >/dev/null
|
||||
fi
|
||||
|
||||
process_sofile() {
|
||||
# extract the library name: libfoo.so
|
||||
soname="${sofile%.so?(+(.+([0-9])))}".so
|
||||
# extract the major version: 1
|
||||
soversion="${sofile##*\.so\.}"
|
||||
if [[ "$soversion" = "$sofile" ]] && ((IGNORE_INTERNAL)); then
|
||||
return
|
||||
fi
|
||||
if ! in_array "${soname}=${soversion}-${soarch}" "${soobjects[@]}"; then
|
||||
# libfoo.so=1-64
|
||||
echo "${soname}=${soversion}-${soarch}"
|
||||
soobjects+=("${soname}=${soversion}-${soarch}")
|
||||
fi
|
||||
}
|
||||
|
||||
case $script_mode in
|
||||
deps) find_args=(-perm -u+x);;
|
||||
provides) find_args=(-name '*.so*');;
|
||||
esac
|
||||
|
||||
find . -type f "${find_args[@]}" | while read -r filename; do
|
||||
if [[ $script_mode = "provides" ]]; then
|
||||
# ignore if we don't have a shared object
|
||||
if ! LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
# get architecture of the file; if soarch is empty it's not an ELF binary
|
||||
soarch=$(LC_ALL=C readelf -h "$filename" 2>/dev/null | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
|
||||
[[ -n $soarch ]] || continue
|
||||
|
||||
if [[ $script_mode = "provides" ]]; then
|
||||
# get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1
|
||||
sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
|
||||
[[ -z $sofile ]] && sofile="${filename##*/}"
|
||||
process_sofile
|
||||
elif [[ $script_mode = "deps" ]]; then
|
||||
# process all libraries needed by the binary
|
||||
for sofile in $(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p'); do
|
||||
process_sofile
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
popd >/dev/null
|
147
artools/0.26.1/artools/bin/pkg/finddeps
Executable file
147
artools/0.26.1/artools/bin/pkg/finddeps
Executable file
|
@ -0,0 +1,147 @@
|
|||
#!/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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ message
|
||||
|
||||
#set +u +o posix
|
||||
|
||||
# shellcheck disable=1091
|
||||
. /usr/share/makepkg/util.sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ -t 2 && "$TERM" != dumb ]]; then
|
||||
colorize
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
fi
|
||||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
# shellcheck disable=2059
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
# shellcheck disable=2059
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n "$1"; then
|
||||
stat_busy "$3"
|
||||
flock "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn "$1"; then
|
||||
stat_busy "$3"
|
||||
flock -s "$1"
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
_setup_workdir=false
|
||||
setup_workdir() {
|
||||
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
|
||||
_setup_workdir=true
|
||||
trap 'trap_abort' INT QUIT TERM HUP
|
||||
trap 'trap_exit' EXIT
|
||||
}
|
||||
|
||||
trap_abort() {
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
abort
|
||||
}
|
||||
|
||||
trap_exit() {
|
||||
local r=$?
|
||||
trap - EXIT INT QUIT TERM HUP
|
||||
cleanup $r
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error 'Aborting...'
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
die() {
|
||||
(( $# )) && error "$@"
|
||||
cleanup 255
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
|
||||
match=$1
|
||||
|
||||
if [[ -z $match ]]; then
|
||||
echo 'Usage: finddeps <depname>'
|
||||
echo ''
|
||||
echo 'Find packages that depend on a given depname.'
|
||||
echo 'Run this script from the top-level directory of your ABS tree.'
|
||||
echo ''
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find . -type d -print0 2>/dev/null| while read -r -d '' d; do
|
||||
if [[ -f "$d/PKGBUILD" ]]; then
|
||||
pkgname=() depends=() makedepends=() optdepends=()
|
||||
# shellcheck source=PKGBUILD.proto
|
||||
. "$d/PKGBUILD"
|
||||
for dep in "${depends[@]}"; do
|
||||
# lose the version comparator, if any
|
||||
depname=${dep%%[<>=]*}
|
||||
[[ $depname = "$match" ]] && msg "$d (depends)"
|
||||
done
|
||||
for dep in "${makedepends[@]}"; do
|
||||
# lose the version comparator, if any
|
||||
depname=${dep%%[<>=]*}
|
||||
[[ $depname = "$match" ]] && msg "$d (makedepends)"
|
||||
done
|
||||
for dep in "${optdepends[@]/:*}"; do
|
||||
# lose the version comaparator, if any
|
||||
depname=${dep%%[<>=]*}
|
||||
[[ $depname = "$match" ]] && msg "$d (optdepends)"
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
50
artools/0.26.1/artools/bin/pkg/finddeps.in
Normal file
50
artools/0.26.1/artools/bin/pkg/finddeps.in
Normal file
|
@ -0,0 +1,50 @@
|
|||
#!/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.
|
||||
|
||||
m4_include(lib/base/message.sh)
|
||||
|
||||
match=$1
|
||||
|
||||
if [[ -z $match ]]; then
|
||||
echo 'Usage: finddeps <depname>'
|
||||
echo ''
|
||||
echo 'Find packages that depend on a given depname.'
|
||||
echo 'Run this script from the top-level directory of your ABS tree.'
|
||||
echo ''
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find . -type d -print0 2>/dev/null| while read -r -d '' d; do
|
||||
if [[ -f "$d/PKGBUILD" ]]; then
|
||||
pkgname=() depends=() makedepends=() optdepends=()
|
||||
# shellcheck source=PKGBUILD.proto
|
||||
. "$d/PKGBUILD"
|
||||
for dep in "${depends[@]}"; do
|
||||
# lose the version comparator, if any
|
||||
depname=${dep%%[<>=]*}
|
||||
[[ $depname = "$match" ]] && msg "$d (depends)"
|
||||
done
|
||||
for dep in "${makedepends[@]}"; do
|
||||
# lose the version comparator, if any
|
||||
depname=${dep%%[<>=]*}
|
||||
[[ $depname = "$match" ]] && msg "$d (makedepends)"
|
||||
done
|
||||
for dep in "${optdepends[@]/:*}"; do
|
||||
# lose the version comaparator, if any
|
||||
depname=${dep%%[<>=]*}
|
||||
[[ $depname = "$match" ]] && msg "$d (optdepends)"
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
338
artools/0.26.1/artools/bin/pkg/gitearepo
Executable file
338
artools/0.26.1/artools/bin/pkg/gitearepo
Executable file
|
@ -0,0 +1,338 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2018-21 artoo@artixlinux.org
|
||||
# Copyright (C) 2021 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.
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ base conf
|
||||
|
||||
DATADIR=${DATADIR:-'/usr/share/artools'}
|
||||
SYSCONFDIR=${SYSCONFDIR:-'/etc/artools'}
|
||||
|
||||
if [[ -n $SUDO_USER ]]; then
|
||||
eval "USER_HOME=~$SUDO_USER"
|
||||
else
|
||||
USER_HOME=$HOME
|
||||
fi
|
||||
|
||||
USER_CONF_DIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/artools"
|
||||
|
||||
prepare_dir(){
|
||||
[[ ! -d $1 ]] && mkdir -p "$1"
|
||||
}
|
||||
|
||||
load_base_config(){
|
||||
|
||||
local conf="$1/artools-base.conf"
|
||||
|
||||
[[ -f "$conf" ]] || return 1
|
||||
|
||||
# shellcheck source=/etc/artools/artools-base.conf
|
||||
[[ -r "$conf" ]] && . "$conf"
|
||||
|
||||
CHROOTS_DIR=${CHROOTS_DIR:-'/var/lib/artools'}
|
||||
|
||||
WORKSPACE_DIR=${WORKSPACE_DIR:-"${USER_HOME}/artools-workspace"}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#}}}
|
||||
|
||||
load_base_config "${USER_CONF_DIR}" || load_base_config "${SYSCONFDIR}"
|
||||
|
||||
prepare_dir "${WORKSPACE_DIR}"
|
||||
prepare_dir "${USER_CONF_DIR}"
|
||||
|
||||
#!/hint/bash
|
||||
|
||||
#{{{ pkg conf
|
||||
|
||||
load_pkg_config(){
|
||||
|
||||
local conf="$1/artools-pkg.conf"
|
||||