Compare commits

...

3 Commits

Author SHA1 Message Date
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
9 changed files with 196 additions and 97 deletions

View File

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

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,28 @@
---
# 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: []
# 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,125 @@ 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")
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_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-apps"
mapfile -t common_apps < <(yq -P '.packages-apps[]' "$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-init.${INITSYS}"
mapfile -t common_init < <(common_key_init="$common_key_init" yq -P 'eval(strenv(common_key_init))' "$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
fi
msg2 "Loading Packages: [%s] ..." "${pkglist##*/}"
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_apps[@]}"
"${common_init[@]}"
"${packages_root[@]}"
"${packages_root_init[@]}"
)
if "${HAS_LIVE}"; then
packages+=(
"${common_xorg}"
)
fi
for svc in "${SERVICES[@]}"; do
case "$svc" in
sddm|gdm|lightdm|mdm|greetd|lxdm|xdm)
display_manager="$svc"
;;
esac
done
;;
livefs)
msg2 "Loading Packages: [%s] ..." "livefs.packages"
mapfile -t packages_live < <(yq -P '.livefs.packages[]' "$profile_yaml")
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")
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,8 +5,8 @@
#{{{ 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
@@ -14,9 +14,22 @@ add_svc_openrc(){
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
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
@@ -25,9 +38,9 @@ add_svc_runit(){
}
add_svc_s6(){
local mnt="$1" names="$2" rlvl="${3:-default}" dep
local mnt="$1" rlvl="${2:-default}" dep
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
@@ -47,22 +60,25 @@ 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 [[ -d $mnt/etc/dinit.d/boot.d ]]; then
msg2 "Setting %s: [%s]" "${INITSYS}" "$svc"
chroot "$mnt" 66-enable -t default "$svc" &>/dev/null
chroot "$mnt" dinitctl enable -o "$svc" &>/dev/null
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"
fi
done
}

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