summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-08-15 15:43:18 -0400
committerJoey Hess <joey@kitenet.net>2011-08-15 15:43:18 -0400
commitcdee8b86523d0c381c9615761c0d54730a4a6448 (patch)
tree81dc4ca1e15e4d95b494f92650b195516c4042c3 /functions
parent63c73e7f4444b3a56d517e7d9c68d0647e3ddb9a (diff)
downloaddebootstrap-cdee8b86523d0c381c9615761c0d54730a4a6448.tar.gz
Search PATH for programs, rather than checking hardcoded locations.
Generally a good idea, but specifically FreeBSD does not keep gunzip in /bin/
Diffstat (limited to 'functions')
-rw-r--r--functions24
1 files changed, 18 insertions, 6 deletions
diff --git a/functions b/functions
index d33939e..4399707 100644
--- a/functions
+++ b/functions
@@ -524,9 +524,9 @@ download_release_indices () {
local i=
if [ "$normi" != "" ]; then
i="$normi"
- elif [ -x /bin/bunzip2 ] && [ "$bz2i" != "" ]; then
+ elif in_path bunzip2 && [ "$bz2i" != "" ]; then
i="$bz2i"
- elif [ -x /bin/gunzip ] && [ "$gzi" != "" ]; then
+ elif in_path gunzip && [ "$gzi" != "" ]; then
i="$gzi"
fi
if [ "$i" != "" ]; then
@@ -552,11 +552,11 @@ download_release_indices () {
ext="$ext $normi ."
i="$normi"
fi
- if [ -x /bin/bunzip2 ] && [ "$bz2i" != "" ]; then
+ if in_path bunzip2 && [ "$bz2i" != "" ]; then
ext="$ext $bz2i bz2"
i="${i:-$bz2i}"
fi
- if [ -x /bin/gunzip ] && [ "$gzi" != "" ]; then
+ if in_path gunzip && [ "$gzi" != "" ]; then
ext="$ext $gzi gz"
i="${i:-$gzi}"
fi
@@ -690,7 +690,7 @@ download_main_indices () {
for c in $COMPONENTS; do
local path="dists/$SUITE/$c/binary-$ARCH/Packages"
local pkgdest="$TARGET/$($DLDEST pkg "$SUITE" "$c" "$ARCH" "$m" "$path")"
- if [ -x /bin/gunzip ] && get "$m/${path}.gz" "${pkgdest}.gz"; then
+ if in_path gunzip && get "$m/${path}.gz" "${pkgdest}.gz"; then
rm -f "$pkgdest"
gunzip "$pkgdest.gz"
elif get "$m/$path" "$pkgdest"; then
@@ -1028,7 +1028,7 @@ setup_dselect_method () {
# For the debootstrap udeb, pkgdetails is provided by the bootstrap-base
# udeb, so the pkgdetails API needs to be kept in sync with that.
-if [ -x /usr/bin/perl ]; then
+if in_path perl; then
PKGDETAILS=pkgdetails_perl
pkgdetails_field () {
@@ -1292,6 +1292,18 @@ on_exit () {
N_EXIT_THINGS="$(( $N_EXIT_THINGS + 1 ))"
}
+in_path () {
+ IFS=":" _in_path "$1"
+}
+_in_path () {
+ for dir in $PATH; do
+ if [ -x "$dir/$1" ]; then
+ return 0
+ fi
+ done
+ return 1
+}
+
############################################################## fakechroot tools
install_fakechroot_tools () {