gen-apt-conf: fix option and output handling

parent a5f5f7b0
......@@ -6,7 +6,7 @@ NETWORK=false
# shellcheck disable=SC1091
. "$(dirname "$0")/common"
OPTS=$(getopt -o h,d:,r: --long help,net,network,dir:,repos: -- "$@") || {
OPTS=$(getopt -o hd:r: --long help,net,network,dir:,repos: -- "$@") || {
print_error "Ошибка обработки опций."
}
......@@ -28,11 +28,11 @@ while true; do
;;
-d|--dir)
buildertmp="$2"
shift
shift 2
;;
-r|--repos)
REPOS="${2//,/ }"
shift
shift 2
;;
--net|--network)
NETWORK=true
......@@ -48,6 +48,12 @@ while true; do
esac
done
if [ -z "$buildertmp" ] || [ "${buildertmp#-}" != "$buildertmp" ]; then
print_error "Не указан tmp каталог: используйте -d или --dir"
fi
mkdir -p -- "$buildertmp" || print_error "Не удалось создать tmp каталог: $buildertmp"
APTCONF="$buildertmp/apt.conf.ximper"
SOURCES="$buildertmp/sources.list.ximper"
......@@ -88,16 +94,18 @@ EOF
}
gen_sources() {
local repo
for repo in $REPOS; do
if [[ "$repo" == *hasher* ]]; then
if [ "$repo" == "hasher" ]; then
cat <<EOF >> "$SOURCES"
rpm-dir file:/tmp/.private/$USER/hasher-sisyphus-64/ repo/x86_64 hasher
EOF
continue
fi
local def="${REPO_DEFS[$repo]}"
[ -z "$def" ] && continue
local def="${REPO_DEFS[$repo]-}"
[ -n "$def" ] || print_error "Неизвестный репозиторий: $repo. Используйте -h для справки."
IFS='|' read -r type path <<< "$def"
add_repo "$type" "$path"
......@@ -105,7 +113,7 @@ EOF
}
gen_config() {
cat <<EOF >> "$APTCONF"
cat <<EOF > "$APTCONF"
/*
* This is the main configuration file for the APT suite of tools,
* see apt.conf(5) for details.
......
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