Changeset 937 in genappalpha for sbin/getapp.pl


Ignore:
Timestamp:
Jun 29, 2016, 1:55:11 AM (6 years ago)
Author:
ehb
Message:

html5 : removed repeater restrictions, now general repeater structures allowed. Still alpha

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sbin/getapp.pl

    r936 r937  
    4646   -gen                run genapp.pl after install
    4747   -nolinks            do not setup html links
     48   -dir directory      use specified directory instead of application name
    4849
    4950when using usage[2];
     
    5657my $gen;
    5758my $nolinks;
     59my $targetdir;
    5860
    5961while ( $ARGV[ 0 ] =~ /^-/ ) {
     
    6264        die "$0: option $option requries an argument\n" . $notes if !@ARGV;
    6365        $admin = shift @ARGV;
     66        next;
     67    }
     68    if ( $option =~ /^-dir$/ ) {
     69        die "$0: option $option requries an argument\n" . $notes if !@ARGV;
     70        $targetdir = shift @ARGV;
    6471        next;
    6572    }
     
    167174}
    168175
    169 $app     = shift || die $notes;
     176$app       = shift || die $notes;
     177$targetdir = $app if !$targetdir;
    170178
    171179die "$0: svn-type must be svn or svn+ssh and you specified '$svntype'\n" if $svntype !~ /^svn(\+ssh|)$/;
    172180
    173 die "$0: $app file already exists\n" if -e $app && !$force;
     181die "$0: $targetdir directory already exists\n" if -e $targetdir && !$force;
    174182
    175183@l = listapps();
     
    180188die "$0: Error: $app is not known as an application name\n" if !$vapp{ $app };
    181189
    182 $cmd = "svn $force co ${svntype}://$svnbase/$app $app";
     190$cmd = "svn $force co ${svntype}://$svnbase/$app $targetdir";
    183191
    184192print "$cmd\n";
     
    192200
    193201sub setappconfig {
    194     my $app    = $_[0];
    195     my $admin  = $_[1];
     202    my $app        = $_[0];
     203    my $targetdir  = $_[1];
     204    my $admin      = $_[2];
    196205
    197206    my $json = {};
     
    217226    $$json{ "lockdir" } = "$gb/etc";
    218227
    219     $f = "$app/appconfig.json";
     228    $f = "$targetdir/appconfig.json";
    220229    open  $fh, ">$f" || die "$0: could not open $f for writing\n";
    221230    print $fh to_json( $json, { utf8 => 1, pretty => 1 } );
     
    224233}
    225234
    226 setappconfig( $app, $admin );
     235setappconfig( $app, $targetdir, $admin );
    227236
    228237# setup directives.json
     
    232241
    233242sub setdirectives {
    234     my $app     = $_[0];
    235     my $webroot = $_[1];
     243    my $app       = $_[0];
     244    my $targetdir = $_[1];
     245    my $webroot   = $_[2];
    236246
    237247    my $f      = "directives.json.template";
    238248    my $fo     = "directives.json";
    239249   
    240     die "$0: $app/$f does not exist for this application. 
    241 This is an error of the application developer and they should be informed.\n$devmsg" if !-e "$app/$f";
    242 
    243     die "$0: $app/$fo already exists for this application.
     250    die "$0: $targetdir/$f does not exist for this application. 
     251This is an error of the application developer and they should be informed.\n$devmsg" if !-e "$targetdir/$f";
     252
     253    die "$0: $targetdir/$fo already exists for this application.
    244254This file must be manually removed before continuing. 
    245255If this error recurrs after removing,
    246 This is an error of the application developer and they should be informed.\n$devmsg" if -e "$app/$fo";
    247 
    248     my $djson  = get_file_json( "$app/$f" );
    249 
    250     open my $fh, "$app/$f" || die "$0: file open error on $app/$f\n";
     256This is an error of the application developer and they should be informed.\n$devmsg" if -e "$targetdir/$fo";
     257
     258    my $djson  = get_file_json( "$targetdir/$f" );
     259
     260    open my $fh, "$targetdir/$f" || die "$0: file open error on $targetdir/$f\n";
    251261    my @l = <$fh>;
    252262    close $fh;
     
    255265    chomp $dir;
    256266
    257     die "$0: $app/$f error, missing __app_parent_directory__ tags.
     267    die "$0: $targetdir/$f error, missing __app_parent_directory__ tags.
    258268This is an error of the application developer and they should be informed.\n$devmsg" if !( grep /__app_parent_directory__/, @l );
    259269
    260     die "$0: $app/$f error, missing __webroot__ tags.
     270    die "$0: $targetdir/$f error, missing __webroot__ tags.
    261271This is an error of the application developer and they should be informed.\n$devmsg" if !( grep /__webroot__/, @l );
    262272
    263 #    die "$0: $app/$f error, missing __application__ tags.
     273#    die "$0: $targetdir/$f error, missing __application__ tags.
    264274# This is an error of the application developer and they should be informed.\n$devmag" if !( grep /__application__/, @l );
    265275
    266276    grep s/__app_parent_directory__/$dir/g, @l;
    267277
    268     grep s/__webroot__/$dir/g, @l;
     278    grep s/__webroot__/$webroot/g, @l;
    269279
    270280#    grep s/__application__/$app/g, @l;
     281
     282    if ( $app ne $targetdir ) {
     283        grep s/"$app"/"$targetdir"/g, @l;
     284        grep s/\/$app\//\/$targetdir\//g, @l;
     285    }       
    271286
    272287    if ( $$djson{ 'usewss' } && !$$cfgjson{ 'https' } ) {
     
    283298    }
    284299
    285     die "$0 : $app/$f error: can not locate json closure.
     300    die "$0 : $targetdir/$f error: can not locate json closure.
    286301This is an error of the application developer and they should be informed.\n$devmsg" if $l[ -1 ] !~ /^\s*}\s*$/;
    287302
     
    290305    push @l, "}\n";
    291306
    292     open  $fh, ">$app/$fo" || die "$0: could not open $app/$fo for writing\n";
     307    open  $fh, ">$targetdir/$fo" || die "$0: could not open $targetdir/$fo for writing\n";
    293308    print $fh ( join '', @l );
    294309    close $fh;
    295     print "created $app/$fo\n";
    296 }
    297 
    298 setdirectives( $app, $$cfgjson{'webroot'} );
     310    print "created $targetdir/$fo\n";
     311}
     312
     313setdirectives( $app, $targetdir, $$cfgjson{'webroot'} );
    299314
    300315sub runcmd {
     
    321336
    322337if ( $gen ) {
    323     runcmd( "cd $app; env GENAPP=$gb \$GENAPP/bin/genapp.pl" );
     338    runcmd( "cd $targetdir; env GENAPP=$gb \$GENAPP/bin/genapp.pl" );
    324339    if ( !$nolinks ) {
    325340        my $dir = `pwd`;
    326341        chomp $dir;
    327342        my $cmds =
    328 "cd $app
    329 ln -sf $dir/$app/output/html5 $$cfgjson{'webroot'}/$app
     343"cd $targetdir
     344ln -sf $dir/$targetdir/output/html5 $$cfgjson{'webroot'}/$targetdir
    330345mkdir -p output/html5/results output/html5/deleted 2> /dev/null
    331346rm ajax results util 2> /dev/null
Note: See TracChangeset for help on using the changeset viewer.