[2239] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # Project Builder conf file convertor
|
---|
| 4 | #
|
---|
| 5 | # $Id$
|
---|
| 6 | #
|
---|
| 7 | # Copyright B. Cornec 2016-today
|
---|
| 8 | # Provided under the GPL v2
|
---|
| 9 |
|
---|
| 10 | use strict 'vars';
|
---|
| 11 |
|
---|
| 12 | use Getopt::Long qw(:config auto_abbrev no_ignore_case);
|
---|
| 13 | use Carp qw/confess cluck/;
|
---|
| 14 | use Data::Dumper;
|
---|
| 15 | use English;
|
---|
| 16 | use ProjectBuilder::Version;
|
---|
| 17 | use ProjectBuilder::Base;
|
---|
| 18 | use ProjectBuilder::Display;
|
---|
| 19 | use ProjectBuilder::Env;
|
---|
| 20 | use ProjectBuilder::Conf;
|
---|
| 21 |
|
---|
| 22 | =pod
|
---|
| 23 |
|
---|
| 24 | =head1 NAME
|
---|
| 25 |
|
---|
| 26 | pbupdconf, updates project-builder.org conf files format to the latest version
|
---|
| 27 |
|
---|
| 28 | =head1 DESCRIPTION
|
---|
| 29 |
|
---|
| 30 | pbupdconf, updates project-builder.org conf files format to the latest version
|
---|
| 31 | Starting with version 0.15, YAML is the default format for conf files
|
---|
| 32 | Up to version 0.14 the file format was 'proprietary', meaning dedicated to pb.
|
---|
| 33 |
|
---|
| 34 | =head1 SYNOPSIS
|
---|
| 35 |
|
---|
| 36 | pbupdconf [-vhq] /path/to/conffile
|
---|
| 37 |
|
---|
| 38 | pbupdconf [--verbose][--help][--man][--quiet] /path/to/conffile
|
---|
| 39 |
|
---|
| 40 | =head1 OPTIONS
|
---|
| 41 |
|
---|
| 42 | =over 4
|
---|
| 43 |
|
---|
| 44 | =item B<-v|--verbose>
|
---|
| 45 |
|
---|
| 46 | Increase verbosity
|
---|
| 47 |
|
---|
| 48 | =item B<-q|--quiet>
|
---|
| 49 |
|
---|
| 50 | Do not print any output.
|
---|
| 51 |
|
---|
| 52 | =item B<-h|--help>
|
---|
| 53 |
|
---|
| 54 | Print a brief help message and exits.
|
---|
| 55 |
|
---|
| 56 | =item B<--man>
|
---|
| 57 |
|
---|
| 58 | Prints the manual page and exits.
|
---|
| 59 |
|
---|
| 60 | =back
|
---|
| 61 |
|
---|
| 62 | #=head1 ARGUMENTS
|
---|
| 63 |
|
---|
| 64 | #<action> can be:
|
---|
| 65 |
|
---|
| 66 | #=over 4
|
---|
| 67 |
|
---|
| 68 | #=item B<sbx2build>
|
---|
| 69 |
|
---|
| 70 | #=back
|
---|
| 71 |
|
---|
| 72 | =head1 WEB SITES
|
---|
| 73 |
|
---|
| 74 | The main Web site of the project is available at L<http://www.project-builder.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.project-builder.org/>.
|
---|
| 75 |
|
---|
| 76 | =head1 AUTHORS
|
---|
| 77 |
|
---|
| 78 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
---|
| 79 |
|
---|
| 80 | =head1 COPYRIGHT
|
---|
| 81 |
|
---|
| 82 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
| 83 | described in the file C<COPYING> included with the distribution.
|
---|
| 84 |
|
---|
| 85 | =cut
|
---|
| 86 |
|
---|
| 87 | my ($projectbuilderver,$projectbuilderrev,$pbconfver) = pb_version_init();
|
---|
| 88 | my $appname = "pbupdconf";
|
---|
| 89 |
|
---|
| 90 | # Initialize the syntax string
|
---|
| 91 |
|
---|
| 92 | pb_syntax_init("$appname (aka project-builder.org) Version $projectbuilderver-$projectbuilderrev\n");
|
---|
| 93 |
|
---|
| 94 | my %opts;
|
---|
| 95 |
|
---|
| 96 | GetOptions("help|?|h+" => \$opts{'h'},
|
---|
| 97 | "man" => \$opts{'man'},
|
---|
| 98 | "quiet|q" => \$opts{'q'},
|
---|
| 99 | "verbose|v+" => \$opts{'v'},
|
---|
| 100 | "version|V=s" => \$opts{'V'},
|
---|
| 101 | "stop-on-error!" => \$Global::pb_stop_on_error,
|
---|
| 102 | ) || pb_syntax(-1,0);
|
---|
| 103 |
|
---|
| 104 | if (defined $opts{'h'}) {
|
---|
| 105 | pb_syntax(0,$opts{'h'}-1);
|
---|
| 106 | }
|
---|
| 107 | if (defined $opts{'man'}) {
|
---|
| 108 | pb_syntax(0,2);
|
---|
| 109 | }
|
---|
| 110 | if (defined $opts{'v'}) {
|
---|
| 111 | $pbdebug = $opts{'v'};
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | if (defined $opts{'q'}) {
|
---|
| 115 | $pbdebug=-1;
|
---|
| 116 | }
|
---|
| 117 | pb_display_init("text","");
|
---|
| 118 |
|
---|
| 119 | # We need to force the version
|
---|
| 120 | if (not defined $opts{'V'}) {
|
---|
| 121 | pb_log(0, "You need to specify the current version of your conf files (use 0 if you don't know)\n");
|
---|
| 122 | pb_syntax(-1,0);
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | use vars qw($VERSION $REVISION $PBCONFVER @ISA @EXPORT);
|
---|
| 126 | use Exporter;
|
---|
| 127 | ($VERSION,$REVISION,$PBCONFVER) = pb_version_init();
|
---|
| 128 |
|
---|
| 129 | my ($filteredfiles, $supfiles, $defpkgdir, $extpkgdir) = pb_env_init(undef,0,"getconf",0);
|
---|
| 130 |
|
---|
| 131 | while (@ARGV) {
|
---|
| 132 | # Process each cnf file at its turn
|
---|
| 133 | pb_conf_read()
|
---|
| 134 |
|
---|
| 135 | my $h = pb_conf_get_hash();
|
---|
| 136 | #print "%pbconffiles".Dumper(%pbconffiles)."\n";
|
---|
| 137 | print "\$h".Dumper($h)."\n";
|
---|
| 138 |
|
---|
| 139 | # Dump the Perl data structures back into YAML.
|
---|
| 140 | print Dump($string, $arrayref, $hashref);
|
---|
| 141 |
|
---|
| 142 | # YAML::Dump is used the same way you'd use Data::Dumper::Dumper
|
---|
| 143 | use Data::Dumper;
|
---|
| 144 | print Dumper($string, $arrayref, $hashref);
|
---|
| 145 |
|
---|