summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-11-22 14:15:24 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-11-22 14:15:24 +0000
commitc879294087d1f55b5992ff194bae9d0ded78c31a (patch)
treee54ee940894d61a91f93ee69fc66b3e0d08e58ed /kernel
parent0a60319a0b805bf9c7dfe191ab2bd64fb0fa60e6 (diff)
downloaddrakx-c879294087d1f55b5992ff194bae9d0ded78c31a.tar
drakx-c879294087d1f55b5992ff194bae9d0ded78c31a.tar.gz
drakx-c879294087d1f55b5992ff194bae9d0ded78c31a.tar.bz2
drakx-c879294087d1f55b5992ff194bae9d0ded78c31a.tar.xz
drakx-c879294087d1f55b5992ff194bae9d0ded78c31a.zip
- no more kernel/all.modules, things are in kernel/all.kernels
- cleanup what we keep in kernel/all.kernels: only vmlinuz, modules.dep, *.mar, all_modules.tar, modules.cz - replace all_modules.list + modules with all_modules.tar - kernel/all.modules/modules.cz-VERSION are now in kernel/all.kernels/VERSION/modules.cz - allow having a normal in isolinux, but don't use it for floppy images (for this, add kernel/all.kernels/.main-BOOT) - add many modules kernel/list_modules.pm in unused categories since we don't take all modules from kernel, only those listed (needed to have a not too big modules.cz for normal kernel) - complete rewrite of update_kernel (now written in perl)
Diffstat (limited to 'kernel')
-rw-r--r--kernel/.cvsignore1
-rw-r--r--kernel/Makefile6
-rw-r--r--kernel/dependencies.pl13
-rw-r--r--kernel/list_modules.pm17
-rw-r--r--kernel/modules.pl119
-rwxr-xr-xkernel/update_kernel267
6 files changed, 216 insertions, 207 deletions
diff --git a/kernel/.cvsignore b/kernel/.cvsignore
index 827e0ba13..66624465e 100644
--- a/kernel/.cvsignore
+++ b/kernel/.cvsignore
@@ -1,3 +1,2 @@
modules.description
-all.modules
all.kernels
diff --git a/kernel/Makefile b/kernel/Makefile
index 9e4dd9bb5..585d85d7b 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -1,13 +1,13 @@
-all: all.modules
+all: all.kernels
-all.modules: ../mdk-stage1/mar/mar update_kernel list_modules.pm
+all.kernels: ../mdk-stage1/mar/mar update_kernel list_modules.pm
./update_kernel
../mdk-stage1/mar/mar:
make -C `dirname $@` mar
clean:
- rm -rf *~ modules.description all.modules all.modules64
+ rm -rf *~ modules.description all.kernels
check:
perl modules.pl check > /dev/null
diff --git a/kernel/dependencies.pl b/kernel/dependencies.pl
deleted file mode 100644
index e3be14212..000000000
--- a/kernel/dependencies.pl
+++ /dev/null
@@ -1,13 +0,0 @@
-use strict;
-
-use MDK::Common;
-use list_modules;
-
-my $version = shift @ARGV;
-my $depfile = shift @ARGV;
-load_dependencies($depfile);
-print STDERR "Loaded dependencies from $depfile\n";
-
-my @modules = uniq(map { dependencies_closure($_) } @ARGV);
-print join " ", map { $_ . ($version == 24 ? '.o' : '.ko') } @modules;
-print "\n";
diff --git a/kernel/list_modules.pm b/kernel/list_modules.pm
index 99edf778d..798f87ff0 100644
--- a/kernel/list_modules.pm
+++ b/kernel/list_modules.pm
@@ -39,7 +39,7 @@ our %l = (
],
raw => [
- qw(ppp_generic ppp_async),
+ qw(ppp_generic ppp_async ppp_deflate bsd_comp),
],
pcmcia => [
qw(3c574_cs 3c589_cs axnet_cs fmvj18x_cs),
@@ -132,7 +132,7 @@ our %l = (
if_(arch() =~ /^ppc/, qw(hfs)),
qw(reiserfs),
],
- various => [ qw(smbfs romfs ext3 xfs) ],
+ various => [ qw(smbfs romfs ext3 xfs jfs ufs) ],
},
@@ -170,10 +170,12 @@ our %l = (
# just here for classification, unused categories (nor auto-detect, nor load_thiskind)
{
raid => [
- qw(linear raid0 raid1 raid5 lvm-mod multipath),
+ qw(linear raid0 raid1 raid5 lvm-mod multipath dm-mod),
],
mouse => [
qw(busmouse msbusmouse logibusmouse serial qpmouse atixlmouse),
+ if_(arch() =~ /ppc/, 'macserial'),
+ qw(hid mousedev usbhid usbmouse),
],
char => [
if_(arch() =~ /ia64/, qw(efivars)),
@@ -185,6 +187,11 @@ our %l = (
qw(parport_pc parport_serial),
qw(btaudio),
+ arch() =~ /i.86/ ? 'aes-i586' : 'aes',
+ if_(arch() =~ /sparc/, 'openprom'),
+
+ qw(wacom evdev), qw(usblp printer),
+
#- these need checking
qw(tmspci rrunner meye),
],
@@ -226,6 +233,10 @@ sub category2modules {
} split(' ', $_[0]);
}
+sub all_modules() {
+ map { @$_ } map { values %$_ } values %l;
+}
+
sub module2category {
my ($module) = @_;
foreach my $t1 (keys %l) {
diff --git a/kernel/modules.pl b/kernel/modules.pl
index 587674e8f..b8207087a 100644
--- a/kernel/modules.pl
+++ b/kernel/modules.pl
@@ -105,28 +105,117 @@ my %images = (
all => 'fs/cdrom disk/cdrom|raw bus/usb|usb_keyboard disk/usb|scsi fs/loopback|local bus/pcmcia disk/pcmcia|hardware_raid fs/network network/main|pcmcia|usb|raw|gigabit bus/firewire disk/firewire',
);
-my $verbose = "@ARGV" =~ /-v/;
-images() if "@ARGV" =~ /images/;
-check() if "@ARGV" =~ /check/;
-pci_modules4stage1($1) if "@ARGV" =~ /pci_modules4stage1:(.*)/;
-
-sub images() {
- while (my ($image, $l) = each %images) {
- my @modules = if_($image !~ /drivers/, @modules_always_on_stage1);
- push @modules, map { category2modules($_) } split(' ', $l);
+my $verbose = $ARGV[0] eq '-v' && shift;
+my ($f, @para) = @ARGV;
+$::{$f}->(@para);
+
+sub image2modules {
+ my ($image) = @_;
+ my $l = $images{$image};
+
+ my @modules = if_($image !~ /drivers/, @modules_always_on_stage1);
+ push @modules, map { category2modules($_) } split(' ', $l);
- @modules = difference2(\@modules, \@modules_removed_from_stage1);
+ @modules = difference2(\@modules, \@modules_removed_from_stage1);
+
+ if ($image !~ /all/) {
+ @modules = difference2(\@modules, \@modules_only_for_all_img);
+ }
+
+ @modules;
+}
+
+sub remove_unneeded_modules {
+ my ($kern_ver) = @_;
+
+ #- need creating a first time the modules.dep for all modules
+ #- it will be redone in make_modules_dep when unneeded modules are removed
+ make_modules_dep($kern_ver);
+ load_dependencies("all.kernels/$kern_ver/modules.dep");
+
+ my $ext = module_extension($kern_ver);
+
+ my @all = list_modules::all_modules();
+ my @all_with_deps = map { dependencies_closure($_) } @all;
+ my %wanted_modules = map {; "$_.$ext" => 1 } @all_with_deps;
+ foreach (all("all.kernels/$kern_ver/modules")) {
+ $wanted_modules{$_} or unlink "all.kernels/$kern_ver/modules/$_";
+ }
+}
+
+sub make_modules_per_image {
+ my ($kern_ver) = @_;
+
+ make_modules_dep($kern_ver);
+ load_dependencies("all.kernels/$kern_ver/modules.dep");
- if ($image !~ /all/) {
- @modules = difference2(\@modules, \@modules_only_for_all_img);
+ my $ext = module_extension($kern_ver);
+
+ foreach my $image (keys %images) {
+ my @modules_with_deps = uniq(map { dependencies_closure($_) } image2modules($image));
+ my @l = map { "$_.$ext" } @modules_with_deps;
+
+ my $dir = "all.kernels/$kern_ver/modules";
+ @l = grep { -e "$dir/$_" } @l;
+
+ if ($image =~ /all/) {
+ system("cd $dir ; tar cf ../${image}_modules.tar @l") == 0 or die "tar failed\n";
+ } else {
+ my $gi_base_dir = chomp_(`pwd`) . '/..';
+ system("cd $dir ; $gi_base_dir/mdk-stage1/mar/mar -c ../${image}_modules.mar @l") == 0 or die "mar failed\n";
+ }
+ }
+}
+
+sub make_modules_dep {
+ my ($kern_ver) = @_;
+
+ my @l =
+ kernel_is_26($kern_ver) ?
+ cat_("all.kernels/$kern_ver/lib/modules/$kern_ver/modules.dep") :
+ `/sbin/depmod-24 -F all.kernels/$kern_ver/boot/System.map-$kern_ver -e *.o | perl -pe 's/\\\n//'`;
+
+ @l = map {
+ if (/(\S+):\s+(.*)/) {
+ my ($module, @deps) = map { m!.*/(.*)\.k?o(\.gz)$! && $1 } $1, split(' ', $2);
+ if (member($module, 'plip', 'ppa', 'imm')) {
+ @deps = map { $_ eq 'parport' ? 'parport_pc' : $_ } @deps;
+ } elsif ($module eq 'vfat') {
+ push @deps, 'nls_cp437', 'nls_iso8859-1';
+ }
+ if_(@deps, join(' ', "$module:", @deps));
+ } else {
+ ();
}
- printf qq(%s_modules_raw="%s"\n), $image, join ' ', @modules;
+ } @l;
+
+ output("all.kernels/$kern_ver/modules.dep", map { "$_\n" } @l);
+}
+
+sub make_modules_description {
+ my ($kern_ver) = @_;
+ my $ext = module_extension($kern_ver);
+ my $dir = "all.kernels/$kern_ver/modules";
+
+ my @l;
+ if (kernel_is_26(`uname -r`)) { #- modinfo behaves differently depending on the build kernel used
+ my $name;
+ @l = map {
+ $name = $1 if m!^filename:\s*(.*)\.$ext!;
+ if_($name && /^description:\s*(.*)/, "$name\t$1");
+ } `cd $dir ; /sbin/modinfo *.$ext`;
+ } else {
+ @l = map {
+ if_(/(.*?)\.$ext "(.*)"/, "$1\t$2\n");
+ } `cd $dir ; /sbin/modinfo-24 -f '%{filename} %{description}\n' *.$ext`;
}
- printf qq(images="%s"\n), join(' ', keys %images);
+ output("modules.description", @l);
}
sub pci_modules4stage1 {
- print "$_\n" foreach uniq(map { dependencies_closure($_) } difference2([ category2modules($_[0]) ], \@modules_removed_from_stage1));
+ my ($category) = @_;
+ my @modules = difference2([ category2modules($category) ], \@modules_removed_from_stage1);
+ print "$_\n" foreach uniq(map { dependencies_closure($_) } @modules);
}
sub check() {
diff --git a/kernel/update_kernel b/kernel/update_kernel
index 4e0924efa..13a9b3203 100755
--- a/kernel/update_kernel
+++ b/kernel/update_kernel
@@ -1,187 +1,110 @@
-#!/bin/bash
+#!/usr/bin/perl
-ALL_KERNELS="all.kernels"
-RPMS=/export/media/main
+use MDK::Common;
+use list_modules;
-ARCH=`uname -m | sed -e 's/i.86/i386/' -e 's/sparc.*/sparc/'`
+my $RPMS = '/export/media/main';
+my $rpm = 'rpm --nosignature';
-# move stuff to this new "kernel" directory
-if [ ! -d all.kernels ]; then
- if [ -d ../all.kernels ]; then
- mv ../all.kernels .
- rm -rf ../all.modules
- else
- # make sure "all.kernels" directory exists
- mkdir all.kernels
- fi
-fi
+my $MOVE = $ARGV[0] eq '--move' && shift;
-function create_marfile() {
- marfile=$1
- shift
- $GIBASEDIR/mdk-stage1/mar/mar -c $marfile $*
-}
+@ARGV <= 1 or die "usage: ./update_kernel [--move] [<kernel rpm>]\n";
-function build_kernel_is_26() {
- uname -r | grep -q '^2\.6'
-}
-function kern_version() {
- if echo $1 | grep -q ^2.4; then
- version=24
- objects="*.o"
- else
- version=25
- objects="*.ko"
- fi
-}
-
-function create_modules() {
- kernel_path=$1
- kern=$2
- echo "Updating modules in '`pwd`' for kernel '$kern'"
- kern_version $kern
- find $kernel_path/lib/modules/ -name "$objects" -exec cp -f {} . \;
- if [ $version -eq 24 ]; then
- /sbin/depmod-24 -F $kernel_path/boot/System.map* -e *.o | perl -pe 's/\\\n//' \
- | perl -ne 's/\.o//g; s/[ \t]+/ /g; print if /: /' > modules.dep
- else
- cp $kernel_path/lib/modules/*/modules.dep .
- perl -ni -e 's|/\S+/([^/]+)\.k?o(\.gz)|$1|g; print if /: /' modules.dep
- fi
- perl -pi -e 's/((plip|ppa|imm): parport)/$1 parport_pc/' modules.dep
- perl -pi -e 's/(vfat: fat)/$1 nls_cp437 nls_iso8859-1/' modules.dep
-
- if build_kernel_is_26; then
- /sbin/modinfo $objects | perl -lne 'print "$name\t$1" if $name && /^description:\s*(.*)/; $name = $1 if m!^filename:\s*(.*)\.k?o!' > modules.description
- else
- /sbin/modinfo-$version -f '%{filename} %{description}\n' $objects | perl -lne 'print "$1\t$2" if /(.*?)\.k?o "(.*)"/' > modules.description
- fi
-}
+mkdir 'all.kernels'; # make sure "all.kernels" directory exists
+eval { rm_rf('all.modules') }; #- not used anymore
+
+my $main = chomp_(cat_('all.kernels/.main'));
+my $main_BOOT = chomp_(cat_('all.kernels/.main-BOOT'));
-function create_modules_mar() {
- kern_version $kern
-
- if [ $version -eq 24 ]; then
- echo -n "stripping $kern: "
- $GIBASEDIR/kernel/strip_modules *.o 2>/dev/null
- echo "done"
- else
- echo "don't strip on 2.6 since it breaks modules"
- fi
-
- if [ -z "$MOVE" ]; then
- echo -n "packdrake $kern: "
- ls $objects | packdrake -b9s "modules.cz" 400000
- echo "done"
- mv modules.cz ../modules.cz-$kern
- fi
- for i in $images; do
- eval "modules=\$${i}_modules_raw"
- modules_with_deps=`perl -I $GIBASEDIR/kernel $GIBASEDIR/kernel/dependencies.pl $version modules.dep $modules`
- if [ $i = "all" ]; then
- echo $modules_with_deps > "${i}_modules.list"
- else
- eval "create_marfile ${i}_modules.mar $modules_with_deps"
- fi
- done
- echo
+if (@ARGV) {
+ install_kernel($ARGV[0]);
+} else {
+ update_kernel_from_repository($RPMS, '2.6', 0);
+ update_kernel_from_repository($RPMS, '2.6', 1);
+ update_kernel_from_repository($RPMS, '2.4', 1);
}
-function install_kernel() {
- rpm=$1
-
- ver=$(rpm --nosignature -qpl $rpm | sed -n 's!/boot/vmlinuz-!!p')
- [ -n "$ver" ] || return
-
- if [ -n "$2" ]; then
- [ -d $ALL_KERNELS/$ver ] && return
- main_ver=$2
- echo Removing previous kernel $ALL_KERNELS/$main_ver*
- rm -rf $ALL_KERNELS/$main_ver*
- fi
-
- rm -rf $ALL_KERNELS/$ver
- echo "Installing kernel $ver"
- mkdir -p $ALL_KERNELS/$ver
- rpm2cpio $rpm | (cd $ALL_KERNELS/$ver ; cpio -id)
-
- find $ALL_KERNELS/$ver -type f -name "*.o.gz" -o -name "*.ko.gz" | xargs gunzip
-
- # remove those files during update_kernel, they will get back when make_boot_img is called
- for dir in /tftpboot /var/lib/tftpboot; do
- rm -f $dir/{vmlinuz,network.rdz,all.rdz}
- done
+
+sub system_verbose { print join(' ', @_), "\n"; system(@_) }
+sub sys { &system_verbose; $? and die }
+
+sub rpm2version {
+ my ($kernel_rpm) = @_;
+ `$rpm -qpl $kernel_rpm` =~ m!/boot/vmlinuz-(.*)! && $1 or die "can't find vmlinuz in $kernel_rpm\n";
}
-[ -e $ALL_KERNELS/.main ] && main=$(cat $ALL_KERNELS/.main)
-
-if [ "$1" = "--move" ]; then
- MOVE=1
- shift
-fi
-
-if [ "$ARCH" == "ia64" ] || [ "$ARCH" == "ppc" ]; then
- name=kernel
-else
- name=kernel-BOOT
-fi
-
-if [ -n "$1" ]; then
- #- allow specifying a kernel file on commandline (./update_kernel /RPMS/kernel-2.4.22.10mdk-1-1mdk.i586.rpm)
- install_kernel $1
-else
-# install_kernel $RPMS/kernel-BOOT-2.4*.rpm 2.4
- install_kernel $RPMS/kernel-BOOT-2.6*.rpm 2.6
-fi
-
-[ -n "$main" -a -e $ALL_KERNELS/$main ] || {
- cd $ALL_KERNELS
- main=$(echo 2.6* | sed 's/.* //')
- [ -e "$main" ] || main=$(echo 2.4* | sed 's/.* //')
- [ -e "$main" ] || { echo "no kernel installed in $ALL_KERNELS"; exit 1; }
- echo "Choosing $main"
- echo $main > .main
- cd ..
+sub update_kernel_from_repository {
+ my ($RPMS, $main_ver, $is_BOOT) = @_;
+ my $rpm_wildcard = 'kernel-' . ($is_BOOT ? 'BOOT-' : '') . $main_ver . '*.rpm';
+ my ($kernel_rpm) = my @kernels = glob("$RPMS/$rpm_wildcard");
+ @kernels <= 1 or die "more than one kernel match $rpm_wildcard";
+ @kernels >= 1 or die "no kernel match $rpm_wildcard";
+
+ install_kernel($kernel_rpm, 1);
}
+sub install_kernel {
+ my ($kernel_rpm, $o_update) = @_;
+
+ my $kern_ver = rpm2version($kernel_rpm);
+ my $dir = "all.kernels/$kern_ver";
+
+ -d $dir and return if $o_update;
+
+ my $is_BOOT = $kern_ver =~ /BOOT/;
+ my ($main_ver) = $kern_ver =~ /^(2\.\d)/;
+ if (my @previous = grep { ($is_BOOT xor !/BOOT/) && /^\Q$main_ver/ } all('all.kernels')) {
+ warn "Removing previous kernels ", join(' ', @previous), "\n";
+ rm_rf("all.kernels/$_") foreach @previous;
+ }
+
+ if (!$main || !-d "all.kernels/$main") {
+ $main = $kern_ver;
+ output('all.kernels/.main', "$main\n");
+ }
+ if ($is_BOOT && (!$main_BOOT || !-d "all.kernels/$main_BOOT")) {
+ $main_BOOT = $kern_ver;
+ output('all.kernels/.main-BOOT', "$main_BOOT\n");
+ }
-if [ "$ARCH" == "i386" ]; then
- for i in $ALL_KERNELS/*/boot/vmlinuz*; do
- #disable any existing resolution!!!
- /usr/sbin/rdev -v $i 65535 #788 #785
- done
-fi
-
-
-GIBASEDIR=`pwd`/..
-
-rm -rf all.modules ; mkdir all.modules
-for i in $ALL_KERNELS/*; do
- kern=`basename $i`
- (
- mkdir all.modules/$kern
- cd all.modules/$kern
-
- create_modules ../../$i $kern
- ) || exit 1
-done
-cp -f all.modules/$main/modules.description .
-
-l=`MOVE=$MOVE perl modules.pl images` || exit 1
-eval $l
-
-for i in $ALL_KERNELS/*; do
- kern=`basename $i`
- (
- cd all.modules/$kern
-
- if [ "$kern" = "$main" ]; then
- create_modules_mar ../../$i $kern
- else
- echo "$kern ($main)"
- create_modules_mar ../../$i $kern 2>/dev/null
- fi
- ) || exit 1
-done
+ warn "Installing kernel $kern_ver\n";
+
+ eval { rm_rf($dir) };
+ mkdir_p("$dir/modules");
+ sys("rpm2cpio $kernel_rpm | (cd $dir ; cpio -id)");
+
+ rename "$dir/boot/vmlinuz-$kern_ver", "$dir/vmlinuz" or die "can't find vmlinuz\n";
+
+ sys("find $dir -name '*.gz' | xargs gunzip");
+
+ my $ext = module_extension($kern_ver);
+
+ open(my $F, "find $dir -name '*.$ext' |");
+ my $file; while ($file = <$F>) {
+ chomp($file);
+ rename $file, "$dir/modules/" . basename($file) or warn "conflict for $file\n";
+ }
+
+ if (kernel_is_26($kern_ver)) {
+ warn "no stripping on 2.6 since it breaks modules\n";
+ } else {
+ print STDERR "stripping $kern_ver: ";
+ sys("./strip_modules $dir/modules/*.$ext");
+ print STDERR "done\n";
+ }
+
+ sys('perl', 'modules.pl', 'remove_unneeded_modules', $kern_ver) if $kern_ver !~ /BOOT/;
+
+ sys('perl', 'modules.pl', 'make_modules_per_image', $kern_ver);
+ sys('perl', 'modules.pl', 'make_modules_description', $kern_ver) if $kern_ver eq $main;
+
+ if (!$MOVE) {
+ print STDERR "packdrake $kern_ver: ";
+ sys("cd $dir/modules ; ls *.$ext | packdrake -b9s ../modules.cz 400000");
+ print STDERR "done\n";
+ }
+
+ eval { rm_rf("$dir$_") } foreach qw(/boot /lib /usr /modules);
+}
so-8859-1', 'nl', 'nl_NL:nl' ], # 'nb' is the new locale name in glibc 2.2 'no' => [ 'Norwegian (Bokmaal)', 'iso-8859-1', 'no', 'no:nb:no@nynorsk:no_NY' ], # no_NY is used by KDE (but not standard); 'ny' is the new locale in glibc 2.2 'no@nynorsk' => [ 'Norwegian (Nynorsk)','iso-8859-1', 'no', 'no@nynorsk:ny:no_NY:no' ], #-'oc' => [ 'Occitan', 'iso-8859-1', 'oc', 'oc:fr_FR' ], #-'pd' => [ 'Plauttdietsch', 'iso-8859-1', 'pd', 'pd' ], #-'ph' => [ 'Pilipino', 'iso-8859-1', 'ph', 'ph:tl' ], 'pl' => [ 'Polish', 'iso-8859-2', 'pl', 'pl' ], #-'pp' => [ 'Papiamento', 'iso-8859-1', 'pp', 'pp' ], 'pt_BR' => [ 'Portuguese (Brazil)', 'iso-8859-1', 'pt_BR', 'pt_BR:pt_PT:pt' ], 'pt_PT' => [ 'Portuguese (Portugal)', 'iso-8859-1', 'pt', 'pt_PT:pt:pt_BR' ], 'ro' => [ 'Romanian', 'iso-8859-2', 'ro', 'ro' ], 'ru_RU.KOI8-R' => [ 'Russian', 'koi8-r', 'ru', 'ru_RU.KOI8-R:ru' ], 'sk' => [ 'Slovak', 'iso-8859-2', 'sk', 'sk' ], 'sl' => [ 'Slovenian', 'iso-8859-2', 'sl', 'sl' ], 'sp' => [ 'Serbian (Cyrillic)', 'iso-8859-5', 'sp', 'sp:sr' ], 'sr' => [ 'Serbian (Latin)', 'iso-8859-2', 'sr', 'sr' ], 'sv@traditionell' => [ 'Swedish (traditional sorting [V = W])','iso-8859-1', 'sv', 'sv' ], 'sv@ny' => [ 'Swedish (new sorting [V != W])','iso-8859-1', 'sv', 'sv' ], #-'ta' => [ 'Tamil', 'tscii-0', 'ta', 'ta' ], 'tg' => [ 'Tajik', 'koi8-c', 'tg', 'tg' ], 'th' => [ 'Thai', 'tis620', 'th', 'th' ], 'tr' => [ 'Turkish', 'iso-8859-9', 'tr', 'tr' ], 'tt' => [ 'Tatar', 'tatar-cyr', 'tg', 'tg' ], #-'ur' => [ 'Urdu', 'cp1256', 'ur', 'ur' ], 'uk_UA' => [ 'Ukrainian', 'koi8-u', 'uk', 'uk_UA:uk' ], 'vi' => [ 'Vietnamese (TCVN)', 'tcvn', 'vi', 'vi_VN.tcvn:vi_VN.tcvn-5712:vi' ], 'vi_VN.viscii' => [ 'Vietnamese (VISCII)','viscii', 'vi', 'vi_VN.viscii:vi_VN.tcvn-viscii1.1-1:vi' ], 'wa' => [ 'Walon', 'iso-8859-1', 'wa', 'wa:fr_BE:fr' ], #-'yi' => [ 'Yiddish', 'cp1255', 'yi', 'yi' ], 'zh_TW.Big5' => [ 'Chinese (Big5)', 'Big5', 'zh_TW.Big5', 'zh_TW.Big5:zh_TW.big5:zh' ], 'zh_CN' => [ 'Chinese (GuoBiao)', 'gb2312', 'zh_CN.GB2312', 'zh_CN.GB2312:zh_CN.gb2312:zh_CN:zh' ], ); my %xim = ( 'zh_TW.Big5' => { ENC => 'big5', XIM => 'xcin', XIM_PROGRAM => 'xcin', XMODIFIERS => '"@im=xcin"', CONSOLE_NOT_LOCALIZED => 'yes', }, 'zh_CN.GB2312' => { ENC => 'gb', XIM => 'xcin-zh_CN.GB2312', XIM_PROGRAM => 'xcin', XMODIFIERS => '"@im=xcin-zh_CN.GB2312"', CONSOLE_NOT_LOCALIZED => 'yes', }, 'ko' => { ENC => 'kr', XIM => 'Ami', XIM_PROGRAM => 'ami', XMODIFIERS => '"@im=Ami"', CONSOLE_NOT_LOCALIZED => 'yes', }, 'ja' => { ENC => 'eucj', XIM => 'kinput2', XIM_PROGRAM => 'kinput2', XMODIFIERS => '"@im=kinput2"', }, # right to left languages only work properly on console 'ar' => { X11_NOT_LOCALIZED => "yes", }, 'fa' => { X11_NOT_LOCALIZED => "yes", }, 'he' => { X11_NOT_LOCALIZED => "yes", }, 'ur' => { X11_NOT_LOCALIZED => "yes", }, 'yi' => { X11_NOT_LOCALIZED => "yes", }, ); sub std2 { "-*-*-medium-r-normal-*-$_[1]-*-*-*-*-*-$_[0]" } sub std_ { std2($_[0], 10), std2($_[0], 10) } sub std { std2($_[0], $_[1] || 10), std2($_[0], 8) } #- [0]: console font name; [1]: unicode map for console font #- [2]: acm file for console font; [3]: X11 fontset my %charsets = ( "armscii-8" => [ "arm8", "armscii8.uni", "trivial.trans", std_("armscii-8") ], #- chinese needs special console driver for text mode "Big5" => [ undef, undef, undef, "-*-*-*-*-*-*-*-*-*-*-*-*-big5-0" ], "gb2312" => [ undef, undef, undef, "-*-*-*-*-*-*-*-*-*-*-*-*-gb2312.1980-0" ], "georgian-academy" => [ "t_geors", "geors.uni", "trivial.trans", "-*-*-*-*-*-*-*-*-*-*-*-*-georgian-academy" ], "georgian-ps" => [ "t_geors", "geors.uni", "geors_to_geops.trans", "-*-*-*-*-*-*-*-*-*-*-*-*-georgian-academy" ], "iso-8859-1" => [ "lat0-sun16", undef, "iso15", sub { std("iso8859-1", @_) } ], "iso-8859-2" => [ "lat2-sun16", undef, "iso02", sub { std("iso8859-2", @_) } ], "iso-8859-3" => [ "iso03.f16", undef, "iso03", std_("iso8859-3") ], "iso-8859-4" => [ "lat4u-16", undef, "iso04", std_("iso8859-4") ], "iso-8859-5" => [ "iso05.f16", "iso05", "trivial.trans", std2("iso8859-5", 10), std2("iso8859-5", 8) ], #- arabic needs special console driver for text mode [acon] #- (and gtk support isn't done yet) "iso-8859-6" => [ "iso06.f16", "iso06", "trivial.trans", std_("iso8859-6") ], "iso-8859-7" => [ "iso07.f16", "iso07", "trivial.trans", std_("iso8859-7") ], #- hebrew needs special console driver for text mode [acon] #- (and gtk support isn't done yet) "iso-8859-8" => [ "iso08.f16", "iso08", "trivial.trans", std_("iso8859-8") ], "iso-8859-9" => [ "iso09.f16", "iso09", "trivial.trans", sub { std("iso8859-9", @_) } ], "iso-8859-13" => [ "tlat7", "iso01", "trivial.trans", std_("iso8859-13") ], "iso-8859-14" => [ "tlat8", "iso01", "trivial.trans", std_("iso8859-14") ], "iso-8859-15" => [ "lat0-sun16", undef, "iso15", std("iso8859-15") ], "iso-8859-9e" => [ "tiso09e", "iso09", "trivial.trans", std("iso8859-9e") ], #- japanese needs special console driver for text mode [kon2] "jisx0208" => [ undef, undef, "trivial.trans", "-*-*-*-*-*-*-*-*-*-*-*-*-jisx*.*-0" ], "koi8-r" => [ "UniCyr_8x16", undef, "koi8-r", std("koi8-r") ], "koi8-u" => [ "UniCyr_8x16", undef, "koi8-u", std("koi8-u") ], "koi8-c" => [ "koi8-c", "iso01", "trivial.trans", std("koi8-c") ], "tatar-cyr" => [ "tatar-cyr", undef, "cp1251", std("tatar-cyr") ], "cp1251" => [ "UniCyr_8x16", undef, "cp1251", std("microsoft-cp1251") ], #- Yiddish needs special console driver for text mode [acon] #- (and gtk support isn't done yet) "cp1255" => [ "iso08.f16", "iso08", "trivial.trans", std_("microsoft-cp1255") ], #- Urdu needs special console driver for text mode [acon] #- (and gtk support isn't done yet) "cp1256" => [ undef, undef, "trivial.trans", std_("microsoft-cp1255") ], #- korean needs special console driver for text mode "ksc5601" => [ undef, undef, undef, "-*-*-*-*-*-*-*-*-*-*-*-*-ksc5601.1987-*" ], #- I have no console font for Thai... "tis620" => [ undef, undef, "trivial.trans", std2("tis620.2533-1",12) ], "tcvn" => [ "tcvn8x16", "tcvn", "trivial.trans", std2("tcvn-5712", 13), std2("tcvn-5712", 10) ], "viscii" => [ "viscii10-8x16", "viscii.uni", "viscii1.0_to_viscii1.1.trans", "-*-*-*-*-*-*-*-*-*-*-*-*-viscii1.1-1" ], #- Farsi (iranian) needs special console driver for text mode [acon] #- (and gtk support isn't done yet) "isiri-3342" => [ undef, undef, "trivial.trans", "-*-*-*-*-*-*-*-*-*-*-*-*-isiri-3342" ], "tscii-0" => [ "tamil", undef, "trivial.trans", "-*-*-*-*-*-*-*-*-*-*-*-*-tscii-0" ], ); #-###################################################################################### #- Functions #-###################################################################################### sub list { keys %languages } sub lang2text { $languages{$_[0]} && $languages{$_[0]}[0] } sub lang2charset { $languages{$_[0]} && $languages{$_[0]}[1] } sub set { my ($lang) = @_; if ($lang && $languages{$lang}) { #- use "packdrake -x" that follow symlinks and expand directory. #- it is necessary as there is a lot of symlinks inside locale.cz2, #- using a compressed cpio archive is nighmare to extract all files. #- reset locale environment variable to avoid any warnings by perl, #- so installation of new locale is done with empty locale ... unless (-e "$ENV{SHARE_PATH}/locale/$languages{$lang}[2]") { @ENV{qw(LANG LC_ALL LANGUAGE LINGUAS)} = (); eval { commands::rm("-r", "$ENV{SHARE_PATH}/locale") }; require 'run_program.pm'; run_program::run("packdrake", "-x", "$ENV{SHARE_PATH}/locale.cz2", "$ENV{SHARE_PATH}/locale", $languages{$lang}[2]); } $ENV{LC_ALL} = $lang; $ENV{LANG} = $languages{$lang}[2]; $ENV{LANGUAGE} = $languages{$lang}[3]; } else { # stick with the default (English) */ delete $ENV{LANG}; delete $ENV{LC_ALL}; delete $ENV{LINGUAGE}; delete $ENV{LINGUAS}; delete $ENV{RPM_INSTALL_LANG}; } } sub set_langs { my ($l) = @_; $l or return; $ENV{RPM_INSTALL_LANG} = member('all', @$l) ? 'all' : join ':', uniq(map { substr($languages{$_}[2], 0, 2) } @$l); log::l("RPM_INSTALL_LANG: $ENV{RPM_INSTALL_LANG}"); } sub get_langs { [ $ENV{RPM_INSTALL_LANG} eq 'all' ? map { substr($_->[2], 0, 2) } values %languages : split(':', $ENV{RPM_INSTALL_LANG}) ]; } sub write { my ($prefix) = @_; my $lang = $ENV{LC_ALL}; $lang or return; my $h = { RPM_INSTALL_LANG => $ENV{RPM_INSTALL_LANG} }; $h->{$_} = $lang foreach qw(LC_COLLATE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_MONETARY LC_TIME); if (my $l = $languages{$lang}) { add2hash $h, { LANG => $l->[2], LANGUAGE => $l->[3], RPM_INSTALL_LANG => $l->[3] }; my $c = $charsets{$l->[1] || ''}; if ($c) { my $p = "$prefix/usr/lib/kbd"; if ($c->[0]) { add2hash $h, { SYSFONT => $c->[0] }; eval { commands::cp("-f", "$p/consolefonts/$c->[0].psf.gz", "$prefix/etc/sysconfig/console"); }; $@ and log::l("missing console font $c->[0]"); } if ($c->[1]) { add2hash $h, { UNIMAP => $c->[1] }; eval { commands::cp("-f", glob_("$p/consoletrans/$c->[1]*"), "$prefix/etc/sysconfig/console"); }; $@ and log::l("missing console unimap file $c->[1]"); } if ($c->[2]) { add2hash $h, { SYSFONTACM => $c->[2] }; eval { commands::cp("-f", glob_("$p/consoletrans/$c->[2]*"), "$prefix/etc/sysconfig/console"); }; $@ and log::l("missing console acm file $c->[2]"); } } add2hash $h, $xim{$lang}; } setVarsInSh("$prefix/etc/sysconfig/i18n", $h); } sub load_po($) { my ($lang) = @_; my ($s, $from, $to, $state, $fuzzy); $s .= "package po::I18N;\n"; $s .= "no strict;\n"; $s .= "\%{'$lang'} = ("; my $f; -e ($f = "$_/po/$lang.po") and last foreach @INC; local *F; unless ($f && -e $f) { -e ($f = "$_/po/$lang.po.bz2") and last foreach @INC; if (-e $f) { open F, "bzip2 -dc $f 2>/dev/null |"; } else { -e ($f = "$_/po.cz2") and last foreach @INC; log::l("trying to load $lang.po from $f"); open F, "packdrake -x $f '' $lang.po 2>/dev/null |"; } } else { open F, $f; #- not returning here help avoiding reading the same multiple times. } foreach (<F>) { /^msgstr/ and $state = 1; /^msgid/ && !$fuzzy and $state = 2; if (/^(#|$)/ && $state != 3) { $state = 3; if (my @l = $to =~ /%(\d+)\$/g) { $to =~ s/%(\d+)\$/%/g; $to = qq([ "$to", ) . join(",", map { $_ - 1 } @l) . " ],"; } else { $to = qq("$to"); } $s .= qq("$from" => $to,\n) if $from; $from = $to = ''; } $to .= (/"(.*)"/)[0] if $state == 1; $from .= (/"(.*)"/)[0] if $state == 2; $fuzzy = /^#, fuzzy/; } $s .= ");"; no strict "vars"; eval $s; !$@; } sub console_font_files { map { -e $_ ? $_ : "$_.gz" } (map { "/usr/lib/kbd/consolefonts/$_.psf" } uniq grep {$_} map { $_->[0] } values %charsets), (map { -e $_ ? $_ : "$_.sfm" } map { "/usr/lib/kbd/consoletrans/$_" } uniq grep {$_} map { $_->[1] } values %charsets), (map { -e $_ ? $_ : "$_.acm" } map { "/usr/lib/kbd/consoletrans/$_" } uniq grep {$_} map { $_->[2] } values %charsets), } sub load_console_font { my ($lang) = @_; my ($charset) = $languages{$lang} && $languages{$lang}[1] ; my ($f, $u, $m) = @{$charsets{$charset} || []}; run_program::run('consolechars', '-v', ('-f', $f || 'lat0-sun16'), $u ? ('-u', $u) : (), $m ? ('-m', $m) : ()); } #-sub load_font { #- my ($charset) = @_; #- my $fontFile = "lat0-sun16"; #- #- if (my $c = $charsets{$charset}) { #- log::l("loading $charset font"); #- $fontFile = $c->[0]; #- } #- #- # text mode font #- log::l("loading font $ENV{SHARE_PATH}/consolefonts/$fontFile"); #- #c::loadFont("/tmp/$fontFile") or log::l("error in loadFont: one of PIO_FONT PIO_UNIMAPCLR PIO_UNIMAP PIO_UNISCRNMAP failed: $!"); #- #print STDERR "\033(K"; #- #-} sub get_x_fontset { my ($lang, $size) = @_; my $l = $languages{$lang} or return; my $c = $charsets{$l->[1]} or return; my ($big, $small) = @$c[3..4]; ($big, $small) = $big->($size) if ref $big; ($big, $small); } sub charset { my ($lang, $prefix) = @_; my $l = $languages{$lang} && $languages{$lang}[2]; foreach (cat_("$prefix/usr/X11R6/lib/X11/locale/locale.alias")) { /$l:\s+.*\.(\S+)/ and return $1; } } #-###################################################################################### #- Wonderful perl :( #-###################################################################################### 1;