Compare commits

..

1 Commits

Author SHA1 Message Date
87f7efa2f7 modify(makepkg.conf): Flags. Use comma separated list 2024-01-23 05:02:17 +00:00
69 changed files with 847 additions and 2239 deletions

View File

@@ -3,7 +3,7 @@ run-name: ${{ gitea.actor }}
on: on:
push: push:
branches: branches:
- artools/0.33.x - artools/0.32.x
- master - master
tags: tags:
- 0.* - 0.*
@@ -16,15 +16,13 @@ jobs:
steps: steps:
- name: checkout repo - name: checkout repo
uses: actions/checkout@main uses: actions/checkout@main
- name: build - name: build artools
run: make run: make
- name: shellcheck - name: shellcheck artools
uses: ludeeus/action-shellcheck@master uses: ludeeus/action-shellcheck@master
env: env:
SHELLCHECK_OPTS: -x -e SC2034 SHELLCHECK_OPTS: -x -e SC2034
with: with:
scandir: './build/bin' scandir: './build/bin'
format: tty format: tty
severity: error
additional_files: 'contrib/completion/bash/artools'

View File

@@ -1,6 +1,6 @@
SHELL=/bin/bash SHELL=/bin/bash
V=0.37 V=0.32
BUILDTOOLVER ?= $(V) BUILDTOOLVER ?= $(V)
CHROOTVER=0.12 CHROOTVER=0.12
@@ -35,16 +35,13 @@ SETARCH_ALIASES = $(wildcard config/setarch-aliases.d/*)
TOOLS_CONFIGS_PKG=$(wildcard config/conf/*pkg*) TOOLS_CONFIGS_PKG=$(wildcard config/conf/*pkg*)
TOOLS_CONFIGS_ISO=$(wildcard config/conf/*iso*) TOOLS_CONFIGS_ISO=$(wildcard config/conf/*iso*)
COMPLETIONS = $(addprefix $(BUILDDIR)/,$(patsubst %.in,%,$(wildcard contrib/completion/*/*))) all: binprogs_base binprogs_pkg binprogs_iso library_base library_pkg library_iso conf_base conf_pkg conf_iso
all: binprogs_base binprogs_pkg binprogs_iso library_base library_pkg library_iso conf_base conf_pkg conf_iso completion
binprogs_base: $(BINPROGS_BASE) binprogs_base: $(BINPROGS_BASE)
binprogs_pkg: $(BINPROGS_PKG) binprogs_pkg: $(BINPROGS_PKG)
binprogs_iso: $(BINPROGS_ISO) binprogs_iso: $(BINPROGS_ISO)
library_base: $(LIBRARY_BASE) library_base: $(LIBRARY_BASE)
library_pkg: $(LIBRARY_PKG) library_pkg: $(LIBRARY_PKG)
library_iso: $(LIBRARY_ISO) library_iso: $(LIBRARY_ISO)
completion: $(COMPLETIONS)
edit = sed -e "s|@datadir[@]|$(DATADIR)|g" \ edit = sed -e "s|@datadir[@]|$(DATADIR)|g" \
-e "s|@libdir[@]|$(LIBDIR)|g" \ -e "s|@libdir[@]|$(LIBDIR)|g" \
@@ -72,15 +69,13 @@ $(eval $(call buildInScript,build/bin,src/pkg/,.in,755))
$(eval $(call buildInScript,build/bin,src/iso/,.in,755)) $(eval $(call buildInScript,build/bin,src/iso/,.in,755))
$(eval $(call buildInScript,build/lib,src/lib/,,644)) $(eval $(call buildInScript,build/lib,src/lib/,,644))
$(foreach completion,$(wildcard contrib/completion/*),$(eval $(call buildInScript,build/$(completion),$(completion)/,.in,444)))
conf_base: conf_base:
@install -d $(BUILDDIR)/pacman.conf.d $(BUILDDIR)/artools @install -d $(BUILDDIR)/pacman.conf.d $(BUILDDIR)/artools
@cp -a $(PACMAN_CONFIGS) $(BUILDDIR)/pacman.conf.d @cp -a $(PACMAN_CONFIGS) $(BUILDDIR)/pacman.conf.d
conf_pkg: conf_pkg:
@install -d $(BUILDDIR)/makepkg.conf.d $(BUILDDIR)/artools @install -d $(BUILDDIR)/makepkg.conf.d $(BUILDDIR)/artools
@cp -ra $(MAKEPKG_CONFIGS) $(BUILDDIR)/makepkg.conf.d @cp -a $(MAKEPKG_CONFIGS) $(BUILDDIR)/makepkg.conf.d
@cp -a $(TOOLS_CONFIGS_PKG) $(BUILDDIR)/artools @cp -a $(TOOLS_CONFIGS_PKG) $(BUILDDIR)/artools
conf_iso: conf_iso:
@@ -111,14 +106,10 @@ install_pkg: binprogs_pkg
for conf in $(notdir $(TOOLS_CONFIGS_PKG)); do install -Dm0644 $(BUILDDIR)/$(TOOLS)/$$conf $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)/$${conf##*/}; done for conf in $(notdir $(TOOLS_CONFIGS_PKG)); do install -Dm0644 $(BUILDDIR)/$(TOOLS)/$$conf $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)/$${conf##*/}; done
cp -ra $(BUILDDIR)/makepkg.conf.d -t $(DESTDIR)$(DATADIR) 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 a in $(SETARCH_ALIASES); do install -m0644 $$a -t $(DESTDIR)$(DATADIR)/setarch-aliases.d; done
ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides
install -Dm0644 $(BUILDDIR)/contrib/completion/bash/artixpkg $(DESTDIR)$(PREFIX)/share/bash-completion/completions/artixpkg
install -Dm0644 $(BUILDDIR)/contrib/completion/zsh/_artixpkg $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_artixpkg
install_iso: binprogs_iso install_iso: binprogs_iso
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/$(TOOLS) install -dm0755 $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)
install -dm0755 $(DESTDIR)$(PREFIX)/bin install -dm0755 $(DESTDIR)$(PREFIX)/bin
@@ -135,12 +126,13 @@ uninstall:
for f in $(notdir $(LIBRARY)); do rm -f $(DESTDIR)$(DATADIR)/lib/$$f; done for f in $(notdir $(LIBRARY)); do rm -f $(DESTDIR)$(DATADIR)/lib/$$f; done
rm -rf $(DESTDIR)$(DATADIR)/lib rm -rf $(DESTDIR)$(DATADIR)/lib
for conf in $(notdir $(TOOLS_CONFIGS)); do rm -f $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)/$${conf##*/}; done for conf in $(notdir $(TOOLS_CONFIGS)); do rm -f $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)/$${conf##*/}; done
rm -rf $(DESTDIR)$(DATADIR)/makepkg.conf.d 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 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 f in $(notdir $(SETARCH_ALIASES)); do rm -f $(DESTDIR)$(DATADIR)/setarch-aliases.d/$$f; done
rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides
rmdir --ignore-fail-on-non-empty \ rmdir --ignore-fail-on-non-empty \
$(DESTDIR)$(DATADIR)/setarch-aliases.d \ $(DESTDIR)$(DATADIR)/setarch-aliases.d \
$(DESTDIR)$(DATADIR)/makepkg.conf.d \
$(DESTDIR)$(DATADIR)/pacman.conf.d \ $(DESTDIR)$(DATADIR)/pacman.conf.d \
$(DESTDIR)$(DATADIR) \ $(DESTDIR)$(DATADIR) \
$(DESTDIR)$(SYSCONFDIR)/$(TOOLS) $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)
@@ -152,5 +144,5 @@ dist:
check: $(BINPROGS_SRC_BASE) $(BINPROGS_SRC_PKG) $(BINPROGS_SRC_ISO) config/makepkg/x86_64.conf contrib/makepkg/PKGBUILD.proto check: $(BINPROGS_SRC_BASE) $(BINPROGS_SRC_PKG) $(BINPROGS_SRC_ISO) config/makepkg/x86_64.conf contrib/makepkg/PKGBUILD.proto
shellcheck -x $^ shellcheck -x $^
.PHONY: all binprogs_base binprogs_pkg binprogs_iso library_base library_pkg library_iso conf_base conf_pkg conf_iso clean install install_base install_pkg install_iso uninstall dist check contrib .PHONY: all binprogs_base binprogs_pkg binprogs_iso library_base library_pkg library_iso conf_base conf_pkg conf_iso clean install install_base install_pkg install_iso uninstall dist check
.DELETE_ON_ERROR: .DELETE_ON_ERROR:

View File

@@ -32,15 +32,3 @@
# default packaging org # default packaging org
# GIT_ORG='packages' # GIT_ORG='packages'
# default archiving org
# GIT_ORG_ARCHIVE='landfill'
# whether to include custom maintainer line when importing from arch
# PATCH_MAINTAINER=false
# override the default git url for patches repo
# PATCH_URL=${GIT_SSH}:artix/artix-patches.git
# override the default debug pool
# PKGDEST_DBG=${WORKSPACE_DIR}/packages-debug

View File

@@ -1,18 +0,0 @@
#!/hint/bash
#
# /etc/makepkg.conf.d/fortran.conf
#
#########################################################################
# FORTRAN LANGUAGE SUPPORT
#########################################################################
# Flags used for the Fortran compiler, similar in spirit to CFLAGS. Read
# linkman:gfortran[1] for more details on the available flags.
#FFLAGS="-O2 -pipe"
#FCFLAGS="$FFLAGS"
# Additional compiler flags appended to `FFLAGS` and `FCFLAGS` for use in debugging. Usually
# this would include: ``-g''. Read linkman:gfortran[1] for more details on the wide
# variety of compiler flags available.
#DEBUG_FFLAGS="-g"

View File

@@ -1,19 +0,0 @@
#!/hint/bash
# shellcheck disable=2034
#
# /etc/makepkg.conf.d/rust.conf
#
#########################################################################
# RUST LANGUAGE SUPPORT
#########################################################################
# Flags used for the Rust compiler, similar in spirit to CFLAGS. Read
# linkman:rustc[1] for more details on the available flags.
RUSTFLAGS="-Cforce-frame-pointers=yes"
# Additional compiler flags appended to `RUSTFLAGS` for use in debugging.
# Usually this would include: ``-C debuginfo=2''. Read linkman:rustc[1] for
# more details on the available flags.
DEBUG_RUSTFLAGS="-C debuginfo=2"

View File

@@ -25,7 +25,7 @@ DLAGENTS=('file::/usr/bin/curl -qgC - -o %o %u'
#-- The package required by makepkg to download VCS sources #-- The package required by makepkg to download VCS sources
# Format: 'protocol::package' # Format: 'protocol::package'
VCSCLIENTS=('bzr::breezy' VCSCLIENTS=('bzr::bzr'
'fossil::fossil' 'fossil::fossil'
'git::git' 'git::git'
'hg::mercurial' 'hg::mercurial'
@@ -41,18 +41,18 @@ CHOST="x86_64-pc-linux-gnu"
#-- Compiler and Linker Flags #-- Compiler and Linker Flags
#CPPFLAGS="" #CPPFLAGS=""
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \ CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
-Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security \ -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
-fstack-clash-protection -fcf-protection" -fstack-clash-protection -fcf-protection"
# -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS" CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now \ LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now,-z,pack-relative-relocs"
-Wl,-z,pack-relative-relocs"
LTOFLAGS="-flto=auto" LTOFLAGS="-flto=auto"
RUSTFLAGS=""
#-- Make Flags: change this for DistCC/SMP systems #-- Make Flags: change this for DistCC/SMP systems
#MAKEFLAGS="-j2" #MAKEFLAGS="-j2"
#-- Debugging flags #-- Debugging flags
DEBUG_CFLAGS="-g" DEBUG_CFLAGS="-g"
DEBUG_CXXFLAGS="$DEBUG_CFLAGS" DEBUG_CXXFLAGS="$DEBUG_CFLAGS"
DEBUG_RUSTFLAGS="-C debuginfo=2"
######################################################################### #########################################################################
# BUILD ENVIRONMENT # BUILD ENVIRONMENT
@@ -81,7 +81,7 @@ BUILDENV=(!distcc color !ccache check !sign)
# These are default values for the options=() settings # These are default values for the options=() settings
######################################################################### #########################################################################
# #
# Makepkg defaults: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug !lto !autodeps) # Makepkg defaults: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug !lto)
# A negated option will do the opposite of the comments below. # A negated option will do the opposite of the comments below.
# #
#-- strip: Strip symbols from binaries/libraries #-- strip: Strip symbols from binaries/libraries
@@ -93,7 +93,6 @@ BUILDENV=(!distcc color !ccache check !sign)
#-- purge: Remove files specified by PURGE_TARGETS #-- purge: Remove files specified by PURGE_TARGETS
#-- debug: Add debugging flags as specified in DEBUG_* variables #-- debug: Add debugging flags as specified in DEBUG_* variables
#-- lto: Add compile flags for building with link time optimization #-- lto: Add compile flags for building with link time optimization
#-- autodeps: Automatically add depends/provides
# #
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug lto) OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug lto)
@@ -113,8 +112,6 @@ DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod) PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
#-- Directory to store source code in for debug packages #-- Directory to store source code in for debug packages
DBGSRCDIR="/usr/src/debug" DBGSRCDIR="/usr/src/debug"
#-- Prefix and directories for library autodeps
LIB_DIRS=('lib:usr/lib' 'lib32:usr/lib32')
######################################################################### #########################################################################
# PACKAGE OUTPUT # PACKAGE OUTPUT

View File

@@ -1 +0,0 @@
../conf.d/fortran.conf

View File

@@ -1 +0,0 @@
../conf.d/rust.conf

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -35,8 +35,6 @@ Color
CheckSpace CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 10 ParallelDownloads = 10
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -35,8 +35,6 @@ Color
CheckSpace CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 10 ParallelDownloads = 10
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -35,8 +35,6 @@ Color
CheckSpace CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 10 ParallelDownloads = 10
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -36,8 +36,6 @@ NoProgressBar
#CheckSpace #CheckSpace
VerbosePkgLists VerbosePkgLists
ParallelDownloads = 5 ParallelDownloads = 5
DownloadUser = alpm
#DisableSandbox
# By default, pacman accepts packages signed by keys that its local keyring # By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages. # trusts (see pacman-key and its man page), as well as unsigned packages.

View File

@@ -1,296 +0,0 @@
#/usr/bin/env bash
LIBDIR=${LIBDIR:-'@libdir@'}
_artixpkg_pkgbase() {
source "${LIBDIR}"/pkg/util.sh
ls -1 "${TREE_DIR_ARTIX}" | tr '\n' ' '
}
_artixpkg_remotepkgbase() {
curl -s "https://checkupdates.artixlinux.org/api/1.0/packages?startswith=$1"
}
_artixpkg_maintainers() {
curl -s "https://checkupdates.artixlinux.org/api/1.0/maintainers"
}
_artixpkg_completion() {
local cur prev comps comps_all repos autorepos teams agents cwords comp_cword_exflag agent_flag_present
source "${LIBDIR}"/pkg/db/db.sh 2>/dev/null
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
for ((i = COMP_CWORD - 1; i >= 0; i--)); do
if [[ ${COMP_WORDS[i]} != -* ]]; then
last_non_flag_word="${COMP_WORDS[i]}"
break
fi
done
comps=""
comps_all=""
comp_cword_exflag=0
comp_cword_all=0
agent_flag_present=false
for ((i = 0; i < ${#COMP_WORDS[@]} - 1; i++)); do
word="${COMP_WORDS[i]}"
comps_all+=" $word"
((comp_cword_all++))
if [[ $word != -* ]]; then
comps+=" $word"
((comp_cword_exflag++))
fi
if [[ $word == -a || $word == --agent ]]; then
# -a can also refer to --adopt
agent_flag_present=true
fi
done
comps="${comps:1}"
comps_all="${comps_all:1}"
repos=""
for word in "${ARTIX_DB[@]}"; do
if [[ $word != -* ]]; then
repos+=" $word"
fi
done
repos="${repos:1}"
autorepos=""
for word in "${ARTIX_DB_MAP[@]}"; do
if [[ $word != -* ]]; then
autorepos+=" $word"
fi
done
autorepos="${autorepos:1}"
teams=""
for word in "${ARTIX_TEAMS[@]}"; do
if [[ $word != -* ]]; then
teams+=" $word"
fi
done
teams="${teams:1}"
agents=""
for word in "${AGENTS[@]}"; do
if [[ $word != -* ]]; then
agents+=" $word"
fi
done
agents="${agents:1}"
case "${comp_cword_exflag}" in
1)
COMPREPLY=($(compgen -W "admin git repo version -h --help" -- "${cur}"))
return 0
;;
2)
case ${prev} in
admin)
COMPREPLY=($(compgen -W "maintainer query team topic transfer -h --help" -- ${cur}))
;;
git)
COMPREPLY=($(compgen -W "clone config create pull push -h --help" -- ${cur}))
;;
repo)
COMPREPLY=($(compgen -W "add remove move import show -h --help" -- ${cur}))
;;
version)
COMPREPLY=($(compgen -W "-h --help" -- ${cur}))
;;
esac
;;
*)
case "${comps}" in
"artixpkg repo import"*)
case "${prev}" in
"--tag")
# this flag expects a parameter
COMPREPLY=()
;;
*)
COMPREPLY=($(compgen -W "--del -h --help --tag $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
"artixpkg repo show")
COMPREPLY=($(compgen -W "-b --base -p --pkgs -h --help" -- ${cur}))
;;
"artixpkg repo"*)
if [ "$agent_flag_present" = true ] ; then
((comp_cword_exflag--))
fi
case "${prev}" in
"-a"|"--agent")
COMPREPLY=($(compgen -W "$agents" -- ${cur}))
;;
*)
case "${comps}" in
"artixpkg repo add"*)
local repoAddCommon="-p --push -r --rebuild -n --nocheck -a --agent -h --help"
case "${comp_cword_exflag}" in
3)
COMPREPLY=($(compgen -W "$repoAddCommon $autorepos $repos" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -W "$repoAddCommon $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
"artixpkg repo remove"*)
case "${comp_cword_exflag}" in
3)
COMPREPLY=($(compgen -W "-p --push -a --agent -h --help $autorepos $repos" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -W "-p --push -a --agent -h --help $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
"artixpkg repo move"*)
case "${comp_cword_exflag}" in
3|4)
COMPREPLY=($(compgen -W "-p --push -a --agent -h --help $autorepos $repos" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -W "-p --push -a --agent -h --help $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
esac
;;
esac
;;
"artixpkg git clone"*)
case "${prev}" in
"--protocol")
COMPREPLY=($(compgen -W "https" -- ${cur}))
;;
"-t"|"--team")
COMPREPLY=($(compgen -W "$teams" -- ${cur}))
;;
"-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-s"|"--search"|"-j"|"--jobs")
# these flags expect a parameter
COMPREPLY=()
;;
*)
COMPREPLY=($(compgen -W "-m --maintainer --protocol -s --search -t --team -j --jobs --all -h --help $(_artixpkg_remotepkgbase ${cur})" -- ${cur}))
;;
esac
;;
"artixpkg git config"*)
case "${prev}" in
"--protocol")
COMPREPLY=($(compgen -W "https" -- ${cur}))
;;
"-j"|"--jobs")
# these flags expect a parameter
COMPREPLY=()
;;
*)
COMPREPLY=($(compgen -W "--protocol -j --jobs -h --help $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
"artixpkg git create"*)
case "${prev}" in
"-t"|"--team")
COMPREPLY=($(compgen -W "$teams" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -W "-c --clone -t --team -h --help" -- ${cur}))
;;
esac
;;
"artixpkg git pull"*)
case "${prev}" in
"-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-t"|"--topic"|"-j"|"--jobs")
# these flags expect a parameter
COMPREPLY=()
;;
*)
case "${comps_all}" in
*--all*)
COMPREPLY=($(compgen -W "-m --maintainer -t --topic -j --jobs -h --help" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -W "-m --maintainer -t --topic -j --jobs --all -h --help $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
esac
;;
"artixpkg git push"*)
case "${prev}" in
"-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-t"|"--topic")
# this flag expects a parameter
COMPREPLY=()
;;
*)
COMPREPLY=($(compgen -W "-m --maintainer -t --topic -h --help $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
"artixpkg admin maintainer"*)
case "${comp_cword_all}" in
3)
COMPREPLY=($(compgen -W "-a --adopt -o --orphan -h --help" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -W "-h --help $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
"artixpkg admin query"*)
case "${prev}" in
"-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-t"|"--topic")
# this flag expects a parameter
COMPREPLY=()
;;
*)
COMPREPLY=($(compgen -W "-m --maintainer -t --topic -h --help $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
"artixpkg admin team"*)
case "${prev}" in
"-a"|"--add"|"-r"|"--remove")
COMPREPLY=($(compgen -W "$teams" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -W "-a --add -c --check -l --list -r --remove -h --help $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
"artixpkg admin topic"*)
case "${prev}" in
"-a"|"--add"|"-r"|"--remove"|"-j"|"--jobs")
# this flag expects a parameter
COMPREPLY=()
;;
*)
COMPREPLY=($(compgen -W "-a --add -r --remove -d --delete -j --jobs -h --help $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
"artixpkg admin transfer"*)
COMPREPLY=($(compgen -W "-h --help $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;
esac
}
complete -F _artixpkg_completion artixpkg

View File

@@ -1,205 +0,0 @@
#compdef artixpkg
local -a addcmd admincmd cicmd clonecmd configcmd createcmd gitcmd importcmd \
initialcmd maintainercmd movecmd querycmd pullcmd pushcmd removecmd \
repocmd showcmd teamcmd topiccmd transfercmd versioncmd
_regex_words maintainer '' \
'-a' \
'--adopt' \
'-h' \
'--help' \
'-o' \
'--orphan'
maintainercmd=("$reply[@]")
_regex_words query '' \
'-h' \
'--help' \
'-m' \
'-t'
querycmd=("$reply[@]")
_regex_words team '' \
'-a' \
'--add' \
'-c' \
'--check' \
'-h' \
'--help' \
'-r' \
'--remove'
teamcmd=("$reply[@]")
_regex_words topic '' \
'-a' \
'--add' \
'-d' \
'--delete' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-r' \
'--remove'
topiccmd=("$reply[@]")
_regex_words transfer '' \
'-h' \
'--help'
transfercmd=("$reply[@]")
_regex_words admin '' \
'-h:Help text' \
'--help:Help text' \
'maintainer:Manage repo maintainer:$maintainercmd' \
'query:Query maintainers and topics:$querycmd' \
'team:Manage repo team:$teamcmd' \
'topic:Manage topics:$topiccmd' \
'transfer:Transfer obsolete repositories to landfill:$transfercmd'
admincmd=("$reply[@]")
_regex_words ci '' \
'-a' \
'--agent' \
'-h' \
'--help'
cicmd=("$reply[@]")
_regex_words clone '' \
'-a' \
'--agent' \
'--all' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-m' \
'--maintainer' \
'--protocol' \
'-s' \
'--search' \
'-t' \
'--team'
clonecmd=("$reply[@]")
_regex_words config '' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'--protocol'
configcmd=("$reply[@]")
_regex_words create '' \
'-a' \
'--agent' \
'-c' \
'--create' \
'-h' \
'--help' \
'-t' \
'--team'
createcmd=("$reply[@]")
_regex_words pull '' \
'--all' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-m' \
'--maintainer' \
'-t' \
'--topic'
pullcmd=("$reply[@]")
_regex_words push '' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-m' \
'--maintainer' \
'-t' \
'--topic'
pushcmd=("$reply[@]")
_regex_words git '' \
'ci:Configure CI agent:$cicmd' \
'clone:Clone a package:$clonecmd' \
'config:Configure a clone:$configcmd' \
'create:Create a new gitea package repository:$createcmd' \
'-h:Help text' \
'--help:Help text' \
'pull:Pull a package repository:$pullcmd' \
'push:Push a package repository:$pushcmd'
gitcmd=("$reply[@]")
_regex_words add '' \
'-h' \
'--help' \
'-n' \
'--nocheck' \
'-p' \
'--push' \
'-r' \
'--rebuild'
addcmd=("$reply[@]")
_regex_words import '' \
'--del' \
'-h' \
'--help' \
'--tag'
importcmd=("$reply[@]")
_regex_words move '' \
'-h' \
'--help' \
'-p' \
'--push'
movecmd=("$reply[@]")
_regex_words remove '' \
'-h' \
'--help' \
'-p' \
'--push'
removecmd=("$reply[@]")
_regex_words show '' \
'-b' \
'--base' \
'-h' \
'--help' \
'-p' \
'--pkgs'
showcmd=("$reply[@]")
_regex_words repo '' \
'add:Add pkgbase to repo:$addcmd' \
'-h:Help text' \
'--help:Help text' \
'import:Import latest tag from arch upstream:$importcmd' \
'move:Move pkgbase between repos:$movecmd' \
'remove:Remove pkgbase from repo:$removecmd' \
'show:Show pkgbase repo db:$showcmd'
repocmd=("$reply[@]")
_regex_words version '' \
'-h' \
'--help'
versioncmd=("$reply[@]")
_regex_words initial '' \
'admin:Manage topics:$admincmd' \
'git:Manage git:$gitcmd' \
'-h:Help text' \
'--help:Help text' \
'repo:Pacman database modification:$repocmd' \
'version:Show artixpkg version:$versioncmd'
initialcmd=("$reply[@]")
_regex_arguments _artixpkg /$'[^\0]##\0'/ "${initialcmd[@]}"
_artixpkg "$@"

View File

@@ -0,0 +1,17 @@
################ install ################
# start services
# bluetoothd, cupsd, DM are added to the pkglist dynamicly
# metalog or syslog-ng is added to the pkglist dynamicly
# connmand or NetworkManager is added to the pkglist dynamicly
# only added if in array, these pkgs have no list entry
SERVICES=('acpid' 'bluetoothd' 'cronie' 'cupsd' 'metalog' 'connmand')
################# live-session #################
# default value
# PASSWORD="artix"
# Set to false to disable autologin in the live session
AUTOLOGIN="false"

View File

@@ -1,30 +0,0 @@
---
# required
live-session:
user: "artix"
password: "artix"
autologin: true
use-xlibre: false
services: []
user-services: []
# required
rootfs:
packages: []
packages-init:
dinit: []
openrc: []
runit: []
s6: []
# optional
livefs:
packages: []
# optional
packages-init:
dinit: []
openrc: []
runit: []
s6: []

View File

@@ -88,7 +88,7 @@ make_rootfs() {
msg "Prepare [Base installation] (rootfs)" msg "Prepare [Base installation] (rootfs)"
local rootfs="${work_dir}/rootfs" local rootfs="${work_dir}/rootfs"
load_pkgs "rootfs" load_pkgs "${root_list}"
prepare_dir "${rootfs}" prepare_dir "${rootfs}"
@@ -100,9 +100,7 @@ make_rootfs() {
copy_overlay "${root_overlay}" "${rootfs}" copy_overlay "${root_overlay}" "${rootfs}"
if ! "${HAS_LIVE}"; then [[ -z ${live_list} ]] && configure_chroot "${rootfs}"
configure_chroot "${rootfs}"
fi
clean_up_chroot "${rootfs}" clean_up_chroot "${rootfs}"
@@ -117,7 +115,7 @@ make_livefs() {
msg "Prepare [Live installation] (livefs)" msg "Prepare [Live installation] (livefs)"
local livefs="${work_dir}/livefs" local livefs="${work_dir}/livefs"
load_pkgs "livefs" load_pkgs "${live_list}"
prepare_dir "${livefs}" prepare_dir "${livefs}"
@@ -143,7 +141,7 @@ make_bootfs() {
if [[ ! -e ${work_dir}/bootfs.lock ]]; then if [[ ! -e ${work_dir}/bootfs.lock ]]; then
msg "Prepare [/iso/boot]" msg "Prepare [/iso/boot]"
load_pkgs "bootfs" load_pkgs "${common_dir}/Packages-boot"
prepare_dir "${iso_root}/boot" prepare_dir "${iso_root}/boot"
@@ -173,9 +171,7 @@ make_grub(){
msg "Prepare [/iso/boot/grub]" msg "Prepare [/iso/boot/grub]"
local layer=${work_dir}/rootfs local layer=${work_dir}/rootfs
if "${HAS_LIVE}"; then [[ -n ${live_list} ]] && layer=${work_dir}/livefs
layer=${work_dir}/livefs
fi
prepare_grub "${work_dir}/rootfs" "$layer" prepare_grub "${work_dir}/rootfs" "$layer"
@@ -284,7 +280,7 @@ mk_boot(){
mk_chroots(){ mk_chroots(){
run_safe "make_rootfs" run_safe "make_rootfs"
if "${HAS_LIVE}"; then if [[ -n ${live_list} ]]; then
run_safe "make_livefs" run_safe "make_livefs"
fi fi
} }

View File

@@ -8,39 +8,25 @@ yaml_array() {
local array yaml local array yaml
for entry in "$@"; do for entry in "$@"; do
yaml="{name: ${entry}, action: enable}" yaml="{name: ${entry}, action: enable, alias: add, target: default}"
array="${array:-}${array:+,} ${yaml}" array="${array:-}${array:+,} ${yaml}"
done done
printf "%s\n" "[${array}]" printf "%s\n" "[${array}]"
} }
configure_calamares(){ configure_calamares(){
for config in online offline; do local mods="$1/etc/calamares/modules"
local mods="$1/etc/calamares-$config/modules" if [[ -d "$mods" ]];then
if [[ -d "$mods" ]];then msg2 "Configuring: Calamares"
msg2 "Configuring: Calamares %s" "$config"
if [[ -f "$mods"/services-artix.conf ]]; then if [[ -f "$mods"/services-artix.conf ]]; then
local svc usvc local svc init
svc=$(yaml_array "${SERVICES[@]}") \ init="${INITSYS}" svc=$(yaml_array "${SERVICES[@]}") \
yq -P 'with(.; yq -P 'with(.;
.command = "artix-service" | .manager = env(init) |
.services = env(svc) )' \ .services = env(svc) )' \
-i "$mods"/services-artix.conf -i "$mods"/services-artix.conf
fi
if [[ -f "$mods"/postcfg.conf ]]; then
local usvc initsys
initsys="${INITSYS}" \
usvc=$(yaml_array "${USER_SERVICES[@]}") \
yq -P 'with(.;
.initsys = env(initsys) |
.user-services = env(usvc) )' \
-i "$mods"/postcfg.conf
fi
fi fi
done
if [[ -d "$1"/etc/calamares-offline ]]; then
ln -sf calamares-offline "$1"/etc/calamares
fi fi
} }

View File

@@ -4,21 +4,9 @@
#{{{ session #{{{ session
configure_user(){
local -r grps="users,lp,video,network,storage,wheel,audio,power,log,optical,network,scanner"
chroot "$1" useradd -m -G "$grps" -s /bin/bash "${LIVEUSER}"
echo "${LIVEUSER}:${PASSWORD}" | chroot "$1" chpasswd
echo "root:${PASSWORD}" | chroot "$1" chpasswd
}
configure_services(){ configure_services(){
local mnt="$1" local mnt="$1"
add_svc_"${INITSYS}" "$mnt" add_svc_"${INITSYS}" "$mnt" "${SERVICES[*]}"
if [[ "${INITSYS}" == "openrc" ]] || [[ "${INITSYS}" == "dinit" ]]; then
add_user_svc_"${INITSYS}" "$mnt"
fi
} }
@@ -26,14 +14,13 @@ write_live_session_conf(){
local conf='' local conf=''
conf+=$(printf '%s\n' '# live session configuration') conf+=$(printf '%s\n' '# live session configuration')
conf+=$(printf "\nAUTOLOGIN=%s\n" "${AUTOLOGIN}") conf+=$(printf "\nAUTOLOGIN=%s\n" "${AUTOLOGIN}")
conf+=$(printf "\nLIVEUSER=%s\n" "${LIVEUSER}") conf+=$(printf "\nPASSWORD=%s\n" "${PASSWORD}")
printf '%s' "$conf" printf '%s' "$conf"
} }
configure_chroot(){ configure_chroot(){
local fs="$1" local fs="$1"
msg "Configuring [%s]" "${fs##*/}" msg "Configuring [%s]" "${fs##*/}"
configure_user "$fs"
configure_services "$fs" configure_services "$fs"
configure_calamares "$fs" configure_calamares "$fs"
[[ ! -d "$fs/etc/artools" ]] && mkdir -p "$fs/etc/artools" [[ ! -d "$fs/etc/artools" ]] && mkdir -p "$fs/etc/artools"

View File

@@ -7,7 +7,6 @@
show_profile(){ show_profile(){
msg2 "iso_file: %s" "${iso_file}" msg2 "iso_file: %s" "${iso_file}"
msg2 "AUTOLOGIN: %s" "${AUTOLOGIN}" msg2 "AUTOLOGIN: %s" "${AUTOLOGIN}"
msg2 "LIVEUSER: %s" "${LIVEUSER}"
msg2 "PASSWORD: %s" "${PASSWORD}" msg2 "PASSWORD: %s" "${PASSWORD}"
msg2 "SERVICES: %s" "${SERVICES[*]}" msg2 "SERVICES: %s" "${SERVICES[*]}"
} }
@@ -16,121 +15,79 @@ load_profile(){
local profile_dir="${DATADIR}/iso-profiles" local profile_dir="${DATADIR}/iso-profiles"
[[ -d "${WORKSPACE_DIR}"/iso-profiles ]] && profile_dir="${WORKSPACE_DIR}"/iso-profiles [[ -d "${WORKSPACE_DIR}"/iso-profiles ]] && profile_dir="${WORKSPACE_DIR}"/iso-profiles
root_list="$profile_dir/${profile}/Packages-Root"
root_overlay="$profile_dir/${profile}/root-overlay" root_overlay="$profile_dir/${profile}/root-overlay"
[[ -f "$profile_dir/${profile}/Packages-Live" ]] && live_list="$profile_dir/${profile}/Packages-Live"
[[ -d "$profile_dir/${profile}/live-overlay" ]] && live_overlay="$profile_dir/${profile}/live-overlay" [[ -d "$profile_dir/${profile}/live-overlay" ]] && live_overlay="$profile_dir/${profile}/live-overlay"
common_dir="${DATADIR}/iso-profiles/common" common_dir="${DATADIR}/iso-profiles/common"
[[ -d "$profile_dir"/common ]] && common_dir="${profile_dir}"/common [[ -d "$profile_dir"/common ]] && common_dir="${profile_dir}"/common
profile_yaml=$profile_dir/${profile}/profile.yaml [[ -f $profile_dir/${profile}/profile.conf ]] || return 1
common_yaml="${common_dir}/common.yaml" # shellcheck source=contrib/iso/profile.conf.example
[[ -r "$profile_dir/${profile}"/profile.conf ]] && . "$profile_dir/${profile}"/profile.conf
[[ -f $profile_yaml ]] || return 1 AUTOLOGIN=${AUTOLOGIN:-true}
LIVEUSER=$(yq -P '.live-session.user' "$profile_yaml") PASSWORD=${PASSWORD:-'artix'}
PASSWORD=$(yq -P '.live-session.password' "$profile_yaml") if [[ -z "${SERVICES[*]}" ]];then
SERVICES=('acpid' 'bluetoothd' 'cronie' 'cupsd' 'syslog-ng' 'connmand')
AUTOLOGIN=$(yq -P '.live-session.autologin' "$profile_yaml") fi
USE_XLIBRE=$(yq -P '.live-session.use-xlibre' "$profile_yaml")
mapfile -t SERVICES < <(yq -P '.live-session.services[]' "$profile_yaml")
mapfile -t USER_SERVICES < <(yq -P '.live-session.user-services[]' "$profile_yaml")
HAS_LIVE=$(yq -P '. | has("livefs")' "$profile_yaml")
HAS_LIVE_INIT=$(yq -P '.livefs | has("packages-init")' "$profile_yaml")
return 0 return 0
} }
load_pkgs(){ read_from_list() {
local list="$1" local list="$1"
local _space="s| ||g"
#local _clean=':a;N;$!ba;s/\n/ /g'
local _clean='/^$/d'
local _com_rm="s|#.*||g"
local _init="s|@initsys@|${INITSYS}|g"
local common_base mapfile -t pkgs < <(sed "$_com_rm" "$list" \
local common_apps | sed "$_space" \
local common_misc | sed "$_init" \
local common_xorg | sed "$_clean" | sort -u)
local common_boot }
local common_init
local packages_root
local packages_live
local packages_root_init
local packages_live_init
local common_key_init=".packages-init.${INITSYS}[]"
local root_key_init=".rootfs.packages-init.${INITSYS}[]"
local live_key_init=".livefs.packages-init.${INITSYS}[]"
load_pkgs(){
local pkglist="$1"
packages=() packages=()
case "$list" in if [[ "${pkglist##*/}" == "Packages-Root" ]]; then
rootfs) for l in base apps "${INITSYS}"; do
msg2 "Loading Packages: [%s] ..." "common.packages-base" msg2 "Loading Packages: [%s] ..." "Packages-${l}"
mapfile -t common_base < <(yq -P '.packages-base[]' "$common_yaml") read_from_list "${common_dir}/Packages-${l}"
packages+=("${pkgs[@]}")
msg2 "Loading Packages: [%s] ..." "common.packages-init.${INITSYS}" done
mapfile -t common_init < <(common_key_init="$common_key_init" yq -P 'eval(strenv(common_key_init))' "$common_yaml")
msg2 "Loading Packages: [%s] ..." "common.packages-apps" if [[ -n "${live_list}" ]]; then
mapfile -t common_apps < <(yq -P '.packages-apps[]' "$common_yaml") msg2 "Loading Packages: [Packages-xorg] ..."
read_from_list "${common_dir}/Packages-xorg"
packages+=("${pkgs[@]}")
fi
if "${HAS_LIVE}"; then for svc in "${SERVICES[@]}"; do
if ${USE_XLIBRE}; then case "$svc" in
msg2 "Loading Packages: [%s] ..." "common.packages-xlibre" sddm|gdm|lightdm|mdm|greetd|lxdm|xdm)
mapfile -t common_xorg < <(yq -P '.packages-xlibre[]' "$common_yaml") packages+=("$svc-${INITSYS}"); display_manager="$svc" ;;
else NetworkManager) packages+=("networkmanager-${INITSYS}") ;;
msg2 "Loading Packages: [%s] ..." "common.packages-xorg" connmand) packages+=("connman-${INITSYS}") ;;
mapfile -t common_xorg < <(yq -P '.packages-xorg[]' "$common_yaml") cupsd) packages+=("cups-${INITSYS}") ;;
fi bluetoothd) packages+=("bluez-${INITSYS}") ;;
syslog-ng|metalog) packages+=("$svc-${INITSYS}") ;;
esac
done
msg2 "Loading Packages: [%s] ..." "common.packages-misc" fi
mapfile -t common_misc < <(yq -P '.packages-misc[]' "$common_yaml") msg2 "Loading Packages: [%s] ..." "${pkglist##*/}"
fi read_from_list "${pkglist}"
packages+=("${pkgs[@]}")
msg2 "Loading Packages: [%s] ..." "rootfs.packages"
mapfile -t packages_root < <(yq -P '.rootfs.packages[]' "$profile_yaml")
msg2 "Loading Packages: [%s] ..." "rootfs.packages-init.${INITSYS}"
mapfile -t packages_root_init < <(root_key_init="$root_key_init" yq -P 'eval(strenv(root_key_init))' "$profile_yaml")
packages+=(
"${common_base[@]}"
"${common_init[@]}"
"${common_apps[@]}"
"${packages_root[@]}"
"${packages_root_init[@]}"
"${common_xorg[@]}"
"${common_misc[@]}"
)
;;
livefs)
msg2 "Loading Packages: [%s] ..." "livefs.packages"
mapfile -t packages_live < <(yq -P '.livefs.packages[]' "$profile_yaml")
if "${HAS_LIVE_INIT}"; then
msg2 "Loading Packages: [%s] ..." "livefs.packages-init.${INITSYS}"
mapfile -t packages_live_init < <(live_key_init="$live_key_init" yq -P 'eval(strenv(live_key_init))' "$profile_yaml")
fi
packages+=(
"${packages_live[@]}"
"${packages_live_init[@]}"
)
;;
bootfs)
msg2 "Loading Packages: [%s] ..." "common.packages-boot"
mapfile -t common_boot < <(yq -P '.packages-boot[]' "$common_yaml")
packages+=(
"${common_boot[@]}"
)
;;
esac
} }
#}}} #}}}

View File

@@ -5,68 +5,35 @@
#{{{ services #{{{ services
add_svc_openrc(){ add_svc_openrc(){
local mnt="$1" rlvl="${2:-default}" local mnt="$1" names="$2" rlvl="${3:-default}"
for svc in "${SERVICES[@]}"; do for svc in $names; do
if [[ -f $mnt/etc/init.d/$svc ]];then if [[ -f $mnt/etc/init.d/$svc ]];then
msg2 "Setting %s: [%s]" "${INITSYS}" "$svc" msg2 "Setting %s: [%s]" "${INITSYS}" "$svc"
chroot "$mnt" rc-update add "$svc" "$rlvl" &>/dev/null chroot "$mnt" rc-update add "$svc" "$rlvl" &>/dev/null
else
warning "Service %s not found. Skipping." "$svc"
fi
done
}
add_user_svc_openrc(){
local mnt="$1" rlvl="${2:-default}"
for svc in "${USER_SERVICES[@]}"; do
if [[ -f "$mnt"/etc/user/init.d/"$svc" ]];then
msg2 "Setting user %s: [%s]" "${INITSYS}" "$svc"
local rc=".config/rc/runlevels/default"
chroot "$mnt" mkdir -p /home/"${LIVEUSER}/$rc"
chroot "$mnt" ln -s /etc/user/init.d/"$svc" /home/"${LIVEUSER}/$rc/$svc"
chroot "$mnt" chown -R "${LIVEUSER}:${LIVEUSER}" /home/"${LIVEUSER}"/.config/rc
else
warning "Service %s not found. Skipping." "$svc"
fi fi
done done
} }
add_svc_runit(){ add_svc_runit(){
local mnt="$1" rlvl="${2:-default}" local mnt="$1" names="$2" rlvl="${3:-default}"
for svc in "${SERVICES[@]}"; do for svc in $names; do
if [[ -d $mnt/etc/runit/sv/$svc ]]; then if [[ -d $mnt/etc/runit/sv/$svc ]]; then
msg2 "Setting %s: [%s]" "${INITSYS}" "$svc" msg2 "Setting %s: [%s]" "${INITSYS}" "$svc"
chroot "$mnt" ln -s /etc/runit/sv/"$svc" /etc/runit/runsvdir/"$rlvl" &>/dev/null chroot "$mnt" ln -s /etc/runit/sv/"$svc" /etc/runit/runsvdir/"$rlvl" &>/dev/null
else
warning "Service %s not found. Skipping." "$svc"
fi fi
done done
} }
add_svc_s6(){ add_svc_s6(){
local mnt="$1" rlvl="${2:-default}" dep local mnt="$1" names="$2" rlvl="${3:-default}" dep
local display_manager
local supported_dms=(sddm gdm lightdm mdm greetd lxdm xdm)
for dm in "${supported_dms[@]}"; do
if in_array "$dm" "${SERVICES[@]}"; then
display_manager="$dm"
fi
done
dep="$mnt"/etc/s6/sv/"$display_manager"-srv/dependencies.d dep="$mnt"/etc/s6/sv/"$display_manager"-srv/dependencies.d
for svc in $names; do
for svc in "${SERVICES[@]}"; do
msg2 "Setting %s: [%s]" "${INITSYS}" "$svc" msg2 "Setting %s: [%s]" "${INITSYS}" "$svc"
if [[ -d "$mnt"/etc/s6/sv/"$svc" ]] || [[ -d "$mnt"/etc/s6/sv/"$svc"-srv ]]; then chroot "$mnt" s6-service add "$rlvl" "$svc"
chroot "$mnt" s6-service add "$rlvl" "$svc" if [[ "$svc" == "$display_manager" ]]; then
if [[ "$svc" == "$display_manager" ]]; then if [[ -d "$dep" ]]; then
if [[ -d "$dep" ]]; then touch "$dep"/artix-live
touch "$dep"/artix-live
fi
fi fi
else
warning "Service %s not found. Skipping." "$svc"
fi fi
done done
@@ -80,29 +47,22 @@ add_svc_s6(){
chroot "$mnt" cp -a "$src"/bin /usr chroot "$mnt" cp -a "$src"/bin /usr
} }
add_svc_dinit(){ add_svc_suite66(){
local mnt="$1" local mnt="$1" names="$2"
for svc in "${SERVICES[@]}"; do for svc in $names; do
if [[ -f "$mnt"/etc/dinit.d/"$svc" ]]; then if [[ -f "$mnt"/etc/66/service/"$svc" ]]; then
msg2 "Setting %s: [%s]" "${INITSYS}" "$svc" msg2 "Setting %s: [%s]" "${INITSYS}" "$svc"
chroot "$mnt" dinitctl enable -o "$svc" &>/dev/null chroot "$mnt" 66-enable -t default "$svc" &>/dev/null
else
warning "Service %s not found. Skipping." "$svc"
fi fi
done done
} }
add_user_svc_dinit(){ add_svc_dinit(){
local mnt="$1" local mnt="$1" names="$2"
for svc in "${USER_SERVICES[@]}"; do for svc in $names; do
if [[ -f "$mnt"/etc/dinit.d/user/"$svc" ]]; then if [[ -d $mnt/etc/dinit.d/boot.d ]]; then
msg2 "Setting user %s: [%s]" "${INITSYS}" "$svc" msg2 "Setting %s: [%s]" "${INITSYS}" "$svc"
local usr_sv="/home/${LIVEUSER}/.config/dinit.d" chroot "$mnt" ln -s ../"$svc" /etc/dinit.d/boot.d/"$svc" &>/dev/null
chroot "$mnt" mkdir -p "$usr_sv"/boot.d
chroot "$mnt" ln -s /etc/dinit.d/user/"$svc" "$usr_sv"/boot.d/"$svc"
chroot "$mnt" chown -R "${LIVEUSER}:${LIVEUSER}" "$usr_sv"
else
warning "Service %s not found. Skipping." "$svc"
fi fi
done done
} }

View File

@@ -5,10 +5,6 @@
[[ -z ${ARTOOLS_INCLUDE_ADMIN_SH:-} ]] || return 0 [[ -z ${ARTOOLS_INCLUDE_ADMIN_SH:-} ]] || return 0
ARTOOLS_INCLUDE_ADMIN_SH=1 ARTOOLS_INCLUDE_ADMIN_SH=1
# shellcheck source=src/lib/pkg/db/db.sh
source "${LIBDIR}"/pkg/db/db.sh
set -e set -e
artixpkg_admin_usage() { artixpkg_admin_usage() {
@@ -17,21 +13,17 @@ artixpkg_admin_usage() {
Usage: ${COMMAND} [COMMAND] [OPTIONS] Usage: ${COMMAND} [COMMAND] [OPTIONS]
COMMANDS COMMANDS
maintainer Manage repo maintainer
query Query maintainers and topics
team Manage repo team
topic Manage topics
transfer Transfer obsolete repository to landfill transfer Transfer obsolete repository to landfill
query Query maintainers and topics
topic Manage topics
OPTIONS OPTIONS
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} transfer libfoo libbar $ ${COMMAND} transfer libfoo libbar
$ ${COMMAND} query --topic mytopic $ ${COMMAND} query --maintainer tux
$ ${COMMAND} topic --add mytopic libfoo $ ${COMMAND} query --topic kf5
$ ${COMMAND} team --add ${ARTIX_TEAMS[3]} libfoo
$ ${COMMAND} maintainer --adopt libfoo libbar
_EOF_ _EOF_
} }
@@ -48,31 +40,6 @@ artixpkg_admin() {
artixpkg_admin_usage artixpkg_admin_usage
exit 0 exit 0
;; ;;
query)
_ARTOOLS_COMMAND+=" $1"
shift
# shellcheck source=src/lib/pkg/admin/query.sh
source "${LIBDIR}"/pkg/admin/query.sh
artixpkg_admin_query "$@"
exit 0
;;
team)
_ARTOOLS_COMMAND+=" $1"
shift
# shellcheck source=src/lib/pkg/admin/team.sh
source "${LIBDIR}"/pkg/admin/team.sh
artixpkg_admin_team "$@"
exit 0
;;
topic)
_ARTOOLS_COMMAND+=" $1"
shift
# shellcheck source=src/lib/pkg/admin/query.sh
source "${LIBDIR}"/pkg/admin/topic.sh
artixpkg_admin_topic "$@"
exit 0
;;
transfer) transfer)
_ARTOOLS_COMMAND+=" $1" _ARTOOLS_COMMAND+=" $1"
shift shift
@@ -81,12 +48,20 @@ artixpkg_admin() {
artixpkg_admin_transfer "$@" artixpkg_admin_transfer "$@"
exit 0 exit 0
;; ;;
maintainer) query)
_ARTOOLS_COMMAND+=" $1" _ARTOOLS_COMMAND+=" $1"
shift shift
# shellcheck source=src/lib/pkg/admin/maintainer.sh # shellcheck source=src/lib/pkg/admin/query.sh
source "${LIBDIR}"/pkg/admin/maintainer.sh source "${LIBDIR}"/pkg/admin/query.sh
artixpkg_admin_maintainer "$@" artixpkg_admin_query "$@"
exit 0
;;
topic)
_ARTOOLS_COMMAND+=" $1"
shift
# shellcheck source=src/lib/pkg/admin/query.sh
source "${LIBDIR}"/pkg/admin/topic.sh
artixpkg_admin_topic "$@"
exit 0 exit 0
;; ;;
-*) -*)

View File

@@ -1,139 +0,0 @@
#!/bin/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
[[ -z ${ARTOOLS_INCLUDE_ADMIN_MAINTAINER_SH:-} ]] || return 0
ARTOOLS_INCLUDE_ADMIN_MAINTAINER_SH=1
set -e
artixpkg_admin_maintainer_usage() {
local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
cat <<- _EOF_
Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS
-a, --adopt Adopt repo
-o, --orphan Orphan repo
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} --adopt libfoo
$ ${COMMAND} --orphan libfoo libbar
_EOF_
}
artixpkg_admin_maintainer() {
if (( $# < 1 )); then
artixpkg_admin_maintainer_usage
exit 0
fi
# options
local pkgbases=()
local pkgbase
local ADOPT=0
local ORPHAN=0
local packager_name
local maintainer
local -r orphan="orphan"
local RUNCMD=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
while (( $# )); do
case $1 in
-h|--help)
artixpkg_admin_maintainer_usage
exit 0
;;
-a|--adopt)
ADOPT=1
RUNCMD+=" $1"
shift
;;
-o|--orphan)
ORPHAN=1
RUNCMD+=" $1"
shift
;;
--)
shift
break
;;
-*)
die "invalid argument: %s" "$1"
;;
*)
break
;;
esac
done
pkgbases+=("$@")
# shellcheck source=src/lib/pkg/util/packager.sh
source "${LIBDIR}"/pkg/util/packager.sh
if [[ -n ${PACKAGER} ]]; then
if ! packager_name=$(get_packager_name "${PACKAGER}") || \
! packager_email=$(get_packager_email "${PACKAGER}"); then
die "invalid PACKAGER format '${PACKAGER}' in makepkg.conf"
fi
if ! is_packager_name_valid "${packager_name}"; then
die "invalid PACKAGER '${PACKAGER}' in makepkg.conf"
fi
if is_packager_email_official "${packager_email}"; then
maintainer="maintainer-${packager_name}"
fi
fi
if [[ -n ${GIT_TOKEN} ]]; then
# parallelization
if [[ ${jobs} != 1 ]] && (( ${#pkgbases[@]} > 1 )); then
# force colors in parallel if parent process is colorized
if [[ -n ${BOLD} ]]; then
export ARTOOLS_COLOR=always
fi
if ! parallel --bar --jobs "${jobs}" "${RUNCMD}" ::: "${pkgbases[@]}"; then
die 'Failed to manange some packages, please check the output'
exit 1
fi
exit 0
fi
for pkgbase in "${pkgbases[@]}"; do
local gitname
gitname=$(get_compliant_name "${pkgbase}")
if (( ADOPT )); then
if ! add_topic "${gitname}" "$maintainer"; then
warning "failed to add topic: $maintainer"
fi
if ! remove_topic "${gitname}" "$orphan"; then
warning "failed to remove topic: $orphan"
fi
fi
if (( ORPHAN )); then
if ! add_topic "${gitname}" "$orphan"; then
warning "failed to add topic: $orphan"
fi
if ! remove_topic "${gitname}" "$maintainer"; then
warning "failed to remove topic: $maintainer"
fi
fi
done
fi
}

View File

@@ -14,8 +14,8 @@ artixpkg_admin_query_usage() {
Usage: ${COMMAND} [OPTIONS] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS OPTIONS
-m, --maintainer NAME Query for packages of the named maintainer -m, --maintainer=NAME Query for packages of the named maintainer
-t, --topic NAME Query for packages of the named topic -t, --topic=NAME Query for packages of the named topic
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
@@ -47,11 +47,19 @@ artixpkg_admin_query() {
MAINTAINER="$2" MAINTAINER="$2"
shift 2 shift 2
;; ;;
--maintainer=*)
MAINTAINER="${1#*=}"
shift
;;
-t|--topic) -t|--topic)
(( $# <= 1 )) && die "missing argument for %s" "$1" (( $# <= 1 )) && die "missing argument for %s" "$1"
TOPIC="$2" TOPIC="$2"
shift 2 shift 2
;; ;;
--topic=*)
TOPIC="${1#*=}"
shift
;;
--) --)
shift shift
break break

View File

@@ -1,154 +0,0 @@
#!/bin/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
[[ -z ${ARTOOLS_INCLUDE_ADMIN_TEAM_SH:-} ]] || return 0
ARTOOLS_INCLUDE_ADMIN_TEAM_SH=1
set -e
artixpkg_admin_team_usage() {
local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
cat <<- _EOF_
Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS
-c, --check Check if team is assigned
-l, --list List repo teams
-a, --add NAME Add team to repo
Possible values: (${ARTIX_TEAMS[@]})
-r, --remove NAME Remove team from repo
Possible values: (${ARTIX_TEAMS[@]})
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} --check libfoo
$ ${COMMAND} --list libfoo
$ ${COMMAND} --add ${ARTIX_TEAMS[1]} libfoo
$ ${COMMAND} --remove ${ARTIX_TEAMS[3]} libfoo
_EOF_
}
artixpkg_admin_team() {
if (( $# < 1 )); then
artixpkg_admin_team_usage
exit 0
fi
# options
local CHECK=0
local LIST=0
local TEAM_ADD
local TEAM_RM
local pkgbases=()
local pkgbase
while (( $# )); do
case $1 in
-h|--help)
artixpkg_admin_team_usage
exit 0
;;
-a|--add)
(( $# <= 1 )) && die "missing argument for %s" "$1"
TEAM_ADD="$2"
shift 2
;;
-r|--remove)
(( $# <= 1 )) && die "missing argument for %s" "$1"
TEAM_RM="$2"
shift 2
;;
-c|--check)
CHECK=1
shift
;;
-l|--list)
LIST=1
shift
;;
--)
shift
break
;;
-*)
die "invalid argument: %s" "$1"
;;
*)
break
;;
esac
done
pkgbases+=("$@")
if [[ -n ${GIT_TOKEN} ]]; then
for pkgbase in "${pkgbases[@]}"; do
if [[ -d "${pkgbase}" ]];then
if [[ ! -d "${pkgbase}/.git" ]]; then
error "Not a Git repository: ${pkgbase}"
continue
fi
( cd "${pkgbase}" || return
local gitname
gitname=$(get_compliant_name "${pkgbase}")
if (( CHECK )); then
local team
team=$(team_from_yaml)
res=$(check_repo_team "${gitname}" "${team}" | yq -rP '.name')
if [[ "$res" == "null" ]]; then
error "[%s] does not have team (%s) assigned" "$pkgbase" "${team}"
else
msg "[%s] has team (%s) assigned" "$pkgbase" "${team}"
fi
fi
if (( LIST )); then
list_repo_teams "${gitname}" | yq -rP '.[] | .name'
fi
if [[ -n ${TEAM_ADD} ]]; then
if ! add_team_to_repo "${gitname}" "${TEAM_ADD}"; then
warning "failed to add team: ${TEAM_ADD}"
fi
if [[ "$(team_from_yaml)" != "${TEAM_ADD}" ]] \
|| [[ "$(team_from_yaml)" == "null" ]]; then
update_yaml_team "${TEAM_ADD}"
git add "${REPO_DB}"
git commit -m "Set team ${TEAM_ADD}"
fi
fi
if [[ -n ${TEAM_RM} ]]; then
if ! remove_team_from_repo "${gitname}" "${TEAM_RM}"; then
warning "failed to add team: ${TEAM_RM}"
fi
fi
msg "Querying ${pkgbase} ..."
if ! show_db; then
warning "Could not query ${REPO_DB}"
fi
)
fi
done
fi
}

View File

@@ -14,18 +14,16 @@ artixpkg_admin_topic_usage() {
Usage: ${COMMAND} [OPTIONS] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS OPTIONS
-a, --add NAME Add a topic to repo -a, --add Add a topic
-r, --remove NAME Remove a topic from repo -d, --del Delete a topic
-d, --delete Delete all topics from repo -j, --jobs N Run up to N jobs in parallel (default: $(nproc))
-j, --jobs N Run up to N jobs in parallel (default: $(nproc)) -h, --help Show this help text
-h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} --add mytopic libfoo $ ${COMMAND} --add mytopic libfoo
$ ${COMMAND} --remove mytopic libbar $ ${COMMAND} --del mytopic libbar
$ ${COMMAND} --add mytopic libfoo libbar $ ${COMMAND} --add mytopic libfoo libbar
$ ${COMMAND} --remove mytopic libfoo libbar $ ${COMMAND} --del mytopic libfoo libbar
$ ${COMMAND} --delete libfoo
_EOF_ _EOF_
} }
@@ -42,9 +40,8 @@ artixpkg_admin_topic() {
local pkgbase local pkgbase
local ADD_TOPIC local ADD_TOPIC
local RM_TOPIC local DEL_TOPIC
local ADD=0 local ADD=0
local RM=0
local DEL=0 local DEL=0
local jobs= local jobs=
jobs=$(nproc) jobs=$(nproc)
@@ -53,29 +50,36 @@ artixpkg_admin_topic() {
while (( $# )); do while (( $# )); do
case $1 in case $1 in
-h|--help)
artixpkg_admin_topic_usage
exit 0
;;
-a|--add) -a|--add)
(( $# <= 1 )) && die "missing argument for %s" "$1" (( $# <= 1 )) && die "missing argument for %s" "$1"
ADD_TOPIC="$2" ADD_TOPIC="$2"
ADD=1 ADD=1
RUNCMD+=" $1 ${ADD_TOPIC}" RUNCMD+=" -a ${ADD_TOPIC}"
shift 2 shift 2
;; ;;
-r|--remove) --add=*)
(( $# <= 1 )) && die "missing argument for %s" "$1" ADD_TOPIC="${1#*=}"
RM_TOPIC="$2" ADD=1
RM=1 RUNCMD+=" --add=${ADD_TOPIC}"
RUNCMD+=" $1 ${RM_TOPIC}"
shift 2
;;
-d|--delete)
DEL=1
RUNCMD+=" $1"
shift shift
;; ;;
-d|--del)
(( $# <= 1 )) && die "missing argument for %s" "$1"
DEL_TOPIC="$2"
DEL=1
RUNCMD+=" -d ${DEL_TOPIC}"
shift 2
;;
--del=*)
DEL_TOPIC="${1#*=}"
DEL=1
RUNCMD+=" --del=${DEL_TOPIC}"
shift
;;
-h|--help)
artixpkg_admin_topic_usage
exit 0
;;
-j|--jobs) -j|--jobs)
(( $# <= 1 )) && die "missing argument for %s" "$1" (( $# <= 1 )) && die "missing argument for %s" "$1"
jobs=$2 jobs=$2
@@ -111,25 +115,21 @@ artixpkg_admin_topic() {
fi fi
for pkgbase in "${pkgbases[@]}"; do for pkgbase in "${pkgbases[@]}"; do
local gitname
gitname=$(get_compliant_name "${pkgbase}")
# topics meta # topics meta
if (( ADD )); then if (( ADD )); then
local gitname
gitname=$(get_compliant_name "${pkgbase}")
if ! add_topic "${gitname}" "${ADD_TOPIC}"; then if ! add_topic "${gitname}" "${ADD_TOPIC}"; then
warning "failed to add topic: ${ADD_TOPIC}" warning "failed to add the topic: ${ADD_TOPIC}"
fi
fi
if (( RM )); then
if ! remove_topic "${gitname}" "${RM_TOPIC}"; then
warning "failed to remove topic: ${RM_TOPIC}"
fi fi
fi fi
if (( DEL )); then if (( DEL )); then
if ! remove_all_topics "${gitname}" "${GIT_ORG}"; then local gitname
warning "failed to delete all topics: ${gitname}" gitname=$(get_compliant_name "${pkgbase}")
if ! remove_topic "${gitname}" "${DEL_TOPIC}"; then
warning "failed to delete the topic: ${DEL_TOPIC}"
fi fi
fi fi

View File

@@ -33,6 +33,7 @@ artixpkg_admin_transfer() {
# options # options
local pkgbases=() local pkgbases=()
local pkgbase local pkgbase
local waste_org="landfill"
local command=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}} local command=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
@@ -59,12 +60,7 @@ artixpkg_admin_transfer() {
if [[ -n ${GIT_TOKEN} ]]; then if [[ -n ${GIT_TOKEN} ]]; then
for pkgbase in "${pkgbases[@]}"; do for pkgbase in "${pkgbases[@]}"; do
local gitname transfer_repo "${pkgbase}" "${waste_org}"
gitname=$(get_compliant_name "${pkgbase}")
transfer_repo "${gitname}" "${GIT_ORG_ARCHIVE}"
archive_repo "${gitname}" "${GIT_ORG_ARCHIVE}"
remove_all_topics "${gitname}" "${GIT_ORG_ARCHIVE}"
done done
fi fi
} }

View File

@@ -37,7 +37,7 @@ add_team_to_repo() {
local pkgbase="$1" local pkgbase="$1"
local team="$2" local team="$2"
local url local url
url="${API_URL}/repos/${GIT_ORG}/$pkgbase/teams/$team" url="${GIT_HTTPS}/api/v1/repos/${GIT_ORG}/$pkgbase/teams/$team"
stat_busy "Adding team ($team) to package repo [$pkgbase]" stat_busy "Adding team ($team) to package repo [$pkgbase]"
api_put "$url" \ api_put "$url" \
@@ -50,7 +50,7 @@ remove_team_from_repo() {
local pkgbase="$1" local pkgbase="$1"
local team="$2" local team="$2"
local url local url
url="${API_URL}/repos/${GIT_ORG}/$pkgbase/teams/$team" url="${GIT_HTTPS}/api/v1/repos/${GIT_ORG}/$pkgbase/teams/$team"
stat_busy "Removing team ($team) from package repo [$pkgbase]" stat_busy "Removing team ($team) from package repo [$pkgbase]"
api_delete "$url" \ api_delete "$url" \
@@ -62,7 +62,7 @@ remove_team_from_repo() {
create_repo() { create_repo() {
local pkgbase="$1" local pkgbase="$1"
local url json local url json
url="${API_URL}/org/${GIT_ORG}/repos" url="${GIT_HTTPS}/api/v1/org/${GIT_ORG}/repos"
json="{ \"auto_init\": true, \"name\": \"$pkgbase\", \"gitignores\": \"ArtixLinuxPackages\", \"readme\": \"Default\" }" json="{ \"auto_init\": true, \"name\": \"$pkgbase\", \"gitignores\": \"ArtixLinuxPackages\", \"readme\": \"Default\" }"
stat_busy "Create package repo [$pkgbase] in org (${GIT_ORG})" stat_busy "Create package repo [$pkgbase] in org (${GIT_ORG})"
@@ -78,8 +78,8 @@ transfer_repo() {
local pkgbase="$1" local pkgbase="$1"
local new_owner="$2" local new_owner="$2"
local json url local json url
json="{ \"new_owner\": \"$new_owner\", \"team_ids\": [], \"archived\": \"true\" }" json="{ \"new_owner\": \"$new_owner\", \"team_ids\": [] }"
url="${API_URL}/repos/${GIT_ORG}/$pkgbase/transfer" url="${GIT_HTTPS}/api/v1/repos/${GIT_ORG}/$pkgbase/transfer"
stat_busy "Transfer package repo [$pkgbase] in org ($new_owner)" stat_busy "Transfer package repo [$pkgbase] in org ($new_owner)"
api_post "$url" \ api_post "$url" \
@@ -92,7 +92,7 @@ transfer_repo() {
list_all_repos() { list_all_repos() {
local url local url
url="${API_URL}/orgs/${GIT_ORG}/repos?limit=10000" url="${GIT_HTTPS}/api/v1/orgs/${GIT_ORG}/repos?limit=10000"
stat_busy "Query all packages" stat_busy "Query all packages"
api_get "$url" \ api_get "$url" \
@@ -104,7 +104,7 @@ add_topic() {
local url local url
local pkgbase="$1" local pkgbase="$1"
local topic="$2" local topic="$2"
url="${API_URL}/repos/${GIT_ORG}/$pkgbase/topics/$topic" url="${GIT_HTTPS}/api/v1/repos/${GIT_ORG}/$pkgbase/topics/$topic"
stat_busy "Add topic ($topic) to [$pkgbase]" stat_busy "Add topic ($topic) to [$pkgbase]"
api_put "$url" \ api_put "$url" \
@@ -117,7 +117,7 @@ remove_topic() {
local url local url
local pkgbase="$1" local pkgbase="$1"
local topic="$2" local topic="$2"
url="${API_URL}/repos/${GIT_ORG}/$pkgbase/topics/$topic" url="${GIT_HTTPS}/api/v1/repos/${GIT_ORG}/$pkgbase/topics/$topic"
stat_busy "Remove topic ($topic) from [$pkgbase]" stat_busy "Remove topic ($topic) from [$pkgbase]"
api_delete "$url" \ api_delete "$url" \
@@ -128,10 +128,8 @@ remove_topic() {
search_topic() { search_topic() {
local search="$1" local search="$1"
local url args local url
args="topic=true&includeDesc=false&private=false&is_private=false" url="${GIT_HTTPS}/api/v1/repos/search?q=${search}&topic=true&includeDesc=false&private=false&is_private=false&template=false&archived=false&order=asc&limit=10000"
args+="&template=false&archived=false&order=asc&limit=10000"
url="${API_URL}/repos/search?q=${search}&${args}"
stat_busy "Query for topic (${search})" stat_busy "Query for topic (${search})"
api_get "$url" \ api_get "$url" \
@@ -139,63 +137,4 @@ search_topic() {
stat_done stat_done
} }
list_repo_teams() {
local pkgbase="$1"
local url
url="${API_URL}/repos/${GIT_ORG}/$pkgbase/teams"
stat_busy "List repo teams [$pkgbase]"
api_get "$url" \
-H 'accept: application/json' \
-H "Authorization: token ${GIT_TOKEN}"
stat_done
}
check_repo_team() {
local pkgbase="$1"
local team="$2"
local url
url="${API_URL}/repos/${GIT_ORG}/$pkgbase/teams/$team"
stat_busy "Check if team ($team) is assigned to [$pkgbase]"
api_get "$url" \
-H 'accept: application/json' \
-H "Authorization: token ${GIT_TOKEN}"
stat_done
}
archive_repo() {
local pkgbase="$1"
local org="$2"
local url
local json
url="${API_URL}/repos/$org/$pkgbase"
json="{ \"archived\": true }"
stat_busy "Archive repo [$pkgbase] in org ($org)"
api_patch "$url" \
-H "accept: application/json" \
-H "content-type: application/json" \
-H "Authorization: token ${GIT_TOKEN}" \
-d "$json"
stat_done
}
remove_all_topics() {
local pkgbase="$1"
local org="$2"
local url
local json
url="${API_URL}/repos/$org/$pkgbase/topics"
json="{ \"topics\": [] }"
stat_busy "Delete all topics from [$pkgbase]"
api_put "$url" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: token ${GIT_TOKEN}" \
-d "$json"
stat_done
}
#}}} #}}}

View File

@@ -17,48 +17,27 @@ readonly ARTIX_DB=(
galaxy galaxy
) )
readonly ARTIX_DB_MAP=(
goblins
gremlins
stable
)
readonly AGENTS=(
orion
taurus
)
readonly ARTIX_TEAMS=(
"${ARTIX_DB[2]}"
"${ARTIX_DB[5]}"
"${ARTIX_DB[8]}"
"${ARTIX_DB[11]}"
)
declare -A AGENT_MAP=(
["${ARTIX_TEAMS[0]}"]=${AGENTS[0]}
["${ARTIX_TEAMS[1]}"]=${AGENTS[0]}
["${ARTIX_TEAMS[2]}"]=${AGENTS[1]}
["${ARTIX_TEAMS[3]}"]=${AGENTS[1]}
)
readonly REPO_DB='.artixlinux/pkgbase.yaml' readonly REPO_DB='.artixlinux/pkgbase.yaml'
readonly REPO_CI='.artixlinux/Jenkinsfile' readonly REPO_CI='.artixlinux/Jenkinsfile'
readonly SRCINFO='.artixlinux/srcinfo.yaml' yaml_array() {
local array
for entry in "$@"; do
array="${array:-}${array:+,} ${entry}"
done
printf "%s\n" "[${array}]"
}
print_package_names() { print_package_names() {
local version local version
local array
local architecture pkg local architecture pkg
version=$(get_full_version) version=$(get_full_version)
for pkg in "${pkgname[@]}"; do for pkg in "${pkgname[@]}"; do
architecture=$(get_pkg_arch "${pkg}") architecture=$(get_pkg_arch "${pkg}")
array="${array:-}${array:+,} $pkg-$version-$architecture$PKGEXT" printf "%s-%s-%s%s\n" "$pkg" "$version" "$architecture" "$PKGEXT"
done done
printf "%s\n" "[${array}]"
} }
print_debug_package_names() { print_debug_package_names() {
@@ -67,9 +46,7 @@ print_debug_package_names() {
version=$(get_full_version) version=$(get_full_version)
if check_option "debug" "y" && check_option "strip" "y"; then if check_option "debug" "y" && check_option "strip" "y"; then
architecture=$(get_pkg_arch) architecture=$(get_pkg_arch)
printf "[%s-%s-%s-%s%s]\n" "$pkgbase" "debug" "$version" "$architecture" "$PKGEXT" printf "%s-%s-%s-%s%s\n" "$pkgbase" "debug" "$version" "$architecture" "$PKGEXT"
else
printf "%s\n" "[]"
fi fi
} }
@@ -81,6 +58,17 @@ version_from_yaml() {
printf "%s\n" "${version}" printf "%s\n" "${version}"
} }
packages_from_yaml() {
local dest="$1"
local repo pkgs packages
repo=".repos.${dest}"
mapfile -t packages < <(repo="${repo}" yq -r 'eval(strenv(repo)).packages[]' "${REPO_DB}")
for p in "${packages[@]}"; do
pkgs="${pkgs:-}${pkgs:+,} ${p}"
done
printf "%s\n" "[${pkgs}]"
}
to_bool() { to_bool() {
local int="$1" local int="$1"
case "${int}" in case "${int}" in
@@ -112,9 +100,15 @@ create_repo_db() {
yq -n '"---"' > "${REPO_DB}" yq -n '"---"' > "${REPO_DB}"
yq -P ' yq -P 'with(
.team = null | .pkgbase;
with( .name = null |
.version = null |
.arch = [] |
.pkgname = [] )' \
-i "${REPO_DB}"
yq -P 'with(
.actions; .actions;
.addRepo = null | .addRepo = null |
.removeRepo = null | .removeRepo = null |
@@ -122,26 +116,41 @@ create_repo_db() {
.triggersRebuild = false | .triggersRebuild = false |
.triggersRepoAdd = false | .triggersRepoAdd = false |
.triggersRepoRemove = false | .triggersRepoRemove = false |
.triggersNoCheck = false ) | .triggersNoCheck = false )' \
.repos = {} -i "${REPO_DB}"
' -i "${REPO_DB}"
yq -P '.repos = {}' -i "${REPO_DB}"
for r in "${ARTIX_DB[@]}"; do for r in "${ARTIX_DB[@]}"; do
local repo local repo
repo=".repos.${r}" \ repo=".repos.${r}" \
yq -P ' yq -P 'with(
with( eval(strenv(repo));
eval(strenv(repo)); .version = null |
.version = null | .packages = [] )' \
.packages = [] | -i "${REPO_DB}"
.debug = [] )
' -i "${REPO_DB}"
done done
} }
update_yaml_team() { update_yaml_base() {
local team="${1:-${ARTIX_DB[5]}}" local version
team="$team" yq -P '.team = env(team)' -i "${REPO_DB}" local name
local pkgnames
local arches
pkgbase="${pkgbase:-${pkgname}}"
version="$(get_full_version)"
pkgnames=$(yaml_array "${pkgname[@]}")
arches=$(yaml_array "${arch[@]}")
name="${pkgbase}" version="${version}" pkgnames="${pkgnames}" arches="${arches}" \
yq -P 'with(
.pkgbase;
.name = env(name) |
.version = env(version) |
.arch = env(arches) |
.pkgname = env(pkgnames) )' \
-i "${REPO_DB}"
} }
update_yaml_add() { update_yaml_add() {
@@ -164,41 +173,36 @@ update_yaml_add() {
local pkgs local pkgs
local version local version
local pkgfiles local pkgfiles
local debug_pkgfiles
pkgs=$(print_package_names) mapfile -t pkgfiles < <(print_package_names)
debug_pkgs=$(print_debug_package_names) pkgs=$(yaml_array "${pkgfiles[@]}")
version=$(get_full_version) version=$(get_full_version)
repo=".repos.${dest}" repo=".repos.${dest}"
version="${version}" repo="${repo}" \ version="${version}" pkgs="${pkgs}" repo="${repo}" \
pkgs="${pkgs}" debug_pkgs="${debug_pkgs}" \ yq -P 'with(
yq -P ' eval(strenv(repo));
with( .version = env(version) |
eval(strenv(repo)); .packages = env(pkgs) )' \
.version = env(version) | -i "${REPO_DB}"
.packages = env(pkgs) |
.debug = env(debug_pkgs) )
' -i "${REPO_DB}"
fi fi
nocheck=$(to_bool "${nocheck}") nocheck=$(to_bool "${nocheck}")
nocheck="${nocheck}" add="${add}" \ nocheck="${nocheck}" add="${add}" \
rebuild="${rebuild}" build="${build}" dest="${dest}" \ rebuild="${rebuild}" build="${build}" dest="${dest}" \
yq -P ' yq -P 'with(
with( .actions;
.actions; .addRepo = env(dest) |
.addRepo = env(dest) | .removeRepo = null |
.removeRepo = null | .triggersBuild = env(build) |
.triggersBuild = env(build) | .triggersRebuild = env(rebuild) |
.triggersRebuild = env(rebuild) | .triggersRepoAdd = env(add) |
.triggersRepoAdd = env(add) | .triggersRepoRemove = false |
.triggersRepoRemove = false | .triggersNoCheck = env(nocheck) )' \
.triggersNoCheck = env(nocheck) ) -i "${REPO_DB}"
' -i "${REPO_DB}"
} }
update_yaml_remove() { update_yaml_remove() {
@@ -207,30 +211,30 @@ update_yaml_remove() {
local repo local repo
repo=".repos.${dest}" repo=".repos.${dest}"
repo="${repo}" dest="${dest}" \ repo="${repo}" \
yq -P ' yq -P 'with(
with( eval(strenv(repo));
eval(strenv(repo)); .version = null |
.version = null | .packages = [] )' \
.packages = [] | -i "${REPO_DB}"
.debug = [] ) |
with( dest="${dest}" \
.actions; yq -P 'with(
.addRepo = null | .actions;
.removeRepo = env(dest) | .addRepo = null |
.triggersBuild = false | .removeRepo = env(dest) |
.triggersRebuild = false | .triggersBuild = false |
.triggersRepoAdd = false | .triggersRebuild = false |
.triggersRepoRemove = true | .triggersRepoAdd = false |
.triggersNoCheck = false ) .triggersRepoRemove = true |
' -i "${REPO_DB}" .triggersNoCheck = false )' \
-i "${REPO_DB}"
} }
update_yaml_move() { update_yaml_move() {
local src="$1" local src="$1"
local dest="$2" local dest="$2"
local pkgs local pkgs
local debug_pkgs
local version local version
local src_repo local src_repo
local dest_repo local dest_repo
@@ -239,64 +243,39 @@ update_yaml_move() {
dest_repo=".repos.${dest}" dest_repo=".repos.${dest}"
version=$(version_from_yaml "${src}") version=$(version_from_yaml "${src}")
pkgs=$(packages_from_yaml "${src}")
pkgs=$(src_repo="${src_repo}" yq -Pr -o json 'eval(strenv(src_repo)).packages' "${REPO_DB}") src_repo="${src_repo}" \
debug_pkgs=$(src_repo="${src_repo}" yq -Pr -o json 'eval(strenv(src_repo)).debug' "${REPO_DB}") yq -P 'with(
eval(strenv(src_repo));
.version = null |
.packages = [] )' \
-i "${REPO_DB}"
src_repo="${src_repo}" dest_repo="${dest_repo}" \ version="${version}" pkgs="${pkgs}" dest_repo="${dest_repo}" \
version="${version}" src=${src} dest="${dest}" \ yq -P 'with(
pkgs="${pkgs}" debug_pkgs="${debug_pkgs}" \ eval(strenv(dest_repo));
yq -P ' .version = env(version) |
with( .packages = env(pkgs) )' \
eval(strenv(src_repo)); -i "${REPO_DB}"
.version = null |
.packages = [] |
.debug = [] ) |
with(
eval(strenv(dest_repo));
.version = env(version) |
.packages = env(pkgs) |
.debug = env(debug_pkgs) ) |
with(
.actions;
.addRepo = env(dest) |
.removeRepo = env(src) |
.triggersBuild = false |
.triggersRebuild = false |
.triggersRepoAdd = true |
.triggersRepoRemove = true |
.triggersNoCheck = false )
' -i "${REPO_DB}"
}
team_from_yaml() { src=${src} dest="${dest}" \
local team yq -P 'with(
team=$(yq -rP '.team' "${REPO_DB}") .actions;
printf "$team" .addRepo = env(dest) |
} .removeRepo = env(src) |
.triggersBuild = false |
detect_team() { .triggersRebuild = false |
local team .triggersRepoAdd = true |
.triggersRepoRemove = true |
for repo in "${ARTIX_TEAMS[@]}"; do .triggersNoCheck = false )' \
local key res -i "${REPO_DB}"
res=$(key=".repos.$repo" yq -rP 'eval(strenv(key)) | .version' "${REPO_DB}")
if [[ "${res}" != "null" ]]; then
team=${repo}
fi
done
printf "%s\n" "$team"
} }
show_agent() { show_agent() {
local agent local agent="orion"
local ci if grep @galaxy "${REPO_CI}" &>/dev/null; then
local branch agent="taurus"
agent="${AGENTS[0]}"
ci=$(head -n 1 "${REPO_CI}" | cut -d "'" -f2)
branch=${ci#*@}
if [[ -n "$branch" ]]; then
agent="$branch"
fi fi
msg2 "agent: %s" "$agent" msg2 "agent: %s" "$agent"
} }
@@ -306,16 +285,15 @@ show_db() {
if ! yq -r "${REPO_DB}" 1>/dev/null 2>/dev/null; then if ! yq -r "${REPO_DB}" 1>/dev/null 2>/dev/null; then
die "${REPO_DB} invalid!" die "${REPO_DB} invalid!"
fi fi
yq -rP 'with_entries(select(.key == "team"))' "${REPO_DB}" yq -rP '. | with_entries(select(.value.name))' "${REPO_DB}"
yq -rP '.repos | with_entries(select(.value.version))' "${REPO_DB}" yq -rP '. | .repos | with_entries(select(.value.version))' "${REPO_DB}"
return 0 return 0
} }
write_jenkinsfile() { show_srcinfo_base() {
local branch="$1" pkg2yaml . | yq '.pkgbase'
{ }
printf "@Library('artix-ci@%s') import org.artixlinux.RepoPackage\n" "${branch}"
printf '\n' show_srcinfo_pkgs() {
printf 'PackagePipeline(new RepoPackage(this))\n' pkg2yaml . | yq '.pkgnames'
} > "${REPO_CI}"
} }

View File

@@ -1,20 +0,0 @@
#!/hint/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
upgrade_db() {
local d
for db in "${ARTIX_DB[@]}"; do
local res
res=$(d=".repos.$db" yq 'eval(strenv(d)) | has("debug")' "${REPO_DB}")
if ! "${res}"; then
d=".repos.$db" \
yq 'eval(strenv(d)).debug = []' -i "${REPO_DB}"
fi
done
if $(yq '. | has("pkgbase") ' "${REPO_DB}"); then
yq 'del(.pkgbase)' -i "${REPO_DB}"
fi
}

View File

@@ -25,8 +25,8 @@ artixpkg_git_usage() {
EXAMPLES EXAMPLES
$ ${COMMAND} clone libfoo linux libbar $ ${COMMAND} clone libfoo linux libbar
$ ${COMMAND} clone --maintainer tux $ ${COMMAND} clone --maintainer tux
$ ${COMMAND} clone --search mytopic $ ${COMMAND} config --topic mytopic
$ ${COMMAND} config libfoo $ ${COMMAND} config --maintainer tux
$ ${COMMAND} create -c libfoo $ ${COMMAND} create -c libfoo
_EOF_ _EOF_
} }

View File

@@ -7,8 +7,6 @@ ARTOOLS_INCLUDE_GIT_CLONE_SH=1
# shellcheck source=src/lib/pkg/git/config.sh # shellcheck source=src/lib/pkg/git/config.sh
source "${LIBDIR}"/pkg/git/config.sh source "${LIBDIR}"/pkg/git/config.sh
# shellcheck source=src/lib/pkg/admin/team.sh
source "${LIBDIR}"/pkg/admin/team.sh
set -e set -e
@@ -19,20 +17,21 @@ artixpkg_git_clone_usage() {
Usage: ${COMMAND} [OPTIONS] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS OPTIONS
-m, --maintainer NAME Clone all packages of the named maintainer -m, --maintainer=NAME Clone all packages of the named maintainer
-s, --search TOPIC Clone all packages of the named topic
-t, --team NAME Assign team name (default: ${ARTIX_TEAMS[1]})
Possible values: (${ARTIX_TEAMS[@]})
-j, --jobs N Run up to N jobs in parallel (default: $(nproc))
--protocol https Clone the repository over https --protocol https Clone the repository over https
-t, --topic=NAME Clone all packages of the named topic
-a, --agent=NAME Set the CI agent (default: official)
Possible values: [official, galaxy]
-j, --jobs N Run up to N jobs in parallel (default: $(nproc))
--all Clone all existing packages, useful for cache warming --all Clone all existing packages, useful for cache warming
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} libfoo linux libbar $ ${COMMAND} libfoo linux libbar
$ ${COMMAND} --maintainer tux $ ${COMMAND} --maintainer tux
$ ${COMMAND} --search mytopic $ ${COMMAND} --topic mytopic
$ ${COMMAND} -j 8 --search mytopic $ ${COMMAND} -j 8 --topic mytopic
$ ${COMMAND} --agent galaxy libfoo
_EOF_ _EOF_
} }
@@ -49,8 +48,7 @@ artixpkg_git_clone() {
local CLONE_ALL=0 local CLONE_ALL=0
local MAINTAINER= local MAINTAINER=
local TOPIC= local TOPIC=
local CONFIG_OPTS=() local CONFIGURE_OPTIONS=()
local TEAM_OPTS=()
local jobs= local jobs=
jobs=$(nproc) jobs=$(nproc)
@@ -64,7 +62,7 @@ artixpkg_git_clone() {
;; ;;
--protocol=https) --protocol=https)
GIT_REPO_BASE_URL="${GIT_HTTPS}/" GIT_REPO_BASE_URL="${GIT_HTTPS}/"
CONFIG_OPTS+=("$1") CONFIGURE_OPTIONS+=("$1")
shift shift
;; ;;
--protocol) --protocol)
@@ -74,7 +72,7 @@ artixpkg_git_clone() {
else else
die "unsupported protocol: %s" "$2" die "unsupported protocol: %s" "$2"
fi fi
CONFIG_OPTS+=("$1" "$2") CONFIGURE_OPTIONS+=("$1" "$2")
shift 2 shift 2
;; ;;
-m|--maintainer) -m|--maintainer)
@@ -82,16 +80,28 @@ artixpkg_git_clone() {
MAINTAINER="$2" MAINTAINER="$2"
shift 2 shift 2
;; ;;
-s|--search) --maintainer=*)
MAINTAINER="${1#*=}"
shift
;;
-t|--topic)
(( $# <= 1 )) && die "missing argument for %s" "$1" (( $# <= 1 )) && die "missing argument for %s" "$1"
TOPIC="$2" TOPIC="$2"
shift 2 shift 2
;; ;;
-t|--team) --topic=*)
TOPIC="${1#*=}"
shift
;;
-a|--agent)
(( $# <= 1 )) && die "missing argument for %s" "$1" (( $# <= 1 )) && die "missing argument for %s" "$1"
TEAM_OPTS=("--add" "$2") CONFIGURE_OPTIONS+=("$1" "$2")
shift 2 shift 2
;; ;;
--agent=*)
CONFIGURE_OPTIONS+=("${1}")
shift
;;
--all) --all)
CLONE_ALL=1 CLONE_ALL=1
shift shift
@@ -157,8 +167,6 @@ artixpkg_git_clone() {
warning "Skip cloning ${pkgbase}: Directory exists" warning "Skip cloning ${pkgbase}: Directory exists"
fi fi
artixpkg_git_config "${CONFIG_OPTS[@]}" "${pkgbase}" artixpkg_git_config "${CONFIGURE_OPTIONS[@]}" "${pkgbase}"
artixpkg_admin_team "${TEAM_OPTS[@]}" "${pkgbase}"
done done
} }

View File

@@ -11,21 +11,92 @@ source "${LIBDIR}"/pkg/db/db.sh
set -e set -e
commit_ci(){
[[ -d .artixlinux ]] || mkdir .artixlinux
if [[ ${AGENT} == "${ARTIX_DB[11]}" ]]; then
printf "@Library('artix-ci@%s') import org.artixlinux.RepoPackage\n" "${AGENT}" > "${REPO_CI}"
else
printf "@Library('artix-ci') import org.artixlinux.RepoPackage\n" > "${REPO_CI}"
fi
{
printf '\n'
printf 'PackagePipeline(new RepoPackage(this))\n'
} >> "${REPO_CI}"
git add "${REPO_CI}"
git commit -m "initial ci commit"
}
artixpkg_git_config_usage() { artixpkg_git_config_usage() {
local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}} local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
cat <<- _EOF_ cat <<- _EOF_
Usage: ${COMMAND} [OPTIONS] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS OPTIONS
-m, --maintainer Set the maintainer topic via gitea api
-d, --drop Drop the maintainer topic via gitea api
-a, --agent NAME Set the CI agent (default: official)
Possible values: [official, galaxy]
--protocol https Configure remote url to use https --protocol https Configure remote url to use https
-j, --jobs N Run up to N jobs in parallel (default: $(nproc)) -j, --jobs N Run up to N jobs in parallel (default: $(nproc))
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} --maintainer libfoo
$ ${COMMAND} --agent galaxy libfoo
$ ${COMMAND} --drop libfoo
$ ${COMMAND} * $ ${COMMAND} *
_EOF_ _EOF_
} }
get_packager_name() {
local packager=$1
local packager_pattern="(.+) <(.+@.+)>"
local name
if [[ ! $packager =~ $packager_pattern ]]; then
return 1
fi
name=$(echo "${packager}"|sed -E "s/${packager_pattern}/\1/")
printf "%s" "${name}"
}
get_packager_email() {
local packager=$1
local packager_pattern="(.+) <(.+@.+)>"
local email
if [[ ! $packager =~ $packager_pattern ]]; then
return 1
fi
email=$(echo "${packager}"|sed -E "s/${packager_pattern}/\2/")
printf "%s" "${email}"
}
is_packager_name_valid() {
local packager_name=$1
if [[ -z ${packager_name} ]]; then
return 1
elif [[ ${packager_name} == "John Tux" ]]; then
return 1
elif [[ ${packager_name} == "Unknown Packager" ]]; then
return 1
fi
return 0
}
is_packager_email_official() {
local packager_email=$1
if [[ -z ${packager_email} ]]; then
return 1
elif [[ $packager_email =~ .+@artixlinux.org ]]; then
return 0
fi
return 1
}
artixpkg_git_config() { artixpkg_git_config() {
# options # options
local GIT_REPO_BASE_URL=${GIT_HTTPS} local GIT_REPO_BASE_URL=${GIT_HTTPS}
@@ -36,8 +107,13 @@ artixpkg_git_config() {
jobs=$(nproc) jobs=$(nproc)
local paths=() local paths=()
local SET_TOPIC=0
local DROP_TOPIC=0
local AGENT=
local CI_ADDED=0
# variables # variables
local command=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}} local RUNCMD=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
local path realpath pkgbase local path realpath pkgbase
local PACKAGER GPGKEY packager_name packager_email local PACKAGER GPGKEY packager_name packager_email
@@ -47,6 +123,27 @@ artixpkg_git_config() {
artixpkg_git_config_usage artixpkg_git_config_usage
exit 0 exit 0
;; ;;
-m|--maintainer)
SET_TOPIC=1
RUNCMD+=" -m"
shift
;;
-d|--drop)
DROP_TOPIC=1
RUNCMD+=" -d"
shift
;;
-a|--agent)
(( $# <= 1 )) && die "missing argument for %s" "$1"
AGENT="$2"
RUNCMD+=" -a ${AGENT}"
shift 2
;;
--agent=*)
AGENT="${1#*=}"
RUNCMD+=" -a ${AGENT}"
shift
;;
--protocol=https) --protocol=https)
proto_force=1 proto_force=1
shift shift
@@ -91,10 +188,8 @@ artixpkg_git_config() {
# Load makepkg.conf variables to be available for packager identity # Load makepkg.conf variables to be available for packager identity
msg "Collecting packager identity from makepkg.conf" msg "Collecting packager identity from makepkg.conf"
# shellcheck source=config/makepkg/x86_64.conf
# shellcheck source=src/lib/pkg/util/packager.sh load_makepkg_config
source "${LIBDIR}"/pkg/util/packager.sh
if [[ -n ${PACKAGER} ]]; then if [[ -n ${PACKAGER} ]]; then
if ! packager_name=$(get_packager_name "${PACKAGER}") || \ if ! packager_name=$(get_packager_name "${PACKAGER}") || \
! packager_email=$(get_packager_email "${PACKAGER}"); then ! packager_email=$(get_packager_email "${PACKAGER}"); then
@@ -126,7 +221,7 @@ artixpkg_git_config() {
if [[ -n ${BOLD} ]]; then if [[ -n ${BOLD} ]]; then
export ARTOOLS_COLOR=always export ARTOOLS_COLOR=always
fi fi
if ! parallel --bar --jobs "${jobs}" "${command}" ::: "${paths[@]}"; then if ! parallel --bar --jobs "${jobs}" "${RUNCMD}" ::: "${paths[@]}"; then
die 'Failed to configure some packages, please check the output' die 'Failed to configure some packages, please check the output'
exit 1 exit 1
fi fi
@@ -169,18 +264,38 @@ artixpkg_git_config() {
git config user.signingKey "${GPGKEY}" git config user.signingKey "${GPGKEY}"
fi fi
# topics meta
if (( SET_TOPIC )); then
if [[ -n ${GIT_TOKEN} ]]; then
local topic gitname
topic="maintainer-${packager_name}"
gitname=$(get_compliant_name "${pkgbase}")
if ! add_topic "${gitname}" "${topic}"; then
warning "failed to set the maintainer topic: ${topic}"
fi
fi
fi
if (( DROP_TOPIC )); then
if [[ -n ${GIT_TOKEN} ]]; then
local topic gitname
topic="maintainer-${packager_name}"
gitname=$(get_compliant_name "${pkgbase}")
if ! remove_topic "${gitname}" "${topic}"; then
warning "failed to drop the maintainer topic: ${topic}"
fi
fi
fi
if [[ ! -f ${REPO_CI} ]]; then if [[ ! -f ${REPO_CI} ]]; then
[[ -d .artixlinux ]] || mkdir .artixlinux
msg "Adding ci support ..." msg "Adding ci support ..."
local agent commit_ci
agent="${AGENT_MAP["${TEAM_OPTS[1]}"]}" CI_ADDED=1
write_jenkinsfile "$agent" fi
git add "${REPO_CI}"
git commit -m "add ci support"
if [[ -n ${AGENT} ]] && (( ! CI_ADDED )); then
msg "Switching ci support for [%s] ..." "${AGENT}"
commit_ci
fi fi
if [[ ! -f ${REPO_DB} ]]; then if [[ ! -f ${REPO_DB} ]]; then
@@ -189,13 +304,18 @@ artixpkg_git_config() {
create_repo_db create_repo_db
if [[ -f PKGBUILD ]]; then if [[ -f PKGBUILD ]]; then
pkg2yaml -o "${SRCINFO}" # shellcheck source=contrib/makepkg/PKGBUILD.proto
source PKGBUILD
update_yaml_base
fi fi
git add "${REPO_DB}" git add "${REPO_DB}"
git commit -m "create repo db" git commit -m "Create repo db"
fi fi
msg "Querying ${pkgbase} ..."
if ! show_db; then
warning "Could not query ${REPO_DB}"
fi
) )
done done
} }

View File

@@ -9,8 +9,6 @@ ARTOOLS_INCLUDE_GIT_CREATE_SH=1
source "${LIBDIR}"/pkg/git/clone.sh source "${LIBDIR}"/pkg/git/clone.sh
# shellcheck source=src/lib/pkg/git/config.sh # shellcheck source=src/lib/pkg/git/config.sh
source "${LIBDIR}"/pkg/git/config.sh source "${LIBDIR}"/pkg/git/config.sh
# shellcheck source=src/lib/pkg/admin/team.sh
source "${LIBDIR}"/pkg/admin/team.sh
set -e set -e
@@ -22,8 +20,8 @@ artixpkg_git_create_usage() {
OPTIONS OPTIONS
-c, --clone Clone the Git repository after creation -c, --clone Clone the Git repository after creation
-t, --team NAME Assign team name (default: ${ARTIX_TEAMS[1]}) -t, --team=NAME Assign team name (default: world)
Possible values: (${ARTIX_TEAMS[@]}) Possible values: [system, world, lib32, galaxy]
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
@@ -35,11 +33,17 @@ artixpkg_git_create() {
# options # options
local pkgbases=() local pkgbases=()
local pkgbase local pkgbase
local CLONE=0 local clone=0
local CONFIG=0 local config=0
local TEAM="${ARTIX_DB[5]}"
local TEAM_OPTS=("--team" "${ARTIX_TEAMS[1]}") local AGENT=()
local TEAMS=(
"${ARTIX_DB[2]}"
"${ARTIX_DB[5]}"
"${ARTIX_DB[8]}"
"${ARTIX_DB[11]}"
)
# variables # variables
local path local path
@@ -50,26 +54,29 @@ artixpkg_git_create() {
exit 0 exit 0
;; ;;
-c|--clone) -c|--clone)
CLONE=1 clone=1
shift shift
;; ;;
-t|--team) -t|--team)
(( $# <= 1 )) && die "missing argument for %s" "$1" (( $# <= 1 )) && die "missing argument for %s" "$1"
TEAM_OPTS=("$1" "$2") TEAM="$2"
shift 2 shift 2
;; ;;
--team=*)
TEAM="${1#*=}"
shift
;;
-*) -*)
die "invalid argument: %s" "$1" die "invalid argument: %s" "$1"
;; ;;
*) *)
pkgbases=("$@")
break break
;; ;;
esac esac
done done
pkgbases=("$@") if ! in_array "${TEAM}" "${TEAMS[@]}"; then
if ! in_array "${TEAM_OPTS[1]}" "${ARTIX_TEAMS[@]}"; then
die "${TEAM} does not exist!" die "${TEAM} does not exist!"
fi fi
@@ -79,40 +86,41 @@ artixpkg_git_create() {
if ! path=$(realpath -e .); then if ! path=$(realpath -e .); then
die "failed to read path from current directory" die "failed to read path from current directory"
fi fi
pkgbases=("$(basename "${path}")") pkgbases=("$(basename "${path}")")
CLONE=0 clone=0
CONFIG=1 config=1
else else
artixpkg_git_create_usage artixpkg_git_create_usage
exit 1 exit 1
fi fi
fi fi
# create # create
for pkgbase in "${pkgbases[@]}"; do for pkgbase in "${pkgbases[@]}"; do
local gitname local gitname
gitname=$(get_compliant_name "${pkgbase}") gitname=$(get_compliant_name "${pkgbase}")
if [[ -n ${GIT_TOKEN} ]]; then if [[ -n ${GIT_TOKEN} ]]; then
if ! create_repo "${gitname}" >/dev/null; then if ! create_repo "${gitname}" >/dev/null; then
die "failed to create repository: ${pkgbase}" die "failed to create project: ${pkgbase}"
else
msg_success "Successfully created ${pkgbase}"
fi fi
if ! add_team_to_repo "${gitname}" "${TEAM}" >/dev/null; then
warning "failed to assign team: ${TEAM}"
fi
msg_success "Successfully created ${pkgbase}"
fi fi
if [[ ${TEAM} == "${ARTIX_DB[11]}" ]]; then
if (( CLONE )); then AGENT+=(--agent="${TEAM}")
artixpkg_git_clone "${TEAM_OPTS[@]}" "${pkgbase}" fi
elif (( CONFIG )); then if (( clone )); then
artixpkg_git_config "${pkgbase}" artixpkg_git_clone "${AGENT[@]}" "${pkgbase}"
artixpkg_admin_team "${TEAM_OPTS[@]}" "${pkgbase}" elif (( config )); then
artixpkg_git_config "${AGENT[@]}"
fi fi
done done
# some convenience hints if not in auto clone/config mode # some convenience hints if not in auto clone/config mode
if (( ! CLONE )) && (( ! CONFIG )); then if (( ! clone )) && (( ! config )); then
cat <<- _EOF_ cat <<- _EOF_
For new clones: For new clones:

View File

@@ -7,9 +7,6 @@ ARTOOLS_INCLUDE_GIT_PULL_SH=1
set -e set -e
# shellcheck source=src/lib/pkg/db/db.sh
source "${LIBDIR}"/pkg/db/db.sh
artixpkg_git_pull_usage() { artixpkg_git_pull_usage() {
local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}} local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
@@ -17,8 +14,8 @@ artixpkg_git_pull_usage() {
Usage: ${COMMAND} [OPTIONS] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS OPTIONS
-m, --maintainer NAME Pull all packages of the named maintainer -m, --maintainer=NAME Pull all packages of the named maintainer
-t, --topic NAME Pull all packages of the named topic -t, --topic=NAME Pull all packages of the named topic
-j, --jobs N Run up to N jobs in parallel (default: $(nproc)) -j, --jobs N Run up to N jobs in parallel (default: $(nproc))
--all Pull all existing packages --all Pull all existing packages
-h, --help Show this help text -h, --help Show this help text
@@ -60,11 +57,19 @@ artixpkg_git_pull() {
MAINTAINER="$2" MAINTAINER="$2"
shift 2 shift 2
;; ;;
--maintainer=*)
MAINTAINER="${1#*=}"
shift
;;
-t|--topic) -t|--topic)
(( $# <= 1 )) && die "missing argument for %s" "$1" (( $# <= 1 )) && die "missing argument for %s" "$1"
TOPIC="$2" TOPIC="$2"
shift 2 shift 2
;; ;;
--topic=*)
TOPIC="${1#*=}"
shift
;;
--all) --all)
PULL_ALL=1 PULL_ALL=1
shift shift
@@ -126,11 +131,6 @@ artixpkg_git_pull() {
die 'failed to pull %s' "${pkgbase}" die 'failed to pull %s' "${pkgbase}"
fi fi
msg "Querying ${pkgbase} ..."
if ! show_db; then
warning "Could not query ${REPO_DB}"
fi
) )
else else
warning "Skip pulling ${pkgbase}: Directory does not exist" warning "Skip pulling ${pkgbase}: Directory does not exist"

View File

@@ -14,14 +14,16 @@ artixpkg_git_push_usage() {
Usage: ${COMMAND} [OPTIONS] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS OPTIONS
-m, --maintainer NAME Push all packages of the named maintainer -m, --maintainer=NAME Push all packages of the named maintainer
-t, --topic NAME Push all packages of the named topic -t, --topic=NAME Push all packages of the named topic
-j, --jobs N Run up to N jobs in parallel (default: $(nproc))
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} libfoo linux libbar $ ${COMMAND} libfoo linux libbar
$ ${COMMAND} --maintainer tux $ ${COMMAND} --maintainer tux
$ ${COMMAND} --topic mytopic $ ${COMMAND} --topic mytopic
$ ${COMMAND} -j 8 --topic mytopic
_EOF_ _EOF_
} }
@@ -36,6 +38,11 @@ artixpkg_git_push() {
# options # options
local MAINTAINER= local MAINTAINER=
local TOPIC= local TOPIC=
local CONFIGURE_OPTIONS=()
local jobs=
jobs=$(nproc)
local command=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
while (( $# )); do while (( $# )); do
case $1 in case $1 in
@@ -48,11 +55,24 @@ artixpkg_git_push() {
MAINTAINER="$2" MAINTAINER="$2"
shift 2 shift 2
;; ;;
--maintainer=*)
MAINTAINER="${1#*=}"
shift
;;
-t|--topic) -t|--topic)
(( $# <= 1 )) && die "missing argument for %s" "$1" (( $# <= 1 )) && die "missing argument for %s" "$1"
TOPIC="$2" TOPIC="$2"
shift 2 shift 2
;; ;;
--topic=*)
TOPIC="${1#*=}"
shift
;;
-j|--jobs)
(( $# <= 1 )) && die "missing argument for %s" "$1"
jobs=$2
shift 2
;;
--) --)
shift shift
break break
@@ -78,6 +98,19 @@ artixpkg_git_push() {
mapfile -t pkgbases < <(search_topic "${TOPIC}" | yq -P -r '.data | .[].name' | sort) mapfile -t pkgbases < <(search_topic "${TOPIC}" | yq -P -r '.data | .[].name' | sort)
fi fi
# parallelization
if [[ ${jobs} != 1 ]] && (( ${#pkgbases[@]} > 1 )); then
# force colors in parallel if parent process is colorized
if [[ -n ${BOLD} ]]; then
export ARTOOLS_COLOR=always
fi
if ! parallel --bar --jobs "${jobs}" "${command}" ::: "${pkgbases[@]}"; then
die 'Failed to push some packages, please check the output'
exit 1
fi
exit 0
fi
for pkgbase in "${pkgbases[@]}"; do for pkgbase in "${pkgbases[@]}"; do
if [[ -d ${pkgbase} ]]; then if [[ -d ${pkgbase} ]]; then
( cd "${pkgbase}" || return ( cd "${pkgbase}" || return

View File

@@ -8,15 +8,10 @@ ARTOOLS_INCLUDE_REPO_SH=1
# shellcheck source=src/lib/pkg/db/db.sh # shellcheck source=src/lib/pkg/db/db.sh
source "${LIBDIR}"/pkg/db/db.sh source "${LIBDIR}"/pkg/db/db.sh
# shellcheck source=src/lib/pkg/db/upgrade.sh
source "${LIBDIR}"/pkg/db/upgrade.sh
set -e set -e
load_makepkg_config has_remote_changes() {
no_remote_changes() {
local status local status
msg "Checking for remote changes ..." msg "Checking for remote changes ..."
git fetch origin &>/dev/null git fetch origin &>/dev/null
@@ -24,10 +19,10 @@ no_remote_changes() {
if [[ "$status" == *behind* ]]; then if [[ "$status" == *behind* ]]; then
msg2 "changes: yes" msg2 "changes: yes"
error "Remote changes detected! Please pull (%s)" "${pkgbase}" error "Remote changes detected! Please pull (%s)" "${pkgbase}"
return 1 return 0
fi fi
msg2 "changes: no" msg2 "changes: no"
return 0 return 1
} }
artixpkg_repo_usage() { artixpkg_repo_usage() {
@@ -46,12 +41,9 @@ artixpkg_repo_usage() {
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} add ${ARTIX_DB_MAP[2]} libfoo $ ${COMMAND} add world libfoo
$ ${COMMAND} remove ${ARTIX_DB_MAP[2]} libfoo $ ${COMMAND} remove world libfoo
$ ${COMMAND} move ${ARTIX_DB_MAP[1]} ${ARTIX_DB_MAP[2]} libfoo $ ${COMMAND} move world-gremlins world libfoo
$ ${COMMAND} add ${ARTIX_DB[4]} libfoo
$ ${COMMAND} remove ${ARTIX_DB[4]} libfoo
$ ${COMMAND} move ${ARTIX_DB[3]} ${ARTIX_DB[4]} libfoo
$ ${COMMAND} import libfoo $ ${COMMAND} import libfoo
$ ${COMMAND} show libfoo $ ${COMMAND} show libfoo
_EOF_ _EOF_

View File

@@ -38,18 +38,14 @@ artixpkg_repo_add_usage() {
Usage: ${COMMAND} [OPTIONS] [DEST_REPO] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [DEST_REPO] [PKGBASE]...
OPTIONS OPTIONS
-p, --push Push pkgbase -p, --push Push pkgbase
-r, --rebuild Triggers a rebuild -r, --rebuild Triggers a rebuild
-n, --nocheck Disable the check function -n, --nocheck Disable the check function
-a, --agent NAME Set the CI agent -h, --help Show this help text
[default: auto]
possible values: ${AGENTS[@]}
-h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} ${ARTIX_DB[4]} libfoo $ ${COMMAND} world-gremlins libfoo
$ ${COMMAND} --push ${ARTIX_DB[4]} libfoo $ ${COMMAND} -p world-gremlins libfoo
$ ${COMMAND} --push ${ARTIX_DB_MAP[2]} libfoo
_EOF_ _EOF_
} }
@@ -68,8 +64,6 @@ artixpkg_repo_add() {
local REBUILD=0 local REBUILD=0
local NOCHECK=0 local NOCHECK=0
local ADD=1 local ADD=1
local AUTO=0
local AGENT
while (( $# )); do while (( $# )); do
case $1 in case $1 in
@@ -89,11 +83,6 @@ artixpkg_repo_add() {
NOCHECK=1 NOCHECK=1
shift shift
;; ;;
-a|--agent)
(( $# <= 1 )) && die "missing argument for %s" "$1"
AGENT="$2"
shift 2
;;
-*) -*)
die "invalid argument: %s" "$1" die "invalid argument: %s" "$1"
;; ;;
@@ -107,12 +96,8 @@ artixpkg_repo_add() {
shift shift
pkgbases+=("$@") pkgbases+=("$@")
if in_array "${DEST}" "${ARTIX_DB_MAP[@]}"; then if ! in_array "${DEST}" "${ARTIX_DB[@]}"; then
AUTO=1 die "${DEST} does not exist!"
else
if ! in_array "${DEST}" "${ARTIX_DB[@]}"; then
die "${DEST} does not exist!"
fi
fi fi
for pkgbase in "${pkgbases[@]}"; do for pkgbase in "${pkgbases[@]}"; do
@@ -125,7 +110,7 @@ artixpkg_repo_add() {
fi fi
( cd "${pkgbase}" || return ( cd "${pkgbase}" || return
if no_remote_changes; then if ! has_remote_changes; then
if [[ ! -f PKGBUILD ]]; then if [[ ! -f PKGBUILD ]]; then
die "No PKGBUILD found in (%s)" "${pkgbase}" die "No PKGBUILD found in (%s)" "${pkgbase}"
@@ -138,34 +123,9 @@ artixpkg_repo_add() {
manage-pkgbuild-keys --export manage-pkgbuild-keys --export
pkg2yaml -o "${SRCINFO}" update_yaml_base
local team
team=$(detect_team)
if [[ -z "${team}" ]]; then
team=$(team_from_yaml)
fi
if (( AUTO )); then
if [[ "${DEST}" == "${ARTIX_DB_MAP[2]}" ]]; then
DEST="${team}"
else
DEST="${team}-${DEST}"
fi
fi
upgrade_db
update_yaml_add "${REBUILD}" "${ADD}" "${NOCHECK}" "${DEST}" update_yaml_add "${REBUILD}" "${ADD}" "${NOCHECK}" "${DEST}"
update_yaml_team "${team}"
if [[ -z ${AGENT} ]]; then
AGENT=${AGENT_MAP["${team}"]}
fi
write_jenkinsfile "${AGENT}"
local commit_msg local commit_msg
commit_msg=$(get_commit_msg 'add' "${DEST}") commit_msg=$(get_commit_msg 'add' "${DEST}")

View File

@@ -7,60 +7,23 @@ ARTOOLS_INCLUDE_REPO_IMPORT_SH=1
set -e set -e
PATCHDIR=${PATCHDIR:-"${WORKSPACE_DIR}/artix-patches"}
declare -A arch_map=(
["archlinux-mirrorlist"]="pacman-mirrorlist"
["artix-rebuild-order"]="arch-rebuild-order"
["virtualbox-host-modules-artix"]="virtualbox-host-modules-arch"
)
update_patches(){
if [[ ! -d "${PATCHDIR}" ]]; then
# ${GIT_ORG}
if ! git clone "${PATCH_URL}" "${PATCHDIR}"; then
error "failed to clone %s" "${PATCHDIR}"
fi
else
if ! git -C "${PATCHDIR}" pull; then
error "Failed to pull artix-patches"
fi
fi
}
patch_pkgbase(){ patch_pkgbase(){
local name="$1" local name="$1"
local patches="${PATCHDIR}/patches/${name}" case "${name}" in
sed -e 's|arch-meson|artix-meson|' -i PKGBUILD linux|linux-lts|linux-zen|linux-hardened|linux-rt*)
sed -e 's|KBUILD_BUILD_HOST=.*|KBUILD_BUILD_HOST=artixlinux|' -i PKGBUILD
if "${PATCH_MAINTAINER}" && [ -n "${PACKAGER}" ]; then sed -e 's|CONFIG_DEFAULT_HOSTNAME=.*|CONFIG_DEFAULT_HOSTNAME="artixlinux"|' \
sed -e 's|# Maintainer:|# Contributor:|' -i PKGBUILD -i config
printf '%s\n%s\n' "# Maintainer: ${PACKAGER}" "$(cat "PKGBUILD")" >"PKGBUILD" ;;
fi *)
sed -e 's|https://www.archlinux.org/|https://www.artixlinux.org/|' \
if [ -d "${patches}" ]; then -e 's|(Arch Linux)|(Artix Linux)|' \
if [ -f "${patches}/env.txt" ]; then -e 's|arch-meson|artix-meson|' \
while read -r line; do -i PKGBUILD
IFS="=" read -r key value <<< "$line" ;;
if [[ -z "${key}" ]] || [[ -z "${value}" ]]; then esac
die "Invalid key value pair in env.txt" git --no-pager diff PKGBUILD
fi
if declare -p "${key}" &> /dev/null; then
die "Environment variable %s already exists." "${key}"
fi
export "${key}=${value}"
done < "${patches}/env.txt"
fi
for file in "${patches}"/*; do
if [ -x "${file}" ]; then
echo "$> ${name}/$(basename "${file}")"
"${file}" "${TREE_DIR_ARTIX}/${name}"
elif [[ "${file}" == *.diff ]]; then
echo "$> git apply ${name}/$(basename "${file}")"
git -C "${TREE_DIR_ARTIX}/${name}" apply "${file}"
fi
done
fi
} }
artixpkg_repo_import_usage() { artixpkg_repo_import_usage() {
@@ -71,14 +34,12 @@ artixpkg_repo_import_usage() {
OPTIONS OPTIONS
--tag TAG Switch the current workspace to a specified version tag --tag TAG Switch the current workspace to a specified version tag
--del Delete files before rsync import --del Delete files before rsync import
-n --no-patch No patch import
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} libfoo $ ${COMMAND} libfoo
$ ${COMMAND} --tag TAG libfoo $ ${COMMAND} --tag TAG libfoo
$ ${COMMAND} --tag TAG --del libfoo $ ${COMMAND} --tag TAG --del libfoo
$ ${COMMAND} --no-patch libfoo
_EOF_ _EOF_
} }
@@ -92,7 +53,6 @@ artixpkg_repo_import() {
local pkgbases=() local pkgbases=()
local pkgbase local pkgbase
local TAG local TAG
local NP=0
local rsync_args=() local rsync_args=()
rsync_args+=( rsync_args+=(
-axcihW -axcihW
@@ -123,10 +83,6 @@ artixpkg_repo_import() {
rsync_args+=(--delete-before) rsync_args+=(--delete-before)
shift shift
;; ;;
-n|--no-patch)
NP=1
shift
;;
-h|--help) -h|--help)
artixpkg_repo_import_usage artixpkg_repo_import_usage
exit 0 exit 0
@@ -140,10 +96,6 @@ artixpkg_repo_import() {
esac esac
done done
if ! (( NP )); then
update_patches
fi
pkgbases+=("$@") pkgbases+=("$@")
for pkgbase in "${pkgbases[@]}"; do for pkgbase in "${pkgbases[@]}"; do
@@ -156,48 +108,41 @@ artixpkg_repo_import() {
fi fi
( cd "${pkgbase}" || return ( cd "${pkgbase}" || return
upstream="${arch_map["$pkgbase"]:-$pkgbase}"
stat_busy "Checking for upstream url" stat_busy "Checking for upstream url"
if ! git config get remote.upstream.url &>/dev/null; then if ! git config --local --get remote.upstream.url &>/dev/null; then
git remote add upstream "${GIT_UPSTREAM_URL}/${upstream}".git git remote add upstream "${GIT_UPSTREAM_URL}/${pkgbase}".git
fi fi
stat_done stat_done
stat_busy "Fetching upstream tags" msg2 "Fetching upstream tags"
git fetch -fq --prune --tags upstream main git fetch --tags upstream main
stat_done
local latest version local latest version
latest=$(git describe --tags FETCH_HEAD) latest=$(git describe --tags FETCH_HEAD)
version="${latest}" version="${latest}"
if [[ -n "${TAG}" ]]; then if [[ -n "${TAG}" ]]; then
version="${TAG}" version="${TAG}"
fi fi
if no_remote_changes; then if ! has_remote_changes; then
msg "Querying ${pkgbase} ..." msg "Querying ${pkgbase} ..."
if ! show_db; then if ! show_db; then
warning "Could not query ${REPO_DB}" warning "Could not query ${REPO_DB}"
fi fi
git checkout -q "${version}" -b "${version}" git checkout "${version}" -b "${version}" &>/dev/null
local temp local temp
temp=$(mktemp -d --tmpdir "${pkgbase}.XXXXXXXXXX") temp=$(mktemp -d --tmpdir "${pkgbase}.XXXXXXXXXX")
rsync "${rsync_args[@]}" -q "$(pwd)"/ "${temp}"/ rsync "${rsync_args[@]}" "$(pwd)"/ "${temp}"/ &>/dev/null
git checkout -q master git checkout master &>/dev/null
git branch -q -D "${version}" git branch -D "${version}" &>/dev/null
msg "Importing upstream changeset for ${version}" msg "Importing upstream changeset for ${version}"
rsync "${rsync_args[@]}" "${temp}"/ "$(pwd)"/ rsync "${rsync_args[@]}" "${temp}"/ "$(pwd)"/ #&>/dev/null
if ! (( NP )); then msg2 "Patching ${pkgbase} ..."
msg2 "Patching ${pkgbase} ..." patch_pkgbase "${pkgbase}"
patch_pkgbase "${pkgbase}"
fi
git --no-pager diff PKGBUILD
fi fi
) )
fi fi

View File

@@ -14,16 +14,12 @@ artixpkg_repo_move_usage() {
Usage: ${COMMAND} [OPTIONS] [SOURCE_REPO] [DEST_REPO] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [SOURCE_REPO] [DEST_REPO] [PKGBASE]...
OPTIONS OPTIONS
-p, --push Push pkgbase -p, --push Push pkgbase
-a, --agent NAME Set the CI agent -h, --help Show this help text
[default: auto]
possible values: ${AGENTS[@]}
-h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} ${ARTIX_DB[4]} ${ARTIX_DB[5]} libfoo $ ${COMMAND} world-gremlins world libfoo
$ ${COMMAND} --push ${ARTIX_DB[4]} ${ARTIX_DB[5]} libfoo $ ${COMMAND} -p world-gremlins world libfoo
$ ${COMMAND} --push ${ARTIX_DB_MAP[1]} ${ARTIX_DB_MAP[2]} libfoo
_EOF_ _EOF_
} }
@@ -38,11 +34,9 @@ artixpkg_repo_move() {
local pkgbase local pkgbase
local PUSH=0 local PUSH=0
local AUTO=0
local DEST local DEST
local SRC local SRC
local AGENT
while (( $# )); do while (( $# )); do
case $1 in case $1 in
@@ -54,11 +48,6 @@ artixpkg_repo_move() {
PUSH=1 PUSH=1
shift shift
;; ;;
-a|--agent)
(( $# <= 1 )) && die "missing argument for %s" "$1"
AGENT="$2"
shift 2
;;
-*) -*)
die "invalid argument: %s" "$1" die "invalid argument: %s" "$1"
;; ;;
@@ -68,19 +57,15 @@ artixpkg_repo_move() {
esac esac
done done
SRC="$1" SRC="$1"
DEST="$2" DEST="$2"
shift 2 shift 2
if in_array "${SRC}" "${ARTIX_DB_MAP[@]}" && in_array "${DEST}" "${ARTIX_DB_MAP[@]}"; then if ! in_array "${SRC}" "${ARTIX_DB[@]}"; then
AUTO=1 die "${SRC} does not exist!"
else fi
if ! in_array "${SRC}" "${ARTIX_DB[@]}"; then if ! in_array "${DEST}" "${ARTIX_DB[@]}"; then
die "${SRC} does not exist!" die "${DEST} does not exist!"
fi
if ! in_array "${DEST}" "${ARTIX_DB[@]}"; then
die "${DEST} does not exist!"
fi
fi fi
pkgbases+=("$@") pkgbases+=("$@")
@@ -95,140 +80,64 @@ artixpkg_repo_move() {
fi fi
( cd "${pkgbase}" || return ( cd "${pkgbase}" || return
if no_remote_changes; then if ! has_remote_changes; then
if [[ ! -f PKGBUILD ]]; then if [[ ! -f PKGBUILD ]]; then
die "No PKGBUILD found in (%s)" "${pkgbase}" die "No PKGBUILD found in (%s)" "${pkgbase}"
fi fi
local team local commit_msg src_version # dest_version
team=$(detect_team)
if [[ -z "${team}" ]]; then
team=$(team_from_yaml)
fi
if (( AUTO )); then
if [[ "${SRC}" == "${ARTIX_DB_MAP[2]}" ]]; then
SRC="${team}"
else
SRC="${team}-${SRC}"
fi
if [[ "${DEST}" == "${ARTIX_DB_MAP[2]}" ]]; then
DEST="${team}"
else
DEST="${team}-${DEST}"
fi
fi
local commit_msg src_version
commit_msg=$(get_commit_msg 'move' "${DEST}" "${SRC}") commit_msg=$(get_commit_msg 'move' "${DEST}" "${SRC}")
src_version=$(version_from_yaml "${SRC}") src_version=$(version_from_yaml "${SRC}")
# dest_version=$(version_from_yaml "${DEST}")
if [[ "$src_version" != "null" ]]; then if [[ "$src_version" != null ]]; then
if ! [[ -f "${SRCINFO}" ]]; then # local ret
pkg2yaml -o "${SRCINFO}" # ret=$(vercmp "$src_version" "$dest_version")
fi #
# if (( ret > 0 )); then
upgrade_db update_yaml_move "${SRC}" "${DEST}"
update_yaml_move "${SRC}" "${DEST}" if [[ -f .SRCINFO ]]; then
rm .SRCINFO
team=$(detect_team)
if [[ -z "$team" ]]; then
team=$(team_from_yaml)
fi
update_yaml_team "${team}"
if [[ -z ${AGENT} ]]; then
AGENT=${AGENT_MAP["${team}"]}
fi
write_jenkinsfile "${AGENT}"
if [[ -f .SRCINFO ]]; then
rm .SRCINFO
fi
if [[ -n $(git status --porcelain --untracked-files=no) ]]; then
stat_busy 'Staging files'
for f in $(git ls-files --modified); do
if [[ "$f" == "${REPO_DB}" ]]; then
git add "$f"
fi
if [[ "$f" == "${REPO_CI}" ]]; then
git add "$f"
fi
done
for f in $(git ls-files --others); do
if [[ "$f" == "${SRCINFO}" ]]; then
git add "$f"
fi
done
stat_done
msg 'Commit'
git commit -m "${commit_msg}"
if (( PUSH )); then
msg "Push (${pkgbase})"
git push origin master
fi fi
msg "Querying ${pkgbase} ..." if [[ -n $(git status --porcelain --untracked-files=no) ]]; then
if ! show_db; then
warning "Could not query ${REPO_DB}" stat_busy 'Staging files'
for f in $(git ls-files --modified); do
if [[ "$f" == "${REPO_DB}" ]]; then
git add "$f"
fi
done
stat_done
msg 'Commit'
git commit -m "${commit_msg}"
if (( PUSH )); then
msg "Push (${pkgbase})"
git push origin master
fi
msg "Querying ${pkgbase} ..."
if ! show_db; then
warning "Could not query ${REPO_DB}"
fi
fi fi
fi # elif (( ret < 0 )); then
#
if (( ! AUTO )); then # error "${pkgbase}: invalid move: version $src_version < $dest_version!"
#
local gitname # else
gitname=$(get_compliant_name "${pkgbase}") # error "${pkgbase}: invalid move: version $src_version = $dest_version!"
#
# team change on cross repo move system <-> world # fi
if [[ "${SRC}" == ${ARTIX_DB[2]}* ]] \
&& [[ "${DEST}" == ${ARTIX_DB[5]}* ]]; then
if ! add_team_to_repo "${gitname}" "${ARTIX_DB[5]}"; then
warning "failed to add team: ${ARTIX_DB[5]}"
fi
if ! remove_team_from_repo "${gitname}" "${ARTIX_DB[2]}"; then
warning "failed to remove team: ${ARTIX_DB[2]}"
fi
elif [[ "${SRC}" == ${ARTIX_DB[5]}* ]] \
&& [[ "${DEST}" == ${ARTIX_DB[2]}* ]]; then
if ! add_team_to_repo "${gitname}" "${ARTIX_DB[2]}"; then
warning "failed to add team: ${ARTIX_DB[2]}"
fi
if ! remove_team_from_repo "${gitname}" "${ARTIX_DB[5]}"; then
warning "failed to remove team: ${ARTIX_DB[5]}"
fi
fi
# team change on cross repo move world <-> galaxy
if [[ "${SRC}" == ${ARTIX_DB[11]}* ]] \
&& [[ "${DEST}" == ${ARTIX_DB[5]}* ]]; then
if ! add_team_to_repo "${gitname}" "${ARTIX_DB[5]}"; then
warning "failed to add team: ${ARTIX_DB[5]}"
fi
if ! remove_team_from_repo "${gitname}" "${ARTIX_DB[11]}"; then
warning "failed to remove team: ${ARTIX_DB[11]}"
fi
elif [[ "${SRC}" == ${ARTIX_DB[5]}* ]] \
&& [[ "${DEST}" == ${ARTIX_DB[11]}* ]]; then
if ! add_team_to_repo "${gitname}" "${ARTIX_DB[11]}"; then
warning "failed to add team: ${ARTIX_DB[11]}"
fi
if ! remove_team_from_repo "${gitname}" "${ARTIX_DB[5]}"; then
warning "failed to remove team: ${ARTIX_DB[5]}"
fi
fi
fi
else else
error "${pkgbase}: invalid move: version $src_version!" error "${pkgbase}: invalid move: version $src_version!"

View File

@@ -14,16 +14,12 @@ artixpkg_repo_remove_usage() {
Usage: ${COMMAND} [OPTIONS] [DEST_REPO] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [DEST_REPO] [PKGBASE]...
OPTIONS OPTIONS
-p, --push Push pkgbase -p, --push Push pkgbase
-a, --agent NAME Set the CI agent -h, --help Show this help text
[default: auto]
possible values: ${AGENTS[@]}
-h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} ${ARTIX_DB[4]} libfoo $ ${COMMAND} world-gremlins libfoo
$ ${COMMAND} --push ${ARTIX_DB[4]} libfoo $ ${COMMAND} -p world-gremlins libfoo
$ ${COMMAND} --push ${ARTIX_DB_MAP[2]} libfoo
_EOF_ _EOF_
} }
@@ -38,9 +34,7 @@ artixpkg_repo_remove() {
local pkgbase local pkgbase
local PUSH=0 local PUSH=0
local AUTO=0
local DEST='' local DEST=''
local AGENT
while (( $# )); do while (( $# )); do
case $1 in case $1 in
@@ -52,11 +46,6 @@ artixpkg_repo_remove() {
PUSH=1 PUSH=1
shift shift
;; ;;
-a|--agent)
(( $# <= 1 )) && die "missing argument for %s" "$1"
AGENT="$2"
shift 2
;;
-*) -*)
die "invalid argument: %s" "$1" die "invalid argument: %s" "$1"
;; ;;
@@ -70,12 +59,8 @@ artixpkg_repo_remove() {
shift shift
pkgbases=("$@") pkgbases=("$@")
if in_array "${DEST}" "${ARTIX_DB_MAP[@]}"; then if ! in_array "${DEST}" "${ARTIX_DB[@]}"; then
AUTO=1 die "${DEST} does not exist!"
else
if ! in_array "${DEST}" "${ARTIX_DB[@]}"; then
die "${DEST} does not exist!"
fi
fi fi
for pkgbase in "${pkgbases[@]}"; do for pkgbase in "${pkgbases[@]}"; do
@@ -88,43 +73,17 @@ artixpkg_repo_remove() {
fi fi
( cd "${pkgbase}" || return ( cd "${pkgbase}" || return
if no_remote_changes; then if ! has_remote_changes; then
if [[ ! -f PKGBUILD ]]; then if [[ ! -f PKGBUILD ]]; then
die "No PKGBUILD found in (%s)" "${pkgbase}" die "No PKGBUILD found in (%s)" "${pkgbase}"
fi fi
local team
team=$(detect_team)
if [[ -z "${team}" ]]; then
team=$(team_from_yaml)
fi
if (( AUTO )); then
if [[ "${DEST}" == "${ARTIX_DB_MAP[2]}" ]]; then
DEST="${team}"
else
DEST="${team}-${DEST}"
fi
fi
local commit_msg local commit_msg
commit_msg=$(get_commit_msg 'remove' "${DEST}") commit_msg=$(get_commit_msg 'remove' "${DEST}")
if ! [[ -f "${SRCINFO}" ]]; then
pkg2yaml -o "${SRCINFO}"
fi
upgrade_db
update_yaml_remove "${DEST}" update_yaml_remove "${DEST}"
if [[ -z ${AGENT} ]]; then
AGENT=${AGENT_MAP["${team}"]}
fi
write_jenkinsfile "${AGENT}"
if [[ -n $(git status --porcelain --untracked-files=no) ]]; then if [[ -n $(git status --porcelain --untracked-files=no) ]]; then
stat_busy 'Staging files' stat_busy 'Staging files'
@@ -132,14 +91,6 @@ artixpkg_repo_remove() {
if [[ "$f" == "${REPO_DB}" ]]; then if [[ "$f" == "${REPO_DB}" ]]; then
git add "$f" git add "$f"
fi fi
if [[ "$f" == "${REPO_CI}" ]]; then
git add "$f"
fi
done
for f in $(git ls-files --others); do
if [[ "$f" == "${SRCINFO}" ]]; then
git add "$f"
fi
done done
stat_done stat_done

View File

@@ -72,7 +72,7 @@ artixpkg_repo_show() {
fi fi
( cd "${pkgbase}" || return ( cd "${pkgbase}" || return
if no_remote_changes; then if ! has_remote_changes; then
if [[ ! -f PKGBUILD ]]; then if [[ ! -f PKGBUILD ]]; then
die "No PKGBUILD found in (%s)" "${pkgbase}" die "No PKGBUILD found in (%s)" "${pkgbase}"
fi fi
@@ -83,17 +83,13 @@ artixpkg_repo_show() {
fi fi
if (( SRC_BASE )); then if (( SRC_BASE )); then
if [[ -f "${SRCINFO}" ]]; then msg "Showing srcinfo base ..."
msg "Showing srcinfo pkgbase ..." show_srcinfo_base
yq '.pkgbase' "${SRCINFO}"
fi
fi fi
if (( SRC_PKGS )); then if (( SRC_PKGS )); then
if [[ -f "${SRCINFO}" ]]; then msg "Showing srcinfo pkgs ..."
msg "Showing srcinfo pkgname ..." show_srcinfo_pkgs
yq '.pkgname' "${SRCINFO}"
fi
fi fi
fi fi

37
src/lib/pkg/table.sh Normal file
View File

@@ -0,0 +1,37 @@
#!/hint/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
#{{{ 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" "$@"
}
#}}}

View File

@@ -36,12 +36,10 @@ load_pkg_config(){
REPO=${REPO:-'world'} REPO=${REPO:-'world'}
local -r git_domain="gitea.artixlinux.org" local git_domain="gitea.artixlinux.org"
GIT_HTTPS=${GIT_HTTPS:-"https://${git_domain}"} GIT_HTTPS=${GIT_HTTPS:-"https://${git_domain}"}
readonly API_URL="${GIT_HTTPS}/api/v1"
GIT_SSH=${GIT_SSH:-"gitea@${git_domain}"} GIT_SSH=${GIT_SSH:-"gitea@${git_domain}"}
GIT_TOKEN=${GIT_TOKEN:-''} GIT_TOKEN=${GIT_TOKEN:-''}
@@ -50,8 +48,6 @@ load_pkg_config(){
GIT_UPSTREAM_URL=${GIT_UPSTREAM_URL:-"https://gitlab.archlinux.org/archlinux/packaging/packages"} GIT_UPSTREAM_URL=${GIT_UPSTREAM_URL:-"https://gitlab.archlinux.org/archlinux/packaging/packages"}
GIT_ORG_ARCHIVE=${GIT_ORG_ARCHIVE:-'landfill'}
TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"} TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"}
REPOS_ROOT=${REPOS_ROOT:-"${WORKSPACE_DIR}/repos"} REPOS_ROOT=${REPOS_ROOT:-"${WORKSPACE_DIR}/repos"}
@@ -60,12 +56,6 @@ load_pkg_config(){
DBEXT=${DBEXT:-'gz'} DBEXT=${DBEXT:-'gz'}
PATCH_MAINTAINER=${PATCH_MAINTAINER:-false}
PATCH_URL=${PATCH_URL:-"${GIT_SSH}:artix/artix-patches.git"}
PKGDEST_DBG=${PKGDEST_DBG:-"${WORKSPACE_DIR}/packages-debug"}
return 0 return 0
} }

View File

@@ -1,54 +0,0 @@
#!/bin/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
get_packager_name() {
local packager=$1
local packager_pattern="(.+) <(.+@.+)>"
local name
if [[ ! $packager =~ $packager_pattern ]]; then
return 1
fi
name=$(echo "${packager}"|sed -E "s/${packager_pattern}/\1/")
printf "%s" "${name}"
}
get_packager_email() {
local packager=$1
local packager_pattern="(.+) <(.+@.+)>"
local email
if [[ ! $packager =~ $packager_pattern ]]; then
return 1
fi
email=$(echo "${packager}"|sed -E "s/${packager_pattern}/\2/")
printf "%s" "${email}"
}
is_packager_name_valid() {
local packager_name=$1
if [[ -z ${packager_name} ]]; then
return 1
elif [[ ${packager_name} == "John Tux" ]]; then
return 1
elif [[ ${packager_name} == "Unknown Packager" ]]; then
return 1
fi
return 0
}
is_packager_email_official() {
local packager_email=$1
if [[ -z ${packager_email} ]]; then
return 1
elif [[ $packager_email =~ .+@artixlinux.org ]]; then
return 0
fi
return 1
}
# shellcheck source=config/makepkg/x86_64.conf
load_makepkg_config

30
src/lib/pkg/yaml.sh Normal file
View File

@@ -0,0 +1,30 @@
#!/hint/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
#{{{ yaml
write_yaml_header(){
printf '%s\n' '---'
}
write_empty_line(){
printf '\n'
}
write_yaml_map(){
local ident="$1" key="$2" val="$3"
printf "\n%${ident}s%s: %s\n" '' "$key" "$val"
}
write_yaml_seq(){
local ident="$1" val="$2"
printf "\n%${ident}s- %s\n" '' "$val"
}
write_yaml_seq_map(){
local ident="$1" key="$2" val="$3"
printf "\n%${ident}s- %s: %s\n" '' "$key" "$val"
}
#}}}

View File

@@ -20,10 +20,9 @@ usage() {
Usage: ${COMMAND} [COMMAND] [OPTIONS] Usage: ${COMMAND} [COMMAND] [OPTIONS]
COMMANDS COMMANDS
admin Manage topics, teams and obsolete repos repo Pacman database modification for packge update, move etc
git Manage Git packaging repositories and their configuration git Manage Git packaging repositories and their configuration
repo Pacman database modification for package updates, moves, etc. admin Managegement of topics and obsolete repos
version Show artixpkg version information version Show artixpkg version information
OPTIONS OPTIONS
@@ -41,6 +40,8 @@ export _ARTOOLS_COMMAND='artixpkg'
# shellcheck source=src/lib/pkg/util.sh # shellcheck source=src/lib/pkg/util.sh
source "${LIBDIR}"/pkg/util.sh source "${LIBDIR}"/pkg/util.sh
load_makepkg_config
cd "${TREE_DIR_ARTIX}" cd "${TREE_DIR_ARTIX}"
# command checking # command checking

View File

@@ -32,8 +32,6 @@ usage() {
printf ' [default: %s]\n' "${repo}" printf ' [default: %s]\n' "${repo}"
printf ' -a <arch> Build arch chroot\n' printf ' -a <arch> Build arch chroot\n'
printf ' [default: %s]\n' "${arch}" printf ' [default: %s]\n' "${arch}"
printf ' -e <name> Export PACKAGER\n'
printf " format: 'John Doe <john@doe.com>'\n"
printf ' -c Recreate the chroot before building\n' printf ' -c Recreate the chroot before building\n'
printf ' -m Major rebuild\n' printf ' -m Major rebuild\n'
printf ' -N Disable check() function\n' printf ' -N Disable check() function\n'
@@ -46,14 +44,13 @@ usage() {
exit "$1" exit "$1"
} }
opts='hcCNmnr:d:a:e:' opts='hcCNmnr:d:a:'
while getopts "${opts}" arg; do while getopts "${opts}" arg; do
case "${arg}" in case "${arg}" in
r) chroots_pkg="$OPTARG" ;; r) chroots_pkg="$OPTARG" ;;
d) repo="$OPTARG" ;; d) repo="$OPTARG" ;;
a) arch="$OPTARG" ;; a) arch="$OPTARG" ;;
e) packager="$OPTARG" ;;
c) create_first=true ;; c) create_first=true ;;
m) rebuild=true ;; m) rebuild=true ;;
C) mkchrootpkg_args+=(-C) ;; C) mkchrootpkg_args+=(-C) ;;
@@ -93,10 +90,6 @@ else
set_arch="${arch}" set_arch="${arch}"
fi fi
if [[ -n "${packager}" ]]; then
export PACKAGER=${packager}
fi
# Architecture-specific Mount # Architecture-specific Mount
arch_mounts=() arch_mounts=()
if [[ -f "${DATADIR}/mount.d/${arch}" ]]; then if [[ -f "${DATADIR}/mount.d/${arch}" ]]; then

View File

@@ -6,8 +6,10 @@ LIBDIR=${LIBDIR:-'@libdir@'}
# shellcheck source=src/lib/base/message.sh # shellcheck source=src/lib/base/message.sh
source "${LIBDIR}"/base/message.sh source "${LIBDIR}"/base/message.sh
# shellcheck source=src/lib/pkg/util/diff.sh # shellcheck source=src/lib/pkg/diff.sh
source "${LIBDIR}"/pkg/util/diff.sh source "${LIBDIR}"/pkg/diff.sh
load_makepkg_config
usage() { usage() {
cat <<- _EOF_ cat <<- _EOF_

View File

@@ -10,45 +10,13 @@ SYSCONFDIR=${SYSCONFDIR:-'@sysconfdir@/artools'}
source "${LIBDIR}"/pkg/util.sh source "${LIBDIR}"/pkg/util.sh
# shellcheck source=src/lib/base/message.sh # shellcheck source=src/lib/base/message.sh
source "${LIBDIR}"/base/message.sh source "${LIBDIR}"/base/message.sh
# shellcheck source=src/lib/pkg/table.sh
source "${LIBDIR}"/pkg/table.sh
# shellcheck source=src/lib/pkg/db/db.sh # shellcheck source=src/lib/pkg/db/db.sh
source "${LIBDIR}"/pkg/db/db.sh source "${LIBDIR}"/pkg/db/db.sh
shopt -s extglob shopt -s extglob
#{{{ 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" "$@"
}
#}}}
extract_db() { extract_db() {
local u="$1" cdir="$2" local u="$1" cdir="$2"
rm -rf "$cdir" rm -rf "$cdir"

View File

@@ -181,9 +181,7 @@ else
set_arch="${CARCH}" set_arch="${CARCH}"
fi fi
chroot_args=(/usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/bin) ${CARCH:+setarch "${set_arch}"} chroot "${working_dir}" "$@"
${CARCH:+setarch "${set_arch}"} chroot "${working_dir}" "${chroot_args[@]}" "$@"
ret=$? ret=$?

View File

@@ -6,8 +6,8 @@ LIBDIR=${LIBDIR:-'@libdir@'}
# shellcheck source=src/lib/base/message.sh # shellcheck source=src/lib/base/message.sh
source "${LIBDIR}"/base/message.sh source "${LIBDIR}"/base/message.sh
# shellcheck source=src/lib/pkg/util/diff.sh # shellcheck source=src/lib/pkg/diff.sh
source "${LIBDIR}"/pkg/util/diff.sh source "${LIBDIR}"/pkg/diff.sh
usage() { usage() {
cat <<- _EOF_ cat <<- _EOF_

View File

@@ -1,55 +0,0 @@
#!/bin/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
LIBDIR=${LIBDIR:-'@libdir@'}
# shellcheck source=src/lib/base/message.sh
source "${LIBDIR}"/base/message.sh
# shellcheck source=src/lib/base/chroot.sh
source "${LIBDIR}"/base/chroot.sh
# shellcheck source=src/lib/pkg/util/deploy.sh
source "${LIBDIR}"/pkg/util/deploy.sh
# shellcheck source=config/makepkg/x86_64.conf
load_makepkg_config
export PKGDEST
export GPG_KEY
export GPG_PASS
passfiles=("$@")
sign_pkg(){
local file_to_sign="$1"
if [ ! -e "$file_to_sign" ]; then
error "%s does not exist!" "$file_to_sign"
exit 1
fi
if [[ -n "${GPG_KEY}" ]] && [[ -n "${GPG_PASS}" ]]; then
msg "Signing [%s]" "${file_to_sign##*/}"
gpg --homedir /etc/pacman.d/gnupg --no-permission-warning \
--no-default-keyring --default-key "${GPG_KEY}" --passphrase "${GPG_PASS}" \
-q --detach-sign "$file_to_sign"
fi
}
check_root PKGDEST,GPG_KEY,GPG_PASS "${BASH_SOURCE[0]}" "$@"
for pkg in "${passfiles[@]}"; do
msg "Searching %s ..." "$pkg"
if pkgfile=$(find_cached_pkgfile "$pkg");then
msg2 "Found: %s" "${pkgfile}"
[[ -e "${pkgfile}".sig ]] && rm "${pkgfile}".sig
if ! sign_pkg "${pkgfile}"; then
die "Failed to sign package!"
fi
ret=0
else
ret=1
fi
done
exit "$ret"

View File

@@ -6,198 +6,136 @@ LIBDIR=${LIBDIR:-'@libdir@'}
# shellcheck source=src/lib/base/message.sh # shellcheck source=src/lib/base/message.sh
source "${LIBDIR}"/base/message.sh source "${LIBDIR}"/base/message.sh
# shellcheck source=src/lib/pkg/yaml.sh
source "${LIBDIR}"/pkg/yaml.sh
# shellcheck disable=1091 # shellcheck disable=1091
source "${MAKEPKG_LIBRARY}"/util/pkgbuild.sh source "${MAKEPKG_LIBRARY}"/util/pkgbuild.sh
# shellcheck disable=1091 # shellcheck disable=1091
source "${MAKEPKG_LIBRARY}"/util/schema.sh source "${MAKEPKG_LIBRARY}"/util/schema.sh
# {{{ functions #{{{ functions
yaml_array_str() { srcyaml_write_attr(){
local array local ident1="$1" ident2="$2" ident3="$3"
local attrname=$4 attrvalues=("${@:5}")
for entry in "$@"; do # normalize whitespace, strip leading and trailing
array="${array:-}${array:+,} '${entry}'" attrvalues=("${attrvalues[@]//+([[:space:]])/ }")
done attrvalues=("${attrvalues[@]#[[:space:]]}")
printf "%s\n" "[${array}]" attrvalues=("${attrvalues[@]%[[:space:]]}")
case $attrname in
pkgver|pkgrel|epoch|url|install|changelog)
for v in "${attrvalues[@]}"; do
Yaml+=$(write_yaml_map "$ident3" "$attrname" "$v")
done
;;
pkgdesc)
Yaml+=$(write_yaml_map "$ident1" "$attrname" "${attrvalues[@]}")
;;
*)
Yaml+=$(write_yaml_map "$ident1" "$attrname")
for v in "${attrvalues[@]}"; do
Yaml+=$(write_yaml_seq "$ident2" "$v")
done
;;
esac
} }
pkgbuild_extract_to_srcyaml() { pkgbuild_extract_to_yaml() {
# $1: pkgname local pkgname=$1 attrname=$2 isarray=$3 outvalue=
# $2: index
# $3: attr name
# $4: multivalued
local pkgname="$1" i="$2" attrname="$3" isarray="$4" outvalue=
if get_pkgbuild_attribute "$pkgname" "$attrname" "$isarray" 'outvalue'; then if get_pkgbuild_attribute "$pkgname" "$attrname" "$isarray" 'outvalue'; then
local ov an [[ -z $pkgname ]] && srcyaml_write_attr 2 4 2 "$attrname" "${outvalue[@]}"
[[ -n $pkgname ]] && srcyaml_write_attr 4 6 2 "$attrname" "${outvalue[@]}"
if [[ -n $pkgname ]]; then
an=".pkgname[$i].$attrname"
else
an=".pkgbase.$attrname"
fi
if (( isarray )); then
ov=$(yaml_array_str "${outvalue[@]}")
else
ov="${outvalue[*]}"
if [[ -z "$ov" ]]; then
ov="null"
fi
fi
an="$an" ov="$ov" \
yq -P 'eval(strenv(an)) = env(ov)' -i "${YAML}"
fi fi
} }
srcyaml_write_node_details() { srcyaml_write_section_details() {
local attr package_arch a local attr package_arch a
local multivalued_arch_attrs=( local multivalued_arch_attrs=(source provides conflicts depends replaces
source optdepends makedepends checkdepends
provides "${known_hash_algos[@]/%/sums}")
conflicts
depends
replaces
optdepends
makedepends
checkdepends
"${known_hash_algos[@]/%/sums}"
)
for attr in "${singlevalued[@]}"; do for attr in "${singlevalued[@]}"; do
pkgbuild_extract_to_srcyaml "$1" "$2" "$attr" 0 pkgbuild_extract_to_yaml "$1" "$attr" 0
done done
for attr in "${multivalued[@]}"; do for attr in "${multivalued[@]}"; do
pkgbuild_extract_to_srcyaml "$1" "$2" "$attr" 1 pkgbuild_extract_to_yaml "$1" "$attr" 1
done done
get_pkgbuild_attribute "$pn" 'arch' 1 'package_arch' get_pkgbuild_attribute "$1" 'arch' 1 'package_arch'
for a in "${package_arch[@]}"; do for a in "${package_arch[@]}"; do
# 'any' is special. there's no support for, e.g. depends_any. # 'any' is special. there's no support for, e.g. depends_any.
[[ $a = any ]] && continue [[ $a = any ]] && continue
for attr in "${multivalued_arch_attrs[@]}"; do for attr in "${multivalued_arch_attrs[@]}"; do
pkgbuild_extract_to_srcyaml "$1" "$2" "${attr}_$a" 1 pkgbuild_extract_to_yaml "$1" "${attr}_$a" 1
done done
done done
} }
srcyaml_write_global() { yaml_write_global() {
local singlevalued=( local singlevalued=(pkgdesc pkgver pkgrel epoch url install changelog)
pkgdesc local multivalued=(arch groups license checkdepends makedepends
pkgver depends optdepends provides conflicts replaces
pkgrel noextract options backup
epoch source validpgpkeys "${known_hash_algos[@]/%/sums}")
url
install
changelog
)
local multivalued=(
arch
groups
license
checkdepends
makedepends
depends
optdepends
provides
conflicts
replaces
noextract
options
backup
source
validpgpkeys
"${known_hash_algos[@]/%/sums}"
)
srcyaml_write_node_details '' '' Yaml+=$(write_yaml_map 0 "pkgbase")
Yaml+=$(write_yaml_map 2 "name" "${pkgbase:-${pkgname}}")
srcyaml_write_section_details ""
} }
srcyaml_write_package() { yaml_write_package() {
local singlevalued=( local singlevalued=(pkgdesc url install changelog)
pkgdesc local multivalued=(arch groups license checkdepends depends optdepends
url provides conflicts replaces options backup)
install
changelog
)
local multivalued=(
arch
groups
license
checkdepends
depends
optdepends
provides
conflicts
replaces
options
backup
)
srcyaml_write_node_details "$1" "$2" Yaml+=$(write_yaml_map 0 "pkgnames")
for pkg in "${pkgname[@]}"; do
Yaml+=$(write_yaml_seq_map 2 "pkgname" "$pkg")
srcyaml_write_section_details "$pkg"
done
} }
write_srcyaml() { write_srcyaml() {
yq -n '"---"' > "${YAML}" Yaml=$(write_yaml_header)
yaml_write_global
yaml_write_package
local ver # local version
ver=$(get_full_version) \ # version=$(get_full_version)
yq -P '.version = env(ver)' -i "${YAML}" # Yaml+=$(write_yaml_map 2 "version" "${version}")
# https://github.com/mikefarah/yq/issues/1836 printf '%s\n' "${Yaml}"
# yq '. head_comment="generated with artixpkg @buildtoolver@"' -i "${YAML}"
local name=${pkgbase:-$pkgname}
name="$name" \
yq -P '.pkgbase.name = env(name)' -i "${YAML}"
srcyaml_write_global
local pn
local key
for ((i = 0 ; i < "${#pkgname[@]}" ; i++)); do
pn="${pkgname[$i]}" key=".pkgname[$i]" \
yq -P 'eval(strenv(key)).name = env(pn)' -i "${YAML}"
srcyaml_write_package "${pkgname[$i]}" "$i"
done
yq '. foot_comment="generated with artixpkg @buildtoolver@"' -i "${YAML}"
} }
# }}} #}}}
usage() { usage() {
printf 'Usage: %s [options]\n' "${0##*/}" printf 'Usage: %s [options]\n' "${0##*/}"
printf " -o <out> Out file (default: ${YAML})\n"
printf ' -h This help\n' printf ' -h This help\n'
printf '\n' printf '\n'
exit "$1" exit "$1"
} }
YAML=/tmp/srcinfo.yaml
# shellcheck source=config/makepkg/x86_64.conf # shellcheck source=config/makepkg/x86_64.conf
load_makepkg_config load_makepkg_config
opts='o:h' opts='h'
while getopts "${opts}" arg; do while getopts "${opts}" arg; do
case "${arg}" in case "${arg}" in
o) YAML="$OPTARG" ;;
h|?) usage 0 ;; h|?) usage 0 ;;
esac esac
done done
shift $(( OPTIND - 1 )) shift $(( OPTIND - 1 ))
srcpath=$(readlink -f "$1")
# srcpath=$(readlink -f "$1")
[[ -z "$srcpath" ]] && srcpath="."
[[ -f "$srcpath"/PKGBUILD ]] || die "%s/PKGBUILD does not exist!" "$srcpath" [[ -f "$srcpath"/PKGBUILD ]] || die "%s/PKGBUILD does not exist!" "$srcpath"

View File

@@ -10,8 +10,8 @@ SYSCONFDIR=${SYSCONFDIR:-'@sysconfdir@/artools'}
source "${LIBDIR}"/pkg/util.sh source "${LIBDIR}"/pkg/util.sh
# shellcheck source=src/lib/base/message.sh # shellcheck source=src/lib/base/message.sh
source "${LIBDIR}"/base/message.sh source "${LIBDIR}"/base/message.sh
# shellcheck source=src/lib/pkg/util/deploy.sh # shellcheck source=src/lib/pkg/deploy.sh
source "${LIBDIR}"/pkg/util/deploy.sh source "${LIBDIR}"/pkg/deploy.sh
#{{{ deploy #{{{ deploy
@@ -20,7 +20,6 @@ add() {
msg "Found: %s" "${pkgfile}" msg "Found: %s" "${pkgfile}"
packages+=("${pkgname}") packages+=("${pkgname}")
action='add' action='add'
action_args+=(--include-sigs)
ln -sfv "${pkgfile}"{,.sig} "${repo_path}"/ ln -sfv "${pkgfile}"{,.sig} "${repo_path}"/
fi fi
} }
@@ -31,18 +30,6 @@ remove(){
# pkg removal will be done by a patched repo-remove honoring -R # pkg removal will be done by a patched repo-remove honoring -R
} }
update_dbg() {
local rmp
rmp=${pkgname%"${PKGEXT}"}
rmp=${rmp%-*}
rmp=${rmp%-*}
rm -fv "${PKGDEST_DBG}/${rmp}"*
if pkgfile=$(find_cached_pkgfile "${pkgname}"); then
msg "Found: %s" "${pkgfile}"
ln -sfv "${pkgfile}" "${PKGDEST_DBG}"/
fi
}
repo_action() { repo_action() {
local repo_path local repo_path
# shellcheck disable=SC2153 # shellcheck disable=SC2153
@@ -52,13 +39,11 @@ repo_action() {
for pkgname in "${passfiles[@]}"; do for pkgname in "${passfiles[@]}"; do
"$func" "$func"
done done
if ! "${dbg_pkg}"; then ( cd "${repo_path}" || return
( cd "${repo_path}" || return if [[ -n "${action}" ]]; then
if [[ -n "${action}" ]]; then repo-"${action}" -R "${dest_repo}.${db_ext}" "${packages[@]}"
repo-"${action}" "${action_args[@]}" "${dest_repo}.${db_ext}" "${packages[@]}" fi
fi )
)
fi
} }
#}}} #}}}
@@ -69,32 +54,28 @@ db_ext="db.tar.${DBEXT}"
add_pkg=false add_pkg=false
rm_pkg=false rm_pkg=false
dbg_pkg=false
cmd=${0##*/} cmd=${0##*/}
dest_repo=world #${cmd#*-} dest_repo=${cmd#*-}
action_args=(-R)
usage() { usage() {
printf "Usage: %s [options]\n" "${cmd}" printf "Usage: %s [options]\n" "${cmd}"
printf ' -d <dest> Destination repository\n' printf ' -d <dest> Destination repository\n'
printf ' -a Add package(s) to repository\n' printf ' -a Add package(s) to repository\n'
printf ' -r Remove package(s) from repository\n' printf ' -r Remove package(s) from repository\n'
printf ' -u Update debug repository\n'
printf ' -h This help\n' printf ' -h This help\n'
printf '\n' printf '\n'
printf '\n' printf '\n'
exit "$1" exit "$1"
} }
opts='uarhd:' opts='arLRhd:'
while getopts "${opts}" arg; do while getopts "${opts}" arg; do
case "${arg}" in case "${arg}" in
d) dest_repo="$OPTARG" ;; d) dest_repo="$OPTARG" ;;
a) add_pkg=true; rm_pkg=false ;; a) add_pkg=true; rm_pkg=false ;;
r) rm_pkg=true; add_pkg=false ;; r) rm_pkg=true; add_pkg=false ;;
u) dbg_pkg=true ;;
h|?) usage 0 ;; h|?) usage 0 ;;
esac esac
done done
@@ -104,14 +85,10 @@ shift $(( OPTIND - 1 ))
passfiles=("$@") passfiles=("$@")
if [[ -n "${passfiles[*]}" ]]; then if [[ -n "${passfiles[*]}" ]]; then
if ! "${dbg_pkg}"; then if ${add_pkg}; then
if ${add_pkg}; then repo_action add
repo_action add fi
fi if ${rm_pkg}; then
if ${rm_pkg}; then repo_action remove
repo_action remove
fi
else
repo_action update_dbg
fi fi
fi fi

View File

@@ -6,8 +6,8 @@ LIBDIR=${LIBDIR:-'@libdir@'}
# shellcheck source=src/lib/base/message.sh # shellcheck source=src/lib/base/message.sh
source "${LIBDIR}"/base/message.sh source "${LIBDIR}"/base/message.sh
# shellcheck source=src/lib/pkg/util/deploy.sh # shellcheck source=src/lib/pkg/deploy.sh
source "${LIBDIR}"/pkg/util/deploy.sh source "${LIBDIR}"/pkg/deploy.sh
# shellcheck source=config/makepkg/x86_64.conf # shellcheck source=config/makepkg/x86_64.conf
load_makepkg_config load_makepkg_config