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