web/modules/rhn/RHN/Date.pm | 8
web/modules/rhn/RHN/Form/Response.pm | 10 -
web/modules/rhn/RHN/Kickstart/Post.pm | 308 ----------------------------------
web/modules/rhn/RHN/Kickstart/Pre.pm | 6
4 files changed, 332 deletions(-)
New commits:
commit 990e72f075649fb27c0bb4567879b24ae191720d
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 18:15:47 2010 +0100
valid_helpers not used anywhere, removing.
diff --git a/web/modules/rhn/RHN/Kickstart/Pre.pm b/web/modules/rhn/RHN/Kickstart/Pre.pm
index 9052856..a73c408 100644
--- a/web/modules/rhn/RHN/Kickstart/Pre.pm
+++ b/web/modules/rhn/RHN/Kickstart/Pre.pm
@@ -25,8 +25,6 @@ Params::Validate::validation_options(strip_leading =>
"-");
use overload # I, for one, welcome our new operator overloaders
'""' => \&as_string;
-my @valid_helpers = qw//;
-
sub new {
my $class = shift;
my $val = shift;
@@ -47,8 +45,4 @@ sub as_string {
return $$self;
}
-sub valid_helpers {
- return @valid_helpers;
-}
-
1;
commit 177f1fcabe3a2ec7e6f362288b76ddeaae3befc2
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 18:13:20 2010 +0100
Removing most of code from RHN::Kickstart::Post as the methods were not referenced
from anywhere.
diff --git a/web/modules/rhn/RHN/Kickstart/Post.pm
b/web/modules/rhn/RHN/Kickstart/Post.pm
index 343dc3c..2837862 100644
--- a/web/modules/rhn/RHN/Kickstart/Post.pm
+++ b/web/modules/rhn/RHN/Kickstart/Post.pm
@@ -46,312 +46,4 @@ sub as_string {
return $$self;
}
-# Helpers
-
-sub get_rhn_packages {
- my $self = shift;
- my $on_off = shift;
- my $attr = shift;
-
- my @packages = @{$attr->{packages}};
- my $ssl_available = $attr->{ssl_available};
-
- my $expires = time + 43200; # 12 hours
- my @urls;
-
- foreach my $pkg_id (@packages) {
- my $pkg = RHN::Package->lookup(-id => $pkg_id);
-
- push @urls, RHN::TokenGen::Local->generate_url(0, 0, $pkg->path,
"/download", "local", $expires, $ssl_available);
-
- }
-
- my $urls = join(" ", @urls);
-
- return unless $urls;
-
- $self->choose_action($attr->{style}, $on_off, { urls => $urls });
-}
-
-sub update_rhn_packages {
- my $self = shift;
- my $on_off = shift;
- my $attr = shift;
-
- my @packages = @{$attr->{package_names}};
-
- # crude hack
- my $dir = '/tmp/rhn_rpms/optional';
- my $packages = join(" ", map { "$dir/$_*" }
@{$attr->{package_names}});
- $self->choose_action('update_rhn_package', $on_off, { packages =>
$packages });
-}
-
-
-sub add_gpg_keys {
- my $self = shift;
- my $on_off = shift;
- my $attr = shift;
-
- my @key_data = @{$attr->{key_data}};
-
- return unless @key_data;
-
- my $dist = $attr->{dist};
-
- for (my $i = $#key_data; $i >= 0; $i--) { # What's this?! A 'for' loop
in perl? Madness!
- $self->choose_action("import_gpg_keys_${dist}" , $on_off, { index =>
$i + 1 });
- $self->choose_action('write_key_to_file', $on_off, { key =>
$key_data[$i], index => $i + 1, type => 'gpg' });
- }
-}
-
-sub add_ssl_keys {
- my $self = shift;
- my $on_off = shift;
- my $attr = shift;
-
- my @key_data = @{$attr->{key_data}};
-
- return unless @key_data;
-
- $self->choose_action('use_custom_ssl_keys', $on_off);
- $self->choose_action("import_ssl_keys" , $on_off);
-
- for (my $i = $#key_data; $i >= 0; $i--) {
- $self->choose_action('write_key_to_file', $on_off, { key =>
$key_data[$i], index => $i + 1, type => 'ssl' });
- }
-}
-
-sub choose_action {
- my $self = shift;
- my $mode = shift;
- my $toggle = shift;
- my $args = shift;
-
- if (not defined $toggle) { # is it on already?
- return $self->check_for_line($mode);
- }
- elsif ($toggle) { # turn it on...
- return $self->insert_line($mode, $args);
- }
- else { # ...or off
- return $self->remove_line($mode);
- }
-}
-
-my %helpers = (
- enable_cfg_management => {
- regexp => qr|^mkdir -p /etc/sysconfig/rhn/allowed-actions/configfiles\n
- touch
/etc/sysconfig/rhn/allowed-actions/configfiles/all|xm,
- string => "mkdir -p
/etc/sysconfig/rhn/allowed-actions/configfiles\n"
- . "touch /etc/sysconfig/rhn/allowed-actions/configfiles/all",
- position => 1,
- },
- enable_remote_command => {
- regexp => qr|^mkdir -p /etc/sysconfig/rhn/allowed-actions/script\n
- touch
/etc/sysconfig/rhn/allowed-actions/script/all|xm,
- string => "mkdir -p
/etc/sysconfig/rhn/allowed-actions/script\n"
- . "touch /etc/sysconfig/rhn/allowed-actions/script/all",
- position => 1,
- },
- import_rhn_gpg_key_rhel3 => {
- regexp => qr|^rpm --import /usr/share/rhn/RPM-GPG-KEY|m,
- string => "rpm --import /usr/share/rhn/RPM-GPG-KEY",
- position => 1,
- },
- import_rhn_gpg_key_rhel2_1 => {
- regexp => qr|^gpg $(up2date --gpg-flags) --batch --import
/usr/share/rhn/RPM-GPG-KEY\n
- gpg $(up2date --gpg-flags) --batch --import
/usr/share/rhn/RPM-GPG-KEY|xm,
- string => "gpg \$(up2date --gpg-flags) --batch --import
/usr/share/rhn/RPM-GPG-KEY\n"
- . "gpg \$(up2date --gpg-flags) --batch --import
/usr/share/rhn/RPM-GPG-KEY",
- position => 1,
- },
- rhnreg_ks_with_profile_name => {
- regexp => qr|^rhnreg_ks --activationkey=(\S+)|m,
- string => "rhnreg_ks --activationkey={key}
--profilename=\"{profile_name}\"",
- position => 1,
- },
- rhnreg_ks => {
- regexp => qr|^rhnreg_ks --activationkey=(\S+)|m,
- string => "rhnreg_ks --activationkey={key}",
- position => 1,
- },
- up2date_conf_www => {
- regexp => qr|^perl -npe \'s/www.rhns.redhat.com/.*/\' -i
/etc/sysconfig/rhn/up2date|m,
- string => "perl -npe 's/www.rhns.redhat.com/{kickstart_host}/' -i
/etc/sysconfig/rhn/up2date",
- position => 1,
- },
- up2date_conf_xmlrpc => {
- regexp => qr|^perl -npe \'s/xmlrpc.rhn.redhat.com/.*/\' -i
/etc/sysconfig/rhn/up2date|m,
- string => "perl -npe 's/xmlrpc.rhn.redhat.com/{kickstart_host}/' -i
/etc/sysconfig/rhn/up2date",
- position => 1,
- },
- rhn_register_conf_www => {
- regexp => qr|^perl -npe \'s/www.rhns.redhat.com/.*/\' -i
/etc/sysconfig/rhn/rhn_register|m,
- string => "perl -npe 's/www.rhns.redhat.com/{kickstart_host}/' -i
/etc/sysconfig/rhn/rhn_register",
- position => 1,
- },
- rhn_register_conf_xmlrpc => {
- regexp => qr|^perl -npe \'s/xmlrpc.rhn.redhat.com/.*/\' -i
/etc/sysconfig/rhn/rhn_register|m,
- string => q(perl -npe 's/xmlrpc.rhn.redhat.com/{kickstart_host}/' -i
/etc/sysconfig/rhn/rhn_register),
- position => 1,
- },
- make_rhn_packages_dir => {
- regexp => qr|^mkdir -p /tmp/rhn_rpms/optional|m,
- string => "mkdir -p /tmp/rhn_rpms/optional",
- position => 1,
- },
- download_rhn_packages => {
- regexp => qr|^wget -P /tmp/rhn_rpms [^\n]*|m,
- string => "wget -P /tmp/rhn_rpms {urls}",
- position => 1,
- },
- download_optional_rhn_packages => {
- regexp => qr|^wget -P /tmp/rhn_rpms/optional [^\n]*|m,
- string => "wget -P /tmp/rhn_rpms/optional {urls}",
- position => 1,
- },
- freshen_rhn_packages => {
- regexp => qr|^rpm -Fvh /tmp/rhn_rpms/\*rpm|m,
- string => "rpm -Fvh /tmp/rhn_rpms/*rpm",
- position => 1,
- },
- update_rhn_package => {
- regexp => qr|^rpm -Uvh --replacepkgs --replacefiles
(/tmp/rhn_rpms/optional/.*?\*)+|m,
- string => "rpm -Uvh --replacepkgs --replacefiles {packages}",
- position => 1,
- },
- rhn_check => {
- regexp => qr|^rhn_check$|m,
- string => "rhn_check",
- position => 1,
- },
- copy_out => {
- string => "\n# now copy from the ks-tree we saved in the non-chroot
checkout\n" .
- "cp -fav /tmp/ks-tree-copy/* /\n" .
- "rm -Rf /tmp/ks-tree-copy",
- position => 2,
- },
- write_key_to_file => {
- regexp => qr!cat > /tmp/({type})-key-({index})
<<'EOF'.*EOF\n# \1-key-\2!sm,
- string => "cat > /tmp/{type}-key-{index}
<<'EOF'\n{key}\nEOF\n# {type}-key-{index}",
- position => 1,
- },
- import_gpg_keys_rhel3 => {
- regexp => qr|rpm --import
/tmp/gpg-key-({index})|m,
- string => 'rpm --import
/tmp/gpg-key-{index}',
- position => 1,
- },
- import_gpg_keys_rhel2_1 => {
- regexp => qr|^gpg $(up2date --gpg-flags) --batch
--import /tmp/gpg-key-({index})\n
- gpg $(up2date --gpg-flags) --batch
--import /tmp/gpg-key-\1|xm,
- string => "gpg \$(up2date --gpg-flags)
--batch --import /tmp/gpg-key-{index}\n"
- . "gpg \$(up2date --gpg-flags) --batch
--import /tmp/gpg-key-{index}",
- position => 1,
- },
- import_ssl_keys => {
- regexp => qr|cat /tmp/ssl-key-\* >
/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT|m,
- string => 'cat /tmp/ssl-key-* >
/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT',
- position => 1,
- },
- use_custom_ssl_keys => {
- regexp => qr|^perl -npe
\'s/RHNS-CA-CERT/RHN-ORG-TRUSTED-SSL-CERT/g\' -i /etc/sysconfig/rhn/*|m,
- string => q(perl -npe
's/RHNS-CA-CERT/RHN-ORG-TRUSTED-SSL-CERT/g' -i /etc/sysconfig/rhn/*),
- position => 1,
- },
- start_log => {
- regexp => qr|^\( # Log \%post errors$|m,
- string => '( # Log %post errors',
- position => 0,
- },
- end_log => {
- regexp => qr|^\) > /root/ks-post\.log 2>&1$|m,
- string => ') > /root/ks-post.log 2>&1',
- },
- add_comment => {
- regexp => qr|^#always add new comments|,
- string => qq(\n# {comment}\n),
- position => 1,
- },
- set_resolv_conf => {
- regexp => qr|^cp /etc/resolv\.conf /mnt/sysimage/etc/resolv\.conf|,
- string => qq(cp /etc/resolv.conf /mnt/sysimage/etc/resolv.conf),
- position => 0,
- },
- # we use oldtmp below because, in rhel3, /oldtmp is
- # what we made on the initrd; /tmp is a ramfs copy (and
- # an imperffect copy that skips some files and doesn't
- # preserve directory permissions).
- copy_preserved_files => {
- string => "mkdir /mnt/sysimage/tmp/ks-tree-copy\n"
- . "if [ -d /oldtmp/ks-tree-shadow ]; then\n"
- . " cp -fa /oldtmp/ks-tree-shadow/*
/mnt/sysimage/tmp/ks-tree-copy\n"
- . "elif [ -d /tmp/ks-tree-shadow ]; then\n"
- . " cp -fa /tmp/ks-tree-shadow/*
/mnt/sysimage/tmp/ks-tree-copy\n"
- . "fi",
- position => 0,
- },
- );
-
-sub valid_helpers {
- return (keys %helpers);
-}
-
-sub check_for_line {
- my $self = shift;
- my $mode = shift;
-
- my $check = $self->as_string =~ $helpers{$mode}->{regexp};
- return $1 ? $1 : $check;
-}
-
-sub insert_line {
- my $self = shift;
- my $mode = shift;
- my $subst = shift;
-
- my $options = $helpers{$mode};
-
- if ($options->{regexp} && $self->as_string =~ $options->{regexp}) {
- my $regexp = $options->{regexp};
- $regexp = PXT::Utils->perform_substitutions($regexp, $subst);
- $$self =~ s/$regexp/PXT::Utils->perform_substitutions($options->{string},
$subst)/egsm;
- }
- else {
- my @lines = split(/\n/, $self->as_string);
-
- push @lines, (''); # make sure we append when position is '-1'
-
- if (defined $options->{position}) {
- splice(@lines, $options->{position}, 0,
PXT::Utils->perform_substitutions($options->{string}, $subst));
- }
- else {
- push @lines, PXT::Utils->perform_substitutions($options->{string}, $subst);
- }
-
- $$self = join("\n", @lines);
- }
-
- return 1;
-}
-
-sub remove_line {
- my $self = shift;
- my $mode = shift;
-
- my ($index, $found);
- my @lines = split(/\n/, $self->as_string);
-
- for ($index = 0; $index <= $#lines; $index++) {
- if ($lines[$index] =~ $helpers{$mode}->{regexp}) {
- $found = 1;
- last;
- }
- }
-
- splice(@lines, $index, 1);
-
- $$self = join("\n", @lines);
- return 1;
-}
-
1;
commit 78abcf0b896d49e8054ca0fda5ad9a24b4b88437
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 18:10:39 2010 +0100
long_date_with_zone is not called from anywhere, removing.
diff --git a/web/modules/rhn/RHN/Date.pm b/web/modules/rhn/RHN/Date.pm
index 67db890..2af8a5b 100644
--- a/web/modules/rhn/RHN/Date.pm
+++ b/web/modules/rhn/RHN/Date.pm
@@ -179,14 +179,6 @@ sub short_date {
return $self->strftime("%Y-%m-%d");
}
-# helper function for our classical "long_date" format, with abbreviated zone
name
-sub long_date_with_zone {
- my $self = shift;
- my $user = shift;
-
- return $self->long_date . " " . $self->user_short_timezone($user);
-}
-
# increment an RHN::Date object. parameters are passed straight
# through to the datetime add method, which basically is like
# "$foo->add(hours => 2, minutes => 7), etc
commit d54505a385c3f37203bae01e1b235c158eb8270f
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 18:09:30 2010 +0100
lookup_widget_value is not called from anywhere, removing.
diff --git a/web/modules/rhn/RHN/Form/Response.pm b/web/modules/rhn/RHN/Form/Response.pm
index eb0499d..3c4450a 100644
--- a/web/modules/rhn/RHN/Form/Response.pm
+++ b/web/modules/rhn/RHN/Form/Response.pm
@@ -97,14 +97,4 @@ sub status {
return 'partial';
}
-sub lookup_widget_value {
- my $self = shift;
- my $var = shift;
-
- my $widget = $self->lookup_widget($var);
- return unless defined $widget;
-
- return $widget->value;
-}
-
1;