drop util-pac-conf and util-iso-log

This commit is contained in:
udeved 2016-02-27 00:39:58 +01:00
parent a444946df8
commit bec3a5c595
5 changed files with 114 additions and 139 deletions

View file

@ -18,7 +18,6 @@ LIBS_BASE = \
lib/util.sh \
lib/util-mount.sh \
lib/util-msg.sh \
lib/util-pac-conf.sh \
lib/util-fstab.sh
SHARED_BASE = \
@ -70,8 +69,7 @@ LIBS_ISO = \
lib/util-iso-image.sh \
lib/util-iso-calamares.sh \
lib/util-iso-boot.sh \
lib/util-publish.sh \
lib/util-iso-log.sh
lib/util-publish.sh
SHARED_ISO = \
data/pacman-gfx.conf \

View file

@ -1,58 +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.
error_function() {
if [[ -p $logpipe ]]; then
rm "$logpipe"
fi
# first exit all subshells, then print the error
if (( ! BASH_SUBSHELL )); then
error "A failure occurred in %s()." "$1"
plain "Aborting..."
fi
for mp in ${work_dir}/{root,${profile},live,mhwd,boot}-image;do
umount_image "$mp"
done
exit 2
}
# $1: function
run_log(){
local func="$1"
local tmpfile=/tmp/$func.ansi.log logfile=${log_dir}/$(gen_iso_fn).$func.log
logpipe=$(mktemp -u "/tmp/$func.pipe.XXXXXXXX")
mkfifo "$logpipe"
tee "$tmpfile" < "$logpipe" &
local teepid=$!
$func &> "$logpipe"
wait $teepid
rm "$logpipe"
cat $tmpfile | perl -pe 's/\e\[?.*?[\@-~]//g' > $logfile
rm "$tmpfile"
}
run_safe() {
local restoretrap func="$1"
set -e
set -E
restoretrap=$(trap -p ERR)
trap 'error_function $func' ERR SIGINT SIGTERM
if ${is_log};then
run_log "$func"
else
"$func"
fi
eval $restoretrap
set +E
set +e
}

View file

@ -12,8 +12,73 @@
import ${LIBDIR}/util-iso-image.sh
import ${LIBDIR}/util-iso-boot.sh
import ${LIBDIR}/util-iso-calamares.sh
import ${LIBDIR}/util-pac-conf.sh
import ${LIBDIR}/util-iso-log.sh
error_function() {
if [[ -p $logpipe ]]; then
rm "$logpipe"
fi
# first exit all subshells, then print the error
if (( ! BASH_SUBSHELL )); then
error "A failure occurred in %s()." "$1"
plain "Aborting..."
fi
for mp in ${work_dir}/{root,${profile},live,mhwd,boot}-image;do
umount_image "$mp"
done
exit 2
}
# $1: function
run_log(){
local func="$1"
local tmpfile=/tmp/$func.ansi.log logfile=${log_dir}/$(gen_iso_fn).$func.log
logpipe=$(mktemp -u "/tmp/$func.pipe.XXXXXXXX")
mkfifo "$logpipe"
tee "$tmpfile" < "$logpipe" &
local teepid=$!
$func &> "$logpipe"
wait $teepid
rm "$logpipe"
cat $tmpfile | perl -pe 's/\e\[?.*?[\@-~]//g' > $logfile
rm "$tmpfile"
}
run_safe() {
local restoretrap func="$1"
set -e
set -E
restoretrap=$(trap -p ERR)
trap 'error_function $func' ERR SIGINT SIGTERM
if ${is_log};then
run_log "$func"
else
"$func"
fi
eval $restoretrap
set +E
set +e
}
clean_pacman_conf(){
local repositories=$(get_repos "${pacman_conf}") uri='file://'
msg "Cleaning [%s/etc/pacman.conf] ..." "$1"
for repo in ${repositories[@]}; do
case ${repo} in
'options'|'core'|'extra'|'community'|'multilib') continue ;;
*)
msg2 "parsing [%s] ..." "${repo}"
parse_section "${repo}" "${pacman_conf}"
if [[ ${pc_value} == $uri* ]]; then
msg2 "Removing local repo [%s] ..." "${repo}"
sed -i "/^\[${repo}/,/^Server/d" $1/etc/pacman.conf
fi
;;
esac
done
msg "Done cleaning [%s/etc/pacman.conf]" "$1"
}
# $1: image path
make_sqfs() {

View file

@ -1,74 +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.
# $1: section
parse_section() {
local is_section=0
while read line; do
[[ $line =~ ^\ {0,}# ]] && continue
[[ -z "$line" ]] && continue
if [ $is_section == 0 ]; then
if [[ $line =~ ^\[.*?\] ]]; then
line=${line:1:$((${#line}-2))}
section=${line// /}
if [[ $section == $1 ]]; then
is_section=1
continue
fi
continue
fi
elif [[ $line =~ ^\[.*?\] && $is_section == 1 ]]; then
break
else
pc_key=${line%%=*}
pc_key=${pc_key// /}
pc_value=${line##*=}
pc_value=${pc_value## }
eval "$pc_key='$pc_value'"
fi
done < "${pacman_conf}"
}
get_repos() {
local section repos=() filter='^\ {0,}#'
while read line; do
[[ $line =~ "${filter}" ]] && continue
[[ -z "$line" ]] && continue
if [[ $line =~ ^\[.*?\] ]]; then
line=${line:1:$((${#line}-2))}
section=${line// /}
case ${section} in
"options") continue ;;
*) repos+=("${section}") ;;
esac
fi
done < "${pacman_conf}"
echo ${repos[@]}
}
clean_pacman_conf(){
local repositories=$(get_repos) uri='file://'
msg "Cleaning [%s/etc/pacman.conf] ..." "$1"
for repo in ${repositories[@]}; do
case ${repo} in
'options'|'core'|'extra'|'community'|'multilib') continue ;;
*)
msg2 "parsing [%s] ..." "${repo}"
parse_section ${repo}
if [[ ${pc_value} == $uri* ]]; then
msg2 "Removing local repo [%s] ..." "${repo}"
sed -i "/^\[${repo}/,/^Server/d" $1/etc/pacman.conf
fi
;;
esac
done
msg "Done cleaning [%s/etc/pacman.conf]" "$1"
}

View file

@ -8,6 +8,51 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# $1: section
parse_section() {
local is_section=0
while read line; do
[[ $line =~ ^\ {0,}# ]] && continue
[[ -z "$line" ]] && continue
if [ $is_section == 0 ]; then
if [[ $line =~ ^\[.*?\] ]]; then
line=${line:1:$((${#line}-2))}
section=${line// /}
if [[ $section == $1 ]]; then
is_section=1
continue
fi
continue
fi
elif [[ $line =~ ^\[.*?\] && $is_section == 1 ]]; then
break
else
pc_key=${line%%=*}
pc_key=${pc_key// /}
pc_value=${line##*=}
pc_value=${pc_value## }
eval "$pc_key='$pc_value'"
fi
done < "$2"
}
get_repos() {
local section repos=() filter='^\ {0,}#'
while read line; do
[[ $line =~ "${filter}" ]] && continue
[[ -z "$line" ]] && continue
if [[ $line =~ ^\[.*?\] ]]; then
line=${line:1:$((${#line}-2))}
section=${line// /}
case ${section} in
"options") continue ;;
*) repos+=("${section}") ;;
esac
fi
done < "$1"
echo ${repos[@]}
}
read_set(){
local _space="s| ||g" \
_clean=':a;N;$!ba;s/\n/ /g' \
@ -32,10 +77,9 @@ list_sets(){
# $2: buildset
eval_buildset(){
eval "case $2 in
$(list_sets $1)) is_buildset=true ;;
$(list_sets $1)) is_buildset=true; read_set $1/$2 ;;
*) is_buildset=false ;;
esac"
${is_buildset} && read_set $1/$2
}
get_edition(){