Compare commits

..

13 Commits

Author SHA1 Message Date
Luka Zeljko
405a4501fc More complete version of zsh autocompletion
All checks were successful
Artools shellcheck / lint (pull_request) Successful in 1m3s
- Mimics bash autocompletion with addition of descriptions of every command and option on tabbing
2025-11-24 14:21:17 +01:00
Luka Zeljko
c2bc4ee01c Rewritten zsh autocompletion script.
- Added all core commands, subcommands and options available in the tooling
- Packages and maintainers now dynamically shown on tabbing
2025-11-23 22:18:06 +01:00
e17b84f4a0 iso-fixes (#156)
All checks were successful
Artools shellcheck / lint (push) Successful in 25s
Reviewed-on: #156
Co-authored-by: Artoo <artoo@artixlinux.org>
Co-committed-by: Artoo <artoo@artixlinux.org>
2025-08-29 22:38:21 +02:00
4718c88229 Merge pull request 'buildiso: load optional livefs packages-init' (#155) from iso-opt-yaml-key into master
All checks were successful
Artools shellcheck / lint (push) Successful in 29s
Reviewed-on: #155
2025-08-28 00:55:17 +02:00
d1ddaaf06a buildiso: load optional livefs packages-init
All checks were successful
Artools shellcheck / lint (pull_request) Successful in 56s
2025-08-27 23:48:23 +02:00
9484fff9f8 buildiso: handle s6 DM in proper lib (#154)
All checks were successful
Artools shellcheck / lint (push) Successful in 1m14s
Reviewed-on: #154
Co-authored-by: Artoo <artoo@artixlinux.org>
Co-committed-by: Artoo <artoo@artixlinux.org>
2025-08-26 17:11:44 +02:00
1e2e5f44e1 buildiso: add s6 service error handling
All checks were successful
Artools shellcheck / lint (push) Successful in 41s
2025-08-22 15:42:18 +02:00
764d47ad8f buildiso: add service error handling
All checks were successful
Artools shellcheck / lint (push) Successful in 1m37s
2025-08-22 15:11:38 +02:00
9e67c31d61 iso-yaml (#153)
All checks were successful
Artools shellcheck / lint (push) Successful in 31s
Reviewed-on: #153
Co-authored-by: Artoo <artoo@artixlinux.org>
Co-committed-by: Artoo <artoo@artixlinux.org>
2025-08-20 20:14:31 +02:00
41c90f8d49 iso services: use dinitctl instead of symlinks
All checks were successful
Artools shellcheck / lint (push) Successful in 1m2s
2025-08-15 20:50:54 +02:00
c97a0cdd59 artixpkg repo import: show git diff with -n flag
All checks were successful
Artools shellcheck / lint (push) Successful in 31s
2025-06-28 14:55:24 +02:00
1ba16c45f9 artixpkg: fix removal by git add srcinfo.yaml
All checks were successful
Artools shellcheck / lint (push) Successful in 30s
2025-06-12 17:33:20 +02:00
95afc31152 artixpkg git: show repo db after pull
All checks were successful
Artools shellcheck / lint (push) Successful in 58s
2025-06-08 17:19:48 +02:00
12 changed files with 962 additions and 282 deletions

View File

@@ -1,6 +1,6 @@
SHELL=/bin/bash
V=0.36
V=0.37
BUILDTOOLVER ?= $(V)
CHROOTVER=0.12

View File

@@ -1,205 +1,748 @@
#compdef artixpkg
#compdef _artixpkg 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[@]")
LIBDIR=${LIBDIR:-'@libdir@'}
# LIBDIR='/usr/share/artools/lib'
_regex_words query '' \
'-h' \
'--help' \
'-m' \
'-t'
querycmd=("$reply[@]")
ARTIX_DB=(
"system-goblins"
"system-gremlins"
"system"
"world-goblins"
"world-gremlins"
"world"
"lib32-goblins"
"lib32-gremlins"
"lib32"
"galaxy-goblins"
"galaxy-gremlins"
"galaxy"
)
_regex_words team '' \
'-a' \
'--add' \
'-c' \
'--check' \
'-h' \
'--help' \
'-r' \
'--remove'
teamcmd=("$reply[@]")
ARTIX_DB_MAP=(
"goblins"
"gremlins"
"stable"
)
_regex_words topic '' \
'-a' \
'--add' \
'-d' \
'--delete' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-r' \
'--remove'
topiccmd=("$reply[@]")
AGENTS=(
"orion"
"taurus"
)
_regex_words transfer '' \
'-h' \
'--help'
transfercmd=("$reply[@]")
ARTIX_TEAMS=(
"system"
"world"
"lib32"
"galaxy"
)
_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_pkgbase() {
source "${LIBDIR}/pkg/util.sh"
ls -1 "${TREE_DIR_ARTIX}" | tr '\n' ' '
}
function _artixpkg { # DONE
_arguments -C \
'1:command:->subcmd' \
'*::args:->args'
case $state in
subcmd)
local -a subcmds
subcmds=(
"--help:Show help text"
"-h:Show help text"
"admin:Manage topics, teams and obsolete repos"
"git:Manage Git packaging repositories and their configuration"
"repo:Pacman database modification for package updates, moves, etc."
"version:Show artixpkg version information"
)
_describe 'command' subcmds
return
;;
args)
case $words[1] in
admin)
_admin
;;
git)
_git
;;
repo)
_repo
;;
version)
_arguments \
'-h[Show help text]' \
'--help[Show help text]'
;;
esac
;;
esac
}
_admin() { #DONE
local state
_arguments -C \
'1:admin-cmd:->admin-subcmd' \
'*::admin-arg:->admin-args'
case $state in
admin-subcmd)
local -a admin_subcommands
admin_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"maintainer:Manage repo maintainer"
"query:Query maintainers and topics"
"team:Manage repo team"
"topic:Manage topics"
"transfer:Transfer obsolete repository to landfill"
)
_describe 'admin-cmd' admin_subcommands
return
;;
admin-args)
case $words[1] in
maintainer)
_admin_maintainer
;;
query)
_admin_query
;;
team)
_admin_team
;;
topic)
_admin_topic
;;
transfer)
admin_transfer
;;
esac
;;
esac
}
_git() { # DONE
local state
_arguments \
'1:git-cmd:->git-subcmd' \
'*::git-arg:->git-args'
case $state in
git-subcmd)
local -a git_subcommands
git_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"clone:Clone a package repository"
"config:Configure a clone according to artix specs"
"create:Create a new Gitea package repository"
"pull:Pull a package repository"
"push:Push a package repository"
)
_describe 'git-cmd' git_subcommands
return
;;
git-args)
case $words[1] in
clone)
_git_clone
;;
config)
_git_config
;;
create)
_git_create
;;
pull)
_git_pull
;;
push)
_git_push
;;
esac
;;
esac
}
_repo() { # DONE
local state
_arguments \
'1:repo-cmd:->repo-subcmd' \
'*::repo-arg:->repo-args'
case $state in
repo-subcmd)
local -a repo_subcommands
repo_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"add:Add built pkgbase to repo"
"move:Move built pkgbase between repos"
"remove:Remove built pkgbase from repo"
"import:Import latest tag from arch upstream"
"show:Show the pkgbase's repo db"
)
_describe 'repo-cmd' repo_subcommands
;;
repo-args)
case $words[1] in
add)
_repo_add
;;
move)
_repo_move
;;
remove)
_repo_remove
;;
import)
_repo_import
;;
show)
_repo_show
;;
esac
;;
esac
}
_admin_maintainer() { # DONE
local state
_arguments \
'1:maintainer-cmd:->maintainer-subcmd' \
'*::maintainer-arg:->maintainer-args'
case $state in
maintainer-subcmd)
local -a maintainer_subcommands
maintainer_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--adopt:Adopt repo"
"-a:Adopt repo"
"--orphan:Orphan repo"
"-o:Orphan repo"
)
_describe 'maintainer-cmd' maintainer_subcommands
;;
maintainer-args)
local -a localpkgs
localpkgs=(${(z)$(_artixpkg_pkgbase)})
case $words[1] in
--adopt|-a|--orphan|-o)
_describe 'locals-cmd' localpkgs
;;
esac
;;
esac
}
_admin_query() { # DONE
local state
local -a localpkgs
localpkgs=(${(z)$(_artixpkg_pkgbase)})
local -a query_subcommands
query_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--maintainer:Query for packages of the named maintainer"
"-m:Query for packages of the named maintainer"
"--topic:Query for packages of the named topic"
"-t:Query for packages of the named topic"
)
_arguments \
'1:query-cmd:->query-subcmd' \
'*::query-arg:->query-args'
case $state in
query-subcmd)
_describe 'query-cmd' query_subcommands -- localpkgs
;;
query-args)
local -a maintainers
maintainers=("${(z)$(_artixpkg_maintainers)}")
if [[ ${words[CURRENT-1]} == "-m" || ${words[CURRENT-1]} == "--maintainer" ]] then
_describe 'maintainers-cmd' maintainers
elif [[ ${words[CURRENT-1]} == "-t" || ${words[CURRENT-1]} == "--topic" ]] then
return 0
else
_describe 'query-cmd' query_subcommands -- localpkgs
fi
;;
esac;
}
_admin_team() { # DONE
local -a localpkgs
localpkgs=(${(z)$(_artixpkg_pkgbase)})
local state
local -a team_subcommands
team_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--check:Check if team is assigned"
"-c:Check if team is assigned"
"--list:List repo teams"
"-l:List repo teams"
"--add:Add team to repo"
"-a:Add team to repo"
"--remove:Remove team from repo"
"-r:Remove team from repo"
)
_arguments \
'1:team-cmd:->team-subcmd' \
'*::team-arg:->team-args'
case $state in
team-subcmd)
_describe 'team-cmd' team_subcommands -- localpkgs
;;
team-args)
local -a maintainers
maintainers=("${(z)$(_artixpkg_maintainers)}")
if [[ ${words[CURRENT-1]} == "-a" || ${words[CURRENT-1]} == "--add" || ${words[CURRENT-1]} == "-r" || ${words[CURRENT-1]} == "--remove" ]] then
_describe 'elses cmd' ARTIX_TEAMS
else
_describe 'query-cmd' team_subcommands -- localpkgs
fi
;;
esac
}
_admin_topic() { # DONE
local state
local -a localpkgs
local -a topic_subcommands
topic_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--add:Add a topic to repo"
"-a:Add a topic to repo"
"--remove:Remove a topic from repo"
"-r:Remove a topic from repo"
"--delete:Delete all topics from repo"
"-d:Delete all topics from repo"
"--jobs:Run up to N jobs in parallel (default: 4)"
"-j:Run up to N jobs in parallel (default: 4)"
)
localpkgs=(${(z)$(_artixpkg_pkgbase)})
_arguments \
'1:topic-cmd:->topic-subcmd' \
'*::topic-arg:->topic-args'
case $state in
topic-subcmd)
_describe 'topic-cmd' topic_subcommands -- localpkgs
;;
topic-args)
if [[ ${words[CURRENT-1]} == "-j" || ${words[CURRENT-1]} == "--jobs" || ${words[CURRENT-1]} == "-h" || ${words[CURRENT-1]} == "--help" || ${words[CURRENT-1]} == "-a" || ${words[CURRENT-1]} == "--add" || ${words[CURRENT-1]} == "-r" || ${words[CURRENT-1]} == "--remove" || ${words[CURRENT-1]} == "-d" || ${words[CURRENT-1]} == "--delete" ]] then
return 0
else
_describe 'topic-cmd' topic_subcommands -- localpkgs
fi
;;
esac
}
_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[@]")
admin_transfer() { # DONE
local state
local -a transfer_subcommands
transfer_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
)
local -a localpkgs
localpkgs=(${(z)$(_artixpkg_pkgbase)})
_regex_words ci '' \
'-a' \
'--agent' \
'-h' \
'--help'
cicmd=("$reply[@]")
_arguments \
'1:transfer-cmd:->transfer-subcmd' \
'*::transfer-arg:->transfer-args'
_regex_words clone '' \
'-a' \
'--agent' \
'--all' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-m' \
'--maintainer' \
'--protocol' \
'-s' \
'--search' \
'-t' \
'--team'
clonecmd=("$reply[@]")
case $state in
transfer-subcmd)
_describe 'transfer-cmd' transfer_subcommands -- localpkgs
;;
transfer-args)
case $words[@] in
*)
_describe 'transfer_else-cmd' transfer_subcommands -- localpkgs
;;
esac
;;
esac
}
_regex_words config '' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'--protocol'
configcmd=("$reply[@]")
_git_clone() { # DONE
local state
local -a remotepkgs
local -a clone_subcommands
clone_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--maintainer:Clone all packages of the named maintainer"
"-m:Clone all packages of the named maintainer"
"--search:Clone all packages of the named topic"
"-s:Clone all packages of the named topic"
"--team:Assign team name (default: world)"
"-t:Assign team name (default: world)"
"--jobs:Run up to N jobs in parallel (default: 4)"
"-j:Run up to N jobs in parallel (default: 4)"
"--protocol https:Clone the repository over https"
"--all:Clone all existing packages, useful for cache warming"
)
_regex_words create '' \
'-a' \
'--agent' \
'-c' \
'--create' \
'-h' \
'--help' \
'-t' \
'--team'
createcmd=("$reply[@]")
_arguments \
'1:clone-cmd:->clone-subcmd' \
'*::clone-arg:->clone-args'
_regex_words pull '' \
'--all' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-m' \
'--maintainer' \
'-t' \
'--topic'
pullcmd=("$reply[@]")
case $state in
clone-subcmd)
remotepkgs=(${(z)$(_artixpkg_remotepkgbase)})
_regex_words push '' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-m' \
'--maintainer' \
'-t' \
'--topic'
pushcmd=("$reply[@]")
_describe 'clone-cmd' clone_subcommands -- remotepkgs
;;
clone-args)
case $words[@] in
*)
remotepkgs=(${(z)$(_artixpkg_remotepkgbase)})
_describe 'cloneall-cmd' clone_subcommands -- remotepkgs
;;
esac
;;
esac
}
_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[@]")
_git_config() { # DONE
local state
local -a localpkgs
localpkgs=(${(z)$(_artixpkg_pkgbase)})
local -a config_subcommands
config_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--jobs:Run up to N jobs in parallel (default: 4)"
"-j:Run up to N jobs in parallel (default: 4)"
"--protocol:Configure remote url to use https"
)
_regex_words add '' \
'-h' \
'--help' \
'-n' \
'--nocheck' \
'-p' \
'--push' \
'-r' \
'--rebuild'
addcmd=("$reply[@]")
_arguments \
'1:config-cmd:->config-subcmd' \
'*::config-arg:->config-args'
_regex_words import '' \
'--del' \
'-h' \
'--help' \
'--tag'
importcmd=("$reply[@]")
case $state in
config-subcmd)
_describe 'config-cmd' config_subcommands -- localpkgs
;;
config-args)
if [[ ${words[CURRENT-1]} == "--protocol" ]] then
all_completions=(
'https:HTTPS protocol'
)
_describe 'protocl val' all_completions
elif [[ ${words[CURRENT-1]} == "-j" || ${words[CURRENT-1]} == "--jobs" ]] then
return 0
else
_describe 'localpkgs-cmd' config_subcommands -- localpkgs
fi
;;
esac
}
_regex_words move '' \
'-h' \
'--help' \
'-p' \
'--push'
movecmd=("$reply[@]")
_git_create() { # DONE
local state
local -a create_subcommands
create_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--clone:Clone the Git repository after creation"
"-c:Clone the Git repository after creation"
"--team:Assign team name (default: world)"
"-t:Assign team name (default: world)"
)
_regex_words remove '' \
'-h' \
'--help' \
'-p' \
'--push'
removecmd=("$reply[@]")
_arguments \
'1:create-cmd:->create-subcmd' \
'*::create-arg:->create-args'
_regex_words show '' \
'-b' \
'--base' \
'-h' \
'--help' \
'-p' \
'--pkgs'
showcmd=("$reply[@]")
case $state in
create-subcmd)
_describe 'create-cmd' create_subcommands
;;
create-args)
if [[ ${words[CURRENT-1]} == "-t" || ${words[CURRENT-1]} == "--topic" ]] then
_describe 'teams-cmd' ARTIX_TEAMS
else
_describe 'create-cmd' create_subcommands
fi
esac
}
_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[@]")
_git_pull() { # DONE
local state
local -a localpkgs
localpkgs=(${(z)$(_artixpkg_pkgbase)})
local -a pull_subcommands
pull_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--maintainer:Pull all packages of the named maintainer"
"-m:Pull all packages of the named maintainer"
"--topic:Pull all packages of the named topic"
"-t:Pull all packages of the named topic"
"--jobs:Run up to N jobs in parallel (default: 4)"
"-j:Run up to N jobs in parallel (default: 4)"
"--all:Pull all existing packages"
)
_regex_words version '' \
'-h' \
'--help'
versioncmd=("$reply[@]")
_arguments \
'1:pull-cmd:->pull-subcmd' \
'*::pull-arg:->pull-args'
_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[@]")
case $state in
pull-subcmd)
_describe 'pull-cmd' pull_subcommands -- localpkgs
;;
pull-args)
if [[ ${words[CURRENT-1]} == "--all" ]] then
return 0
elif [[ ${words[CURRENT-1]} == "-m" || ${words[CURRENT-1]} == "--maintainer" ]] then
local -a maintainers
maintainers=("${(z)$(_artixpkg_maintainers)}")
_describe 'maintainers-cmd' maintainers
elif [[ ${words[CURRENT-1]} == "-j" || ${words[CURRENT-1]} == "--jobs" || ${words[CURRENT-1]} == "-t" || ${words[CURRENT-1]} == "--topic" ]] then
return 0
else
_describe 'pull-cmd' pull_subcommands -- localpkgs
fi
;;
esac
}
_git_push() {
local state
local -a push_subcommands
push_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--maintainer:Push all packages of the named maintainer"
"-m:Push all packages of the named maintainer"
"--topic:Push all packages of the named topic"
"-t:Push all packages of the named topic"
)
local -a localpkgs
localpkgs=(${(z)$(_artixpkg_pkgbase)})
_arguments \
'1:push-cmd:->push-subcmd' \
'*::push-arg:->push-args'
case $state in
push-subcmd)
_describe 'push-cmd' push_subcommands -- localpkgs
;;
push-args)
if [[ ${words[CURRENT-1]} == "-m" || ${words[CURRENT-1]} == "--maintainer" ]] then
local -a maintainers
maintainers=("${(z)$(_artixpkg_maintainers)}")
_describe 'maintainers-cmd' maintainers
elif [[ ${words[CURRENT-1]} == "-t" || ${words[CURRENT-1]} == "--topic" ]] then
return 0
else
_describe 'push-cmd' push_subcommands -- localpkgs
fi
;;
esac
}
_repo_add() { # DONE
local state
local -a add_subcommands
local -a localpkgs
localpkgs=(${(z)$(_artixpkg_pkgbase)})
local -a combined_db
combined_db=("${ARTIX_DB[@]}" "${ARTIX_DB_MAP[@]}")
add_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--push:Push pkgbase"
"-p:Push pkgbase"
"--rebuild:Triggers a rebuild"
"-r:Triggers a rebuild"
"--nocheck:Disable the check function"
"-n:Disable the check function"
"--agent:Set the CI agent"
"-a:Set the CI agent"
)
_arguments \
'1:add-cmd:->add-subcmd' \
'*::add-arg:->add-args'
case $state in
add-subcmd)
_describe 'add_cmd' add_subcommands -- ARTIX_DB -- ARTIX_DB_MAP
;;
add-args)
intersections=(${words:*combined_db})
if [[ ${words[CURRENT-1]} == "-a" || ${words[CURRENT-1]} == "--agent" ]] then
_describe 'add_cmd' AGENTS
elif [[ ${#intersections} > 0 ]] then
_describe 'push-cmd' add_subcommands -- localpkgs
else
_describe 'add_cmd' add_subcommands -- combined_db
fi
;;
esac
}
_repo_move() { # DONE
local state
local -a move_subcommands
local -a intersections
local -a localpkgs
localpkgs=(${(z)$(_artixpkg_pkgbase)})
move_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--push:Push pkgbase"
"-p:Push pkgbase"
"--agent:Set the CI agent"
"-a:Set the CI agent"
)
local -a combined_db
combined_db=("${ARTIX_DB[@]}" "${ARTIX_DB_MAP[@]}")
_arguments \
'1:move-cmd:->move-subcmd' \
'*::move-arg:->move-args'
case $state in
move-subcmd)
_describe 'move_cmd' move_subcommands -- ARTIX_DB -- ARTIX_DB_MAP
;;
move-args)
intersections=(${words:*combined_db})
if [[ ${words[CURRENT-1]} == "-a" || ${words[CURRENT-1]} == "--agent" ]] then
_describe 'add_cmd' AGENTS
elif (( ${#intersections} > 1 )) then
_describe 'push-cmd' move_subcommands -- localpkgs
else
_describe 'add_cmd' move_subcommands -- ARTIX_DB -- ARTIX_DB_MAP
fi
;;
esac
}
_repo_remove() { # DONE
local state
local -a remove_subcommands
local -a intersections
remove_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--push:Push pkgbase"
"-p:Push pkgbase"
"--agent:Set the CI agent"
"-a:Set the CI agent"
)
local -a localpkgs
localpkgs=(${(z)$(_artixpkg_pkgbase)})
local -a combined_db
combined_db=("${ARTIX_DB[@]}" "${ARTIX_DB_MAP[@]}")
_arguments \
'1:remove-cmd:->remove-subcmd' \
'*::remove-arg:->remove-args'
case $state in
remove-subcmd)
_describe 'remove_cmd' remove_subcommands -- combined_db
;;
remove-args)
intersections=(${words:*combined_db})
if [[ ${words[CURRENT-1]} == "-a" || ${words[CURRENT-1]} == "--agent" ]] then
_describe 'add_cmd' AGENTS
elif [[ ${#intersections} > 0 ]] then
_describe 'push-cmd' remove_subcommands -- localpkgs
else
_describe 'add_cmd' remove_subcommands -- combined_db
fi
;;
esac
}
_repo_import() {
local state
local -a import_subcommands
import_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--tag:Switch the current workspace to a specified version tag"
"--del:Delete files before rsync import"
"--no-patch:No patch import"
"-n:No patch import"
)
local -a localpkgs
localpkgs=(${(z)$(_artixpkg_pkgbase)})
_arguments \
'1:import-cmd:->import-subcmd' \
'*::import-arg:->import-args'
case $state in
import-subcmd)
_describe 'import-cmd' import_subcommands -- localpkgs
;;
import-args)
if [[ ${words[CURRENT-1]} == "--tag" || ${words[CURRENT-1]} == "-tag" ]] then
return 0
else
_describe 'import-cmd' import_subcommands -- localpkgs
fi
;;
esac
}
_repo_show() {
local state
_arguments \
'1:show-cmd:->show-subcmd' \
'*::show-arg:->show-args'
case $state in
*)
local -a show_subcommands
show_subcommands=(
"-h:Show this help text"
"--help:Show this help text"
"--base:Show srcinfo base"
"-b:Show srcinfo base"
"--pkgs:Show srcinfo pkgs"
"-p:Show srcinfo pkgs"
)
_describe 'show-cmd' show_subcommands
;;
esac
}
_regex_arguments _artixpkg /$'[^\0]##\0'/ "${initialcmd[@]}"
_artixpkg "$@"

View File

@@ -1,17 +0,0 @@
################ 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

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

View File

@@ -21,13 +21,22 @@ configure_calamares(){
msg2 "Configuring: Calamares %s" "$config"
if [[ -f "$mods"/services-artix.conf ]]; then
local svc
local svc usvc
svc=$(yaml_array "${SERVICES[@]}") \
yq -P 'with(.;
.command = "artix-service" |
.services = env(svc) )' \
-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
done
if [[ -d "$1"/etc/calamares-offline ]]; then

View File

@@ -4,9 +4,21 @@
#{{{ 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(){
local mnt="$1"
add_svc_"${INITSYS}" "$mnt" "${SERVICES[*]}"
add_svc_"${INITSYS}" "$mnt"
if [[ "${INITSYS}" == "openrc" ]] || [[ "${INITSYS}" == "dinit" ]]; then
add_user_svc_"${INITSYS}" "$mnt"
fi
}
@@ -14,13 +26,14 @@ write_live_session_conf(){
local conf=''
conf+=$(printf '%s\n' '# live session configuration')
conf+=$(printf "\nAUTOLOGIN=%s\n" "${AUTOLOGIN}")
conf+=$(printf "\nPASSWORD=%s\n" "${PASSWORD}")
conf+=$(printf "\nLIVEUSER=%s\n" "${LIVEUSER}")
printf '%s' "$conf"
}
configure_chroot(){
local fs="$1"
msg "Configuring [%s]" "${fs##*/}"
configure_user "$fs"
configure_services "$fs"
configure_calamares "$fs"
[[ ! -d "$fs/etc/artools" ]] && mkdir -p "$fs/etc/artools"

View File

@@ -7,6 +7,7 @@
show_profile(){
msg2 "iso_file: %s" "${iso_file}"
msg2 "AUTOLOGIN: %s" "${AUTOLOGIN}"
msg2 "LIVEUSER: %s" "${LIVEUSER}"
msg2 "PASSWORD: %s" "${PASSWORD}"
msg2 "SERVICES: %s" "${SERVICES[*]}"
}
@@ -15,79 +16,121 @@ load_profile(){
local profile_dir="${DATADIR}/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"
[[ -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"
common_dir="${DATADIR}/iso-profiles/common"
[[ -d "$profile_dir"/common ]] && common_dir="${profile_dir}"/common
[[ -f $profile_dir/${profile}/profile.conf ]] || return 1
profile_yaml=$profile_dir/${profile}/profile.yaml
# shellcheck source=contrib/iso/profile.conf.example
[[ -r "$profile_dir/${profile}"/profile.conf ]] && . "$profile_dir/${profile}"/profile.conf
common_yaml="${common_dir}/common.yaml"
AUTOLOGIN=${AUTOLOGIN:-true}
[[ -f $profile_yaml ]] || return 1
PASSWORD=${PASSWORD:-'artix'}
LIVEUSER=$(yq -P '.live-session.user' "$profile_yaml")
if [[ -z "${SERVICES[*]}" ]];then
SERVICES=('acpid' 'bluetoothd' 'cronie' 'cupsd' 'syslog-ng' 'connmand')
fi
PASSWORD=$(yq -P '.live-session.password' "$profile_yaml")
AUTOLOGIN=$(yq -P '.live-session.autologin' "$profile_yaml")
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
}
read_from_list() {
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"
mapfile -t pkgs < <(sed "$_com_rm" "$list" \
| sed "$_space" \
| sed "$_init" \
| sed "$_clean" | sort -u)
}
load_pkgs(){
local pkglist="$1"
local list="$1"
local common_base
local common_apps
local common_misc
local common_xorg
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}[]"
packages=()
if [[ "${pkglist##*/}" == "Packages-Root" ]]; then
for l in base apps "${INITSYS}"; do
msg2 "Loading Packages: [%s] ..." "Packages-${l}"
read_from_list "${common_dir}/Packages-${l}"
packages+=("${pkgs[@]}")
case "$list" in
rootfs)
msg2 "Loading Packages: [%s] ..." "common.packages-base"
mapfile -t common_base < <(yq -P '.packages-base[]' "$common_yaml")
done
msg2 "Loading Packages: [%s] ..." "common.packages-init.${INITSYS}"
mapfile -t common_init < <(common_key_init="$common_key_init" yq -P 'eval(strenv(common_key_init))' "$common_yaml")
if [[ -n "${live_list}" ]]; then
msg2 "Loading Packages: [Packages-xorg] ..."
read_from_list "${common_dir}/Packages-xorg"
packages+=("${pkgs[@]}")
fi
msg2 "Loading Packages: [%s] ..." "common.packages-apps"
mapfile -t common_apps < <(yq -P '.packages-apps[]' "$common_yaml")
for svc in "${SERVICES[@]}"; do
case "$svc" in
sddm|gdm|lightdm|mdm|greetd|lxdm|xdm)
packages+=("$svc-${INITSYS}"); display_manager="$svc" ;;
NetworkManager) packages+=("networkmanager-${INITSYS}") ;;
connmand) packages+=("connman-${INITSYS}") ;;
cupsd) packages+=("cups-${INITSYS}") ;;
bluetoothd) packages+=("bluez-${INITSYS}") ;;
syslog-ng|metalog) packages+=("$svc-${INITSYS}") ;;
esac
done
if "${HAS_LIVE}"; then
if ${USE_XLIBRE}; then
msg2 "Loading Packages: [%s] ..." "common.packages-xlibre"
mapfile -t common_xorg < <(yq -P '.packages-xlibre[]' "$common_yaml")
else
msg2 "Loading Packages: [%s] ..." "common.packages-xorg"
mapfile -t common_xorg < <(yq -P '.packages-xorg[]' "$common_yaml")
fi
fi
msg2 "Loading Packages: [%s] ..." "${pkglist##*/}"
read_from_list "${pkglist}"
packages+=("${pkgs[@]}")
msg2 "Loading Packages: [%s] ..." "common.packages-misc"
mapfile -t common_misc < <(yq -P '.packages-misc[]' "$common_yaml")
fi
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,35 +5,68 @@
#{{{ services
add_svc_openrc(){
local mnt="$1" names="$2" rlvl="${3:-default}"
for svc in $names; do
local mnt="$1" rlvl="${2:-default}"
for svc in "${SERVICES[@]}"; do
if [[ -f $mnt/etc/init.d/$svc ]];then
msg2 "Setting %s: [%s]" "${INITSYS}" "$svc"
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
done
}
add_svc_runit(){
local mnt="$1" names="$2" rlvl="${3:-default}"
for svc in $names; do
local mnt="$1" rlvl="${2:-default}"
for svc in "${SERVICES[@]}"; do
if [[ -d $mnt/etc/runit/sv/$svc ]]; then
msg2 "Setting %s: [%s]" "${INITSYS}" "$svc"
chroot "$mnt" ln -s /etc/runit/sv/"$svc" /etc/runit/runsvdir/"$rlvl" &>/dev/null
else
warning "Service %s not found. Skipping." "$svc"
fi
done
}
add_svc_s6(){
local mnt="$1" names="$2" rlvl="${3:-default}" dep
local mnt="$1" rlvl="${2:-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
for svc in $names; do
for svc in "${SERVICES[@]}"; do
msg2 "Setting %s: [%s]" "${INITSYS}" "$svc"
chroot "$mnt" s6-service add "$rlvl" "$svc"
if [[ "$svc" == "$display_manager" ]]; then
if [[ -d "$dep" ]]; then
touch "$dep"/artix-live
if [[ -d "$mnt"/etc/s6/sv/"$svc" ]] || [[ -d "$mnt"/etc/s6/sv/"$svc"-srv ]]; then
chroot "$mnt" s6-service add "$rlvl" "$svc"
if [[ "$svc" == "$display_manager" ]]; then
if [[ -d "$dep" ]]; then
touch "$dep"/artix-live
fi
fi
else
warning "Service %s not found. Skipping." "$svc"
fi
done
@@ -47,22 +80,29 @@ add_svc_s6(){
chroot "$mnt" cp -a "$src"/bin /usr
}
add_svc_suite66(){
local mnt="$1" names="$2"
for svc in $names; do
if [[ -f "$mnt"/etc/66/service/"$svc" ]]; then
add_svc_dinit(){
local mnt="$1"
for svc in "${SERVICES[@]}"; do
if [[ -f "$mnt"/etc/dinit.d/"$svc" ]]; then
msg2 "Setting %s: [%s]" "${INITSYS}" "$svc"
chroot "$mnt" 66-enable -t default "$svc" &>/dev/null
chroot "$mnt" dinitctl enable -o "$svc" &>/dev/null
else
warning "Service %s not found. Skipping." "$svc"
fi
done
}
add_svc_dinit(){
local mnt="$1" names="$2"
for svc in $names; do
if [[ -d $mnt/etc/dinit.d/boot.d ]]; then
msg2 "Setting %s: [%s]" "${INITSYS}" "$svc"
chroot "$mnt" ln -s ../"$svc" /etc/dinit.d/boot.d/"$svc" &>/dev/null
add_user_svc_dinit(){
local mnt="$1"
for svc in "${USER_SERVICES[@]}"; do
if [[ -f "$mnt"/etc/dinit.d/user/"$svc" ]]; then
msg2 "Setting user %s: [%s]" "${INITSYS}" "$svc"
local usr_sv="/home/${LIVEUSER}/.config/dinit.d"
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
done
}

View File

@@ -7,6 +7,9 @@ ARTOOLS_INCLUDE_GIT_PULL_SH=1
set -e
# shellcheck source=src/lib/pkg/db/db.sh
source "${LIBDIR}"/pkg/db/db.sh
artixpkg_git_pull_usage() {
local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
@@ -123,6 +126,11 @@ artixpkg_git_pull() {
die 'failed to pull %s' "${pkgbase}"
fi
msg "Querying ${pkgbase} ..."
if ! show_db; then
warning "Could not query ${REPO_DB}"
fi
)
else
warning "Skip pulling ${pkgbase}: Directory does not exist"

View File

@@ -61,8 +61,6 @@ patch_pkgbase(){
fi
done
fi
git --no-pager diff PKGBUILD
}
artixpkg_repo_import_usage() {
@@ -199,6 +197,7 @@ artixpkg_repo_import() {
msg2 "Patching ${pkgbase} ..."
patch_pkgbase "${pkgbase}"
fi
git --no-pager diff PKGBUILD
fi
)
fi

View File

@@ -132,6 +132,14 @@ artixpkg_repo_remove() {
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