Debian Codegraph @

support/GPGDistrib

raw
1 #!/bin/ksh
2 #
3 # GPGDistrib -- make lsof 4.x GPG distribution files
4
5 # Define DEBUG to 1 in the environment to skip to the README file construction.
6 #
7 # Usage: GPGDistrib [edition]
8 #
9 # edition optional edition suffix to add to version number
10 #set -x # DEBUG
11
12 if test "X$DEBUG" = "X"
13 then
14 DEBUG=0
15 fi
16
17 # Check for GPG pass phrase.
18
19 if test $DEBUG -eq 0
20 then
21 if test "X$PGPPASS" = "X"
22 then
23 echo "No GPG pass phrase is defined in the environment."
24 exit 1
25 fi
26 fi
27
28 # Change working directory.
29
30 HD=$HOME/src/lsof4
31 echo Changing to $HD
32 cd $HD
33
34 # Get version number.
35
36 V=`sed '/VN/s/.ds VN \(.*\)/\1/' version`
37 if test $? -ne 0
38 then
39 echo $V
40 exit 1
41 fi
42
43 # Handle optional edition suffix.
44
45 if test $# -gt 0
46 then
47 if test $# -gt 1
48 then
49 echo "Usage: GPGDistrib [edition]"
50 exit 1
51 fi
52 V=${V}$1
53 fi
54
55 # Define directory and archive file names.
56
57 CK=CHECKSUMS_${V}
58 DN=lsof_${V}
59 DT=${DN}.tar
60 M=00MANIFEST
61 MC=${DN}/manifest_check.${V}
62 R=README.lsof_${V}
63 RM=00.README.FIRST_${V}
64 SF=support/lsof.README
65 DSF=RELEASE.SUMMARY_${V}
66 SN=${DN}_src
67 SD=${DN}/$SN
68 ST=${SN}.tar
69 echo "Creating lsof ${V} GPG distribution ..."
70
71 # Define source files to copy.
72
73 F="00.README.FIRST 00CREDITS 00DCACHE 00DIALECTS 00DIST 00FAQ 00LSOF-L 00MANIFEST 00PORTING 00QUICKSTART 00README 00TEST 00XCONFIG AFSConfig ChangeLog Configure Customize Inventory dialects arg.c lib common.h lsof_fields.h main.c misc.c node.c print.c proc.c proto.h regex.h scripts store.c tests usage.c util.c version"
74 MS=Lsof.8
75 MD=${DN}/${SN}/lsof.8
76 MF=${DN}/${SN}/lsof.man
77
78 # Set exit cleanup trap.
79
80 trap 'rm -rf support/$CK $DN; exit' 1 2 3 15
81
82 # Create source directory.
83
84 if test $DEBUG -eq 0
85 then
86 echo Creating $DN and ${DN}/${SN}
87 rm -rf $DN
88 mkdir $DN
89 (cd $DN; mkdir $SN)
90 echo "Copying to ${SD}:\c"
91 for i in $F
92 do
93 echo " $i\c"
94 cp -rp $i $SD
95 done
96 echo " ... done"
97 echo "Removing extraneous stuff from lib ...\c"
98 find $SD/lib -name OLD -exec rm -rf {} \; > /dev/null 2>&1
99 find $SD/lib -name RCS -exec rm -rf {} \; > /dev/null 2>&1
100 find $SD/lib -name NEW -exec rm -rf {} \; > /dev/null 2>&1
101 rm -rf $SD/lib/Makefile
102 rm -rf $SD/lib/*.[oa]
103 echo " done"
104 echo "Removing extraneous stuff from dialects ...\c"
105 find $SD/dialects -name OLD -exec rm -rf {} \; > /dev/null 2>&1
106 find $SD/dialects -name RCS -exec rm -rf {} \; > /dev/null 2>&1
107 find $SD/dialects -name NEW -exec rm -rf {} \; > /dev/null 2>&1
108 find $SD/dialects -name Makefile.local -exec rm -f {} \; > /dev/null 2>&1
109 find $SD/dialects -name distfile.kvm -exec rm -f {} \; > /dev/null 2>&1
110 find $SD/dialects -name support -exec rm -rf {} \; > /dev/null 2>&1
111 echo " done"
112 echo "Removing extraneous stuff from scripts ...\c"
113 find $SD/scripts -name OLD -exec rm -rf {} \; > /dev/null 2>&1
114 find $SD/scripts -name RCS -exec rm -rf {} \; > /dev/null 2>&1
115 find $SD/scripts -name NEW -exec rm -rf {} \; > /dev/null 2>&1
116 echo " done"
117 echo "Removing extraneous stuff from tests ...\c"
118 find $SD/tests -name OLD -exec rm -rf {} \; > /dev/null 2>&1
119 find $SD/tests -name RCS -exec rm -rf {} \; > /dev/null 2>&1
120 find $SD/tests -name NEW -exec rm -rf {} \; > /dev/null 2>&1
121 rm -rf $SD/tests/config.* $SD/tests/*.o
122 rm -rf $SD/tests/LTbasic $SD/tests/LTbigf $SD/tests/LTdnlc
123 rm -rf $SD/tests/LTlock $SD/tests/LTnfs $SD/tests/LTnlink
124 rm -rf $SD/tests/LTsock $SD/tests/LTszoff $SD/tests/LTunix
125 echo " done"
126 fi
127
128 # Create manual page files.
129
130 if test $DEBUG -eq 0
131 then
132 echo Producing $MD
133 soelim < $MS > $MD
134 echo Producing $MF
135 nroff -man $MD | colcrt - | cat -s > $MF
136 fi
137
138 # Check distribution directory for completeness.
139
140 if test $DEBUG -eq 0
141 then
142 echo "Checking $SD for completeness"
143 rm -f $MC
144 (cd $SD; ls -FR) > $MC
145 diff $M $MC > /dev/null
146 if test $? -ne 0
147 then
148 (echo Some files may be missing.; echo diff $M $MC; diff $M $MC) | less
149 exit 1
150 fi
151 fi
152
153 # Create source distribution tar file.
154
155 if test $DEBUG -eq 0
156 then
157 echo Creating $ST in $DN
158 (cd $DN; tar cf $ST $SN; ls -l $ST)
159 echo Removing $SD
160 rm -rf $SD
161 fi
162
163 # Create source distribution README.lsof_<version> file.
164
165 if test $DEBUG -eq 0
166 then
167 echo Creating $R for $DT
168 rm -f ${DN}/$R
169 EO=${DN}/$R
170 else
171 echo "==== The $R file ====="
172 EO=""
173 fi
174 cat > $EO << END_README_1
175
176 Information About This Lsof Distribution
177
178
179 What You Have
180 =============
181
182 If you got this far without being confused, then you are probably
183 familiar with the construction of the lsof distribution or you have
184 read RELEASE.SUMMARY_${V}. If either is the case, please skip to
185 the Inventory section. If you haven't read RELEASE.SUMMARY_${V},
186 I suggest you do it now, because it explains how the lsof distribution
187 is constructed and other useful things about lsof, including a
188 summary of changes for the past few lsof revisions.
189
190 Even though you may have thought you were getting lsof.tar.bz2,
191 lsof.tar.gz or lsof.tar.Z with ftp, you really got ${DT}.bz2,
192 ${DT}.gz or ${DT}.Z. That's because the triplet of
193 lsof.tar.* files are symbolic links to their longer-named counterparts.
194
195 The bzip2'd, gzip'd or compressed tar files with lsof_, followed by a
196 number, are wrapper archives, designed to package the lsof source
197 archive, this file, other documentation files, and a GPG authentication
198 certificate together.
199
200 The number, ${V}, is the lsof revision number. When you bunzip2'd,
201 gunzip'd or uncompressed ${DT}.* and used tar to unpack
202 ${DT}, you got: ${RM}, describing the contents
203 of ${DN}; ${R}; ${ST}; and
204 ${ST}.sig. All are identified with the revision number.
205 You're reading ${R}. ${ST}.sig is a GPG
206 certificate that authenticates the lsof source archive,
207 ${ST}.
208
209 After you read the Inventory and Security sections, and hopefully
210 after you check the GPG certificate, unpack the ${ST}
211 source archive and you will get a sub-directory, named ${SN},
212 that contains the lsof ${V} source distribution.
213
214
215 Inventory
216 =========
217
218 Once you have unpacked ${ST}.tar, you can check
219 ${SN} for completeness by changing to that sub-directory
220 and running the Inventory script. The ${SN}/Configure
221 script runs the Inventory script, too. The Configure script also
222 calls a customization script, called Customize. You can direct
223 Configure to avoid calling Inventory and Customize with the -n
224 option.
225
226 See the Distribution Contents section of the 00DIST file and The
227 Inventory Script section of the 00README file for more information
228 on the contents of the lsof distribution, and the Configure,
229 Customize and Inventory scripts. The 00DIST and 00README files
230 will be found in the ${SN} sub-directory you just created.
231
232
233 Security
234 ========
235
236 The md5 checksum for $ST is:
237
238 END_README_1
239 echo " \c" >> $EO
240 if test $DEBUG -eq 1
241 then
242 echo "MD5 checksum of $ST would go here." >> $EO
243 else
244 (cd $DN; md5 $ST) >> $EO
245 fi
246 cat >> $EO << END_README_2
247
248 A good source for an MD5 checksum computation tool is the OpenSSL
249 project whose work may be found at:
250
251 www.openssl.org
252
253 You can use the openssl "dgst" operator to compute an MD5 checksum --
254 e.g.,
255
256 $ openssl dgst -md5 $SN
257
258 The old-style sum(1) checksum for $ST (Please read
259 the next paragraph if you don't get this value.) is:
260
261 END_README_2
262 echo " \c" >> $EO
263 if test $DEBUG -eq 1
264 then
265 echo "Sum checksum of $ST would go here." >> $EO
266 else
267 sum -r ${DN}/$ST >> $EO
268 fi
269 cat >> $EO << END_README_3
270
271 If your dialect's sum(1) program defaults to the new style algorithm
272 (e.g., Solaris), you may have to use its -r option (or use the
273 Solaris /usr/ucb/sum). If your Unix dialect doesn't have a sum(1)
274 program (e.g., FreeBSD, or NetBSD), use its cksum(1) program with
275 the -o1 option to get an old-style checksum. You may also need to
276 ignore the block count, depending on the block size used on your
277 your system (i.e., 512 or 1,024). The sum(1) that produced the
278 above checksum considers block size to be 512; in contrast the BSD
279 cksum(1) programs' -o1 option considers block size to be 1,024.
280
281 ${ST}.sig is a GPG certificate file, using my public
282 key. My key may be available on some public key servers under the
283 names:
284
285 Victor A. Abell <[email protected]>
286 or
287 Victor A. Abell <[email protected]>
288
289 You will also find it at:
290
291 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/Victor_A_Abell.gpg
292
293 Get my key and install it in your public key ring.
294
295 Once my key is installed, use this command to check the certificate
296 of $ST:
297
298 gpg --verify ${ST}.sig $ST
299
300 If the certificate check isn't good, $ST is suspect.
301 Report the problem to me via e-mail at <[email protected]>.
302
303 If you don't have GPG, you can compare the md5 checksum of
304 $ST to the value listed in this file. However, that
305 is a less reliable authentication method, since it can't detect
306 changes to both $ST and the md5 checksum value listed
307 in this tile.
308
309 Other Security
310 ==============
311
312 Signature information for the distribution file that contains
313 this file may be found in the CHECKSUMS file that is located
314 where the distribution file was found.
315
316
317 Victor A. Abell <[email protected]>
318 END_README_3
319
320 date >> $EO
321
322 # Create GPG certificate.
323
324 if test $DEBUG -eq 0
325 then
326 echo Creating ${ST}.sig in $DN
327 (cd $DN; rm -f ${ST}.sig; \
328 echo $PGPPASS | gpg -o ${ST}.sig --passphrase-fd 0 -b $ST; \
329 chmod 644 ${ST}.sig)
330 fi
331
332 # Construct distribution's 00.README_FIRST_<version> file.
333
334 if test $DEBUG -eq 0
335 then
336 echo Creating $RM for $DT
337 rm -f ${DN}/$RM
338 EO=${DN}/$RM
339 else
340 echo ""
341 echo "==== The $RM file ====="
342 echo ""
343 EO=""
344 fi
345 echo "A tour of the lsof_${V} distribution:" > $EO
346 echo "" >> $EO
347 echo " $RM is this file." >> $EO
348 echo "" >> $EO
349 echo " $R contains distribution and security information." >> $EO
350 echo "" >> $EO
351 echo " ${DSF} contains a summary of the lsof ${V}" >> $EO
352 echo " distribution." >> $EO
353 echo "" >> $EO
354 echo " $ST is the lsof ${V} source tar archive." >> $EO
355 echo "" >> $EO
356 echo " ${ST}.sig is a detached GPG certificate for" >> $EO
357 echo " ${ST}." >> $EO
358 echo "" >> $EO
359 echo "I suggest you follow these steps:" >> $EO
360 echo "" >> $EO
361 echo "1. Read ${RM}." >> $EO
362 echo "" >> $EO
363 echo "2. Read ${R} and follow its instructions to verify" >> $EO
364 echo " the authenticity of ${ST}." >> $EO
365 echo "" >> $EO
366 echo "3. Unpack ${ST} -- use \`tar xf ${ST}\`." >> $EO
367 echo " That will produce an ${SN} sub-directory." >> $EO
368 echo "" >> $EO
369 echo "4. Change to the ${SN} sub-directory and read its" >> $EO
370 echo " 00.README.FIRST file." >> $EO
371 echo "" >> $EO
372 echo "Vic Abell <[email protected]>" >> $EO
373 echo `date` >> $EO
374
375 # Create distribution summary file.
376
377 if test $DEBUG -eq 0
378 then
379 echo Creating ${DN}/$DSF
380 rm -f ${DN}/$DSF
381 cp $SF ${DN}/$DSF
382 else
383 echo Distribution summary file would be ${DN}/$DSF, copied from $SF.
384 fi
385
386 # Create distribution tar file, then bzip2, compress and gzip it.
387
388 if test $DEBUG -eq 0
389 then
390 rm -f $MC
391 echo Creating $DT
392 rm -f $DT ${DT}.bz2 ${DT}.gz ${DT}.Z
393 tar cf $DT $DN
394 ls -l $DT
395 echo Bzip2ing $DT
396 bzip2 -c $DT > support/${DT}.bz2
397 ls -l support/${DT}.bz2
398 echo Gzipping $DT
399 gzip -c $DT > support/${DT}.gz
400 ls -l support/${DT}.gz
401 echo Compressing $DT
402 compress < $DT > support/${DT}.Z
403 ls -l support/${DT}.Z
404 echo Removing $DN and $DT
405 rm -rf $DN $DT
406
407 # Create checksum files.
408
409 for i in bz2 gz Z
410 do
411 echo Creating ${DT}.${i}.sig
412 SIG=support/${DT}.${i}.sig
413 SRC=support/${DT}.${i}
414 rm -f $SIG
415 echo $PGPPASS | gpg -o $SIG --passphrase-fd 0 -b $SRC
416 done
417 echo Creating $CK
418 rm -f support/$CK
419 cat >> support/$CK << END_CKSUM_1
420
421 Checksums for lsof_${V}
422
423 This file was created when the official lsof ${V} distribution files
424 were created. It contains MD5 checksums and GPG certificate
425 information for the lsof ${V} bzip2, gzip and compressed distribution
426 files.
427
428 There are additional opportunities to validate the lsof distribution
429 with information found inside it. Consult the file ${R}
430 inside the distribution.
431
432 MD5 Checksums
433 =============
434
435 The MD5 checksums are:
436
437 END_CKSUM_1
438
439 for i in bz2 gz Z
440 do
441 echo " \c" >> support/$CK
442 (cd support; md5 ${DT}.$i >> $CK)
443 done
444
445 cat >> support/$CK << END_CKSUM_2
446
447 GPG Certificates
448 ================
449
450 The following files, found with the lsof distribution files, contain
451 GPG certificates:
452
453 lsof.tar.bz2.sig or ${DT}.bz2.sig
454 lsof.tar.gz.sig or ${DT}.gz.sig
455 lsof.tar.Z.sig or ${DT}.Z.sig
456
457 Validating a GPG certificate is the best way to make sure no one has
458 tampered with a distribution file.
459
460 Use the GPG certificate files with the GPG public key for:
461
462 Victor A. Abell <[email protected]>
463
464 You may be able to find the key on some public key servers. It is also
465 available at:
466
467 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/Victor_A_Abell.gpg
468
469 Get the key and install it in your public key ring. Once the key is
470 installed, use one of these command forms to check the certificate of a
471 distribution file:
472
473 gpg --verify ${DT}.<type>.sig ${DT}.<type>
474
475 or
476
477 gpg --verify lsof.tar.<type>.sig lsof.tar.<type>
478
479 Where <type> is bz2, gz or Z.
480
481 Problems
482 ========
483
484 If an MD5 or GPG check reveals a problem, please report it via e-mail
485 to <[email protected]>.
486
487
488 Vic Abell
489 END_CKSUM_2
490 date >> support/$CK
491 (cd support; ls -l $CK)
492 fi
493 echo "all done"