1 |
jmc |
1.1 |
#! /usr/bin/env bash |
2 |
|
|
|
3 |
jmc |
1.4 |
# $Header: /u/gcmpack/mitgcm.org/scripts/mk_git_tarfile,v 1.3 2017/12/13 18:18:52 jmc Exp $ |
4 |
jmc |
1.1 |
|
5 |
|
|
# download the source code from github and make a tar file |
6 |
|
|
repo='altMITgcm' |
7 |
jmc |
1.3 |
code='MITgcm' |
8 |
jmc |
1.4 |
tmpFil="/tmp/"`basename $0`".$$" |
9 |
jmc |
1.1 |
|
10 |
|
|
umask 0002 |
11 |
|
|
|
12 |
jmc |
1.4 |
echo 'Changing dir. to /u/u0/httpd/html/download/git_snapshot' |
13 |
|
|
cd /u/u0/httpd/html/download/git_snapshot |
14 |
jmc |
1.1 |
outp=$? |
15 |
|
|
if test $outp != 0 ; then |
16 |
|
|
echo " Error in cd : $outp" |
17 |
jmc |
1.4 |
exit 1 |
18 |
jmc |
1.1 |
fi |
19 |
jmc |
1.4 |
test -e $code && rm -rf $code |
20 |
jmc |
1.1 |
|
21 |
jmc |
1.2 |
echo "Make a clone of $code from repo: $repo ..." |
22 |
jmc |
1.4 |
git clone --depth 1 https://github.com/$repo/$code.git 2> $tmpFil |
23 |
|
|
outp=$? |
24 |
|
|
if test $outp = 0 ; then |
25 |
|
|
echo ' --> done!' |
26 |
|
|
rm -f $tmpFil |
27 |
|
|
else |
28 |
|
|
echo " Error: 'git clone' returned: $outp" |
29 |
|
|
cat $tmpFil |
30 |
|
|
rm -f $tmpFil |
31 |
|
|
exit 2 |
32 |
|
|
fi |
33 |
jmc |
1.1 |
# chgrp gcmpack $code |
34 |
jmc |
1.4 |
chmod 775 $code |
35 |
jmc |
1.1 |
|
36 |
|
|
rm -rf MITgcm_ss_* |
37 |
|
|
arName='MITgcm_ss_'`date +%Y%m%d`'.tar' |
38 |
jmc |
1.4 |
|
39 |
|
|
echo -n 'Creating the archive file ... ' |
40 |
jmc |
1.1 |
( cd $code ; git archive -o ../$arName master ) |
41 |
|
|
gzip -9 $arName |
42 |
jmc |
1.4 |
#- should check if successful, it not -> exit 3 |
43 |
|
|
echo 'Done!' |
44 |
|
|
|
45 |
jmc |
1.1 |
#chmod 664 ${arName}.gz |
46 |
|
|
ls -l ${arName}* |
47 |
|
|
|
48 |
|
|
exit |
49 |
|
|
|
50 |
|
|
#-- test for new checkpoint |
51 |
|
|
cd .. |
52 |
jmc |
1.4 |
version_file="git_snapshot/$code/doc/tag-index" |
53 |
jmc |
1.1 |
backupDir="other_checkpoints" |
54 |
|
|
if test -f $version_file ; then |
55 |
|
|
thischkpt=`awk '/^checkpoint/{print $1; exit}' $version_file` |
56 |
|
|
short=`echo $thischkpt | sed 's/checkpoint/c/'` |
57 |
|
|
chkptar="MITgcm_$short" |
58 |
|
|
if test -f $chkptar.tar.gz ; then |
59 |
|
|
echo "tar file ($chkptar) exist for current tag: $thischkpt" |
60 |
|
|
else |
61 |
jmc |
1.4 |
# echo -n "Checking out $thischkpt ..." |
62 |
|
|
# rm -f checkout.out checkout.err |
63 |
|
|
# cvs co -P -d $chkptar -r $thischkpt MITgcm 1> checkout.out 2> checkout.err |
64 |
jmc |
1.1 |
outp=$? |
65 |
|
|
if test $outp != 0 ; then |
66 |
|
|
echo " Error in cvs checkout: $outp" |
67 |
|
|
cat checkout.err |
68 |
jmc |
1.4 |
exit 4 |
69 |
jmc |
1.1 |
fi |
70 |
|
|
echo -n " ; making tar file ... " |
71 |
|
|
rm -f checkout.out checkout.err |
72 |
|
|
tar -cf $chkptar.tar $chkptar |
73 |
|
|
outp=$? |
74 |
|
|
if test $outp != 0 ; then |
75 |
|
|
echo " Error in tar command: $outp" |
76 |
jmc |
1.4 |
exit 5 |
77 |
jmc |
1.1 |
else |
78 |
|
|
echo " Done" |
79 |
|
|
rm -r -f $chkptar |
80 |
|
|
fi |
81 |
|
|
gzip $chkptar.tar |
82 |
|
|
ls -l $chkptar.tar* |
83 |
|
|
#-- move previous tar file to backupDir |
84 |
|
|
listTar=`ls MITgcm_c*.tar.gz` |
85 |
|
|
if test -d $backupDir ; then |
86 |
|
|
for xx in $listTar ; do |
87 |
|
|
if test $xx != $chkptar.tar.gz ; then |
88 |
|
|
if test -f other_checkpoints/$xx ; then |
89 |
|
|
echo "error: $backupDir/$xx already exist" |
90 |
|
|
else |
91 |
|
|
echo " mv $xx $backupDir" |
92 |
|
|
mv $xx $backupDir |
93 |
|
|
fi |
94 |
|
|
fi |
95 |
|
|
done |
96 |
|
|
else |
97 |
|
|
echo " no dir: $backupDir" |
98 |
jmc |
1.4 |
exit 6 |
99 |
jmc |
1.1 |
fi |
100 |
|
|
fi |
101 |
|
|
fi |