IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 9, 2007, 10:53:32 AM (19 years ago)
Author:
eugene
Message:

updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psconfig/mkdist

    r11651 r11730  
    11#!/usr/bin/env perl
     2
     3$tagsets = "tagsets";
    24
    35$cvs  = 0;
     
    68$deltag = 0;
    79$setbranch = 0;
    8 $list = 0;
     10$setdevtag = 0;
    911$module = "";
    1012@tARGV = ();
     
    2224        shift; next;
    2325    }
     26    if ($ARGV[0] eq "-devtag") {
     27        $setdevtag = 1;
     28        shift; next;
     29    }
    2430    if ($ARGV[0] eq "-deltag") {
    2531        $deltag = 1;
    26         shift; next;
    27     }
    28     if ($ARGV[0] eq "-list") {
    29         $list = 1;
    3032        shift; next;
    3133    }
     
    3941        shift; next;
    4042    }
     43    if ($ARGV[0] eq "-list") {
     44        &list_distributions ();
     45    }
    4146    if ($ARGV[0] eq "-h")     { &usage (); }
    4247    if ($ARGV[0] eq "-help")  { &usage (); }
     
    4752@ARGV = @tARGV;
    4853
    49 $distdir = "tagsets";
     54if ( @ARGV != 1) { &usage (); }
    5055
    51 if (!$list && @ARGV != 1) { &usage (); }
    52 if ( $list && @ARGV != 0) { &usage (); }
    53 
    54 $file = "$distdir/$ARGV[0].dst";
    55 open (FILE, $file) || die "ERROR: can't open distribution file\n";
    56 @list = <FILE>;
    57 close (FILE);
    58 
    59 $version = $ARGV[0];
    60 
    61 @name = ();
    62 @tag = ();
    63 @branch = ();
    64 
    65 if ($list) {
    66     printf STDERR "Available Distributions\n";
    67     printf STDERR "%-16s  %7s\n", "Module", "Version";
    68     printf STDERR "-------------------------\n";
    69 }
    70 
    71 foreach $line (@list) {
    72     chop $line;
    73     if ($line =~ m|^\s*$|) { next; }
    74     if ($line =~ m|^\s*\#|) { next; }
    75 
    76     ($name, $branch, $branchver, $mode) = split (":", $line);
    77    
    78     if ($name eq "") { die "missing module name\n"; }
    79    
    80     if ($branch eq "") {
    81         $branch = "HEAD";
    82     }
    83     if ($branch eq "HEAD") {
    84         $tag = "HEAD";
    85     }
    86     if ($branch eq "NONE") {
    87         $tag = "NONE";
    88     }
    89     if (($tag ne "HEAD") && ($branchver eq "")) {
    90         $branchver = "0";
    91     }
    92     if (($branch ne "HEAD") && ($branch ne NONE)) {
    93         $tag = "$branch-$branchver";
    94     }
    95     if (($branch ne "HEAD") && ($branch ne "NONE") && ($branchver eq "NONE")) {
    96         $tag = "$branch";
    97     }
    98     # print  "module: $name, tag: $tag, branch: $branch\n";
    99 
    100     push @name, $name;
    101     push @branch, $branch;
    102     push @tag, $tag;
    103     push @mode, $mode;
    104 }
    105 
    106 if ($list) { exit 0; }
     56$distribution = $ARGV[0];
     57&load_distfile ();
    10758
    10859if ($diff) { &difflist (); }
    109 
    11060if ($settag) { &settags (); }
    11161
    112 mkdir $version;
    113 chdir $version;
    114 for ($i = 0; $i < @name; $i++) {
    115     if (($module ne "") && ($module ne $name[$i])) { next; }
    116     if ($mode[$i] eq "SKIP") { next; }
    117     if ($tag[$i] eq "HEAD") {
    118         &vsystem ("cvs co $name[$i]");
    119         if ($status) { die "error running cvs"; }
    120     } else {
    121         &vsystem ("cvs co -r $tag[$i] $name[$i]");
    122         if ($status) { die "error running cvs"; }
    123     }   
    124 }
    125 chdir "..";
    126 if ($cvs) { exit 0; }
    127 
    128 &vsystem ("rm -r `find $version -name CVS`");
    129 if (! -e tarballs) { mkdir "tarballs"; }
    130 &vsystem ("tar cvzf tarballs/$version.tgz  $version");
    131 if ($status) { die "error creating tarball\n"; }
    132 exit 0;
     62&package_distribution ();
    13363
    13464sub vsystem {
    13565    print STDERR "@_\n";
    136     $status = system ("@_");
    137     $status;
    138 }
    139 
    140 sub usage {
    141     print STDERR "USAGE: mkdist -list\n";
    142     print STDERR "     : list valid distributions \n\n";
    143     print STDERR "USAGE: mkdist (group) (version) [-cvs]\n";
    144     print STDERR "     : make a distribution tarball\n";
    145     print STDERR "     : -cvs  : only check out the cvs tree, don't make a tarball\n\n";
    146     print STDERR "USAGE: mkdist -diff (group) (version)\n";
    147     print STDERR "     : show the difference between the distribution and current tree\n\n";
    148     exit 2;
     66    #$status = system ("@_");
     67    #$status;
    14968}
    15069
    15170sub difflist {
    15271
    153     for ($i = 0; $i < @name; $i++) {
     72    for ($i = 0; $i < @cvsname; $i++) {
    15473        # the base component cannot be rdiffed
    155         print STDERR "--- $name[$i] ---\n";
    156         if ($name[$i] eq "base") { next; }
     74        print STDERR "--- $cvsname[$i] ---\n";
     75        if ($cvsname[$i] eq "base") { next; }
    15776        if ($tag[$i] eq "") {
    158             &vsystem ("cvs -q rdiff -s -r HEAD $name[$i]");
     77            &vsystem ("cvs -q rdiff -s -r HEAD $cvsname[$i]");
    15978        } else {
    160             &vsystem ("cvs -q rdiff -s -r $tag[$i] $name[$i]");
     79            &vsystem ("cvs -q rdiff -s -r $tag[$i] $cvsname[$i]");
    16180        }       
    16281        print STDERR "\n\n";
     
    16786sub settags {
    16887    print STDERR "setting tags\n";
    169     for ($i = 0; $i < @name; $i++) {
    170         # can the base component be tagged?
    171         if ($name[$i] eq "base") {
    172             # make this automatic by checking it out and cd'ing there
    173             print STDERR "remember to set the base tag by hand\n";
     88    for ($i = 0; $i < @cvsname; $i++) {
     89        if (($module ne "") && ($module ne $cvsname[$i])) { next; }
     90        ($do_tag, $do_build, $do_package, $do_update) = $mode[$i] =~ m|(\S)(\S)(\S)(\S)|;
     91        if ($do_tag eq "N") {
     92            push @remind, $cvsname[$i];
    17493            next;
    17594        }
    176         if ($tag[$i] eq "") { next; }
    177         if ($tag[$i] eq "HEAD") { next; }
    178         if ($tag[$i] eq "NONE") { next; }
    179         if ($mode[$i] eq "EXTERN") {
    180             print STDERR "remember to set tag for $name[$i]\n";
    181             next;
     95        if ($branchtag[$i] eq "") { die "branch tag missing for $cvsname[$i]\n"; }
     96        if ($branchver[$i] eq "") { die "branch tag version missing\n"; }
     97        $tag = "$branchtag[$i]$branchver[$i]";
     98        if ($setbranch) {
     99            &vsystem ("cvs -q rtag -b $branchtag[$i] $cvsname[$i]");
     100            next;
     101        }
     102        if ($setdevtag) {
     103            &vsystem ("cvs -q rtag $tag $cvsname[$i]");
     104            next;
    182105        }
    183         $flag = "";
    184         if ($setbranch) {
    185             &vsystem ("cvs -q rtag -b $branch[$i] $name[$i]");
    186         } else {
    187             &vsystem ("cvs -q rtag -r $branch[$i] $tag[$i] $name[$i]");
    188         }
     106        &vsystem ("cvs -q rtag -r $branchtag[$i] $tag $cvsname[$i]");
     107    }
     108    for ($i = 0; $i < @remind; $i++) {
     109        print STDERR "remember to set tag for $remind[$i] if needed\n";
    189110    }
    190111    exit 0;
    191112}
     113
     114sub package_distribution {
     115    # package distribution into a tarball
     116    mkdir $distribution;
     117    chdir $distribution;
     118    for ($i = 0; $i < @cvsname; $i++) {
     119        if (($module ne "") && ($module ne $cvsname[$i])) { next; }
     120        ($do_tag, $do_build, $do_package, $do_update) = $mode[$i] =~ m|(\S)(\S)(\S)(\S)|;
     121        if ($do_package eq "N") { next; }
     122        if ($tag[$i] eq "HEAD") {
     123            &vsystem ("cvs co $cvsname[$i]");
     124            if ($status) { die "error running cvs"; }
     125        } else {
     126            &vsystem ("cvs co -r $tag[$i] $cvsname[$i]");
     127            if ($status) { die "error running cvs"; }
     128        }       
     129    }
     130    chdir "..";
     131    if ($cvs) { exit 0; }
     132
     133    &vsystem ("rm -r `find $distribution -name CVS`");
     134    if (! -e tarballs) { mkdir "tarballs"; }
     135    &vsystem ("tar cvzf tarballs/$distribution.tgz  $distribution");
     136    if ($status) { die "error creating tarball\n"; }
     137    exit 0;
     138}
     139
     140sub list_distributions {
     141
     142    vsystem ("ls $tagsets/*.dst");
     143    exit 2;
     144}
     145
     146sub load_distfile {
     147    # open and read the distribution file
     148    # results go into @cvsname, @branchtag, @branchver, @mode
     149    $file = "$tagsets/$ARGV[0].dst";
     150    open (FILE, $file) || die "ERROR: can't open distribution file $file\n";
     151    @list = <FILE>;
     152    close (FILE);
     153
     154    @mode = ();
     155    @cvsname = ();
     156    @branchtag = ();
     157    @branchver = ();
     158
     159    foreach $line (@list) {
     160        chop $line;
     161        if ($line =~ m|^\s*$|) { next; }
     162        if ($line =~ m|^\s*\#|) { next; }
     163
     164        ($mode, $cvsname, $branchtag, $branchver) = split (" ", $line);
     165       
     166        if ($cvsname eq "") { die "missing module name\n"; }
     167
     168        ($do_tag, $do_build, $do_package, $do_update) = $mode =~ m|(\S)(\S)(\S)(\S)|;
     169        if (($do_tag ne "Y") && ($do_tag ne "N")) { die "invalid tag option $do_tag\n"; }
     170        if (($do_build ne "Y") && ($do_build ne "N")) { die "invalid tag option $do_build\n"; }
     171        if (($do_package ne "Y") && ($do_package ne "N")) { die "invalid tag option $do_package\n"; }
     172        if (($do_update ne "Y") && ($do_update ne "N")) { die "invalid tag option $do_update\n"; }
     173       
     174        print "module: $cvsname, branchtag: $branchtag, branchver: $branchver ";
     175        print "tag: $do_tag, build: $do_build, package: $do_package, update: $do_update\n";
     176
     177        push @mode, $mode;
     178        push @cvsname, $cvsname;
     179        push @branchtag, $branchtag;
     180        push @branchver, $branchver;
     181    }
     182}
     183
     184sub usage {
     185    print STDERR "USAGE: mkdist -list\n";
     186    print STDERR "     : list valid distributions \n\n";
     187    print STDERR "USAGE: mkdist (distribution) [-cvs]\n";
     188    print STDERR "     : make a distribution tarball\n";
     189    print STDERR "     : -cvs  : only check out the cvs tree, don't make a tarball\n\n";
     190    print STDERR "USAGE: mkdist -diff (group) (version)\n";
     191    print STDERR "     : show the difference between the distribution and current tree\n\n";
     192    exit 2;
     193}
     194
Note: See TracChangeset for help on using the changeset viewer.