--- mitgcm.org/scripts/mk_git_tarfile 2018/02/01 01:16:38 1.6 +++ mitgcm.org/scripts/mk_git_tarfile 2019/04/02 14:06:06 1.11 @@ -1,6 +1,6 @@ #! /usr/bin/env bash -# $Header: /home/ubuntu/mnt/e9_copy/mitgcm.org/scripts/mk_git_tarfile,v 1.6 2018/02/01 01:16:38 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/mitgcm.org/scripts/mk_git_tarfile,v 1.11 2019/04/02 14:06:06 jmc Exp $ # download the source code from github and make a tar file git_repo='MITgcm'; git_code='MITgcm' @@ -34,23 +34,30 @@ # chgrp gcmpack $git_code chmod 775 $git_code -rm -rf MITgcm_ss_* arName='MITgcm_ss_'`date +%Y%m%d`'.tar' +fixName=MITgcm_today_snapshot.tar.gz +rm -rf MITgcm_ss_* $fixName echo -n 'Creating the archive file ... ' ( cd $git_code ; git archive --prefix MITgcm/ -o ../$arName master ) -gzip -9 $arName + gzip -9 $arName #- should check if successful, it not -> exit 3 -echo 'Done!' - -#chmod 664 ${arName}.gz -ls -l ${arName}* +if test -e ${arName}.gz ; then + echo 'Done!' + #chmod 664 ${arName}.gz + ls -l ${arName}* | tee -a $HOME/testing/logs/tar_file_list +#- make a link to a fixed name: + ln -s ${arName}.gz $fixName + ls -l $fixName +else + echo 'Fail: no gzip archive file!' + ls -l ${arName}* + exit 3 +fi #exit backupDir="other_checkpoints" -if test -d ../$backupDir ; then - #ls -ld ../$backupDir -else +if test ! -d ../$backupDir ; then echo -n " make dir: $backupDir" mkdir ../$backupDir outp=$? @@ -61,6 +68,8 @@ echo " Done" ls -ld ../$backupDir fi +#else +# ls -ld ../$backupDir fi savRepo="${git_code}_git" @@ -74,15 +83,18 @@ ls -l ${savRepo}* #-- test for new checkpoint -version_file="$git_code/doc/tag-index" + version_file="$git_code/doc/tag-index" +#version_file="$git_code/.git/config" if test -f $version_file ; then thischkpt=`awk '/^checkpoint/{print $1; exit}' $version_file` + #- better way to get latest tag ( but only works with git version 2 ) + #thischkpt=`(cd $git_code ; git tag -l --sort=-authordate | head -n 1 )` short=`echo $thischkpt | sed 's/checkpoint/c/'` - chkptar="MITgcm_$short" - if test -f ../$chkptar.tar.gz ; then + chkptar="MITgcm_${short}.tar" + if test -f ../$chkptar.gz ; then echo "tar file ($chkptar) exist for current tag: $thischkpt" else - echo -n " ; checkpoint archive file ... " + echo -n 'Creating the checkpoint archive file ... ' ( cd $git_code ; git archive --prefix MITgcm/ -o ../$chkptar $thischkpt ) outp=$? if test $outp != 0 ; then @@ -91,14 +103,14 @@ else echo " Done" fi - gzip $chkptar.tar - ls -l $chkptar.tar* - mv $chkptar.tar.gz .. - #-- move previous tar file to backupDir + gzip -9 $chkptar + ls -l ${chkptar}* + mv $chkptar.gz .. + #-- move previous tar file to backupDir cd .. listTar=`ls MITgcm_c*.tar.gz` for xx in $listTar ; do - if test $xx != $chkptar.tar.gz ; then + if test $xx != $chkptar.gz ; then if test -f other_checkpoints/$xx ; then echo "error: $backupDir/$xx already exist" else