summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Mizrahi <alan@mizrahi.com.ve>2015-07-25 12:23:49 +0200
committerJuergen Daubert <jue@jue.li>2015-07-25 12:23:49 +0200
commit3d1855e7d20bbb4e394d494a91a484bf6e4bb0c9 (patch)
tree08b88e31087646d8b7d9fb0b7fc8e77c18b82d01
parentbf4255e16b64eb26eeda62b610d24c111a2fe574 (diff)
downloadpkgutils-3d1855e7d20bbb4e394d494a91a484bf6e4bb0c9.tar.gz
pkgutils-3d1855e7d20bbb4e394d494a91a484bf6e4bb0c9.tar.xz
pkgmk: add support for curl
See FS#1060, https://crux.nu/bugs/index.php?do=details&task_id=1060 New variables in /etc/pkgmk.conf: PKGMK_DOWNLOAD_PROG="" (curl or wget) PKGMK_CURL_OPTS="" (parameters for curl, when using curl)
-rw-r--r--pkgmk.8.in5
-rw-r--r--pkgmk.conf1
-rw-r--r--pkgmk.conf.5.in10
-rwxr-xr-xpkgmk.in34
4 files changed, 38 insertions, 12 deletions
diff --git a/pkgmk.8.in b/pkgmk.8.in
index a0b37433..707c6259 100644
--- a/pkgmk.8.in
+++ b/pkgmk.8.in
@@ -86,6 +86,9 @@ MD5 checksum of source files.
.B "/etc/pkgmk.conf"
Global package make configuration.
.TP
+.B "curl"
+Used by pkgmk to download source code.
+.TP
.B "wget"
Used by pkgmk to download source code.
.SH EXIT CODES
@@ -120,7 +123,7 @@ An error occured while running the build function.
.B 9
An error occured while installing the package via pkgadd.
.SH SEE ALSO
-pkgmk.conf(5), pkgadd(8), pkgrm(8), pkginfo(8), rejmerge(8), wget(1)
+pkgmk.conf(5), pkgadd(8), pkgrm(8), pkginfo(8), rejmerge(8), curl(1), wget(1)
.SH COPYRIGHT
pkgmk (pkgutils) is Copyright (c) 2000-2005 Per Liden and Copyright (c) 2006-2013 CRUX team (http://crux.nu).
pkgmk (pkgutils) is licensed through the GNU General Public License.
diff --git a/pkgmk.conf b/pkgmk.conf
index 907ba69e..f6b70a8a 100644
--- a/pkgmk.conf
+++ b/pkgmk.conf
@@ -30,6 +30,7 @@ esac
# PKGMK_IGNORE_FOOTPRINT="no"
# PKGMK_IGNORE_NEW="no"
# PKGMK_NO_STRIP="no"
+# PKGMK_DOWNLOAD_PROG="wget"
# PKGMK_WGET_OPTS=""
# PKGMK_COMPRESSION_MODE="gz"
diff --git a/pkgmk.conf.5.in b/pkgmk.conf.5.in
index f5adb9c3..0af5900c 100644
--- a/pkgmk.conf.5.in
+++ b/pkgmk.conf.5.in
@@ -44,6 +44,16 @@ Set directory for building packages.
.br
Default: '\fBfoo\fP/work', where \fBfoo\fP is the directory of the Pkgfile.
.TP
+\fBPKGMK_DOWNLOAD_PROG='STRING'\fP
+Use specified program to download source archives. Valid strings are curl and wget.
+.br
+Default: 'wget'
+.br
+.TP
+\fBPKGMK_CURL_OPTS='STRING'\fP
+Additional options for curl(1), which is used by pkgmk to download all files.
+.br
+.TP
\fBPKGMK_WGET_OPTS='STRING'\fP
Additional options for wget(1), which is used by pkgmk to download all files.
.br
diff --git a/pkgmk.in b/pkgmk.in
index 997453de..6789eaeb 100755
--- a/pkgmk.in
+++ b/pkgmk.in
@@ -97,20 +97,32 @@ check_file() {
download_file() {
info "Downloading '$1'."
- if [ ! "`type -p wget`" ]; then
- error "Command 'wget' not found."
+ PKGMK_DOWNLOAD_PROG=${PKGMK_DOWNLOAD_PROG:-wget}
+ if [ ! "`type -p ${PKGMK_DOWNLOAD_PROG}`" ]; then
+ error "Command '${PKGMK_DOWNLOAD_PROG}' not found."
exit $E_GENERAL
fi
LOCAL_FILENAME=`get_filename $1`
LOCAL_FILENAME_PARTIAL="$LOCAL_FILENAME.partial"
- DOWNLOAD_OPTS="--passive-ftp --no-directories --tries=3 --waitretry=3 \
- --directory-prefix=$PKGMK_SOURCE_DIR \
- --output-document=$LOCAL_FILENAME_PARTIAL --no-check-certificate"
+
+ case ${PKGMK_DOWNLOAD_PROG} in
+ curl)
+ RESUME_CMD="-C -"
+ DOWNLOAD_OPTS="-L --fail --ftp-pasv --retry 3 --retry-delay 3 \
+ -o $LOCAL_FILENAME_PARTIAL --insecure $PKGMK_CURL_OPTS"
+ ;;
+ wget)
+ RESUME_CMD="-c"
+ DOWNLOAD_OPTS="--passive-ftp --no-directories --tries=3 --waitretry=3 \
+ --directory-prefix=$PKGMK_SOURCE_DIR \
+ --output-document=$LOCAL_FILENAME_PARTIAL --no-check-certificate $PKGMK_WGET_OPTS"
+ ;;
+ esac
if [ -f "$LOCAL_FILENAME_PARTIAL" ]; then
info "Partial download found, trying to resume"
- RESUME_CMD="-c"
+ RESUME_OPTS="$RESUME_CMD"
fi
error=1
@@ -118,7 +130,7 @@ download_file() {
BASENAME=`get_basename $1`
for REPO in ${PKGMK_SOURCE_MIRRORS[@]}; do
REPO="`echo $REPO | sed 's|/$||'`"
- wget $RESUME_CMD $DOWNLOAD_OPTS $PKGMK_WGET_OPTS $REPO/$BASENAME
+ $PKGMK_DOWNLOAD_PROG $DOWNLOAD_OPTS $RESUME_OPTS $REPO/$BASENAME
error=$?
if [ $error == 0 ]; then
break
@@ -127,19 +139,19 @@ download_file() {
if [ $error != 0 ]; then
while true; do
- wget $RESUME_CMD $DOWNLOAD_OPTS $PKGMK_WGET_OPTS $1
+ $PKGMK_DOWNLOAD_PROG $DOWNLOAD_OPTS $RESUME_OPTS $1
error=$?
- if [ $error != 0 ] && [ "$RESUME_CMD" ]; then
+ if [ $error != 0 ] && [ "$RESUME_OPTS" ]; then
info "Partial download failed, restarting"
rm -f "$LOCAL_FILENAME_PARTIAL"
- RESUME_CMD=""
+ RESUME_OPTS=""
else
break
fi
done
fi
- if [ $error != 0 ]; then
+ if [ $error != 0 -o ! -f "$LOCAL_FILENAME_PARTIAL" ]; then
error "Downloading '$1' failed."
exit $E_DOWNLOAD
fi

Generated by cgit