Tue Jan 7 13:32:38 2014 UTC ()
PR/46182: Andreas Gustafsson: Make all files ending in [.-]sh executable.
The perfect is the enemy of the good.


(christos)
diff -r1.38 -r1.39 src/distrib/sets/makesrctars

cvs diff -r1.38 -r1.39 src/distrib/sets/makesrctars (switch to unified diff)

--- src/distrib/sets/makesrctars 2009/11/30 16:13:23 1.38
+++ src/distrib/sets/makesrctars 2014/01/07 13:32:38 1.39
@@ -1,156 +1,156 @@ @@ -1,156 +1,156 @@
1#! /bin/sh 1#! /bin/sh
2# 2#
3# $NetBSD: makesrctars,v 1.38 2009/11/30 16:13:23 uebayasi Exp $ 3# $NetBSD: makesrctars,v 1.39 2014/01/07 13:32:38 christos Exp $
4# 4#
5# makesrctars srcdir setdir 5# makesrctars srcdir setdir
6# Create source tarballs in setdir from the source under srcdir. 6# Create source tarballs in setdir from the source under srcdir.
7# 7#
8 8
9prog="${0##*/}" 9prog="${0##*/}"
10rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/" 10rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
11. "${rundir}/sets.subr" 11. "${rundir}/sets.subr"
12 12
13# set defaults 13# set defaults
14xsrcdir= 14xsrcdir=
15quiet=false 15quiet=false
16 16
17GZIP=-9n 17GZIP=-9n
18export GZIP 18export GZIP
19 19
20usage() 20usage()
21{ 21{
22 cat 1>&2 <<USAGE 22 cat 1>&2 <<USAGE
23Usage: ${prog} [-N password/group dir] [-q] [-x xsrcdir] [-y extsrcsrcdir] srcdir setdir 23Usage: ${prog} [-N password/group dir] [-q] [-x xsrcdir] [-y extsrcsrcdir] srcdir setdir
24 -N dir location which contains master.passwd and group files 24 -N dir location which contains master.passwd and group files
25 (defaults to \${srcdir}/etc) 25 (defaults to \${srcdir}/etc)
26 -q quiet operation 26 -q quiet operation
27 -x xsrcdir build xsrc.tgz from xsrcdir 27 -x xsrcdir build xsrc.tgz from xsrcdir
28 -y extsrcsrcdir build extsrc.tgz from extsrcsrcdir 28 -y extsrcsrcdir build extsrc.tgz from extsrcsrcdir
29 srcdir location of sources 29 srcdir location of sources
30 setdir where to write the .tgz files to 30 setdir where to write the .tgz files to
31USAGE 31USAGE
32 exit 1 32 exit 1
33} 33}
34 34
35msg() 35msg()
36{ 36{
37 $quiet || echo $* 37 $quiet || echo $*
38} 38}
39 39
40 40
41# handle args 41# handle args
42while getopts N:qx:y: ch; do 42while getopts N:qx:y: ch; do
43 case ${ch} in 43 case ${ch} in
44 q) 44 q)
45 quiet=true 45 quiet=true
46 ;; 46 ;;
47 x) 47 x)
48 xsrcdir="${OPTARG}" 48 xsrcdir="${OPTARG}"
49 ;; 49 ;;
50 y) 50 y)
51 extsrcsrcdir="${OPTARG}" 51 extsrcsrcdir="${OPTARG}"
52 ;; 52 ;;
53 N) 53 N)
54 PASSWD="${OPTARG}" 54 PASSWD="${OPTARG}"
55 ;; 55 ;;
56 *) 56 *)
57 usage 57 usage
58 ;; 58 ;;
59 esac 59 esac
60done 60done
61shift $((${OPTIND} - 1)) 61shift $((${OPTIND} - 1))
62 62
63if [ $# -ne 2 ]; then 63if [ $# -ne 2 ]; then
64 usage 64 usage
65fi 65fi
66srcdir="$1" 66srcdir="$1"
67setdir="$2" 67setdir="$2"
68: ${PASSWD:="${srcdir}/etc"} 68: ${PASSWD:="${srcdir}/etc"}
69 69
70if [ ! -d "${setdir}" ]; then 70if [ ! -d "${setdir}" ]; then
71 echo >&2 "${prog}: ${setdir} is not a directory" 71 echo >&2 "${prog}: ${setdir} is not a directory"
72 exit 1 72 exit 1
73fi 73fi
74 74
75makeset() 75makeset()
76{( 76{(
77 set="${1}.tgz" 77 set="${1}.tgz"
78 shift 78 shift
79 dir="$1" 79 dir="$1"
80 shift 80 shift
81 intmp="/tmp/in$$" 81 intmp="/tmp/in$$"
82 msg "Creating ${set}" 82 msg "Creating ${set}"
83 if [ "${dir}" != "." ]; then 83 if [ "${dir}" != "." ]; then
84 cd "${dir}" 84 cd "${dir}"
85 srcprefix="${srcprefix}/${dir}" 85 srcprefix="${srcprefix}/${dir}"
86 fi 86 fi
87 # Gets rid of any obj dirs and things below it  87 # Gets rid of any obj dirs and things below it
88 echo "obj" > "${intmp}" 88 echo "obj" > "${intmp}"
89 egrep="$*" 89 egrep="$*"
90 if [ "${egrep}" = "" ]; then 90 if [ "${egrep}" = "" ]; then
91 egrep='.' 91 egrep='.'
92 fi 92 fi
93 set -f 93 set -f
94 ${MTREE} -c -X "${intmp}" | ${MTREE} -CS -k type | \ 94 ${MTREE} -c -X "${intmp}" | ${MTREE} -CS -k type | \
95 ${EGREP} -v 'type=link' | ${EGREP} ${egrep} | \ 95 ${EGREP} -v 'type=link' | ${EGREP} ${egrep} | \
96 ${SED} -e 's:type=file:& mode=0664:' \ 96 ${SED} -e 's:type=file:& mode=0664:' \
97 -e 's:type=dir:& mode=0775:' \ 97 -e 's:type=dir:& mode=0775:' \
98 -e 's:$: uname=root gname=wsrc:' \ 98 -e 's:$: uname=root gname=wsrc:' \
99 -e '/\/move-if-change /s:\(mode\)=[0-9]*:\1=0775:' \ 99 -e '/\/move-if-change /s:\(mode\)=[0-9]*:\1=0775:' \
100 -e '/^\.\/build.sh /s:\(mode\)=[0-9]*:\1=0775:' | \ 100 -e '/^\.\/.*[.-]sh /s:\(mode\)=[0-9]*:\1=0775:' | \
101 ${PAX} -M -N "${PASSWD}" -w -d -s'|^\.|'"${srcprefix}"'|' | \ 101 ${PAX} -M -N "${PASSWD}" -w -d -s'|^\.|'"${srcprefix}"'|' | \
102 ${GZIP_CMD} > "${setdir}/${set}" 102 ${GZIP_CMD} > "${setdir}/${set}"
103 rm -f "${intmp}" 103 rm -f "${intmp}"
104)} 104)}
105 105
106 106
107# create (base)src sets 107# create (base)src sets
108# 108#
109 109
110if ! cd "${srcdir}"; then 110if ! cd "${srcdir}"; then
111 echo >&2 "${prog}: can't chdir to ${srcdir}" 111 echo >&2 "${prog}: can't chdir to ${srcdir}"
112 exit 1 112 exit 1
113fi 113fi
114 114
115srcprefix=usr/src 115srcprefix=usr/src
116export setdir MTREE PAX CKSUM GZIP PASSWD srcprefix 116export setdir MTREE PAX CKSUM GZIP PASSWD srcprefix
117 117
118makeset src . -v '^\.\/gnu|^\.\/share|^\.\/sys|^\.\/usr\.bin\/config|^\.\/common' 118makeset src . -v '^\.\/gnu|^\.\/share|^\.\/sys|^\.\/usr\.bin\/config|^\.\/common'
119 119
120makeset gnusrc gnu 120makeset gnusrc gnu
121 121
122makeset syssrc . -e '^\..type=dir|^\.\/sys|^\.\/usr\.bin.type=dir|^\.\/usr\.bin\/config|^\.\/common' 122makeset syssrc . -e '^\..type=dir|^\.\/sys|^\.\/usr\.bin.type=dir|^\.\/usr\.bin\/config|^\.\/common'
123 123
124makeset sharesrc share 124makeset sharesrc share
125 125
126 126
127# create xsrc sets 127# create xsrc sets
128# 128#
129if [ -n "${xsrcdir}" ]; then 129if [ -n "${xsrcdir}" ]; then
130 if ! cd "${xsrcdir}"; then 130 if ! cd "${xsrcdir}"; then
131 echo >&2 "${prog}: can't chdir to ${xsrcdir}" 131 echo >&2 "${prog}: can't chdir to ${xsrcdir}"
132 exit 1 132 exit 1
133 fi 133 fi
134 srcprefix=usr/xsrc 134 srcprefix=usr/xsrc
135 makeset xsrc . 135 makeset xsrc .
136fi 136fi
137 137
138 138
139# create extsrc sets 139# create extsrc sets
140# 140#
141if [ -n "${extsrcsrcdir}" ]; then 141if [ -n "${extsrcsrcdir}" ]; then
142 if ! cd "${extsrcsrcdir}"; then 142 if ! cd "${extsrcsrcdir}"; then
143 echo >&2 "${prog}: can't chdir to ${extsrcsrcdir}" 143 echo >&2 "${prog}: can't chdir to ${extsrcsrcdir}"
144 exit 1 144 exit 1
145 fi 145 fi
146 srcprefix=usr/extsrc 146 srcprefix=usr/extsrc
147 makeset extsrc . 147 makeset extsrc .
148fi 148fi
149 149
150 150
151msg "Creating checksum files" 151msg "Creating checksum files"
152(cd "${setdir}" 152(cd "${setdir}"
153 ${CKSUM} -a md5 *.tgz > MD5 153 ${CKSUM} -a md5 *.tgz > MD5
154 ${CKSUM} -a sha512 *.tgz > SHA512 154 ${CKSUM} -a sha512 *.tgz > SHA512
155) 155)
156exit 0 156exit 0