Commit f1d8bb4f authored by udeved's avatar udeved

buildiso, check-yaml: reorganize and prepare for possible python yaml port

parent feab13d1
......@@ -88,7 +88,7 @@ BIN_YAML = \
bin/check-yaml
LIBS_YAML = \
lib/util-yaml.sh \
$(wildcard lib/util-yaml*.sh) \
lib/util-profile.sh
SHARED_YAML = \
......
......@@ -18,13 +18,13 @@ SYSCONFDIR='@sysconfdir@'
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
import ${LIBDIR}/util.sh
import ${LIBDIR}/util-yaml.sh
import ${LIBDIR}/util-yaml-check.sh
import ${LIBDIR}/util-profile.sh
prepare_check(){
profile="$1"
local edition=$(get_edition ${profile})
profile_dir=${run_dir}/${edition}/${profile}
edition=$(get_edition ${profile})
local profile_dir=${run_dir}/${edition}/${profile}
load_profile "${profile_dir}"
......
......@@ -475,18 +475,18 @@ compress_images(){
prepare_images(){
local timer=$(get_timer)
load_pkgs "${root_list}"
load_pkgs "${root_list}" "${target_arch}" "${edition}" "${initsys}" "${kernel}"
run_safe "make_image_root"
if [[ -f "${desktop_list}" ]] ; then
load_pkgs "${desktop_list}"
load_pkgs "${desktop_list}" "${target_arch}" "${edition}" "${initsys}" "${kernel}"
run_safe "make_image_desktop"
fi
if [[ -f ${live_list} ]]; then
load_pkgs "${live_list}"
load_pkgs "${live_list}" "${target_arch}" "${edition}" "${initsys}" "${kernel}"
run_safe "make_image_live"
fi
if ! ${netinstall} ; then
load_pkgs "${mhwd_list}"
load_pkgs "${mhwd_list}" "${target_arch}" "${edition}" "${initsys}" "${kernel}"
run_safe "make_image_mhwd"
fi
run_safe "make_image_boot"
......
......@@ -155,102 +155,86 @@ reset_profile(){
# $1: file name
load_pkgs(){
info "Loading Packages: [%s] ..." "${1##*/}"
local _init _init_rm
case "${initsys}" in
'openrc')
_init="s|>openrc||g"
_init_rm="s|>systemd.*||g"
;;
*)
_init="s|>systemd||g"
_init_rm="s|>openrc.*||g"
;;
esac
local _multi _nonfree_default _nonfree_multi _arch _arch_rm _nonfree_i686 _nonfree_x86_64 _basic _basic_rm _extra _extra_rm
local pkglist="$1" arch="$2" ed="$3" init="$4" _kv="$5"
info "Loading Packages: [%s] ..." "${pkglist##*/}"
local _init="s|>systemd||g" _init_rm="s|>openrc.*||g"
if [[ $init == "openrc" ]];then
_init="s|>openrc||g"
_init_rm="s|>systemd.*||g"
fi
local _basic="s|>basic.*||g"
if ${basic};then
_basic="s|>basic||g"
else
_basic_rm="s|>basic.*||g"
fi
local _extra="s|>extra.*||g"
if ${extra};then
_extra="s|>extra||g"
else
_extra_rm="s|>extra.*||g"
fi
case "${target_arch}" in
"i686")
_arch="s|>i686||g"
_arch_rm="s|>x86_64.*||g"
_multi="s|>multilib.*||g"
_nonfree_multi="s|>nonfree_multilib.*||g"
_nonfree_x86_64="s|>nonfree_x86_64.*||g"
local _edition="s|>manjaro||g" _edition_rm="s|>sonar.*||g"
if [[ "$ed" == 'sonar' ]];then
_edition="s|>sonar||g"
_edition_rm="s|>manjaro.*||g"
fi
local _multi _nonfree_default _nonfree_multi _arch _arch_rm _nonfree_i686 _nonfree_x86_64
if [[ "$arch" == 'i686' ]];then
_arch="s|>i686||g"
_arch_rm="s|>x86_64.*||g"
_multi="s|>multilib.*||g"
_nonfree_multi="s|>nonfree_multilib.*||g"
_nonfree_x86_64="s|>nonfree_x86_64.*||g"
if ${nonfree_mhwd};then
_nonfree_default="s|>nonfree_default||g"
_nonfree_i686="s|>nonfree_i686||g"
else
_nonfree_default="s|>nonfree_default.*||g"
_nonfree_i686="s|>nonfree_i686.*||g"
fi
else
_arch="s|>x86_64||g"
_arch_rm="s|>i686.*||g"
_nonfree_i686="s|>nonfree_i686.*||g"
if ${multilib};then
_multi="s|>multilib||g"
if ${nonfree_mhwd};then
_nonfree_default="s|>nonfree_default||g"
_nonfree_i686="s|>nonfree_i686||g"
_nonfree_x86_64="s|>nonfree_x86_64||g"
_nonfree_multi="s|>nonfree_multilib||g"
else
_nonfree_default="s|>nonfree_default.*||g"
_nonfree_i686="s|>nonfree_i686.*||g"
_nonfree_multi="s|>nonfree_multilib.*||g"
_nonfree_x86_64="s|>nonfree_x86_64.*||g"
fi
;;
*)
_arch="s|>x86_64||g"
_arch_rm="s|>i686.*||g"
_nonfree_i686="s|>nonfree_i686.*||g"
if ${multilib};then
_multi="s|>multilib||g"
if ${nonfree_mhwd};then
_nonfree_default="s|>nonfree_default||g"
_nonfree_x86_64="s|>nonfree_x86_64||g"
_nonfree_multi="s|>nonfree_multilib||g"
else
_nonfree_default="s|>nonfree_default.*||g"
_nonfree_multi="s|>nonfree_multilib.*||g"
_nonfree_x86_64="s|>nonfree_x86_64.*||g"
fi
else
_multi="s|>multilib.*||g"
if ${nonfree_mhwd};then
_nonfree_default="s|>nonfree_default||g"
_nonfree_x86_64="s|>nonfree_x86_64||g"
_nonfree_multi="s|>nonfree_multilib.*||g"
else
_multi="s|>multilib.*||g"
if ${nonfree_mhwd};then
_nonfree_default="s|>nonfree_default||g"
_nonfree_x86_64="s|>nonfree_x86_64||g"
_nonfree_multi="s|>nonfree_multilib.*||g"
else
_nonfree_default="s|>nonfree_default.*||g"
_nonfree_x86_64="s|>nonfree_x86_64.*||g"
_nonfree_multi="s|>nonfree_multilib.*||g"
fi
_nonfree_default="s|>nonfree_default.*||g"
_nonfree_x86_64="s|>nonfree_x86_64.*||g"
_nonfree_multi="s|>nonfree_multilib.*||g"
fi
;;
esac
local _edition _edition_rm
case "${edition}" in
'sonar')
_edition="s|>sonar||g"
_edition_rm="s|>manjaro.*||g"
;;
*)
_edition="s|>manjaro||g"
_edition_rm="s|>sonar.*||g"
;;
esac
fi
fi
local _blacklist="s|>blacklist.*||g" \
_kernel="s|KERNEL|$kernel|g" \
_used_kernel=${kernel:5:2} \
_kernel="s|KERNEL|$_kv|g" \
_used_kernel=${_kv:5:2} \
_space="s| ||g" \
_clean=':a;N;$!ba;s/\n/ /g' \
_com_rm="s|#.*||g" \
_purge="s|>cleanup.*||g" \
_purge_rm="s|>cleanup||g"
packages=($(sed "$_com_rm" "$1" \
packages=($(sed "$_com_rm" "$pkglist" \
| sed "$_space" \
| sed "$_blacklist" \
| sed "$_purge" \
......@@ -267,16 +251,14 @@ load_pkgs(){
| sed "$_edition" \
| sed "$_edition_rm" \
| sed "$_basic" \
| sed "$_basic_rm" \
| sed "$_extra" \
| sed "$_extra_rm" \
| sed "$_clean"))
if [[ $1 == "${mhwd_list}" ]]; then
if [[ $pkglist == "${mhwd_list}" ]]; then
[[ ${_used_kernel} < "42" ]] && local _amd="s|xf86-video-amdgpu||g"
packages_cleanup=($(sed "$_com_rm" "$1" \
packages_cleanup=($(sed "$_com_rm" "$pkglist" \
| grep cleanup \
| sed "$_purge_rm" \
| sed "$_kernel" \
......
#!/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.
import ${LIBDIR}/util-yaml.sh
check_yaml(){
msg2 "Checking validity [%s] ..." "${1##*/}"
local name=${1##*/} data=$1 schema
case ${name##*.} in
yaml)
name=netgroups
# data=$1
;;
conf)
name=${name%.conf}
# data=${tmp_dir}/$name.yaml
# cp $1 $data
;;
esac
local schemas_dir=/usr/share/calamares/schemas
schema=${schemas_dir}/$name.schema.yaml
# pykwalify -d $data -s $schema
kwalify -lf $schema $data
}
write_calamares_yaml(){
configure_calamares "${yaml_dir}"
if ${validate}; then
for conf in "${yaml_dir}"/etc/calamares/modules/*.conf "${yaml_dir}"/etc/calamares/settings.conf; do
check_yaml "$conf"
done
fi
}
write_netgroup_yaml(){
msg2 "Writing %s ..." "${2##*/}"
echo "---" > "$2"
echo "- name: '$1'" >> "$2"
echo " description: '$1'" >> "$2"
echo " selected: false" >> "$2"
echo " hidden: false" >> "$2"
echo " critical: false" >> "$2"
echo " packages:" >> "$2"
for p in ${packages[@]};do
echo " - $p" >> "$2"
done
${validate} && check_yaml "$2"
}
write_pacman_group_yaml(){
packages=$(pacman -Sgq "$1")
prepare_dir "${cache_dir_netinstall}/pacman"
write_netgroup_yaml "$1" "${cache_dir_netinstall}/pacman/$1.yaml"
${validate} && check_yaml "${cache_dir_netinstall}/pacman/$1.yaml"
user_own "${cache_dir_netinstall}/pacman" "-R"
}
gen_fn(){
echo "${yaml_dir}/$1-${target_arch}-${initsys}.yaml"
}
make_profile_yaml(){
prepare_check "$1"
load_pkgs "${root_list}" "${target_arch}" "${edition}" "${initsys}" "${kernel}"
write_netgroup_yaml "$1" "$(gen_fn "Packages-Root")"
if [[ -f "${desktop_list}" ]]; then
load_pkgs "${desktop_list}" "${target_arch}" "${edition}" "${initsys}" "${kernel}"
write_netgroup_yaml "$1" "$(gen_fn "Packages-Desktop")"
fi
${calamares} && write_calamares_yaml "$1"
user_own "${cache_dir_netinstall}/$1" "-R"
reset_profile
unset yaml_dir
}
......@@ -349,73 +349,3 @@ configure_calamares(){
write_settings_conf "$1"
info "Done configuring [Calamares]"
}
check_yaml(){
msg2 "Checking validity [%s] ..." "${1##*/}"
local name=${1##*/} data=$1 schema
case ${name##*.} in
yaml)
name=netgroups
# data=$1
;;
conf)
name=${name%.conf}
# data=${tmp_dir}/$name.yaml
# cp $1 $data
;;
esac
local schemas_dir=/usr/share/calamares/schemas
schema=${schemas_dir}/$name.schema.yaml
# pykwalify -d $data -s $schema
kwalify -lf $schema $data
}
write_calamares_yaml(){
configure_calamares "${yaml_dir}"
if ${validate}; then
for conf in "${yaml_dir}"/etc/calamares/modules/*.conf "${yaml_dir}"/etc/calamares/settings.conf; do
check_yaml "$conf"
done
fi
}
write_netgroup_yaml(){
msg2 "Writing %s ..." "${2##*/}"
echo "---" > "$2"
echo "- name: '$1'" >> "$2"
echo " description: '$1'" >> "$2"
echo " selected: false" >> "$2"
echo " hidden: false" >> "$2"
echo " critical: false" >> "$2"
echo " packages:" >> "$2"
for p in ${packages[@]};do
echo " - $p" >> "$2"
done
${validate} && check_yaml "$2"
}
write_pacman_group_yaml(){
packages=$(pacman -Sgq "$1")
prepare_dir "${cache_dir_netinstall}/pacman"
write_netgroup_yaml "$1" "${cache_dir_netinstall}/pacman/$1.yaml"
${validate} && check_yaml "${cache_dir_netinstall}/pacman/$1.yaml"
user_own "${cache_dir_netinstall}/pacman" "-R"
}
gen_fn(){
echo "${yaml_dir}/$1-${target_arch}-${initsys}.yaml"
}
make_profile_yaml(){
prepare_check "$1"
load_pkgs "${root_list}"
write_netgroup_yaml "$1" "$(gen_fn "Packages-Root")"
if [[ -f "${desktop_list}" ]]; then
load_pkgs "${desktop_list}"
write_netgroup_yaml "$1" "$(gen_fn "Packages-Desktop")"
fi
${calamares} && write_calamares_yaml "$1"
user_own "${cache_dir_netinstall}/$1" "-R"
reset_profile
unset yaml_dir
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment