summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-05-03 01:05:05 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-05-03 01:39:15 -0400
commite5b63059b96ef63bfda4e8d28e2de97a58b6aee3 (patch)
treed48a31cef03c03ddd8be53374d3ca3a5acb8169b /src
parentf9141fda60ca94d9b1c75022f6129fabfab1cc6b (diff)
libredbdiff: simplify downloadfile
Diffstat (limited to 'src')
-rwxr-xr-xsrc/abslibre-tools/libredbdiff64
1 files changed, 31 insertions, 33 deletions
diff --git a/src/abslibre-tools/libredbdiff b/src/abslibre-tools/libredbdiff
index bb2d4c0..e88eb91 100755
--- a/src/abslibre-tools/libredbdiff
+++ b/src/abslibre-tools/libredbdiff
@@ -47,15 +47,9 @@ downloadfile() {
local url=$2
local mesg=("${@:3}")
- if [[ ! -e "$outfile" ]] ; then
- msg "${mesg[@]}"
- if wget -q "$url" -O "$outfile"; then
- return 255
- else
- die "Failed to download %q. Exiting." "$outfile"
- fi
- elif [[ -n "$init" ]]; then
- warning "%q already exists. Skipping." "$outfile"
+ msg "${mesg[@]}"
+ if ! wget -q "$url" -O "$outfile"; then
+ die "Failed to download %q. Exiting." "$outfile"
fi
}
@@ -107,51 +101,55 @@ arguments as root to initialize %s." "$cmd" "$name"
initialize() {
createdir "$statedir"
- downloadfile \
- "$conffile_prbl" \
- "https://projects.parabola.nu/abslibre.git/plain/libre/pacman/pacman.conf.x86_64" \
- "Downloading Parabola %q" \
- pacman.conf
- if [[ $? == 255 ]] ; then
+ if [[ ! -e "$conffile_prbl" ]] ; then
+ downloadfile \
+ "$conffile_prbl" \
+ "https://git.parabola.nu/abslibre.git/plain/libre/pacman/pacman.conf.x86_64" \
+ "Downloading Parabola %q" pacman.conf
msg2 "Setting DBPath in %q" "$conffile_prbl"
sed -i "s|^#DBPath .*|DBPath = $dbpath_prbl|" "$conffile_prbl"
enablerepo nonprism "$conffile_prbl"
enablerepo pcr "$conffile_prbl"
enablerepo libre-multilib "$conffile_prbl"
enablerepo multilib "$conffile_prbl"
+ else
+ warning "%q already exists. Skipping." "$conffile_prbl"
fi
- downloadfile \
- "$conffile_arch" \
- "https://projects.archlinux.org/svntogit/packages.git/plain/pacman/trunk/pacman.conf.x86_64" \
- "Downloading Arch %q" \
- pacman.conf
- if [[ $? == 255 ]] ; then
+ if [[ ! -e "$conffile_arch" ]] ; then
+ downloadfile \
+ "$conffile_arch" \
+ "https://git.archlinux.org/svntogit/packages.git/plain/pacman/trunk/pacman.conf.x86_64" \
+ "Downloading Arch %q" pacman.conf
msg2 "Setting DBPath in %q" "$conffile_arch"
sed -i "s|^#DBPath .*|DBPath = $dbpath_arch|" "$conffile_arch"
msg2 "Setting Arch mirrorlist file in %q" "$conffile_arch"
sed -i "s|/etc/pacman\.d/mirrorlist$|$mirrorlist_arch|" \
"$conffile_arch"
enablerepo multilib "$conffile_arch"
+ else
+ warning "%q already exists. Skipping." "$conffile_arch"
fi
- downloadfile \
- "$mirrorlist_prbl" \
- "https://repo.parabola.nu/mirrorlist.txt" \
- "Downloading Parabola %q" \
- mirrorlist
- if [[ $? == 255 ]] ; then
+ if [[ ! -e "$mirrorlist_prbl" ]] ; then
+ downloadfile \
+ "$mirrorlist_prbl" \
+ "https://repo.parabola.nu/mirrorlist.txt" \
+ "Downloading Parabola %q" mirrorlist
sed -i 's|^Server|#Server|' "$mirrorlist_prbl"
setmirror "Parabola" "$mirror_prbl" "$mirrorlist_prbl"
+ else
+ warning "%q already exists. Skipping." "$mirrorlist_prbl"
fi
- downloadfile \
- "$mirrorlist_arch" \
- "https://projects.archlinux.org/svntogit/packages.git/plain/pacman-mirrorlist/trunk/mirrorlist" \
- "Downloading Arch %q" \
- mirrorlist
- if [[ $? == 255 ]] ; then
+ if [[ ! -e "$mirrorlist_arch" ]] ; then
+ downloadfile \
+ "$mirrorlist_arch" \
+ "https://git.archlinux.org/svntogit/packages.git/plain/pacman-mirrorlist/trunk/mirrorlist" \
+ "Downloading Arch %q" mirrorlist
setmirror "Arch" "$mirror_arch" "$mirrorlist_arch"
+ else
+ warning "%q already exists. Skipping." "$mirrorlist_arch"
fi
}