# pkgutils
#
# Copyright (c) 2000-2005 Per Liden
+# Copyright (c) 2006-2007 by CRUX team (http://crux.nu)
#
# 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
echo $FILE
}
+get_basename() {
+ local FILE="`echo $1 | sed 's|^.*://.*/||g'`"
+ echo $FILE
+}
+
check_pkgfile() {
if [ ! "$name" ]; then
error "Variable 'name' not specified in $PKGMK_PKGFILE."
LOCAL_FILENAME=`get_filename $1`
LOCAL_FILENAME_PARTIAL="$LOCAL_FILENAME.partial"
- DOWNLOAD_CMD="--passive-ftp --no-directories --tries=3 --waitretry=3 \
- --directory-prefix=$PKGMK_SOURCE_DIR --output-document=$LOCAL_FILENAME_PARTIAL $1"
+ DOWNLOAD_OPTS="--passive-ftp --no-directories --tries=3 --waitretry=3 \
+ --directory-prefix=$PKGMK_SOURCE_DIR \
+ --output-document=$LOCAL_FILENAME_PARTIAL"
if [ -f "$LOCAL_FILENAME_PARTIAL" ]; then
info "Partial download found, trying to resume"
RESUME_CMD="-c"
fi
- while true; do
- wget $RESUME_CMD $DOWNLOAD_CMD
+ error=1
+
+ BASENAME=`get_basename $1`
+ for REPO in ${PKGMK_SOURCE_MIRRORS[@]}; do
+ REPO="`echo $REPO | sed 's|/$||'`"
+ wget $RESUME_CMD $DOWNLOAD_OPTS $REPO/$BASENAME
error=$?
- if [ $error != 0 ] && [ "$RESUME_CMD" ]; then
- info "Partial download failed, restarting"
- rm -f "$LOCAL_FILENAME_PARTIAL"
- RESUME_CMD=""
- else
+ if [ $error == 0 ]; then
break
fi
done
+
+ if [ $error != 0 ]; then
+ while true; do
+ wget $RESUME_CMD $DOWNLOAD_OPTS $1
+ error=$?
+ if [ $error != 0 ] && [ "$RESUME_CMD" ]; then
+ info "Partial download failed, restarting"
+ rm -f "$LOCAL_FILENAME_PARTIAL"
+ RESUME_CMD=""
+ else
+ break
+ fi
+ done
+ fi
if [ $error != 0 ]; then
error "Downloading '$1' failed."
fi
find . -type f -printf "%P\n" | $FILTER | while read FILE; do
- if file -b "$FILE" | grep '^.*ELF.*executable.*not stripped$' &> /dev/null; then
+ case $(file -b "$FILE") in
+ *ELF*executable*not\ stripped)
strip --strip-all "$FILE"
- elif file -b "$FILE" | grep '^.*ELF.*shared object.*not stripped$' &> /dev/null; then
+ ;;
+ *ELF*shared\ object*not\ stripped)
strip --strip-unneeded "$FILE"
- elif file -b "$FILE" | grep '^current ar archive$' &> /dev/null; then
+ ;;
+ current\ ar\ archive)
strip --strip-debug "$FILE"
- fi
+ esac
done
}
PKGMK_MD5SUM=".md5sum"
PKGMK_NOSTRIP=".nostrip"
+PKGMK_SOURCE_MIRRORS=()
PKGMK_SOURCE_DIR="$PWD"
PKGMK_PACKAGE_DIR="$PWD"
PKGMK_WORK_DIR="$PWD/work"