/[MITgcm]/mitgcm.org/scripts/mk_git_tarfile
ViewVC logotype

Contents of /mitgcm.org/scripts/mk_git_tarfile

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.10 - (show annotations) (download)
Sat May 5 16:27:10 2018 UTC (5 years, 11 months ago) by jmc
Branch: MAIN
Changes since 1.9: +5 -2 lines
add a better way to get latest tag, using "git tag -l --sort=-authordate";
unfortunately, only works with git version 2 (and not with version 1.8.3.1
that we have on mitgcmcvs.mit.edu) so leave it commented out for now.

1 #! /usr/bin/env bash
2
3 # $Header: /u/gcmpack/mitgcm.org/scripts/mk_git_tarfile,v 1.9 2018/02/25 16:43:19 jmc Exp $
4
5 # download the source code from github and make a tar file
6 git_repo='MITgcm'; git_code='MITgcm'
7 # git_repo='altMITgcm'; #git_code='MITgcm66h'
8 tmpFil="/tmp/"`basename $0`".$$"
9
10 umask 0002
11
12 echo 'Changing dir. to /u/u0/httpd/html/download/git_snapshot'
13 cd /u/u0/httpd/html/download/git_snapshot
14 outp=$?
15 if test $outp != 0 ; then
16 echo " Error in cd : $outp"
17 exit 1
18 fi
19 test -e $git_code && rm -rf $git_code
20
21 echo "Make a clone of $git_code from repo: $git_repo ..."
22 #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=$?
25 if test $outp = 0 ; then
26 echo ' --> done!'
27 rm -f $tmpFil
28 else
29 echo " Error: 'git clone' returned: $outp"
30 cat $tmpFil
31 rm -f $tmpFil
32 exit 2
33 fi
34 # chgrp gcmpack $git_code
35 chmod 775 $git_code
36
37 rm -rf MITgcm_ss_*
38 arName='MITgcm_ss_'`date +%Y%m%d`'.tar'
39
40 echo -n 'Creating the archive file ... '
41 ( cd $git_code ; git archive --prefix MITgcm/ -o ../$arName master )
42 gzip -9 $arName
43 #- should check if successful, it not -> exit 3
44 echo 'Done!'
45
46 #chmod 664 ${arName}.gz
47 ls -l ${arName}* | tee -a $HOME/testing/logs/tar_file_list
48
49 #exit
50 backupDir="other_checkpoints"
51 if test ! -d ../$backupDir ; then
52 echo -n " make dir: $backupDir"
53 mkdir ../$backupDir
54 outp=$?
55 if test $outp != 0 ; then
56 echo " Error in mkdir command: $outp"
57 exit 4
58 else
59 echo " Done"
60 ls -ld ../$backupDir
61 fi
62 #else
63 # ls -ld ../$backupDir
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
77 version_file="$git_code/doc/tag-index"
78 #version_file="$git_code/.git/config"
79 if test -f $version_file ; then
80 thischkpt=`awk '/^checkpoint/{print $1; exit}' $version_file`
81 #- better way to get latest tag ( but only works with git version 2 )
82 #thischkpt=`(cd $git_code ; git tag -l --sort=-authordate | head -n 1 )`
83 short=`echo $thischkpt | sed 's/checkpoint/c/'`
84 chkptar="MITgcm_${short}.tar"
85 if test -f ../$chkptar.gz ; then
86 echo "tar file ($chkptar) exist for current tag: $thischkpt"
87 else
88 echo -n 'Creating the checkpoint archive file ... '
89 ( cd $git_code ; git archive --prefix MITgcm/ -o ../$chkptar $thischkpt )
90 outp=$?
91 if test $outp != 0 ; then
92 echo " Error in 'git archive' command: $outp"
93 exit 5
94 else
95 echo " Done"
96 fi
97 gzip -9 $chkptar
98 ls -l ${chkptar}*
99 mv $chkptar.gz ..
100 #-- move previous tar file to backupDir
101 cd ..
102 listTar=`ls MITgcm_c*.tar.gz`
103 for xx in $listTar ; do
104 if test $xx != $chkptar.gz ; then
105 if test -f other_checkpoints/$xx ; then
106 echo "error: $backupDir/$xx already exist"
107 else
108 echo " mv $xx $backupDir"
109 mv $xx $backupDir
110 # echo " Remove $xx"
111 # /bin/rm -f $xx
112 fi
113 fi
114 done
115 fi
116 else
117 echo "missing file '$version_file' !"
118 fi

  ViewVC Help
Powered by ViewVC 1.1.22