check-yaml: initial commit

This commit is contained in:
udeved 2016-08-21 15:20:29 +02:00
parent 52adabc6bd
commit f46afe9478
6 changed files with 184 additions and 9 deletions

View file

@ -64,7 +64,8 @@ LIST_ISO = \
BIN_ISO = \
bin/buildiso \
bin/testiso \
bin/deployiso
bin/deployiso \
bin/check-yaml
LIBS_ISO = \
lib/util-iso.sh \
@ -73,7 +74,8 @@ LIBS_ISO = \
lib/util-iso-image.sh \
lib/util-iso-calamares.sh \
lib/util-iso-boot.sh \
lib/util-publish.sh
lib/util-publish.sh \
lib/util-iso-yaml.sh
SHARED_ISO = \
data/pacman-mhwd.conf \

106
bin/check-yaml.in Normal file
View file

@ -0,0 +1,106 @@
#!/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.
version=@version@
LIBDIR='@libdir@'
DATADIR='@datadir@'
SYSCONFDIR='@sysconfdir@'
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
import ${LIBDIR}/util.sh
import ${LIBDIR}/util-iso-yaml.sh
show_profile(){
prepare_profile "$1"
msg2 "yaml_dir: %s" "${work_dir}"
msg2 "yaml file: %s" "${yaml}"
msg2 "nonfree_mhwd: %s" "${nonfree_mhwd}"
[[ ${target_arch} == 'x86_64' ]] && msg2 "multilib: %s" "${multilib}"
${netinstall} && msg2 "netgroups: %s" "$(get_yaml)"
reset_profile
}
display_settings(){
show_version
show_config
msg "PROFILE:"
msg2 "list_dir_iso: %s" "${list_dir_iso}"
msg2 "build_lists: %s" "$(show_build_lists ${list_dir_iso})"
msg2 "build_list_iso: %s" "${build_list_iso}"
msg2 "is_build_list: %s" "${is_build_list}"
msg2 "build_mirror: %s" "${build_mirror}/${target_branch}"
${verbose} && msg2 "run_dir: %s" "${run_dir}"
msg "OPTIONS:"
msg2 "arch: %s" "${target_arch}"
msg2 "initsys: %s" "${initsys}"
msg2 "kernel: %s" "${kernel}"
msg "ARGS:"
msg2 "calamares: %s" "${calamares}"
msg "BUILD QUEUE:"
run show_profile "${build_list_iso}"
}
load_user_info
load_config "${USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
# to force old way to have buildiso run in iso-profiles dir
# run_dir=$(pwd)
load_run_dir "${profile_repo}"
calamares=false
cache_dir_netinstall="${cache_dir}/netinstall"
usage() {
echo "Usage: ${0##*/} [options]"
echo " -p <profile> Buildset or profile [default: ${build_list_iso}]"
echo " -a <arch> Arch [default: ${target_arch}]"
echo " -k <name> Kernel to use[default: ${kernel}]"
echo " -i <name> Init system to use [default: ${initsys}]"
echo ' -c Check also calamares yaml files generated for the profile'
echo ' -h This help'
echo ''
echo ''
exit $1
}
orig_argv=("$@")
opts='p:a:i:k:ch'
while getopts "${opts}" arg; do
case "${arg}" in
p) build_list_iso="$OPTARG" ;;
a) target_arch="$OPTARG" ;;
i) initsys="$OPTARG" ;;
k) kernel="$OPTARG" ;;
c) calamares=true ;;
h|?) usage 0 ;;
*) echo "invalid argument '${arg}'"; usage 1 ;;
esac
done
shift $(($OPTIND - 1))
check_root "$0" "${orig_argv[@]}"
run make_profile_yaml "${build_list_iso}"

67
lib/util-iso-yaml.sh Normal file
View file

@ -0,0 +1,67 @@
#!/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-iso.sh
import ${LIBDIR}/util-iso-calamares.sh
check_yaml(){
result=$(python -c 'import yaml,sys;yaml.safe_load(sys.stdin)' < $1)
[[ -n ${result} ]] && error "yaml error: %s [msg: %s]" "$1" "${result}"
}
write_netgroup_yaml(){
echo "- name: '$1'" > "$2"
echo " description: '$1'" >> "$2"
echo " selected: false" >> "$2"
echo " hidden: false" >> "$2"
echo " packages:" >> "$2"
for p in ${packages[@]};do
echo " - $p" >> "$2"
done
check_yaml "$2"
}
prepare_profile(){
profile=$1
edition=$(get_edition ${profile})
profile_dir=${run_dir}/${edition}/${profile}
check_profile
load_profile_config "${profile_dir}/profile.conf"
yaml_dir=${cache_dir_netinstall}/${profile}
prepare_dir "${yaml_dir}"
chown "${OWNER}:${OWNER}" "${yaml_dir}"
}
write_calamares_yaml(){
configure_calamares "${yaml_dir}"
for conf in "${yaml_dir}"/etc/calamares/modules/*.conf "${yaml_dir}"/etc/calamares/settings.conf; do
check_yaml "$conf"
done
}
make_profile_yaml(){
prepare_profile "$1"
load_pkgs "${profile_dir}/Packages-Root"
yaml=${yaml_dir}/root-${target_arch}-${initsys}.yaml
write_netgroup_yaml "$1" "${yaml}"
if [[ -f "${packages_custom}" ]]; then
load_pkgs "${packages_custom}"
yaml=${yaml_dir}/desktop-${target_arch}-${initsys}.yaml
write_netgroup_yaml "$1" "${yaml}"
fi
${calamares} && write_calamares_yaml "$1"
user_own "${yaml_dir}"
reset_profile
unset yaml
unset yaml_dir
}

View file

@ -563,7 +563,7 @@ check_profile(){
[[ -f "${profile_dir}/Packages-Mhwd" ]] && packages_mhwd=${profile_dir}/Packages-Mhwd
if ! ${netinstall};then
if ! ${netinstall} && ! ${unpackfs};then
unpackfs="true"
fi
}
@ -612,7 +612,7 @@ compress_images(){
make_checksum "${iso_file}"
${sign} && sign_iso "${iso_file}"
${torrent} && make_torrent
chown -R "${OWNER}:$(id --group ${OWNER})" "${iso_dir}"
user_own "${iso_dir}"
show_elapsed_time "${FUNCNAME}" "${timer}"
}

View file

@ -250,7 +250,7 @@ move_to_cache(){
mv $src ${pkg_dir}/
${sign} && sign_pkg "${src##*/}"
[[ -n $PKGDEST ]] && rm "$1"
chown -R "${OWNER}:$(id --group ${OWNER})" "${pkg_dir}"
user_own "${pkg_dir}"
}
archive_logs(){

View file

@ -457,15 +457,15 @@ load_profile_config(){
[[ -z ${netgroups} ]] && netgroups="https://raw.githubusercontent.com/manjaro/manjaro-tools-iso-profiles/master/shared/netinstall"
if ! ${unpackfs} && ! ${netinstall};then
netinstall='true'
fi
check_profile_vars
return 0
}
user_own(){
chown -R "${OWNER}:$(id --group ${OWNER})" "$1"
}
clean_dir(){
if [[ -d $1 ]]; then
msg "Cleaning [%s] ..." "$1"