Tue Sep 8 12:37:56 2015 UTC ()
Make the post-fetch hook a bit more useful by also handing down the URL
the file was obtained from. This makes it easier to skip any local
mirrors.


(joerg)
diff -r1.20 -r1.21 pkgsrc/mk/fetch/bsd.fetch-vars.mk
diff -r1.16 -r1.17 pkgsrc/mk/fetch/fetch

cvs diff -r1.20 -r1.21 pkgsrc/mk/fetch/bsd.fetch-vars.mk (expand / switch to unified diff)

--- pkgsrc/mk/fetch/bsd.fetch-vars.mk 2015/09/08 11:13:12 1.20
+++ pkgsrc/mk/fetch/bsd.fetch-vars.mk 2015/09/08 12:37:56 1.21
@@ -1,30 +1,31 @@ @@ -1,30 +1,31 @@
1# $NetBSD: bsd.fetch-vars.mk,v 1.20 2015/09/08 11:13:12 joerg Exp $ 1# $NetBSD: bsd.fetch-vars.mk,v 1.21 2015/09/08 12:37:56 joerg Exp $
2# 2#
3# This Makefile fragment is included separately by bsd.pkg.mk and 3# This Makefile fragment is included separately by bsd.pkg.mk and
4# defines some variables which must be defined earlier than where 4# defines some variables which must be defined earlier than where
5# bsd.fetch.mk is included. 5# bsd.fetch.mk is included.
6# 6#
7# The following variables may be set by the user: 7# The following variables may be set by the user:
8# 8#
9# DISTDIR is the top-level directory into which all original 9# DISTDIR is the top-level directory into which all original
10# distribution files are fetched. 10# distribution files are fetched.
11# 11#
12# DIST_PATH is a list of directories, separated by colons, in which 12# DIST_PATH is a list of directories, separated by colons, in which
13# the distribution files are looked up, additionally to DISTDIR. 13# the distribution files are looked up, additionally to DISTDIR.
14# No files will ever be created in these directories. 14# No files will ever be created in these directories.
15# 15#
16# POST_FETCH_HOOK is a program to execute after fetch successfully 16# POST_FETCH_HOOK is a program to execute after fetch successfully
17# obtained a file. It is called with the path as argument. 17# obtained a file. It is called with the relative path of the distfile
 18# in ${DISTDIR} and the full URL it was obtained from.
18# 19#
19# The following variables may be set in a package Makefile: 20# The following variables may be set in a package Makefile:
20# 21#
21# DIST_SUBDIR is the subdirectory of ${DISTDIR} in which the original 22# DIST_SUBDIR is the subdirectory of ${DISTDIR} in which the original
22# distribution files for the package are fetched. 23# distribution files for the package are fetched.
23# 24#
24# DISTFILES is the list of distribution files that are fetched. 25# DISTFILES is the list of distribution files that are fetched.
25# 26#
26# System-provided variables: 27# System-provided variables:
27# 28#
28# DEFAULT_DISTFILES 29# DEFAULT_DISTFILES
29# The default value for DISTFILES. This can be used when you need 30# The default value for DISTFILES. This can be used when you need
30# more than the usual distfiles. 31# more than the usual distfiles.

cvs diff -r1.16 -r1.17 pkgsrc/mk/fetch/fetch (expand / switch to unified diff)

--- pkgsrc/mk/fetch/fetch 2015/09/08 11:13:12 1.16
+++ pkgsrc/mk/fetch/fetch 2015/09/08 12:37:56 1.17
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: fetch,v 1.16 2015/09/08 11:13:12 joerg Exp $ 3# $NetBSD: fetch,v 1.17 2015/09/08 12:37:56 joerg Exp $
4# 4#
5# Copyright (c) 2006, 2015 The NetBSD Foundation, Inc. 5# Copyright (c) 2006, 2015 The NetBSD Foundation, Inc.
6# All rights reserved. 6# All rights reserved.
7# 7#
8# This code is derived from software contributed to The NetBSD Foundation 8# This code is derived from software contributed to The NetBSD Foundation
9# by Johnny C. Lam. 9# by Johnny C. Lam.
10# 10#
11# Redistribution and use in source and binary forms, with or without 11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions 12# modification, are permitted provided that the following conditions
13# are met: 13# are met:
14# 1. Redistributions of source code must retain the above copyright 14# 1. Redistributions of source code must retain the above copyright
15# notice, this list of conditions and the following disclaimer. 15# notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright 16# 2. Redistributions in binary form must reproduce the above copyright
@@ -58,28 +58,29 @@ @@ -58,28 +58,29 @@
58# OPTIONS 58# OPTIONS
59# -c Verify the checksum for the file. If the checksum 59# -c Verify the checksum for the file. If the checksum
60# does not match, then the fetch is determined to be 60# does not match, then the fetch is determined to be
61# not successful. 61# not successful.
62# 62#
63# -d dir Fetch the files into the specified directory. 63# -d dir Fetch the files into the specified directory.
64# 64#
65# -f distinfo 65# -f distinfo
66# The path to the distinfo file containing the checksums 66# The path to the distinfo file containing the checksums
67# for the file. The file format should match what is 67# for the file. The file format should match what is
68# needed by the pkgsrc/mk/checksum/checksum script. 68# needed by the pkgsrc/mk/checksum/checksum script.
69# 69#
70# -p hook 70# -p hook
71# After a successful fetch, run hook with the relative path 71# After a successful fetch, run hook. The first argument is
72# as argument. 72# the relative path of the distfile and the second argument
 73# the full URL the file was obtained from.
73# 74#
74# -r Resume a previous fetch for the file. In this case, 75# -r Resume a previous fetch for the file. In this case,
75# the file is first saved to a ".pkgsrc.resume" file, 76# the file is first saved to a ".pkgsrc.resume" file,
76# and is later renamed to the final file name if the 77# and is later renamed to the final file name if the
77# complete file has been sucessfully fetched. 78# complete file has been sucessfully fetched.
78# 79#
79# -v Show the actual command line used to fetch the file 80# -v Show the actual command line used to fetch the file
80# from each site. 81# from each site.
81# 82#
82# ENVIRONMENT 83# ENVIRONMENT
83# PKGSRCDIR This is a hint to help locate the default 84# PKGSRCDIR This is a hint to help locate the default
84# checksum script. 85# checksum script.
85# 86#
@@ -298,20 +299,20 @@ while ${TEST} $# -gt 0; do @@ -298,20 +299,20 @@ while ${TEST} $# -gt 0; do
298 if verify_file -v $outputpath; then 299 if verify_file -v $outputpath; then
299 ${TEST} -z "$resume" || ${MV} -f $outputpath $path 300 ${TEST} -z "$resume" || ${MV} -f $outputpath $path
300 break 301 break
301 fi 302 fi
302 if ${TEST} -n "$resume"; then 303 if ${TEST} -n "$resume"; then
303 if ${TEST} -f $path; then 304 if ${TEST} -f $path; then
304 ${CP} -f $path $outputpath 305 ${CP} -f $path $outputpath
305 else 306 else
306 ${TOUCH} $outputpath 307 ${TOUCH} $outputpath
307 fi 308 fi
308 fi 309 fi
309done 310done
310if ${TEST} -f $path && ${TEST} -n "$post_fetch"; then 311if ${TEST} -f $path && ${TEST} -n "$post_fetch"; then
311 "$post_fetch" $path 312 "$post_fetch" $path "$url"
312fi 313fi
313if ${TEST} -f $path; then 314if ${TEST} -f $path; then
314 exit 0 315 exit 0
315else 316else
316 exit 1 317 exit 1
317fi 318fi