| 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] [-t] [-v] version |
| 6 |
# |
| 7 |
# SRCDIR defaults to src |
| 8 |
# MANIFEST defaults to $SRCDIR/MANIFEST |
| 9 |
# |
| 10 |
# Chet Ramey |
| 11 |
# [email protected] |
| 12 |
|
| 13 |
# Copyright (C) 1996-2002 Free Software Foundation, Inc. |
| 14 |
# |
| 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. |
| 19 |
# |
| 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/>. |
| 27 |
# |
| 28 |
|
| 29 |
SRCDIR=src |
| 30 |
ROOTNAME=bash |
| 31 |
|
| 32 |
usage() |
| 33 |
{ |
| 34 |
echo usage: mkdist [-m manifest] [-s srcdir] [-r rootname] [-t] [-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:tv name |
| 46 |
do |
| 47 |
case $name in |
| 48 |
m) MANIFEST=$OPTARG ;; |
| 49 |
s) SRCDIR=$OPTARG ;; |
| 50 |
r) ROOTNAME=$OPTARG ;; |
| 51 |
t) maketar=yes ;; |
| 52 |
v) verbose=yes ;; |
| 53 |
?) usage ;; |
| 54 |
esac |
| 55 |
done |
| 56 |
|
| 57 |
: ${MANIFEST:=$SRCDIR/MANIFEST} |
| 58 |
|
| 59 |
vmsg using $MANIFEST |
| 60 |
|
| 61 |
shift $(( $OPTIND - 1 )) |
| 62 |
|
| 63 |
if [ $# -lt 1 ]; then |
| 64 |
usage |
| 65 |
fi |
| 66 |
|
| 67 |
version=$1 |
| 68 |
newdir=${ROOTNAME}-$version |
| 69 |
|
| 70 |
tarfile=${newdir}.tar |
| 71 |
|
| 72 |
vmsg creating distribution for $ROOTNAME version $version in $newdir |
| 73 |
|
| 74 |
if [ ! -d $newdir ]; then |
| 75 |
mkdir $newdir || { echo $0: cannot make directory $newdir 1>&2 ; exit 1; } |
| 76 |
fi |
| 77 |
|
| 78 |
dirmode=755 |
| 79 |
filmode=644 |
| 80 |
|
| 81 |
while read fname type mode rest |
| 82 |
do |
| 83 |
[ -z "$fname" ] && continue |
| 84 |
|
| 85 |
case "$fname" in |
| 86 |
\#*) continue ;; |
| 87 |
esac |
| 88 |
|
| 89 |
case "$type" in |
| 90 |
d) mkdir $newdir/$fname ;; |
| 91 |
f) cp -p $SRCDIR/$fname $newdir/$fname ;; |
| 92 |
F) cp $SRCDIR/$fname $newdir/$fname ;; |
| 93 |
s) ln -s $mode $newdir/$fname ; mode= ;; # symlink |
| 94 |
l) ln $mode $newdir/$fname ; mode= ;; # hard link |
| 95 |
c) cp $SRCDIR/$mode $newdir/$fname ; mode=$filmode ;; # copy to new name |
| 96 |
*) echo "unknown file type $type" 1>&2 ;; |
| 97 |
esac |
| 98 |
|
| 99 |
# allow trailing comments |
| 100 |
case "$mode" in |
| 101 |
\#*) mode= ;; |
| 102 |
esac |
| 103 |
|
| 104 |
if [ -n "$mode" ]; then |
| 105 |
chmod $mode $newdir/$fname |
| 106 |
elif [ "$type" = "f" ]; then |
| 107 |
chmod $filmode $newdir/$fname |
| 108 |
elif [ "$type" = "d" ]; then |
| 109 |
chmod $dirmode $newdir/$fname |
| 110 |
fi |
| 111 |
|
| 112 |
done < $MANIFEST |
| 113 |
|
| 114 |
# cut off the `-alpha' in something like `2.0-alpha', leaving just the |
| 115 |
# numeric version |
| 116 |
#version=${version%%-*} |
| 117 |
|
| 118 |
#case "$version" in |
| 119 |
#*.*.*) vers=${version%.*} ;; |
| 120 |
#*.*) vers=${version} ;; |
| 121 |
#esac |
| 122 |
|
| 123 |
#echo $vers > $newdir/.distribution |
| 124 |
|
| 125 |
#case "$version" in |
| 126 |
#*.*.*) plevel=${version##*.} ;; |
| 127 |
#*) plevel=0 ;; |
| 128 |
#esac |
| 129 |
#[ -z "$plevel" ] && plevel=0 |
| 130 |
#echo ${plevel} > $newdir/.patchlevel |
| 131 |
|
| 132 |
vmsg $newdir created |
| 133 |
|
| 134 |
if [ -n "$maketar" ]; then |
| 135 |
tar cf ${tarfile} $newdir |
| 136 |
gzip $tarfile |
| 137 |
vmsg ${tarfile}.gz created |
| 138 |
fi |
| 139 |
|
| 140 |
exit 0 |