Add flag to exclude files. Also, update version in module.info to match command line, if given

This commit is contained in:
Jamie Cameron
2017-05-15 21:46:07 -07:00
parent 26d05f0437
commit 7face4b2be

View File

@@ -29,6 +29,7 @@ my $allow_overwrite = 0;
my ($force_theme, $rpmdepends, $no_prefix, $vendor, $provides, $url,
$force_usermin, $final_mod, $sign, $epoch, $dir, $ver);
my @extrareqs;
my @exclude;
# Parse command-line args
while(@ARGV) {
@@ -82,6 +83,9 @@ while(@ARGV) {
elsif ($a eq "--epoch") {
$epoch = shift(@ARGV);
}
elsif ($a eq "--exclude") {
push(@exclude, shift(@ARGV));
}
elsif ($a =~ /^\-\-/) {
print STDERR "Unknown option $a\n";
exit(1);
@@ -183,12 +187,11 @@ else {
}
$prefix = "" if ($no_prefix);
my $ucprog = ucfirst($prog);
$ver ||= $iver; # Use module.info version, or 1
$ver ||= 1;
# Copy the directory to a temp location for tarring
system("/bin/mkdir -p /tmp/makemodulerpm");
system("cd $par && /bin/cp -rpL $source_mod /tmp/makemodulerpm/$mod");
system("/usr/bin/find /tmp/makemodulerpm -name .git | xargs rm -rf");
system("/usr/bin/find /tmp/makemodulerpm -name .svn | xargs rm -rf");
system("/usr/bin/find /tmp/makemodulerpm -name .xvpics | xargs rm -rf");
system("/usr/bin/find /tmp/makemodulerpm -name '*.bak' | xargs rm -rf");
@@ -202,6 +205,23 @@ if (-r "/tmp/makemodulerpm/$mod/EXCLUDE") {
system("cd /tmp/makemodulerpm/$mod && cat EXCLUDE | xargs rm -rf");
system("rm -f /tmp/makemodulerpm/$mod/EXCLUDE");
}
foreach my $e (@exclude) {
system("/usr/bin/find /tmp/makemodulerpm -name ".quotemeta($e)." | xargs rm -rf");
}
# Set version in .info file to make command line, if given
if ($ver) {
if ($minfo{'desc'}) {
$minfo{'version'} = $ver;
&write_file("/tmp/makemodulerpm/$mod/module.info", \%minfo);
}
elsif ($tinfo{'desc'}) {
$tinfo{'version'} = $ver;
&write_file("/tmp/makemodulerpm/$mod/theme.info", \%tinfo);
}
}
$ver ||= $iver; # Use module.info version, or 1
$ver ||= 1;
# Tar up the directory
system("cd /tmp/makemodulerpm && tar czhf $rpm_source_dir/$mod.tar.gz $mod");
@@ -417,6 +437,22 @@ while(<ARFILE>) {
close(ARFILE);
return 1;
}
# write_file(file, array)
# Write out the contents of an associative array as name=value lines
sub write_file
{
my (%old, @order);
&read_file($_[0], \%old, \@order);
open(ARFILE, ">$_[0]");
foreach my $k (@order) {
print ARFILE $k,"=",$_[1]->{$k},"\n" if (exists($_[1]->{$k}));
}
foreach my $k (keys %{$_[1]}) {
print ARFILE $k,"=",$_[1]->{$k},"\n" if (!exists($old{$k}));
}
close(ARFILE);
}
sub untaint
{