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# 10# Chet Ramey 11# chet@po.cwru.edu 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 2, or (at your option) 18# 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, write to the Free Software 27# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. 28 29SRCDIR=src 30ROOTNAME=bash 31 32usage() 33{ 34 echo usage: mkdist [-m manifest] [-s srcdir] [-r rootname] [-v] version 1>&2 35 exit 2 36} 37 38vmsg() 39{ 40 if [ -n "$verbose" ]; then 41 echo mkdist: "$@" 42 fi 43} 44 45while getopts m:s:r:v name 46do 47 case $name in 48 m) MANIFEST=$OPTARG ;; 49 s) SRCDIR=$OPTARG ;; 50 r) ROOTNAME=$OPTARG ;; 51 v) verbose=yes ;; 52 ?) usage ;; 53 esac 54done 55 56: ${MANIFEST:=$SRCDIR/MANIFEST} 57 58vmsg using $MANIFEST 59 60shift $(( $OPTIND - 1 )) 61 62if [ $# -lt 1 ]; then 63 usage 64fi 65 66version=$1 67newdir=${ROOTNAME}-$version 68 69vmsg creating distribution for $ROOTNAME version $version in $newdir 70 71if [ ! -d $newdir ]; then 72 mkdir $newdir || { echo $0: cannot make directory $newdir 1>&2 ; exit 1; } 73fi 74 75dirmode=755 76filmode=644 77 78while read fname type mode 79do 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 ;; 89 s) ln -s $mode $newdir/$fname ; mode= ;; # symlink 90 l) ln $mode $newdir/$fname ; mode= ;; # hard link 91 *) echo "unknown file type $type" 1>&2 ;; 92 esac 93 94 if [ -n "$mode" ]; then 95 chmod $mode $newdir/$fname 96 fi 97 98done < $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 118vmsg $newdir created 119 120exit 0 121