Thu Dec 16 14:10:46 2021 UTC ()
The non-writability check for DISTDIR is intended to prevent wasting
resources when fetchers wouldn't be able to save what they download. On
my build farm with pkgsrc (and pkgsrc/distfiles) mounted over NFS,
however, the check gives false positives for NetBSD 9.2 and -current.
Downgrade it to a warning so that these fetches can succeed, while
leaving a breadcrumb in case someone encounters a true positive.

It would of course be interesting to sort out why, in my environment, a
wide variety of other OSes get 1 for "${TEST} ! -w $fetchdir" while
NetBSD gets 0. In the meantime, joerg@ suggested this workaround and
gdt@ agrees it's reasonable to try.


(schmonz)
diff -r1.20 -r1.21 pkgsrc/mk/fetch/fetch

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

--- pkgsrc/mk/fetch/fetch 2020/08/27 11:45:45 1.20
+++ pkgsrc/mk/fetch/fetch 2021/12/16 14:10:46 1.21
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: fetch,v 1.20 2020/08/27 11:45:45 jperkin Exp $ 3# $NetBSD: fetch,v 1.21 2021/12/16 14:10:46 schmonz 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
@@ -218,30 +218,28 @@ verify_file() { @@ -218,30 +218,28 @@ verify_file() {
218 return 0 218 return 0
219 fi 219 fi
220 return 0; 220 return 0;
221} 221}
222 222
223# If the file already exists and it verifies, then we don't need to fetch 223# If the file already exists and it verifies, then we don't need to fetch
224# it again. 224# it again.
225# 225#
226if verify_file $path; then 226if verify_file $path; then
227 exit 0 227 exit 0
228fi 228fi
229 229
230${TEST} -d $fetchdir || ${MKDIR} -p $fetchdir 2>/dev/null 230${TEST} -d $fetchdir || ${MKDIR} -p $fetchdir 2>/dev/null
231if ${TEST} ! -w $fetchdir; then 231
232 ${ECHO} 1>&2 "$self: Cannot write to `cd $fetchdir && pwd`" 232${TEST} -w $fetchdir || ${ECHO} 1>&2 "$self: WARNING: DISTDIR `cd $fetchdir && pwd` looks non-writable."
233 exit 1 
234fi 
235 233
236# Set the name of the output file. In the "resume" case, we initialize 234# Set the name of the output file. In the "resume" case, we initialize
237# the fetch loop by ensuring that the temporary output file already 235# the fetch loop by ensuring that the temporary output file already
238# exists. 236# exists.
239# 237#
240outputfile="$file" 238outputfile="$file"
241outputpath="$fetchdir/$outputfile" 239outputpath="$fetchdir/$outputfile"
242if ${TEST} -n "$resume"; then 240if ${TEST} -n "$resume"; then
243 outputfile="${file}.pkgsrc.resume" 241 outputfile="${file}.pkgsrc.resume"
244 outputpath="$fetchdir/$outputfile" 242 outputpath="$fetchdir/$outputfile"
245 if ${TEST} ! -f $outputpath; then 243 if ${TEST} ! -f $outputpath; then
246 if ${TEST} -f $path; then 244 if ${TEST} -f $path; then
247 ${CP} -f $path $outputpath 245 ${CP} -f $path $outputpath