summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjoerg <joerg>2015-09-08 11:13:12 +0000
committerjoerg <joerg>2015-09-08 11:13:12 +0000
commitd82b7dcd6905e6d03c2e51baef06b6eec7c9ad3e (patch)
tree7609b56f45b4dfa048d16be5e3e9e305669ae884 /mk
parent067f8709365d8c5696461666841eca34474eb354 (diff)
downloadpkgsrc-d82b7dcd6905e6d03c2e51baef06b6eec7c9ad3e.tar.gz
Add a hook for running an action after a successful fetch.
This is intended for keeping distfile archives synchronised between different machines without requiring NFS mounts or the like.
Diffstat (limited to 'mk')
-rw-r--r--mk/fetch/bsd.fetch-vars.mk5
-rwxr-xr-xmk/fetch/fetch17
-rw-r--r--mk/fetch/fetch.mk5
3 files changed, 21 insertions, 6 deletions
diff --git a/mk/fetch/bsd.fetch-vars.mk b/mk/fetch/bsd.fetch-vars.mk
index 0ffc2a4839c..61dcdb574c7 100644
--- a/mk/fetch/bsd.fetch-vars.mk
+++ b/mk/fetch/bsd.fetch-vars.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.fetch-vars.mk,v 1.19 2015/03/09 15:50:18 tnn Exp $
+# $NetBSD: bsd.fetch-vars.mk,v 1.20 2015/09/08 11:13:12 joerg Exp $
#
# This Makefile fragment is included separately by bsd.pkg.mk and
# defines some variables which must be defined earlier than where
@@ -13,6 +13,9 @@
# the distribution files are looked up, additionally to DISTDIR.
# No files will ever be created in these directories.
#
+# POST_FETCH_HOOK is a program to execute after fetch successfully
+# obtained a file. It is called with the path as argument.
+#
# The following variables may be set in a package Makefile:
#
# DIST_SUBDIR is the subdirectory of ${DISTDIR} in which the original
diff --git a/mk/fetch/fetch b/mk/fetch/fetch
index 7ba04c36d82..b4fe25a64d6 100755
--- a/mk/fetch/fetch
+++ b/mk/fetch/fetch
@@ -1,8 +1,8 @@
#!/bin/sh
#
-# $NetBSD: fetch,v 1.15 2013/02/16 07:32:28 obache Exp $
+# $NetBSD: fetch,v 1.16 2015/09/08 11:13:12 joerg Exp $
#
-# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# Copyright (c) 2006, 2015 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
@@ -43,7 +43,7 @@
# fetch -- fetch files via URLs
#
# SYNOPSIS
-# fetch [-c] [-d dir] [-f distinfo] [-r] [-v] file site ...
+# fetch [-c] [-d dir] [-f distinfo] [-p hook] [-r] [-v] file site ...
#
# DESCRIPTION
# fetch will attempt to fetch the file from the list of specified
@@ -67,6 +67,10 @@
# for the file. The file format should match what is
# needed by the pkgsrc/mk/checksum/checksum script.
#
+# -p hook
+# After a successful fetch, run hook with the relative path
+# as argument.
+#
# -r Resume a previous fetch for the file. In this case,
# the file is first saved to a ".pkgsrc.resume" file,
# and is later renamed to the final file name if the
@@ -118,13 +122,14 @@
self="${0##*/}"
usage() {
- ${ECHO} 1>&2 "usage: $self [-c] [-d dir] [-f distinfo] [-r] [-v] file site ..."
+ ${ECHO} 1>&2 "usage: $self [-c] [-d dir] [-f distinfo] [-p hook] [-r] [-v] file site ..."
}
# Process optional arguments
checksum=
distinfo=
fetchdir=. # A relative directory or "."
+post_fetch=
resume=
verbose=
while ${TEST} $# -gt 0; do
@@ -132,6 +137,7 @@ while ${TEST} $# -gt 0; do
-c) checksum=yes; shift ;;
-d) fetchdir="$2"; shift 2 ;;
-f) distinfo="$2"; shift 2 ;;
+ -p) post_fetch="$2"; shift 2 ;;
-r) resume=yes; shift ;;
-v) verbose=yes; shift ;;
--) shift; break ;;
@@ -301,6 +307,9 @@ while ${TEST} $# -gt 0; do
fi
fi
done
+if ${TEST} -f $path && ${TEST} -n "$post_fetch"; then
+ "$post_fetch" $path
+fi
if ${TEST} -f $path; then
exit 0
else
diff --git a/mk/fetch/fetch.mk b/mk/fetch/fetch.mk
index 7658088f1fd..c2f3d90a42b 100644
--- a/mk/fetch/fetch.mk
+++ b/mk/fetch/fetch.mk
@@ -1,4 +1,4 @@
-# $NetBSD: fetch.mk,v 1.64 2014/10/07 07:27:18 tron Exp $
+# $NetBSD: fetch.mk,v 1.65 2015/09/08 11:13:12 joerg Exp $
_MASTER_SITE_BACKUP= ${MASTER_SITE_BACKUP:=${DIST_SUBDIR}${DIST_SUBDIR:D/}}
_MASTER_SITE_OVERRIDE= ${MASTER_SITE_OVERRIDE:=${DIST_SUBDIR}${DIST_SUBDIR:D/}}
@@ -263,6 +263,9 @@ _FETCH_ARGS+= -r
.if defined(DIST_SUBDIR) && !empty(DIST_SUBDIR)
_FETCH_ARGS+= -d ${DIST_SUBDIR}
.endif
+.if defined(POST_FETCH_HOOK) && !empty(POST_FETCH_HOOK)
+_FETCH_ARGS+= -p ${POST_FETCH_HOOK:Q}
+.endif
.PHONY: do-fetch-file
do-fetch-file: .USE