Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
b4e6dface6 | |||
fa38579488 | |||
07c1605666 | |||
bfde5dbbb1 | |||
0918ff749d | |||
3d3e4376c5 | |||
7499878d00 | |||
d9e99543f6 | |||
43983042dd | |||
1b5f09076f | |||
d770030869 |
3
Makefile
3
Makefile
@@ -26,7 +26,8 @@ LIBS_BASE = \
|
||||
lib/util-msg.sh \
|
||||
lib/util-mount.sh \
|
||||
lib/util-chroot.sh \
|
||||
lib/util-fstab.sh
|
||||
lib/util-fstab.sh \
|
||||
lib/util-yaml.sh
|
||||
|
||||
SHARED_BASE = \
|
||||
$(wildcard data/pacman*.conf)
|
||||
|
@@ -161,12 +161,12 @@ done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
${pretend} && display_settings && exit 1
|
||||
|
||||
check_root
|
||||
|
||||
prepare_traps
|
||||
|
||||
prepare_build
|
||||
|
||||
${pretend} && display_settings && exit 1
|
||||
|
||||
build
|
||||
|
125
bin/pkg2yaml.in
125
bin/pkg2yaml.in
@@ -11,11 +11,21 @@
|
||||
|
||||
VERSION=@version@
|
||||
|
||||
write_attr() {
|
||||
# $1: attr name
|
||||
# $2: attr values
|
||||
LIBDIR='@libdir@'
|
||||
|
||||
local attrname=$1 attrvalues=("${@:2}")
|
||||
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
|
||||
import ${LIBDIR}/util-yaml.sh
|
||||
|
||||
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
|
||||
|
||||
for lib in "$LIBRARY"/*.sh; do
|
||||
source "$lib"
|
||||
done
|
||||
source /etc/makepkg.conf
|
||||
|
||||
write_attr(){
|
||||
local ident1="$1" ident2="$2" ident3="$3"
|
||||
local attrname=$4 attrvalues=("${@:5}")
|
||||
|
||||
# normalize whitespace, strip leading and trailing
|
||||
attrvalues=("${attrvalues[@]//+([[:space:]])/ }")
|
||||
@@ -23,30 +33,26 @@ write_attr() {
|
||||
attrvalues=("${attrvalues[@]%[[:space:]]}")
|
||||
|
||||
case $attrname in
|
||||
depends|makedepends|checkdepends|provides)
|
||||
Yaml+=" $attrname:"$NL
|
||||
makedepends|checkdepends|depends|provides|arch)
|
||||
Yaml+=$(write_yaml_map $ident1 "$attrname")
|
||||
for v in ${attrvalues[@]};do
|
||||
Yaml+=" - $v"$NL
|
||||
Yaml+=$(write_yaml_seq $ident2 "$v")
|
||||
done
|
||||
;;
|
||||
*)
|
||||
for v in ${attrvalues[@]};do
|
||||
Yaml+=" $attrname: ${v}"$NL
|
||||
Yaml+=$(write_yaml_map $ident3 "$attrname" "$v")
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
extract_info() {
|
||||
# $1: pkgname
|
||||
# $2: attr name
|
||||
# $3: multivalued
|
||||
|
||||
local pkgname=$1 attrname=$2 isarray=$3 outvalue=
|
||||
|
||||
if get_pkgbuild_attribute "$pkgname" "$attrname" "$isarray" 'outvalue'; then
|
||||
write_attr "$attrname" "${outvalue[@]}"
|
||||
[[ -z $pkgname ]] && write_attr 2 4 2 "$attrname" "${outvalue[@]}"
|
||||
[[ -n $pkgname ]] && write_attr 4 6 2 "$attrname" "${outvalue[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -54,6 +60,14 @@ write_details() {
|
||||
local attr package_arch a
|
||||
local multivalued_arch_attrs=(provides depends makedepends checkdepends)
|
||||
|
||||
local singlevalued=()
|
||||
local multivalued=(arch provides depends checkdepends)
|
||||
|
||||
if [[ -z "$1" ]];then
|
||||
singlevalued=(pkgver pkgrel epoch)
|
||||
multivalued=(arch provides depends makedepends checkdepends)
|
||||
fi
|
||||
|
||||
for attr in "${singlevalued[@]}"; do
|
||||
extract_info "$1" "$attr" 0
|
||||
done
|
||||
@@ -73,57 +87,62 @@ write_details() {
|
||||
done
|
||||
}
|
||||
|
||||
write_pkginfo_global() {
|
||||
local singlevalued=(pkgver pkgrel epoch)
|
||||
local multivalued=(arch groups provides depends makedepends checkdepends)
|
||||
write_pkg_yaml(){
|
||||
local pkgfile=$(print_all_package_names)
|
||||
|
||||
write_details ''
|
||||
}
|
||||
Yaml=$(write_yaml_header)
|
||||
|
||||
write_pkginfo() {
|
||||
local singlevalued=()
|
||||
local multivalued=(arch groups provides depends checkdepends)
|
||||
Yaml+=$(write_empty_line)
|
||||
|
||||
write_details "$1"
|
||||
}
|
||||
Yaml+=$(write_yaml_map 0 "pkgbase")
|
||||
Yaml+=$(write_yaml_map 2 "pkgname" "${pkgbase:-$pkgname}")
|
||||
${details} && write_details ''
|
||||
|
||||
write_yaml(){
|
||||
Yaml+="---"$NL
|
||||
Yaml+=$(write_empty_line)
|
||||
|
||||
Yaml+=$NL
|
||||
|
||||
Yaml+="pkgfile:"$NL
|
||||
for f in ${pkgfile[@]};do
|
||||
Yaml+=" - ${f##*/}"$NL
|
||||
done
|
||||
Yaml+=$NL
|
||||
|
||||
Yaml+="pkgbase: ${pkgbase:-$pkgname}"$NL
|
||||
write_pkginfo_global
|
||||
Yaml+=$NL
|
||||
|
||||
Yaml+="pkgname:"$NL
|
||||
Yaml+=$(write_yaml_map 0 "package")
|
||||
for pkg in "${pkgname[@]}"; do
|
||||
Yaml+=" - $pkg"$NL
|
||||
write_pkginfo "$pkg"
|
||||
Yaml+=$(write_yaml_seq_map 2 "pkgname" "$pkg")
|
||||
${details} && write_details "$pkg"
|
||||
done
|
||||
|
||||
Yaml+=$(write_empty_line)
|
||||
|
||||
Yaml+=$(write_yaml_map 0 "pkgfile")
|
||||
for f in ${pkgfile[@]};do
|
||||
Yaml+=$(write_yaml_seq 2 "${f##*/}")
|
||||
done
|
||||
|
||||
Yaml+=$(write_empty_line)
|
||||
|
||||
printf '%s' "${Yaml}"
|
||||
}
|
||||
|
||||
if [[ -f "$1"/PKGBUILD ]]; then
|
||||
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options]"
|
||||
echo " -d Don't include details"
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
exit $1
|
||||
}
|
||||
|
||||
for lib in "$LIBRARY"/*.sh; do
|
||||
source "$lib"
|
||||
done
|
||||
. /etc/makepkg.conf
|
||||
details=true
|
||||
|
||||
. "$1"/PKGBUILD
|
||||
opts='dh'
|
||||
|
||||
pkgfile=$(print_all_package_names)
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
d) details=false ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
NL=$'\n'
|
||||
Yaml="%YAML 1.2"$NL
|
||||
write_yaml
|
||||
fi
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
[[ -f "$1"/PKGBUILD ]] || die "%s/PKGBUILD does not exist!" "$1"
|
||||
PACKAGE=$1/PKGBUILD; shift
|
||||
|
||||
source "$PACKAGE"
|
||||
|
||||
write_pkg_yaml
|
||||
|
@@ -60,7 +60,7 @@ load_profile(){
|
||||
[[ -z ${PASSWORD} ]] && PASSWORD="artix"
|
||||
|
||||
if [[ -z ${ADDGROUPS} ]];then
|
||||
ADDGROUPS="video,power,storage,optical,network,lp,scanner,wheel,users,log"
|
||||
ADDGROUPS="video,power,cdrom,network,lp,scanner,wheel,users,log"
|
||||
fi
|
||||
|
||||
if [[ -z ${SERVICES[@]} ]];then
|
||||
@@ -82,23 +82,14 @@ load_profile(){
|
||||
}
|
||||
|
||||
write_live_session_conf(){
|
||||
local path=$1${SYSCONFDIR}
|
||||
[[ ! -d $path ]] && mkdir -p "$path"
|
||||
local conf=$path/live.conf
|
||||
msg2 "Writing %s" "${conf##*/}"
|
||||
echo '# live session configuration' > ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# autologin' >> ${conf}
|
||||
echo "AUTOLOGIN=${AUTOLOGIN}" >> ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# live user name' >> ${conf}
|
||||
echo "USERNAME=${USERNAME}" >> ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# live password' >> ${conf}
|
||||
echo "PASSWORD=${PASSWORD}" >> ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# live group membership' >> ${conf}
|
||||
echo "ADDGROUPS='${ADDGROUPS}'" >> ${conf}
|
||||
msg2 "Writing live.conf"
|
||||
local conf=''
|
||||
conf+=$(printf '%s\n' '# live session configuration')
|
||||
conf+=$(printf "\nAUTOLOGIN=%s\n" "${AUTOLOGIN}")
|
||||
conf+=$(printf "\nUSER_NAME=%s\n" "${USER_NAME}")
|
||||
conf+=$(printf "\nPASSWORD=%s\n" "${PASSWORD}")
|
||||
conf+=$(printf "\nADDGROUPS='%s'\n" "${ADDGROUPS}")
|
||||
printf '%s' "$conf"
|
||||
}
|
||||
|
||||
load_pkgs(){
|
||||
|
@@ -1,84 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
write_users_conf(){
|
||||
local conf="$1/users.conf"
|
||||
msg2 "Writing %s ..." "${conf##*/}"
|
||||
echo "---" > "$conf"
|
||||
echo "defaultGroups:" >> "$conf"
|
||||
local IFS=','
|
||||
for g in ${ADDGROUPS[@]};do
|
||||
echo " - $g" >> "$conf"
|
||||
done
|
||||
unset IFS
|
||||
echo "autologinGroup: autologin" >> "$conf"
|
||||
echo "doAutologin: false" >> "$conf"
|
||||
echo "sudoersGroup: wheel" >> "$conf"
|
||||
echo "setRootPassword: true" >> "$conf"
|
||||
echo "availableShells: /bin/bash, /bin/zsh" >> "$conf" # only used in new 'users' module
|
||||
|
||||
# echo "passwordRequirements:" >> "$conf"
|
||||
# echo " minLength: -1" >> "$conf"
|
||||
# echo " maxLength: -1" >> "$conf"
|
||||
# echo " libpwquality:" >> "$conf"
|
||||
# echo " - minlen=8" >> "$conf"
|
||||
# echo " - minclass=80" >> "$conf"
|
||||
}
|
||||
|
||||
write_servicescfg_conf(){
|
||||
local init="$2"
|
||||
local conf="$1"/services-"$init".conf
|
||||
msg2 "Writing %s ..." "${conf##*/}"
|
||||
echo '---' > "$conf"
|
||||
case "$init" in
|
||||
'runit')
|
||||
echo 'svDir: /etc/runit/sv' >> "$conf"
|
||||
echo '' >> "$conf"
|
||||
echo 'runsvDir: /etc/runit/runsvdir' >> "$conf"
|
||||
echo '' >> "$conf"
|
||||
echo 'services:' >> "$conf"
|
||||
echo " enabled:" >> "$conf"
|
||||
for svc in ${SERVICES[@]};do
|
||||
echo " - name: $svc" >> "$conf"
|
||||
echo ' runlevel: default' >> "$conf"
|
||||
done
|
||||
;;
|
||||
'openrc')
|
||||
echo 'initdDir: /etc/init.d' >> "$conf"
|
||||
echo '' >> "$conf"
|
||||
echo 'runlevelsDir: /etc/runlevels' >> "$conf"
|
||||
echo '' >> "$conf"
|
||||
echo 'services:' >> "$conf"
|
||||
for svc in ${SERVICES[@]};do
|
||||
echo " - name: $svc" >> "$conf"
|
||||
echo ' runlevel: default' >> "$conf"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
write_postcfg_conf(){
|
||||
local conf="$1/postcfg.conf" init="$2"
|
||||
sed -e "s|openrc|$init|" -i "$conf"
|
||||
}
|
||||
|
||||
configure_calamares(){
|
||||
local mods="$1/etc/calamares/modules" init="$2"
|
||||
if [[ -d "$mods" ]];then
|
||||
info "Configuring [Calamares]"
|
||||
write_users_conf "$mods"
|
||||
write_servicescfg_conf "$mods" "$init"
|
||||
write_postcfg_conf "$mods" "$init"
|
||||
local name=services-"$init"
|
||||
sed -e "s|services-openrc|$name|" -i "$1"/etc/calamares/settings.conf
|
||||
info "Done configuring [Calamares]"
|
||||
fi
|
||||
}
|
@@ -11,8 +11,8 @@
|
||||
|
||||
import ${LIBDIR}/util-chroot.sh
|
||||
import ${LIBDIR}/util-iso-grub.sh
|
||||
import ${LIBDIR}/util-iso-yaml.sh
|
||||
import ${LIBDIR}/util-iso-profile.sh
|
||||
import ${LIBDIR}/util-yaml.sh
|
||||
|
||||
track_img() {
|
||||
info "mount: [%s]" "$2"
|
||||
@@ -256,14 +256,79 @@ clean_up_image(){
|
||||
fi
|
||||
}
|
||||
|
||||
write_users_conf(){
|
||||
local yaml=$(write_yaml_header)
|
||||
yaml+=$(write_empty_line)
|
||||
yaml+=$(write_yaml_map 0 'defaultGroups')
|
||||
local IFS=','
|
||||
for g in ${ADDGROUPS[@]};do
|
||||
yaml+=$(write_yaml_seq 2 "$g")
|
||||
done
|
||||
unset IFS
|
||||
yaml+=$(write_yaml_map 0 'autologinGroup' 'autologin')
|
||||
yaml+=$(write_yaml_map 0 'doAutologin' 'false')
|
||||
yaml+=$(write_yaml_map 0 'sudoersGroup' 'wheel')
|
||||
yaml+=$(write_yaml_map 0 'setRootPassword' 'true')
|
||||
yaml+=$(write_yaml_map 0 'availableShells' '/bin/bash, /bin/zsh')
|
||||
# yaml+=$(write_yaml_map 0 'passwordRequirements')
|
||||
# yaml+=$(write_yaml_map 2 'minLength' '-1')
|
||||
# yaml+=$(write_yaml_map 2 'maxLength' '-1')
|
||||
# yaml+=$(write_yaml_map 2 'libpwquality')
|
||||
# yaml+=$(write_yaml_seq 4 "minlen=8")
|
||||
# yaml+=$(write_yaml_seq 4 "minclass=80")
|
||||
yaml+=$(write_empty_line)
|
||||
printf '%s' "${yaml}"
|
||||
}
|
||||
|
||||
write_servicescfg_conf(){
|
||||
local yaml=$(write_yaml_header)
|
||||
yaml+=$(write_empty_line)
|
||||
case "${INITSYS}" in
|
||||
'runit')
|
||||
yaml+=$(write_yaml_map 0 'svDir' '/etc/runit/sv')
|
||||
yaml+=$(write_yaml_map 0 'runsvDir' '/etc/runit/runsvdir')
|
||||
yaml+=$(write_yaml_map 0 'services')
|
||||
yaml+=$(write_yaml_map 2 'enabled')
|
||||
for svc in ${SERVICES[@]};do
|
||||
yaml+=$(write_yaml_seq_map 4 'name' "$svc")
|
||||
yaml+=$(write_yaml_map 6 'runlevel' 'default')
|
||||
done
|
||||
;;
|
||||
'openrc')
|
||||
yaml+=$(write_yaml_map 0 'initdDir' '/etc/init.d')
|
||||
yaml+=$(write_yaml_map 0 'runlevelsDir' '/etc/runlevels')
|
||||
yaml+=$(write_yaml_map 0 'services')
|
||||
for svc in ${SERVICES[@]};do
|
||||
yaml+=$(write_yaml_seq_map 2 'name' "$svc")
|
||||
yaml+=$(write_yaml_map 4 'runlevel' 'default')
|
||||
done
|
||||
;;
|
||||
esac
|
||||
yaml+=$(write_empty_line)
|
||||
printf '%s' "${yaml}"
|
||||
}
|
||||
|
||||
configure_calamares(){
|
||||
local mods="$1/etc/calamares/modules"
|
||||
if [[ -d "$mods" ]];then
|
||||
info "Configuring [Calamares]"
|
||||
write_users_conf > "$mods"/users.conf
|
||||
write_servicescfg_conf > "$mods"/services-"${INITSYS}".conf
|
||||
sed -e "s|openrc|${INITSYS}|" -i "$mods"/postcfg.conf
|
||||
sed -e "s|services-openrc|services-${INITSYS}|" -i "$1"/etc/calamares/settings.conf
|
||||
info "Done configuring [Calamares]"
|
||||
fi
|
||||
}
|
||||
|
||||
configure_live_image(){
|
||||
local fs="$1"
|
||||
msg "Configuring [livefs]"
|
||||
configure_hosts "$fs"
|
||||
configure_system "$fs"
|
||||
configure_services "$fs"
|
||||
configure_calamares "$fs" "${INITSYS}"
|
||||
write_live_session_conf "$fs"
|
||||
configure_calamares "$fs"
|
||||
[[ ! -d "$fs/etc/artools" ]] && mkdir -p "$fs/etc/artools"
|
||||
write_live_session_conf > "$fs/etc/artools/live.conf"
|
||||
msg "Done configuring [livefs]"
|
||||
}
|
||||
|
||||
|
32
lib/util-yaml.sh
Normal file
32
lib/util-yaml.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
write_yaml_header(){
|
||||
printf '%s' '---'
|
||||
}
|
||||
|
||||
write_empty_line(){
|
||||
printf '\n%s\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"
|
||||
}
|
Reference in New Issue
Block a user