Changeset 1470 in ProjectBuilder for projects/casparbuster/devel/bin/cbusterize


Ignore:
Timestamp:
Apr 16, 2012, 4:04:12 AM (12 years ago)
Author:
Bruno Cornec
Message:
  • Improve again cbusterize with more usage of pb functions, including VCS ones now that they are available
File:
1 edited

Legend:

Unmodified
Added
Removed
  • projects/casparbuster/devel/bin/cbusterize

    r1468 r1470  
    114114use ProjectBuilder::Base;
    115115use ProjectBuilder::Conf;
     116use ProjectBuilder::VCS;
    116117
    117118# settings
     
    176177my $cb = \%cb;
    177178($cb->{'basedir'},$cb->{'database'},$cb->{'usemachines'},$cb->{'pluginsdir'},$cb->{'cms'}) = pb_conf_get("cbbasedir","cbdatabase","cbusemachines","cbpluginssubdir","cbcms");
    178 
    179 print Dumper($cb) if ($debug);
     179pb_log(2,"%cb: ",Dumper($cb));
    180180
    181181# Check for mandatory params
     
    190190eval { $basedir =~ s/(\$ENV.+\})/$1/eeg };
    191191
    192 # debug mode overview
    193 if ($debug) {
    194     print <<EOF;
    195 DEBUG MODE, not doing anything, just printing
    196 DEBUG: basedir = $basedir
    197 DEBUG: source  = $source
    198 EOF
    199     if (defined ($machine)) {
    200         print "DEBUG: machine = $machine\n";
    201     }
    202 }
     192pb_log(1, "DEBUG MODE, not doing anything, just printing\nDEBUG: basedir = $basedir\nDEBUG: source  = $source\n");
     193pb_log(1, "DEBUG: machine = $machine\n") if (defined ($machine));
    203194
    204195# Create basedir if it doesn't exist
    205196if (not -d $basedir) {
    206197    if ($debug) {
    207         print "DEBUG: Creating recursively directory $basedir\n";
    208     } else {
    209         mkpath($basedir,0,0755) or die "Unable to recursively create $basedir";
    210         # TODO: Add it to the CMS
     198        pb_log(1, "DEBUG: Creating recursively directory $basedir\n");
     199    } else {
     200        pb_mkdir_p($basedir) || die "Unable to recursively create $basedir";
    211201    }
    212202}
     
    215205my $srcdir = undef;
    216206my $srcfile = undef;
     207# TODO: That should be remote !!
    217208if (-d $source) {
    218209    $srcdir = $source;
     
    222213    }
    223214
    224 if ($debug) {
    225     print "DEBUG: Found srcdir = $srcdir\n";
    226     if (defined $srcfile) {
    227         print "DEBUG: Found srcfile = $srcfile\n";
    228     } else {
    229         print "DEBUG: Found no srcfile\n";
    230     }
     215pb_log(1,"DEBUG: Found srcdir = $srcdir\n");
     216if (defined $srcfile) {
     217    pb_log(1,"DEBUG: Found srcfile = $srcfile\n");
     218} else {
     219    pb_log(1,"DEBUG: Found no srcfile\n");
    231220}
    232221
     
    236225$target .= "$srcdir";
    237226
     227my $scheme = $cb->{'cms'}->{$appname};
     228
    238229# If both source and target are dirs, then copy into the parent of the target
    239230$target = basename($target) if ((not defined $srcfile) && (-d $target));
     
    242233if (not -d $target) {
    243234    if ($debug) {
    244         print "DEBUG: Creating recursively directory $target\n";
    245     } else {
    246         mkpath($target,0,0755) or die "Unable to recursively create $target";
    247         print "INFO: Created $target you may want to add it to your CMS\n";
    248         # TODO: Add it to the CMS
     235        pb_log(1,"DEBUG: Creating recursively directory $target\n");
     236    } else {
     237        pb_mkdir_p($target) || die "Unable to recursively create $target";
     238        pb_vcs_add($scheme,$target);
     239        pb_log(0,"INFO: Created $target and added it to your $scheme system\n");
    249240    }
    250241}
     
    264255
    265256# Now add content if not already there
    266 if ((defined $srcfile) && (! -f "$target/$srcfile")) {
     257if (defined $srcfile) {
     258    # File case
     259    if (! -f "$target/$srcfile") {
     260        if ($debug) {
     261            pb_log(1,"DEBUG: launching $cmd\n");
     262        } else {
     263            pb_system($cmd);
     264            pb_vcs_add($scheme,"$target/$srcfile");
     265            pb_log(0,"INFO: Created $target/$srcfile and added it to your $scheme system\n");
     266        }
     267    } else {
     268        pb_log(0,"INFO: File $target/$srcfile already there\n");
     269    }
     270} else {
     271    # Directory case
     272    # TODO: if targetlocal dir alredy exists, take the parent
    267273    if ($debug) {
    268         print "DEBUG: launching $cmd\n";
    269     } else {
    270         system($cmd);   
    271         print "INFO: Created $target/$srcfile you may want to add it to your CMS\n";
    272     }
    273 }
     274        pb_log(1,"DEBUG: launching $cmd\n");
     275    } else {
     276        pb_system($cmd);
     277        pb_vcs_add($scheme,"$target");
     278        pb_log(0,"INFO: Created $target and added it to your $scheme system\n");
     279    }
     280}
Note: See TracChangeset for help on using the changeset viewer.