Changeset 937 in genappalpha for sbin/getapp.pl
- Timestamp:
- Jun 29, 2016, 1:55:11 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sbin/getapp.pl
r936 r937 46 46 -gen run genapp.pl after install 47 47 -nolinks do not setup html links 48 -dir directory use specified directory instead of application name 48 49 49 50 when using usage[2]; … … 56 57 my $gen; 57 58 my $nolinks; 59 my $targetdir; 58 60 59 61 while ( $ARGV[ 0 ] =~ /^-/ ) { … … 62 64 die "$0: option $option requries an argument\n" . $notes if !@ARGV; 63 65 $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; 64 71 next; 65 72 } … … 167 174 } 168 175 169 $app = shift || die $notes; 176 $app = shift || die $notes; 177 $targetdir = $app if !$targetdir; 170 178 171 179 die "$0: svn-type must be svn or svn+ssh and you specified '$svntype'\n" if $svntype !~ /^svn(\+ssh|)$/; 172 180 173 die "$0: $ app file already exists\n" if -e $app&& !$force;181 die "$0: $targetdir directory already exists\n" if -e $targetdir && !$force; 174 182 175 183 @l = listapps(); … … 180 188 die "$0: Error: $app is not known as an application name\n" if !$vapp{ $app }; 181 189 182 $cmd = "svn $force co ${svntype}://$svnbase/$app $ app";190 $cmd = "svn $force co ${svntype}://$svnbase/$app $targetdir"; 183 191 184 192 print "$cmd\n"; … … 192 200 193 201 sub setappconfig { 194 my $app = $_[0]; 195 my $admin = $_[1]; 202 my $app = $_[0]; 203 my $targetdir = $_[1]; 204 my $admin = $_[2]; 196 205 197 206 my $json = {}; … … 217 226 $$json{ "lockdir" } = "$gb/etc"; 218 227 219 $f = "$ app/appconfig.json";228 $f = "$targetdir/appconfig.json"; 220 229 open $fh, ">$f" || die "$0: could not open $f for writing\n"; 221 230 print $fh to_json( $json, { utf8 => 1, pretty => 1 } ); … … 224 233 } 225 234 226 setappconfig( $app, $ admin );235 setappconfig( $app, $targetdir, $admin ); 227 236 228 237 # setup directives.json … … 232 241 233 242 sub setdirectives { 234 my $app = $_[0]; 235 my $webroot = $_[1]; 243 my $app = $_[0]; 244 my $targetdir = $_[1]; 245 my $webroot = $_[2]; 236 246 237 247 my $f = "directives.json.template"; 238 248 my $fo = "directives.json"; 239 249 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. 251 This 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. 244 254 This file must be manually removed before continuing. 245 255 If 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";256 This 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"; 251 261 my @l = <$fh>; 252 262 close $fh; … … 255 265 chomp $dir; 256 266 257 die "$0: $ app/$f error, missing __app_parent_directory__ tags.267 die "$0: $targetdir/$f error, missing __app_parent_directory__ tags. 258 268 This is an error of the application developer and they should be informed.\n$devmsg" if !( grep /__app_parent_directory__/, @l ); 259 269 260 die "$0: $ app/$f error, missing __webroot__ tags.270 die "$0: $targetdir/$f error, missing __webroot__ tags. 261 271 This is an error of the application developer and they should be informed.\n$devmsg" if !( grep /__webroot__/, @l ); 262 272 263 # die "$0: $ app/$f error, missing __application__ tags.273 # die "$0: $targetdir/$f error, missing __application__ tags. 264 274 # This is an error of the application developer and they should be informed.\n$devmag" if !( grep /__application__/, @l ); 265 275 266 276 grep s/__app_parent_directory__/$dir/g, @l; 267 277 268 grep s/__webroot__/$ dir/g, @l;278 grep s/__webroot__/$webroot/g, @l; 269 279 270 280 # 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 } 271 286 272 287 if ( $$djson{ 'usewss' } && !$$cfgjson{ 'https' } ) { … … 283 298 } 284 299 285 die "$0 : $ app/$f error: can not locate json closure.300 die "$0 : $targetdir/$f error: can not locate json closure. 286 301 This is an error of the application developer and they should be informed.\n$devmsg" if $l[ -1 ] !~ /^\s*}\s*$/; 287 302 … … 290 305 push @l, "}\n"; 291 306 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"; 293 308 print $fh ( join '', @l ); 294 309 close $fh; 295 print "created $ app/$fo\n";296 } 297 298 setdirectives( $app, $ $cfgjson{'webroot'} );310 print "created $targetdir/$fo\n"; 311 } 312 313 setdirectives( $app, $targetdir, $$cfgjson{'webroot'} ); 299 314 300 315 sub runcmd { … … 321 336 322 337 if ( $gen ) { 323 runcmd( "cd $ app; env GENAPP=$gb \$GENAPP/bin/genapp.pl" );338 runcmd( "cd $targetdir; env GENAPP=$gb \$GENAPP/bin/genapp.pl" ); 324 339 if ( !$nolinks ) { 325 340 my $dir = `pwd`; 326 341 chomp $dir; 327 342 my $cmds = 328 "cd $ app329 ln -sf $dir/$ app/output/html5 $$cfgjson{'webroot'}/$app343 "cd $targetdir 344 ln -sf $dir/$targetdir/output/html5 $$cfgjson{'webroot'}/$targetdir 330 345 mkdir -p output/html5/results output/html5/deleted 2> /dev/null 331 346 rm ajax results util 2> /dev/null
Note: See TracChangeset
for help on using the changeset viewer.