Add a note that dntpd can be started at boot time even if the network
[dragonfly.git] / contrib / tcsh / MAKESHAR
blob691690f081d1572c1ce7bae4c958bba791994062
1 #!/bin/sh
3 # MAKESHAR.sh: Make a shar file for the sources
5 # $Id: MAKESHAR,v 3.1 1992/05/09 04:03:53 christos Exp $
7 AWK=/usr/bin/nawk # Must be nawk or gawk cause of 2D arrays
8 WC=/usr/ucb/wc
9 GREP=/usr/bin/egrep
10 SORT=/usr/bin/sort
11 SH=/bin/sh
13 dirs=
14 name=kit
15 files=
16 verbose=0
17 size=45000
19 for i
21 case $i in
22 -n)
23 name=;;
24 -v)
25 verbose=1;;
26 -d)
27 SH=/bin/cat;;
28 -s)
29 size=$1;;
31 if [ -z "$name" ]
32 then
33 name=$i
34 elif [ -d $i ]
35 then
36 dirs="$dirs $i"
37 elif [ -f $i ]
38 then
39 files="$files $i"
40 else
41 echo "$0: File `$i' not found." 1>&2
42 exit 1
43 fi;;
44 esac
45 done
47 if [ \( -z "$files" \) -a \( -z "$dirs" \) ]
48 then
49 echo "Usage: $0 [-n name] [-s size] [-vd] <files>." 1>&2
50 exit 1
53 $WC $files | $GREP -v total | $SORT +2 | $AWK '
54 BEGIN {
55 i = 0;
56 seq = 1;
57 size = 0;
58 name = 1;
59 used = 2;
60 verbose='"$verbose"';
61 tty = "/dev/tty";
62 maxsize = '"$size"';
63 dirs = "'"$dirs"'";
66 a[i, size] = $3;
67 a[i, name] = $4;
68 a[i, used] = 0;
69 i++;
71 END {
72 for (maxi = i--; i >= 0; i--) {
73 idx = 0;
74 if (a[i, used] == 0) {
75 if (verbose && a[i, size] > maxsize)
76 printf("Warning: File %s is %d > %d\n",
77 a[i, name], a[i, size], maxsize) > tty;
78 s = a[i, size];
79 a[i, used] = 1;
80 kit[seq, idx++] = i;
81 j = 0;
82 while (j < maxi) {
83 # Find the greatest file we can add
84 j = maxi;
85 for (k = 0; k < maxi; k++)
86 if (a[k, used] == 0 && a[k, size] + s < maxsize)
87 j = k;
88 if (j < maxi) {
89 s += a[j, size];
90 a[j, used] = 1;
91 kit[seq, idx++] = j;
94 sizes[seq] = s;
95 kit[seq++, idx] = -1;
98 for (i = 1; i < seq; i++) {
99 printf("shar -n%d -e%d %s ", i, seq - 1, dirs);
100 if (verbose) {
101 printf("%3d of %3d: ", i, seq - 1) > tty;
102 len = 12;
104 for (j = 0; kit[i, j] != -1; j++) {
105 s = a[kit[i, j], name];
106 if (verbose) {
107 clen = length(s) + 1;
108 len += clen;
109 if (len > 70) {
110 printf("\n ") > tty;
111 len = 12 + clen;
113 printf("%s ", s) > tty;
115 printf("%s ", s);
117 printf("> '"$name"'-%d.shar;", i);
118 if (verbose)
119 printf("= %5d\n", sizes[i]) > tty;
121 }' | $SH