gen-apt-conf: fix option and output handling

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