use strict;
use warnings;
use rpm_spec;
use config;
my $rpm_target = "i586";
our $opt_specdir;
my $spec_id = 0;
my @specs_to_build = ();
my $build_command;
sub usage (;$) {
my $retval = shift;
print << "EOF";
--dumprc
'parse' command.
exit 0;
}
# --------- utility functions ----------------------------------------------
my $os;
my $os_rel;
sub init () {
chomp ($os);
chomp ($os_rel);
if ($os eq 'sunos') {
if ($os_rel >= 5) {
$os = 'solaris';
}
}
if ($os eq "linux") {
$opt_specdir = "/jds/packages/spec-files/base-specs";
} else {
$opt_specdir = "/jds/packages/spec-files";
}
}
my $defaults;
sub process_defaults () {
'get the self package or rpm name',
0);
'get the child package or rpm names',
0);
'get all source filenames',
0);
'get all source filenames beloging to the specified rpm name',
'');
'get all patch filenames',
0);
'get all patch filenames beloging to the specified rpm name',
'');
'get the build dirname under %{_buildir}',
0);
'get all child build dirnames under %{_buildir}/parent',
0);
'get the build dirname under %{_buildir}/parent belonging to the specified rpm name,',
'');
}
sub add_spec ($) {
my $spec_name = shift;
my $spec;
if (-f $spec_name) {
} else {
$spec_name = "${opt_specdir}/${spec_name}.spec";
}
}
if (not defined ($spec)) {
printf ("error");
} else {
my $this_spec_id = $spec_id ++;
}
}
sub process_args {
my $arg = shift;
if (not defined ($build_command)) {
if (($arg ne "parse")) {
printf ("unknown command: $arg\n");
usage (1);
}
$build_command = $arg;
} else {
}
}
sub process_options {
'get-sources-from-child=s' => sub { shift; $defaults->set ('get_source_names_from_child', shift); },
'get-builddir-from-child=s' => sub { shift; $defaults->set ('get_builddir_name_from_child', shift); },
'help' => \&usage,
'<>' => \&process_args);
}
# --------- parse command --------------------------------------------------
sub print_self_name ($) {
my $spec = shift;
my @sources;
if ($os eq "linux") {
} elsif ($os eq "solaris") {
# printf ("%s\n", $spec);
}
}
sub print_child_names ($) {
my $spec = shift;
my @sources;
if ($os eq "linux") {
return;
} elsif ($os eq "solaris") {
foreach my $spec_name_used (@spec_names_used) {
# printf ("%s\n", $$spec_used->get_base_file_name());
}
}
}
sub print_sources ($) {
my $spec = shift;
my @sources;
if ($os eq "linux") {
if (not defined ($src)) {
next;
}
printf ("%s\n", $src);
}
} elsif ($os eq "solaris") {
if (not defined ($src)) {
next;
}
printf ("%s\n", $src);
}
}
}
sub print_sources_from_child ($$) {
my $spec = shift;
my $user_rpm = shift;
my @sources;
if ($os eq "linux") {
return;
} elsif ($os eq "solaris") {
foreach my $spec_name_used (@spec_names_used) {
foreach my $src (@sources_used) {
printf ("%s\n", $src);
}
exit 0;
}
}
printf ("#### Not Found the rpm: %s\n", $user_rpm);
exit 1;
}
}
sub print_patches ($) {
my $spec = shift;
my @patches;
if ($os eq "linux") {
if (not defined ($patch)) {
next;
}
printf ("%s\n", $patch);
}
} elsif ($os eq "solaris") {
if (not defined ($patch )) {
next;
}
printf ("%s\n", $patch);
}
}
}
sub print_patches_from_child ($$) {
my $spec = shift;
my $user_rpm = shift;
my @sources;
if ($os eq "linux") {
return;
} elsif ($os eq "solaris") {
foreach my $spec_name_used (@spec_names_used) {
foreach my $patch (@patches_used) {
printf ("%s\n", $patch);
}
exit 0;
}
}
printf ("#### Not Found the rpm: %s\n", $user_rpm);
exit 1;
}
}
sub print_builddir ($) {
my $spec = shift;
my @sources;
if ($os eq "linux") {
if (not defined $bsdirname) {
}
printf ("%s\n", $bsdirname);
} elsif ($os eq "solaris") {
if ($bsdirname eq '%{_build_src_dir_name}') {
}
printf ("%s\n", $bsdirname);
}
}
sub print_child_builddirs ($) {
my $spec = shift;
my @sources;
if ($os eq "linux") {
return;
} elsif ($os eq "solaris") {
foreach my $spec_name_used (@spec_names_used) {
if ($bsdirname ne '%{_build_src_dir_name}') {
printf ("%s\n", $bsdirname);
}
}
}
}
sub print_builddir_from_child ($$) {
my $spec = shift;
my $user_rpm = shift;
my @sources;
if ($os eq "linux") {
return;
} elsif ($os eq "solaris") {
foreach my $spec_name_used (@spec_names_used) {
if ($bsdirname ne '%{_build_src_dir_name}') {
printf ("%s\n", $bsdirname);
}
exit 0;
}
}
printf ("#### Not Found the rpm: %s\n", $user_rpm);
exit 1;
}
}
sub get_misc () {
my $spec = shift;
my @sources;
if ($os eq "linux") {
if (not defined ($src)) {
next;
}
# $1 Name:,
# $2 build dir name
# $3 source filename
}
} else {
if (not defined ($src)) {
next;
}
# $1 Solaris Name:,
# $2 Solaris spec filename,
# $3 source filename
}
foreach my $spec_name_used (@spec_names_used) {
foreach my $src (@sources_used) {
# $1 Solaris Name:,
# $2 Solaris spec filename,
# $3 Linux Name:,
# $4 Linux source filename
# I don't know but when used 'printf (' instead of 'printf(', got exec errors.
printf("Spec sources: %s %s %s %s\n", $spec,
$spec->{_base_file_name},
$src);
}
foreach my $patch (@patches_used) {
# $1 Solaris Name:,
# $2 Solaris spec filename,
# $3 Linux Name:,
# $4 Linux patch filename
printf("Spec pths: %s %s %s %s\n", $spec,
$spec->{_base_file_name},
$patch);
}
}
}
}
sub get_parse_options ($) {
my $spec_id = shift;
my @sources;
my $user_rpm_name;
print_self_name ($spec);
exit (0);
}
exit (0);
}
print_sources ($spec);
exit (0);
}
if ($user_rpm_name ne "") {
exit (0);
}
print_patches ($spec);
exit (0);
}
if ($user_rpm_name ne "") {
exit (0);
}
print_builddir ($spec);
exit (0);
}
exit (0);
}
if ($user_rpm_name ne "") {
exit (0);
}
else {
sub get_misc ();
exit (0);
}
}
sub do_build {
while(0){}; #dummy
}
sub do_parse {
for (my $i = 0; $i <=$#specs_to_build; $i++) {
get_parse_options ($i);
}
}
sub main {
process_defaults ();
process_options ();
if ($build_command eq "build") {
} elsif ($build_command eq "parse") {
}
}
init;
main;