Commit | Line | Data |
---|---|---|
d60d9f65 SS |
1 | #! /bin/bash - |
2 | # | |
3 | # mkdist - make a distribution directory from a master manifest file | |
4 | # | |
5 | # usage: mkdist [-m manifest] [-s srcdir] [-r rootname] [-v] version | |
6 | # | |
7 | # SRCDIR defaults to src | |
8 | # MANIFEST defaults to $SRCDIR/MANIFEST | |
9 | # | |
9255ee31 EZ |
10 | # Chet Ramey |
11 | # chet@po.cwru.edu | |
12 | ||
13 | # Copyright (C) 1996-2002 Free Software Foundation, Inc. | |
14 | # | |
cc88a640 JK |
15 | # This program is free software: you can redistribute it and/or modify |
16 | # it under the terms of the GNU General Public License as published by | |
17 | # the Free Software Foundation, either version 3 of the License, or | |
18 | # (at your option) any later version. | |
9255ee31 | 19 | # |
cc88a640 JK |
20 | # This program is distributed in the hope that it will be useful, |
21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 | # GNU General Public License for more details. | |
24 | # | |
25 | # You should have received a copy of the GNU General Public License | |
26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
9255ee31 | 27 | # |
d60d9f65 SS |
28 | |
29 | SRCDIR=src | |
30 | ROOTNAME=bash | |
31 | ||
32 | usage() | |
33 | { | |
34 | echo usage: mkdist [-m manifest] [-s srcdir] [-r rootname] [-v] version 1>&2 | |
35 | exit 2 | |
36 | } | |
37 | ||
38 | vmsg() | |
39 | { | |
40 | if [ -n "$verbose" ]; then | |
41 | echo mkdist: "$@" | |
42 | fi | |
43 | } | |
44 | ||
45 | while getopts m:s:r:v name | |
46 | do | |
47 | case $name in | |
48 | m) MANIFEST=$OPTARG ;; | |
49 | s) SRCDIR=$OPTARG ;; | |
50 | r) ROOTNAME=$OPTARG ;; | |
51 | v) verbose=yes ;; | |
52 | ?) usage ;; | |
53 | esac | |
54 | done | |
55 | ||
56 | : ${MANIFEST:=$SRCDIR/MANIFEST} | |
57 | ||
58 | vmsg using $MANIFEST | |
59 | ||
60 | shift $(( $OPTIND - 1 )) | |
61 | ||
62 | if [ $# -lt 1 ]; then | |
63 | usage | |
64 | fi | |
65 | ||
66 | version=$1 | |
67 | newdir=${ROOTNAME}-$version | |
68 | ||
c862e87b | 69 | vmsg creating distribution for $ROOTNAME version $version in $newdir |
d60d9f65 SS |
70 | |
71 | if [ ! -d $newdir ]; then | |
72 | mkdir $newdir || { echo $0: cannot make directory $newdir 1>&2 ; exit 1; } | |
73 | fi | |
74 | ||
75 | dirmode=755 | |
76 | filmode=644 | |
77 | ||
78 | while read fname type mode | |
79 | do | |
80 | [ -z "$fname" ] && continue | |
81 | ||
82 | case "$fname" in | |
83 | \#*) continue ;; | |
84 | esac | |
85 | ||
86 | case "$type" in | |
87 | d) mkdir $newdir/$fname ;; | |
88 | f) cp -p $SRCDIR/$fname $newdir/$fname ;; | |
9255ee31 EZ |
89 | s) ln -s $mode $newdir/$fname ; mode= ;; # symlink |
90 | l) ln $mode $newdir/$fname ; mode= ;; # hard link | |
d60d9f65 SS |
91 | *) echo "unknown file type $type" 1>&2 ;; |
92 | esac | |
93 | ||
94 | if [ -n "$mode" ]; then | |
95 | chmod $mode $newdir/$fname | |
96 | fi | |
97 | ||
98 | done < $MANIFEST | |
99 | ||
100 | # cut off the `-alpha' in something like `2.0-alpha', leaving just the | |
101 | # numeric version | |
102 | #version=${version%%-*} | |
103 | ||
104 | #case "$version" in | |
105 | #*.*.*) vers=${version%.*} ;; | |
106 | #*.*) vers=${version} ;; | |
107 | #esac | |
108 | ||
109 | #echo $vers > $newdir/.distribution | |
110 | ||
111 | #case "$version" in | |
112 | #*.*.*) plevel=${version##*.} ;; | |
113 | #*) plevel=0 ;; | |
114 | #esac | |
115 | #[ -z "$plevel" ] && plevel=0 | |
116 | #echo ${plevel} > $newdir/.patchlevel | |
117 | ||
118 | vmsg $newdir created | |
119 | ||
120 | exit 0 |