13 my $stringcheck = 0; |
13 my $stringcheck = 0; |
14 my $file = ''; |
14 my $file = ''; |
15 my $id = ''; |
15 my $id = ''; |
16 my $append = 0; |
16 my $append = 0; |
17 my $delete = ''; |
17 my $delete = ''; |
|
18 my $testingonly = 0; |
18 my $verbose = 0; |
19 my $verbose = 0; |
19 my $dryrun = 0; |
20 my $dryrun = 0; |
20 GetOptions(( |
21 GetOptions(( |
21 'create!' => \$create, |
22 'create!' => \$create, |
22 'stringcheck!' => \$stringcheck, |
23 'stringcheck!' => \$stringcheck, |
23 'file=s' => \$file, |
24 'file=s' => \$file, |
24 'update=s' => \$id, |
25 'update=s' => \$id, |
25 'append!' => \$append, |
26 'append!' => \$append, |
26 'remove=s' => \$delete, |
27 'remove=s' => \$delete, |
|
28 'testingonly!' => \$testingonly, |
27 'help!' => \$help, |
29 'help!' => \$help, |
28 'verbose!' => \$verbose, |
30 'verbose!' => \$verbose, |
29 'dryrun!' => \$dryrun, |
31 'dryrun!' => \$dryrun, |
30 )); |
32 )); |
31 |
33 |
35 bitops |
37 bitops |
36 Executes operations on the BIT db |
38 Executes operations on the BIT db |
37 |
39 |
38 Usage: |
40 Usage: |
39 bitops.pl -c [-n] -f FILE |
41 bitops.pl -c [-n] -f FILE |
40 bitops.pl -u ID [-a] -f FILE |
42 bitops.pl -u ID [-a] [-t] -f FILE |
41 bitops.pl -r ID |
43 bitops.pl -r ID |
42 |
44 |
43 Options: |
45 Options: |
44 -h, --help Show this help message and exit |
46 -h, --help Show this help message and exit |
45 -c, --create Create entry for a new build then set the attributes to |
47 -c, --create Create entry for a new build then set the attributes to |
55 changed with the -a option) |
57 changed with the -a option) |
56 -a, --append Do not delete entries in the tables different than |
58 -a, --append Do not delete entries in the tables different than |
57 BUILDS before inserting the data supplied. This option |
59 BUILDS before inserting the data supplied. This option |
58 must be used in conjuntion with -u (see info for -u |
60 must be used in conjuntion with -u (see info for -u |
59 option for more information) |
61 option for more information) |
|
62 -t, --testingonly Only update the TESTING table and use ID obtained by |
|
63 match of build_id_string |
60 -r, --remove Remove build ID (entries in all tables) from the db |
64 -r, --remove Remove build ID (entries in all tables) from the db |
61 -f FILE, --file FILE Use attributes in FILE to create/update the build info |
65 -f FILE, --file FILE Use attributes in FILE to create/update the build info |
62 See below for file format. |
66 See below for file format. |
63 -v, --verbose Increase info level |
67 -v, --verbose Increase info level |
64 -d, --dryrun Only show what would happen, do not actually interact |
68 -d, --dryrun Only show what would happen, do not actually interact |
496 } |
500 } |
497 print "new build id: $newbuildid\n"; |
501 print "new build id: $newbuildid\n"; |
498 } |
502 } |
499 elsif ($id) |
503 elsif ($id) |
500 { |
504 { |
501 print "Updating build $id\n"; |
505 my $extra = ''; |
502 |
506 $extra="for TESTING table only" if ($testingonly); |
503 if (defined $builds_entry->{id} && $id != $builds_entry->{id}) |
507 print "Updating build $id $extra\n"; |
|
508 |
|
509 if (defined $builds_entry->{id} && $id != $builds_entry->{id} && !$testingonly) |
504 { |
510 { |
505 print "ERROR: The build id specified in the input file is different than the one on the command line. Not updating build.\n"; |
511 print "ERROR: The build id specified in the input file is different than the one on the command line. Not updating build.\n"; |
506 exit(1); |
512 exit(1); |
507 } |
513 } |
508 |
514 |
509 if (keys %{$builds_entry}) |
515 if ($testingonly) |
|
516 { |
|
517 die "build_id_string must be provided" if (!defined $builds_entry->{build_id_string}); |
|
518 print "Search for matching build_id_string\n" if ($verbose); |
|
519 my $query=$db->prepare("select id from builds where build_id_string='$builds_entry->{build_id_string}';"); |
|
520 $query->execute(); |
|
521 my @ids_existing=(); |
|
522 my $id_existing=-1; |
|
523 $query->bind_columns(\$id_existing); |
|
524 while($query->fetch()) |
|
525 { |
|
526 push(@ids_existing, $id_existing); |
|
527 } |
|
528 die "More than 1 id matching: @ids_existing" if (scalar(@ids_existing)>1); |
|
529 $id=shift @ids_existing; |
|
530 $builds_entry->{id}=$id; |
|
531 print "Now changing id to $id\n"; |
|
532 } |
|
533 |
|
534 if (keys %{$builds_entry} && !$testingonly) |
510 { |
535 { |
511 my $field_list = ''; |
536 my $field_list = ''; |
512 my @fields = (); |
537 my @fields = (); |
513 for my $field (keys %{$builds_entry}) |
538 for my $field (keys %{$builds_entry}) |
514 { |
539 { |
523 |
548 |
524 print " execute '@fields'\n" if ($verbose); |
549 print " execute '@fields'\n" if ($verbose); |
525 $query->execute(@fields) |
550 $query->execute(@fields) |
526 or print "WARNING: Couldn't execute update builds (@fields): " . $db->errstr() . "\n" if (!$dryrun); |
551 or print "WARNING: Couldn't execute update builds (@fields): " . $db->errstr() . "\n" if (!$dryrun); |
527 } |
552 } |
528 if (@{$envinfo}) |
553 if (@{$envinfo} && !$testingonly) |
529 { |
554 { |
530 if (!$append) |
555 if (!$append) |
531 { |
556 { |
532 print " prepare 'delete from envinfo where build_id=$id'\n" if ($verbose); |
557 print " prepare 'delete from envinfo where build_id=$id'\n" if ($verbose); |
533 my $delete_query = $db->prepare("delete from envinfo where build_id=$id") |
558 my $delete_query = $db->prepare("delete from envinfo where build_id=$id") |
550 print " execute '$tool,$version'\n" if ($verbose); |
575 print " execute '$tool,$version'\n" if ($verbose); |
551 $query->execute($tool, $version) |
576 $query->execute($tool, $version) |
552 or print "WARNING: Couldn't execute insert into envinfo ($tool,$version): " . $db->errstr() . "\n" if (!$dryrun); |
577 or print "WARNING: Couldn't execute insert into envinfo ($tool,$version): " . $db->errstr() . "\n" if (!$dryrun); |
553 } |
578 } |
554 } |
579 } |
555 if (@{$failures}) |
580 if (@{$failures} && !$testingonly) |
556 { |
581 { |
557 if (!$append) |
582 if (!$append) |
558 { |
583 { |
559 print " prepare 'delete from failures where build_id=$id'\n" if ($verbose); |
584 print " prepare 'delete from failures where build_id=$id'\n" if ($verbose); |
560 my $delete_query = $db->prepare("delete from failures where build_id=$id") |
585 my $delete_query = $db->prepare("delete from failures where build_id=$id") |
577 print " execute '$category,$count'\n" if ($verbose); |
602 print " execute '$category,$count'\n" if ($verbose); |
578 $query->execute($category, $count) |
603 $query->execute($category, $count) |
579 or print "WARNING: Couldn't execute insert into failures ($category,$count): " . $db->errstr() . "\n" if (!$dryrun); |
604 or print "WARNING: Couldn't execute insert into failures ($category,$count): " . $db->errstr() . "\n" if (!$dryrun); |
580 } |
605 } |
581 } |
606 } |
582 if (@{$reports}) |
607 if (@{$reports} && !$testingonly) |
583 { |
608 { |
584 if (!$append) |
609 if (!$append) |
585 { |
610 { |
586 print " prepare 'delete from reports where build_id=$id'\n" if ($verbose); |
611 print " prepare 'delete from reports where build_id=$id'\n" if ($verbose); |
587 my $delete_query = $db->prepare("delete from reports where build_id=$id") |
612 my $delete_query = $db->prepare("delete from reports where build_id=$id") |
605 print " execute '$name,$url,$type'\n" if ($verbose); |
630 print " execute '$name,$url,$type'\n" if ($verbose); |
606 $query->execute($name, $url, $type) |
631 $query->execute($name, $url, $type) |
607 or print "WARNING: Couldn't execute insert into reports ($name,$url,$type): " . $db->errstr() . "\n" if (!$dryrun); |
632 or print "WARNING: Couldn't execute insert into reports ($name,$url,$type): " . $db->errstr() . "\n" if (!$dryrun); |
608 } |
633 } |
609 } |
634 } |
610 if (@{$content}) |
635 if (@{$content} && !$testingonly) |
611 { |
636 { |
612 if (!$append) |
637 if (!$append) |
613 { |
638 { |
614 print " prepare 'delete from content where build_id=$id'\n" if ($verbose); |
639 print " prepare 'delete from content where build_id=$id'\n" if ($verbose); |
615 my $delete_query = $db->prepare("delete from content where build_id=$id") |
640 my $delete_query = $db->prepare("delete from content where build_id=$id") |
633 print " execute '$name,$url,$revision'\n" if ($verbose); |
658 print " execute '$name,$url,$revision'\n" if ($verbose); |
634 $query->execute($name, $url, $revision) |
659 $query->execute($name, $url, $revision) |
635 or print "WARNING: Couldn't execute insert into content ($name,$url,$revision): " . $db->errstr() . "\n" if (!$dryrun); |
660 or print "WARNING: Couldn't execute insert into content ($name,$url,$revision): " . $db->errstr() . "\n" if (!$dryrun); |
636 } |
661 } |
637 } |
662 } |
638 if (@{$baselines}) |
663 if (@{$baselines} && !$testingonly) |
639 { |
664 { |
640 if (!$append) |
665 if (!$append) |
641 { |
666 { |
642 print " prepare 'delete from baselines where build_id=$id'\n" if ($verbose); |
667 print " prepare 'delete from baselines where build_id=$id'\n" if ($verbose); |
643 my $delete_query = $db->prepare("delete from baselines where build_id=$id") |
668 my $delete_query = $db->prepare("delete from baselines where build_id=$id") |
660 print " execute '$type,$path'\n" if ($verbose); |
685 print " execute '$type,$path'\n" if ($verbose); |
661 $query->execute($type, $path) |
686 $query->execute($type, $path) |
662 or print "WARNING: Couldn't execute insert into baselines ($type,$path): " . $db->errstr() . "\n" if (!$dryrun); |
687 or print "WARNING: Couldn't execute insert into baselines ($type,$path): " . $db->errstr() . "\n" if (!$dryrun); |
663 } |
688 } |
664 } |
689 } |
665 if (@{$labels}) |
690 if (@{$labels} && !$testingonly) |
666 { |
691 { |
667 if (!$append) |
692 if (!$append) |
668 { |
693 { |
669 print " prepare 'delete from labels where build_id=$id'\n" if ($verbose); |
694 print " prepare 'delete from labels where build_id=$id'\n" if ($verbose); |
670 my $delete_query = $db->prepare("delete from labels where build_id=$id") |
695 my $delete_query = $db->prepare("delete from labels where build_id=$id") |