Compare commits

..

13 Commits

Author SHA1 Message Date
34ed4ef723 buildpkg: add -n to run namcap optionally 2023-07-27 16:01:47 +02:00
aaa319c67a check (#89)
Reviewed-on: #89
Co-authored-by: Artoo <artoo@artixlinux.org>
Co-committed-by: Artoo <artoo@artixlinux.org>
2023-07-27 15:54:18 +02:00
3304c888a5 ckchrootpkg: update help 2023-07-27 00:34:30 +02:00
095c7ced45 add ckchrootpkg 2023-07-26 21:02:19 +02:00
f4eef7a3cd fixes (#88)
Reviewed-on: #88
Co-authored-by: Artoo <artoo@artixlinux.org>
Co-committed-by: Artoo <artoo@artixlinux.org>
2023-07-26 19:22:32 +02:00
6fc1850f1f mkchrootpkg: revert to C locale 2023-07-25 01:27:02 +02:00
c0a3a7e796 arches (#87)
Reviewed-on: #87
Co-authored-by: Artoo <artoo@artixlinux.org>
Co-committed-by: Artoo <artoo@artixlinux.org>
2023-07-25 00:53:58 +02:00
08fff866ed mkchrootpkg: source locale.conf in chroot 2023-07-23 20:22:15 +02:00
8bef697c44 remove deploypkg compat symlink 2023-07-23 19:32:22 +02:00
a6eadf1af4 artixpkg: don't query actions 2023-07-23 12:58:44 +02:00
2595cd2a3a artixpkg: exclude .artixlinux on import rsync 2023-07-22 23:51:20 +02:00
1917c252aa Merge pull request 'artixpkg: remove migration' (#86) from rm-migration into master
Reviewed-on: #86
2023-07-22 16:37:25 +02:00
4c458bf242 artixpkg: remove migration 2023-07-22 11:17:20 +02:00
25 changed files with 186 additions and 184 deletions

View File

@@ -36,28 +36,6 @@ TOOLS_CONFIGS_BASE=$(wildcard config/conf/*base*)
TOOLS_CONFIGS_PKG=$(wildcard config/conf/*pkg*)
TOOLS_CONFIGS_ISO=$(wildcard config/conf/*iso*)
LN_BUILDPKG = \
buildpkg-system-x86_64 \
buildpkg-system-gremlins-x86_64 \
buildpkg-system-goblins-x86_64 \
buildpkg-world-x86_64 \
buildpkg-world-gremlins-x86_64 \
buildpkg-world-goblins-x86_64 \
buildpkg-lib32-x86_64 \
buildpkg-lib32-gremlins-x86_64 \
buildpkg-lib32-goblins-x86_64 \
buildpkg-galaxy-x86_64 \
buildpkg-galaxy-gremlins-x86_64 \
buildpkg-galaxy-goblins-x86_64
LN_BUILDISO = \
buildiso-world \
buildiso-world-gremlins \
buildiso-world-goblins \
buildiso-galaxy \
buildiso-galaxy-gremlins \
buildiso-galaxy-goblins
all: binprogs_base binprogs_pkg binprogs_iso library_base library_pkg library_iso conf_base conf_pkg conf_iso
binprogs_base: $(BINPROGS_BASE)
binprogs_pkg: $(BINPROGS_PKG)
@@ -134,12 +112,8 @@ install_pkg: binprogs_pkg
for conf in $(notdir $(MAKEPKG_CONFIGS)); do install -Dm0644 $(BUILDDIR)/makepkg.conf.d/$$conf $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
for a in $(SETARCH_ALIASES); do install -m0644 $$a -t $(DESTDIR)$(DATADIR)/setarch-aliases.d; done
for l in $(LN_BUILDPKG); do ln -sf buildpkg $(DESTDIR)$(PREFIX)/bin/$$l; done
ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides
# compat symlink
ln -sf repopkg $(DESTDIR)$(PREFIX)/bin/deploypkg
install_iso: binprogs_iso
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)
install -dm0755 $(DESTDIR)$(PREFIX)/bin
@@ -149,8 +123,6 @@ install_iso: binprogs_iso
for conf in $(notdir $(TOOLS_CONFIGS_ISO)); do install -Dm0644 $(BUILDDIR)/$(TOOLS)/$$conf $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)/$${conf##*/}; done
for l in $(LN_BUILDISO); do ln -sf buildiso $(DESTDIR)$(PREFIX)/bin/$$l; done
install: all install_base install_pkg install_iso
uninstall:
@@ -161,8 +133,6 @@ uninstall:
for conf in $(notdir $(MAKEPKG_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
for conf in $(notdir $(PACMAN_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done
for f in $(notdir $(SETARCH_ALIASES)); do rm -f $(DESTDIR)$(DATADIR)/setarch-aliases.d/$$f; done
for l in $(LN_BUILDPKG); do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done
for l in $(LN_BUILDISO); do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done
rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides
rmdir --ignore-fail-on-non-empty \
$(DESTDIR)$(DATADIR)/setarch-aliases.d \

View File

@@ -74,11 +74,11 @@ 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.conf.d/makepkg.conf
usr/share/artools/makepkg.conf.d/${arch}.conf
```
```bash
usr/share/artools/pacmanconf.d/${repo}.conf
usr/share/artools/pacmanconf.d/${repo}-${arch}.conf
```
and can be overridden dropping them in

View File

@@ -10,3 +10,11 @@
# the workspace directory
# WORKSPACE_DIR="${USER_HOME}/artools-workspace"
# the arch to build
# ARCH=$(uname -m)
# default pacman.conf repos to include
# possible buildpkg values: {system,world,galaxy,lib32}{-gremlins,-goblins}
# possible buildiso values: {world,galaxy}{-gremlins,-goblins}
# REPO="world"

View File

@@ -197,8 +197,10 @@ gen_iso_fn(){
prepare_build(){
load_profile
pacman_conf="${DATADIR}/pacman.conf.d/${repo}.conf"
[[ -f "${USER_CONF_DIR}/pacman.conf.d/${repo}.conf" ]] && pacman_conf="${USER_CONF_DIR}/pacman.conf.d/${repo}.conf"
pacman_conf="${DATADIR}/pacman.conf.d/${repo}-${arch}.conf"
if [[ -f "${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf" ]]; then
pacman_conf="${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf"
fi
iso_file=$(gen_iso_fn).iso
@@ -324,17 +326,21 @@ boot_only=false
basestrap_args=(-GMc)
cmd=${0##*/}
repo=${cmd#buildiso-}
repo=${REPO}
owner=${SUDO_USER:-$USER}
profile='base'
chroots_iso="${CHROOTS_DIR}/buildiso"
arch=$(uname -m)
arch=${ARCH}
usage() {
printf 'Usage: %s [options]\n' "${cmd}"
printf ' -p <profile> Profile [default: %s]\n' "${profile}"
printf ' -r <dir> Chroots directory\n'
printf ' [default: %s]\n' "${chroots_iso}"
printf ' -R <repo> Build repo\n'
printf ' [default: %s]\n' "${repo}"
printf ' -a <arch> Build arch\n'
printf ' [default: %s]\n' "${arch}"
printf ' -t <dir> Target directory\n'
printf ' [default: %s]\n' "${ISO_POOL}"
printf ' -i <name> Init system to use\n'
@@ -358,11 +364,13 @@ usage() {
orig_args=("$@")
opts='p:r:t:i:g:czsbxmdqh'
opts='p:r:R:t:i:g:a:czsbxmdqh'
while getopts "${opts}" arg; do
case "${arg}" in
p) profile="$OPTARG" ;;
a) arch="$OPTARG" ;;
R) repo="$OPTARG" ;;
r) chroots_iso="$OPTARG" ;;
t) ISO_POOL="$OPTARG" ;;
i) INITSYS="$OPTARG" ;;

View File

@@ -32,6 +32,10 @@ load_base_config(){
WORKSPACE_DIR=${WORKSPACE_DIR:-"${USER_HOME}/artools-workspace"}
ARCH=${ARCH:-"$(uname -m)"}
REPO=${REPO:-'world'}
return 0
}

View File

@@ -277,7 +277,8 @@ show_db() {
if ! yq -r ${REPO_DB} 1>/dev/null 2>/dev/null; then
die "${REPO_DB} invalid!"
fi
yq -rP '. | .repos |= with_entries(select(.value.version))' "${REPO_DB}"
yq -rP '. | with_entries(select(.value.name))' "${REPO_DB}"
yq -rP '. | .repos | with_entries(select(.value.version))' "${REPO_DB}"
return 0
}

View File

@@ -1,102 +0,0 @@
#!/hint/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
declare -rA REPO_MAP=(
[core-rebuild]=system-goblins
[core-staging]=system-goblins
[core-testing]=system-gremlins
[core]=system
[extra-rebuild]=world-goblins
[extra-staging]=world-goblins
[extra-testing]=world-gremlins
[extra]=world
[multilib-staging]=lib32-goblins
[multilib-testing]=lib32-gremlins
[multilib]=lib32
[community-staging]=galaxy-goblins
[community-testing]=galaxy-gremlins
[community]=galaxy
)
update_gitignore() {
{
printf '*.service\n'
printf '*.timer\n'
printf '*.socket\n'
} >> .gitignore
}
migrate_to_yaml() {
if [[ -f trunk/PKGBUILD ]]; then
stat_busy "Migrating ${pkgbase} to new layout"
create_repo_db
stat_done
# shellcheck source=contrib/makepkg/PKGBUILD.proto
source "trunk/PKGBUILD"
update_yaml_base
if [[ -d x86_64 ]]; then
local repos
mapfile -t repos < <(ls x86_64)
for r in "${repos[@]}"; do
# shellcheck source=contrib/makepkg/PKGBUILD.proto
source "x86_64/${r}/PKGBUILD"
local repo
local pkgs
local version
local pkgfiles
mapfile -t pkgfiles < <(print_package_names)
pkgs=$(yaml_array "${pkgfiles[@]}")
version=$(get_full_version)
repo=".repos.${REPO_MAP[$r]}"
version="${version}" pkgs="${pkgs}" repo="${repo}" \
yq -P 'with(
eval(strenv(repo));
.version = env(version) |
.packages = env(pkgs) )' \
-i "${REPO_DB}"
if [[ -n ${GIT_TOKEN} ]]; then
local topic gitname
gitname=$(get_compliant_name "${pkgbase}")
topic="${REPO_MAP[$r]}"
if ! add_topic "${gitname}" "${topic}"; then
warning "failed to add topic: ${topic}"
fi
topic="${r}"
if ! remove_topic "${gitname}" "${topic}"; then
warning "failed to remove topic: ${topic}"
fi
fi
done
git rm -r x86_64
fi
cp -r trunk/* ./
git rm -r trunk
if [[ -f .artixlinux/agent.yaml ]]; then
git rm .artixlinux/agent.yaml
fi
if [[ -f .gitignore ]]; then
update_gitignore
fi
if [[ -f Jenkinsfile ]]; then
git mv Jenkinsfile "${REPO_CI}"
fi
git add .
git commit -m "migrate to new layout"
fi
}

View File

@@ -31,13 +31,4 @@ find_cached_pkgfile() {
shopt -u extglob
get_pkgbasename() {
local name="$1"
local rm_pkg=${name%.pkg.tar*}
rm_pkg=${rm_pkg%-*}
rm_pkg=${rm_pkg%-*}
rm_pkg=${rm_pkg%-*}
printf "%s\n" "$rm_pkg"
}
#}}}

View File

@@ -7,8 +7,6 @@ ARTOOLS_INCLUDE_GIT_CONFIG_SH=1
# shellcheck source=src/lib/pkg/db/db.sh
source "${LIBDIR}"/pkg/db/db.sh
# shellcheck source=src/lib/pkg/db/migrate.sh
source "${LIBDIR}"/pkg/db/migrate.sh
set -e
@@ -263,13 +261,6 @@ artixpkg_git_config() {
fi
fi
migrate_to_yaml
if [[ -f Jenkinsfile ]]; then
git mv Jenkinsfile "${REPO_CI}"
git commit -m "move jenkinsfile"
fi
if [[ ! -f ${REPO_CI} ]]; then
msg "Adding ci support ..."
commit_ci

View File

@@ -41,12 +41,12 @@ artixpkg_repo_import_usage() {
Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS
--switch TAG Switch the current workspace to a specified version tag
--tag TAG Switch the current workspace to a specified version tag
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} libfoo
$ ${COMMAND} libfoo --switch TAG
$ ${COMMAND} libfoo --tag TAG
_EOF_
}
@@ -61,12 +61,22 @@ artixpkg_repo_import() {
local pkgbase
local TAG
local rsync_args=()
rsync_args+=(-aWxvci --progress --delete-before --no-R --no-implied-dirs)
rsync_args+=(--exclude '.git' --exclude '.gitignore' --exclude 'README.md')
rsync_args+=(
-axcihW
--no-R
--no-implied-dirs
--exclude '.artixlinux'
--exclude '.git'
--exclude '.gitignore'
--exclude 'README.md'
--exclude '*.service'
--exclude '*.timer'
--exclude '*.socket'
)
while (( $# )); do
case $1 in
--switch=*)
--tag=*)
TAG="${1#*=}"
shift
;;
@@ -122,11 +132,11 @@ artixpkg_repo_import() {
git checkout master &>/dev/null
git branch -D "${version}" &>/dev/null
rsync "${rsync_args[@]}" "${temp}"/ "$(pwd)"/ &>/dev/null
stat_done
rsync "${rsync_args[@]}" "${temp}"/ "$(pwd)"/ #&>/dev/null
patch_pkgbase "${pkgbase}"
stat_done
)
fi

View File

@@ -16,26 +16,27 @@ source "${LIBDIR}"/base/chroot.sh
create_first=false
rebuild=false
mkchrootpkg_args=(-c -n)
mkchrootpkg_args=(-c)
base_packages=('base-devel')
chroots_pkg="${CHROOTS_DIR}/buildpkg"
cmd=${0##*/}
tag=${cmd#buildpkg-}
arch=${tag##*-}
repo=${tag%-*}
arch=${ARCH}
repo=${REPO}
usage() {
printf 'Usage: %s [options] -- [mkchrootpkg_args]\n' "${0##*/}"
printf ' -r <dir> Create chroots in this directory\n'
printf ' -d <dir> Destination repo chroot\n'
printf ' [default: %s]\n' "${chroots_pkg}"
printf ' -d <dest> Destination repo chroot\n'
printf ' [default: %s]\n' "${repo}"
printf ' -a <arch> Build arch chroot\n'
printf ' [default: %s]\n' "${arch}"
printf ' -c Recreate the chroot before building\n'
printf ' -m Major rebuild\n'
printf ' -N Disable check() function\n'
printf ' -C Run checkpkg after built\n'
printf ' -C Run checkpkg after build\n'
printf ' -n Run namcap after build\n'
printf ' -h This help\n'
printf '\n'
printf 'Default mkchrootpkg_args args: %s\n' "${mkchrootpkg_args[*]}"
@@ -43,7 +44,7 @@ usage() {
exit "$1"
}
opts='hcCNmr:d:a:'
opts='hcCNmnr:d:a:'
while getopts "${opts}" arg; do
case "${arg}" in
@@ -54,6 +55,7 @@ while getopts "${opts}" arg; do
m) rebuild=true; repo=${repo%-*} ;;
C) mkchrootpkg_args+=(-C) ;;
N) mkchrootpkg_args+=(-N) ;;
n) mkchrootpkg_args+=(-n) ;;
h|?) usage 0 ;;
esac
done
@@ -62,15 +64,9 @@ if [[ "${repo}" == lib32* ]]; then
base_packages+=('multilib-devel')
fi
pacman_conf="${DATADIR}/pacman.conf.d/${repo}.conf"
if [[ -f ${USER_CONF_DIR}/pacman.conf.d/${repo}.conf ]]; then
pacman_conf="${USER_CONF_DIR}/pacman.conf.d/${repo}.conf"
fi
if [[ -f ${DATADIR}/pacman.conf.d/${repo}-${arch}.conf ]]; then
pacman_conf="${DATADIR}/pacman.conf.d/${repo}-${arch}.conf"
if [[ -f ${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf ]]; then
pacman_conf="${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf"
fi
pacman_conf="${DATADIR}/pacman.conf.d/${repo}-${arch}.conf"
if [[ -f ${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf ]]; then
pacman_conf="${USER_CONF_DIR}/pacman.conf.d/${repo}-${arch}.conf"
fi
makepkg_conf="${DATADIR}/makepkg.conf.d/${arch}.conf"

123
src/pkg/ckchrootpkg.in Normal file
View File

@@ -0,0 +1,123 @@
#!/bin/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
LIBDIR=${LIBDIR:-'@libdir@'}
# shellcheck source=src/lib/base/util.sh
source "${LIBDIR}"/base/util.sh
# shellcheck source=src/lib/base/message.sh
source "${LIBDIR}"/base/message.sh
# shellcheck source=src/lib/base/chroot.sh
source "${LIBDIR}"/base/chroot.sh
shopt -s nullglob
chrootdir=
makepkg_user=
passeddir="${CHROOTS_DIR}/buildpkg"
arch=${ARCH}
repo=${REPO}
copy=$USER
[[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER
[[ -z "$copy" || $copy = root ]] && copy=copy
usage() {
printf 'Usage: %s [options] -r <chrootdir>\n' "${0##*/}"
printf ' -r <dir> Create chroots in this directory\n'
printf ' Default: %s\n' "${passeddir}"
printf ' -d <dest> Destination repo chroot\n'
printf ' Default: %s\n' "${repo}"
printf ' -a <arch> Build arch chroot\n'
printf ' Default: %s\n' "${arch}"
printf ' -l <copy> The directory to use as the working copy of the chroot\n'
printf ' Useful for maintaining multiple copies\n'
printf ' Default: %s\n' "$copy"
printf ' -U Run makepkg as a specified user\n'
exit 1
}
opts='hr:l:U:d:a:'
while getopts "${opts}" arg; do
case "$arg" in
r) passeddir="$OPTARG" ;;
l) copy="$OPTARG" ;;
U) makepkg_user="$OPTARG" ;;
d) repo="$OPTARG" ;;
a) arch="$OPTARG" ;;
h|*) usage ;;
esac
done
[[ ! -f PKGBUILD ]] && die 'This must be run in a directory containing a PKGBUILD.'
[[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.'
makepkg_user=${makepkg_user:-${SUDO_USER:-$USER}}
check_root "" "${BASH_SOURCE[0]}" "$@"
# # Canonicalize chrootdir, getting rid of trailing /
chrootdir=$(readlink -e "$passeddir")
chrootdir="$chrootdir"/"${repo}-${arch}"
[[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir"
[[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkchroot %s/root base-devel" "$chrootdir"
if [[ ${copy:0:1} = / ]]; then
copydir=$copy
else
copydir="$chrootdir/$copy"
fi
umask 0022
ORIG_HOME=$HOME
IFS=: read -r _ _ _ _ _ HOME _ < <(getent passwd "${SUDO_USER:-$USER}")
load_makepkg_config
HOME=$ORIG_HOME
msg "Running checkpkg"
if chroot-run \
-b "-B:${PWD}:/startdir -B:${SRCDEST}:/srcdest" \
"$copydir" true
then
mapfile -t pkgnames < <(sudo -u "$makepkg_user" bash -c 'source PKGBUILD; printf "%s\n" "${pkgname[@]}"')
fi
mapfile -t remotepkgs < <(pacman --config "$copydir"/etc/pacman.conf \
--dbpath "$copydir"/var/lib/pacman \
-Sddp "${pkgnames[@]}")
if ! wait $!; then
warning "Skipped checkpkg due to missing repo packages"
exit 0
fi
# download package files if any non-local location exists
for remotepkg in "${remotepkgs[@]}"; do
if [[ $remotepkg != file://* ]]; then
msg2 "Downloading current versions"
chroot-run "$copydir" pacman --noconfirm -Swdd "${pkgnames[@]}"
mapfile -t remotepkgs < <(pacman --config "$copydir"/etc/pacman.conf \
--dbpath "$copydir"/var/lib/pacman \
-Sddp "${pkgnames[@]}")
break
fi
done
pkgfiles="${remotepkgs[@]/#file:\/\//}"
sudo -u "$makepkg_user" checkpkg --rmdir --warn --makepkg-config "$copydir/etc/makepkg.conf" "${pkgfiles[@]}"
msg "Running namcap"
#msg2 "Checking %s\n" "PKGBUILD"
sudo -u "$makepkg_user" namcap PKGBUILD 2>&1 | tee "PKGBUILD-namcap.log"
for pkgfile in "${pkgfiles[@]}"; do
#msg2 "Checking %s\n" "${pkgfile##*/}"
sudo -u "$makepkg_user" namcap "$pkgfile" 2>&1 | tee "${pkgfile##*/}-namcap.log"
done

View File

@@ -205,6 +205,8 @@ _chrootbuild() {
# No coredumps
ulimit -c 0
. /etc/locale.conf
# shellcheck source=/dev/null
. /etc/profile