summaryrefslogtreecommitdiff
path: root/misc/pascal/zipme
blob: 06017df52070119a9e17efbcf81ccee441eb6ca5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh

#set -x

DATECODE=$1

TAR="tar cvf"
ZIP=gzip

# Move up one directory

cd ..
HOME=`pwd`
DIR=${HOME}/pascal
SUBDIR=pascal-${DATECODE}

# Make sure we know what is going on

if [ -z ${DATECODE} ] ; then
   echo "You must supply a date code like a.b.c as a parameter"
   exit 1;
fi

if [ ! -d ${SUBDIR} ] ; then
   echo "Directory ${SUBDIR} does not exist."
   exit 1;
fi

if [ ! -x ${SUBDIR}/$0 ] ; then
   echo "You must cd to the directory containing this script."
   exit 1;
fi

# Define the ZIP file pathes

TAR_NAME=${SUBDIR}.tar
ZIP_NAME=${TAR_NAME}.gz

# Prepare the directory

make -C ${SUBDIR} deep-clean

find ${SUBDIR} -name \*~ -exec rm -f {} \; || \
	{ echo "Removal of emacs garbage failed!" ; exit 1 ; }

find ${SUBDIR} -name \#\* -exec rm -f {} \; || \
	{ echo "Removal of emacs garbage failed!" ; exit 1 ; }

find ${SUBDIR} -name .\*swp\* -exec rm -f {} \; || \
	{ echo "Removal of vi garbage failed!" ; exit 1 ; }

# Remove any previous tarballs

if [ -f ${TAR_NAME} ] ; then
    echo "Removing ${HOME}/${TAR_NAME}"
    rm -f ${TAR_NAME} || \
	{ echo "rm ${TAR_NAME} failed!" ; exit 1 ; }
fi

if [ -f ${ZIP_NAME} ] ; then
    echo "Removing ${HOME}/${ZIP_NAME}"
    rm -f ${ZIP_NAME} || \
	{ echo "rm ${ZIP_NAME} failed!" ; exit 1 ; }
fi

# Then zip it

${TAR} ${TAR_NAME} ${SUBDIR} || \
    { echo "tar of ${DIR} failed!" ; exit 1 ; }
${ZIP} ${TAR_NAME} || \
    { echo "zip of ${TAR_NAME} failed!" ; exit 1 ; }