scriba-tar.pl 2.08 KB
Newer Older
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 72 73 74 75 76 77 78 79 80
#! /usr/bin/perl

# Create mktar.sh that creates a TAR file from the ScriptBasic sources.

# You may think that this is a simple
#
#             tar cf scriba.tar *
#
# but this is more than that. When the tarball is created the directory
# may not be fresh. There can be a lot of generated garbage that is not
# part of the source. This script reads the CV Entries files and creates
# mktar.sh that puts exactly those files into the tar archive that are source
# files.

open(BUILD,"build.txt") or die "Can not read build number";
$BUILD = <BUILD>;
close BUILD;
chomp $BUILD;

open(VERSION,"version.txt") or die "Can not read version";
$VERSION = <VERSION>;
close VERSION;
chomp $VERSION;
$DIRNAME = "scriba-${VERSION}b${BUILD}";


sub AddDirToTar {
  my $dir = shift;
  my $printdir = $dir;
  
  $printdir = "${DIRNAME}" . substr($printdir,1);

  open(IN,"$dir/CVS/Entries") or die "Can not open CVS/Entries";
  my @lines = <IN>;
  close IN;
  for my $L (@lines){
    if( $L =~ m{^/(.*?)/} ){
      print TAR "tar -rf scriba-${VERSION}b${BUILD}-source.tar $printdir/$1\n";
      }elsif( $L =~ m{^D/(.*?)/} ){
      AddDirToTar("$dir/$1");
      }elsif( $L =~ m{^D\s*$} ){
      }else{
      print "Invalid line in $dir/CVS/Entries:\n>>> $L\n"
      }
    }
  }

open(TAR,">mktar") or die "Can not write mktar.sh";
print TAR <<END;
#! /bin/sh
# FILE: mktar
#
# This file was generated by scriba-tar.pl
# The program that created this file searched the
# CVS/Entries files for CV file entries and added the
# entries to this file to create the source TAR for
# ScriptBasic
#

# First of all delete the TAR file if it exists
rm scriba-${VERSION}b${BUILD}-source.tar.gz
# maybe without compression
rm scriba-${VERSION}b${BUILD}-source.tar
# create the soft link to the actual directory so that
# the tarball will contain no flat file
rm ${DIRNAME}
ln -s . ${DIRNAME}
END

&AddDirToTar('.');

print TAR <<END;
# compress the archive
gzip scriba-${VERSION}b${BUILD}-source.tar
# remove the symbolic link
rm  ${DIRNAME}
END

close TAR;
chmod(700,"mktar");