Changeset 2021

Show
Ignore:
Timestamp:
02/22/08 08:41:58 (3 months ago)
Author:
joshr
Message:

added --(no-)latest option (to create symlink to latest build dir or not).
Made code to rewrite tarball for .src.rpms more robust.
Comment cleanups.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • swish_website/bin/swish-daily.pl

    r2008 r2021  
    1818my %config = ( 
    1919        svnco           => 'svn co http://svn.swish-e.org/swish-e/trunk/', 
     20        #svnco           => 'svn co http://svn.swish-e.org/swish-e/branches/2.6/',  # for 2.6/2.7 
    2021        tar_keep_days   => 15,  # number of days to keep tarfiles 
    2122        build_keep_days => 2,   # number of days to keep previous build 
     
    2526        symlink         => 1,   # create symlink 
    2627        srpm           => 1,   # build srpms 
     28        latest         => 1,   # make 'latest.tar.gz'  
     29        verbose        => 1, 
    2730); 
    2831 
     
    4548       symlink! 
    4649       srpm! 
     50       latest! 
    4751       help man options 
    4852       config_options=s 
     
    7377 
    7478 
    75  
    7679pod2usage( { 
    7780    -verbose => ($config{man} ? 2 : $config{options} ? 1 : 0), 
     
    160163#======================================================================= 
    161164# make_src_rpm( $c ) 
    162 # makes a .src.rpm from the source tree  
    163 #  by setting up a rpmbuild environment and creating a special 
    164 #  rpmrc file for rpmbuild. 
    165 #  The version for rpm must look like '2.5.6', and we set 
    166 #  the release of the rpm to the svn revision number. 
    167 #  (This will need to be revisited for release .src.rpms) 
     165# makes a .src.rpm from the source tree, by setting up a rpmbuild  
     166#  environment, creating a rpmrc file for rpmbuild, and 
     167#  using rpmbuild to make a .src.rpm from the source tree  
     168#  and tarball. 
     169#  The 'version' for rpm must look like '2.5.6', and we set 
     170#  the release of the rpm to the current date. 
     171#  (For release .src.rpms, use --no-timestamps to disable timestamps, 
     172#   and the revision will come straight from the .spec file) 
    168173# 
    169174# The .src.rpm is deposited into $builddir/rpmbuild/SRPMS 
     
    178183 
    179184    my ($rpmbuilddir, $rpmrcfile) = setup_rpmbuild_environment( $c ); 
    180     my $tarball  = "$c->{tardir}/swish-e-$c->{version}.tar.gz"; # this should be factored out 
     185    my $tarball_for_rpm  = "$c->{tardir}/swish-e-$c->{version}.tar.gz"; # this should be factored out 
    181186    my $srcdir   = $c->{srcdir};   
    182187    my $builddir = $c->{builddir};   
     
    191196                                   # IE, from 2.5.6-2007-12-08 to 2.5.6  
    192197 
    193         my $newtarball = $tarball
     198        my $newtarball = $tarball_for_rpm
    194199        $newtarball  =~ s/-\d+-\d+-\d+\.tar.gz$/.tar.gz/;  # remove -2007-12-12 from tarball 
    195200 
    196201        die "$0: failed to figure out name of new tarball for .src.rpm\n"  
    197             unless ($newtarball ne $tarball); 
    198  
    199         # create a new tarball that extacts to the right dirname, and set $tarball to it 
    200         _rewrite_tarball( $c, $tarball, $newtarball, "swish-e-$origspecversion", "swish-e-$specversion" );  
    201         $tarball = $newtarball; 
    202     } 
    203  
    204     run_command( "cp $tarball                   $rpmbuilddir/SOURCES/swish-e-$specversion.tar.gz" ); 
    205     run_command( "cp $srcdir/rpm/swish-e.xpm    $rpmbuilddir/SOURCES" ); 
    206     run_command( "cp $builddir/rpm/swish-e.spec $rpmbuilddir/SPECS" ); 
     202            unless ($newtarball ne $tarball_for_rpm); 
     203 
     204        # create a new tarball that extracts to the right dirname, and set $tarball to it 
     205        _rewrite_tarball( $c, $tarball_for_rpm, $newtarball, "swish-e-$origspecversion", "swish-e-$specversion" );  
     206        $tarball_for_rpm = $newtarball; 
     207    } 
     208 
     209    run_command( "cp $tarball_for_rpm           $rpmbuilddir/SOURCES/swish-e-$specversion.tar.gz" ); 
     210    run_command( "cp $srcdir/rpm/swish-e.xpm    $rpmbuilddir/SOURCES/" ); 
     211    run_command( "cp $builddir/rpm/swish-e.spec $rpmbuilddir/SPECS/" ); 
    207212 
    208213    # fixup the version string in the .spec file, IE, from 2.5.6-2007-12-08 to 2.5.6  
     
    213218    # also, if in timestamp mode, change the specrelease to be YYYYMMDD 
    214219    if ($c->{timestamp}) { 
    215         chomp(my $specrelease = `date '+%Y%m%d'`);  # normally this is a 1-2 digits 
     220        chomp(my $specrelease = `date '+%Y%m%d'`);  # normally for rpms this is 1-2 digits, not 8. 
    216221        _apply_regexes( "$rpmbuilddir/SPECS/swish-e.spec",  
    217222            qq{s/^%define[[:space:]]+release.*/%define release $specrelease/ims} ); 
     223 
     224        # also, remove our special tarball 
     225        run_command( "rm -f $tarball_for_rpm" ); 
    218226    }  
    219227 
     
    258266    close($fh) || die "$0: Failed to close $rpmmacrosfile: $!"; 
    259267 
    260     # write our rpmrc file that gets rpmbuild to use our special $rpmmacros file 
     268    # write our rpmrc file to get rpmbuild to use our special $rpmmacros file 
    261269    my $rpmrcfile = "$rpmbuilddir/rpmrc"; 
    262270    log_message( "Creating new $rpmrcfile" ); 
     
    330338 
    331339        run_command( "mv swish-e-$c->{version}.tar.gz $c->{tardir}" ); 
    332  
    333         run_command( "rm -f $latest" ); 
    334         run_command( "ln -s $c->{tardir}/swish-e-$c->{version}.tar.gz $latest"); 
     340         
     341        if ($c->{latest}) { # don't update our latest link unless we're supposed to 
     342            run_command( "rm -f $latest" ); 
     343            run_command( "ln -s $c->{tardir}/swish-e-$c->{version}.tar.gz $latest"); 
     344        } 
    335345 
    336346    } else { 
     
    424434    log_message( $command ); 
    425435 
    426     #return !system( $command ); 
    427     system( $command ) && die "$0: Command failed: $command: $!"; 
     436    system( $command ) && die "$0: Command failed: $command: $!";  
     437         
    428438    return 1; 
    429439} 
     
    600610 
    601611    # uncompress and recompress the tarball with a different dir name. 
     612    die "$0: Couldn't find tarball: $fromtarball\n" unless -f $fromtarball; 
    602613    run_command( "tar -zxf $fromtarball" ); 
    603614    die "$0: tarball didn't extract into $fromdir\n" unless -d $fromdir;