diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2005-09-14 17:58:07 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2005-09-14 17:58:07 +0000 |
commit | 176b024d1f8d42d0c5b791847f46ad58be14387a (patch) | |
tree | bef6d09c4135d04dd2185458eb9653eaaad9b62e | |
parent | 3dc12f70ed9bc6200452e74348240db1985cb8c2 (diff) | |
download | drakx-176b024d1f8d42d0c5b791847f46ad58be14387a.tar drakx-176b024d1f8d42d0c5b791847f46ad58be14387a.tar.gz drakx-176b024d1f8d42d0c5b791847f46ad58be14387a.tar.bz2 drakx-176b024d1f8d42d0c5b791847f46ad58be14387a.tar.xz drakx-176b024d1f8d42d0c5b791847f46ad58be14387a.zip |
add upgrade script for conectiva
-rw-r--r-- | perl-install/install_any.pm | 2 | ||||
-rw-r--r-- | perl-install/pkgs.pm | 31 | ||||
-rw-r--r-- | perl-install/share/list.xml | 2 | ||||
-rw-r--r-- | perl-install/share/upgrade/conectiva.10/map (renamed from perl-install/share/upgrade-map.conectiva.10) | 0 | ||||
-rwxr-xr-x | perl-install/share/upgrade/conectiva.10/pre.merge-groups.sh | 87 | ||||
-rwxr-xr-x | perl-install/share/upgrade/conectiva.10/pre.remove-conflicting-files.sh | 3 |
6 files changed, 113 insertions, 12 deletions
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index 4cb124916..0350a827d 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -659,7 +659,7 @@ sub setPackages { $wait_message->('', $current++, $total); } }; - push @{$o->{default_packages}}, pkgs::upgrade_by_removing_pkgs($o->{packages}, $callback, $extension, "$ENV{SHARE_PATH}/upgrade-map.$o->{isUpgrade}"); + push @{$o->{default_packages}}, pkgs::upgrade_by_removing_pkgs($o->{packages}, $callback, $extension, $o->{isUpgrade}); log::l("Removing packages took: ", formatTimeRaw(time() - $time)); } diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index 9d64b55f6..72d041a50 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -1232,9 +1232,17 @@ sub install { } sub upgrade_by_removing_pkgs { - my ($packages, $callback, $extension, $o_map) = @_; + my ($packages, $callback, $extension, $upgrade_name) = @_; + + my $upgrade_data; + if ($upgrade_name) { + my @l = glob("$ENV{SHARE_PATH}/upgrade/$upgrade_name*"); + @l == 0 and log::l("upgrade_by_removing_pkgs: no special upgrade data"); + @l > 1 and log::l("upgrade_by_removing_pkgs: many special upgrade data (" . join(' ', @l) . ")"); + $upgrade_data = $l[0]; + } - log::l("upgrade_by_removing_pkgs (extension=$extension, map=$o_map)"); + log::l("upgrade_by_removing_pkgs (extension=$extension, upgrade_data=$upgrade_data)"); #- put the release file in /root/drakx so that we continue an upgrade even if the file has gone my $f = common::release_file($::prefix); @@ -1244,6 +1252,15 @@ sub upgrade_by_removing_pkgs { my $busy_var_tmp = "$::prefix/var/tmp/ensure-rpm-does-not-remove-this-dir"; touch($busy_var_tmp); + if ($upgrade_data) { + foreach (glob("$upgrade_data/pre.*")) { + my $f = '/tmp/' . basename($_); + cp_af($_, "$::prefix$f"); + run_program::rooted($::prefix, $f); + unlink "$::prefix$f"; + } + } + my @was_installed = remove_pkgs_to_upgrade($packages, $callback, $extension); { @@ -1255,19 +1272,13 @@ sub upgrade_by_removing_pkgs { unlink $busy_var_tmp; } - if ($o_map) { - my @l = glob("$o_map*"); - @l == 0 and log::l("upgrade_by_removing_pkgs: no map matching $o_map*"); - @l > 1 and log::l("upgrade_by_removing_pkgs: many maps (" . join(' ', @l) . ")"); - $o_map = $l[0]; - } my %map = map { chomp; my ($name, @new) = split; $name => \@new; - } $o_map ? cat_($o_map) : (); + } $upgrade_data ? cat_("$upgrade_data/map") : (); - log::l("upgrade_by_removing_pkgs: map $o_map gave " . (int keys %map) . " rules"); + log::l("upgrade_by_removing_pkgs: map $upgrade_data/map gave " . (int keys %map) . " rules"); my $log; my @to_install = uniq(map { diff --git a/perl-install/share/list.xml b/perl-install/share/list.xml index 77836ead1..2f58e672d 100644 --- a/perl-install/share/list.xml +++ b/perl-install/share/list.xml @@ -344,7 +344,7 @@ <to dir="/usr/share"> consolefonts devices - upgrade-map.conectiva.10 + upgrade <from expand="glob"> *.png diff --git a/perl-install/share/upgrade-map.conectiva.10 b/perl-install/share/upgrade/conectiva.10/map index 8594168cd..8594168cd 100644 --- a/perl-install/share/upgrade-map.conectiva.10 +++ b/perl-install/share/upgrade/conectiva.10/map diff --git a/perl-install/share/upgrade/conectiva.10/pre.merge-groups.sh b/perl-install/share/upgrade/conectiva.10/pre.merge-groups.sh new file mode 100755 index 000000000..b735d2bbe --- /dev/null +++ b/perl-install/share/upgrade/conectiva.10/pre.merge-groups.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# +# cnc2mdv /etc/group file merger +# +# What it does: +# +# - Adds three new groups: +# - Check if these groups or its gids already exists; +# - Remove root from the wheel group. +# + +destfile=${destfile:-/etc/group} +backupfile=${destfile}.cnc2mdv + +# these are the new groups that are introduced by Mandriva +groups=( usb 43 tape 21 nogroup 65534 ) + +# error codes +group_already_exists_=8 +group_already_exists=9 +gid_not_unique=4 + +sort_groups_by_gid() +{ + sort -nt: +2 -3 -o $destfile $destfile #wow + + return 0 +} + + +add_new_groups() +{ + for (( i=0; i < ${#groups[@]}; i += 2)); do + n=$[$i+1] + gid=${groups[$n]} + gname=${groups[$i]} + + errors=yes + while [ $errors = "yes" ]; do + groupadd -g $gid $gname + case $? in + 0) + # ok, no errors, group really added + errors=no + ;; + + $group_already_exists | $group_already_exists_ ) + # ok, no problem at all + errors=no + ;; + + $gid_not_unique) + # bleh, increment gid and try again + # hum, but if ... 65534? + gid=$[$gid+1] + ;; + + *) + echo "unexpected error during groupadd ($?)" + return 1; + ;; + esac + done # while errors + done # for + + return 0 +} + + +remove_root_from_wheel() +{ + sed -i 's/\(wheel:[^:]*:[^:]*:\)root,*\(.*\)/\1\2/' ${destfile} + + return 0 +} + + +main() +{ + add_new_groups && + sort_groups_by_gid && + remove_root_from_wheel +} + +main + +# vim:ts=4:sw=4:ai diff --git a/perl-install/share/upgrade/conectiva.10/pre.remove-conflicting-files.sh b/perl-install/share/upgrade/conectiva.10/pre.remove-conflicting-files.sh new file mode 100755 index 000000000..3db2fee4f --- /dev/null +++ b/perl-install/share/upgrade/conectiva.10/pre.remove-conflicting-files.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +rm -f /usr/share/apps/kdm |