summaryrefslogtreecommitdiffstats
path: root/perl-install/devices.pm
blob: ffc1aeaef2278e7742468d62a78d5661420df797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package devices;

use diagnostics;
use strict;

use common qw(:system :file);
use run_program;
use log;
use c;

1;


sub size($) {
    local *F;
    sysopen F, $_[0], 0 or log::l("open $_[0]: $!"), return 0;

    my $valid_offset = sub { sysseek(F, $_[0], 0) && sysread(F, my $a, 1) };

    #- first try getting the size nicely
    my $size = 0;
    ioctl(F, c::BLKGETSIZE(), $size) and return unpack("i", $size) * $common::SECTORSIZE;

    #- sad it didn't work, well searching the size using the dichotomy algorithm!
    my $low = 0;
    my ($high, $mid);

    #- first find n where 2^n < size <= 2^n+1
    for ($high = 1; $high > 0 && &$valid_offset($high); $high *= 2) { $low = $high; }

    while ($low < $high - 1) {
	$mid = int ($low + $high) / 2;
	&$valid_offset($mid) ? $low : $high = $mid;
    }
    $low + 1;
}

sub make($) {
    local $_ = my $file = $_[0];
    my ($type, $major, $minor);

    if (m,^(.*/(?:dev|tmp))/(.*),) {
	$_ = $2;
    } else {
	$file = "/tmp/$_";
	-e $file or $file = "/dev/$_";
    }
    -e $file and return $file; #- assume nobody takes fun at creating files named as device

    if (/^sd(.)(\d{0,2})/) {
	$type = c::S_IFBLK();
	$major = 8;
	$minor = 16 * (ord($1) - ord('a')) + ($2 || 0);
    } elsif (/^hd(.)(\d{0,2})/) {
	$type = c::S_IFBLK();
	($major, $minor) =
	    @{ $ {{'a' => [3, 0], 'b' => [3, 64],
		   'c' => [22,0], 'd' => [22,64],
		   'e' => [33,0], 'f' => [33,64],
		   'g' => [34,0], 'h' => [34,64],
	       }}{$1} or die "unknown device $_" };
	$minor += $2 || 0;
    } elsif (/^ram(.*)/) {
	$type = c::S_IFBLK();
	$major = 1;
	$minor = $1 eq '' ? 1 : $1;
    } elsif (m|^rd/c(\d+)d(\d+)(p(\d+))?|) {
	# dac 960 "/rd/cXdXXpX"
        $type = c::S_IFBLK();
	$major = 48 + $1;
	$minor = 8 * $2 + $4;
    } elsif (m|ida/c(\d+)d(\d+)(p(\d+))?|) {
	# Compaq Smart Array "ida/c0d0{p1}"
	$type = c::S_IFBLK();
	$major = 72 + $1;
	$minor = 16 * $2 + ($4 || 0);
    } elsif (/(.*)(\d+)$/) {
	    ($type, $major, $minor) =
	     @{ ${{"fd"     => [ c::S_IFBLK(), 2,  0 ],
		   "hidbp-mse-" => [ c::S_IFCHR(), 10, 32 ],
		   "lp"     => [ c::S_IFCHR(), 6,  0 ],
		   "md"     => [ c::S_IFBLK(), 9,  0 ],
		   "nst"    => [ c::S_IFCHR(), 9, 128],
		   "scd"    => [ c::S_IFBLK(), 11, 0 ],
		   "ttyS"   => [ c::S_IFCHR(), 4, 64 ],
	       }}{$1}};
	    $minor += $2;
    }
    unless ($type) {
	($type, $major, $minor) =
	     @{ ${{"aztcd"   => [ c::S_IFBLK(), 29, 0 ],
		   "bpcd"    => [ c::S_IFBLK(), 41, 0 ],
		   "cdu31a"  => [ c::S_IFBLK(), 15, 0 ],
		   "cdu535"  => [ c::S_IFBLK(), 24, 0 ],
		   "cm206cd" => [ c::S_IFBLK(), 32, 0 ],
		   "gscd"    => [ c::S_IFBLK(), 16, 0 ],
		   "mcd"     => [ c::S_IFBLK(), 23, 0 ],
		   "mcdx"    => [ c::S_IFBLK(), 20, 0 ],
		   "mem"     => [ c::S_IFCHR(), 1,  1 ],
		   "optcd"   => [ c::S_IFBLK(), 17, 0 ],
		   "psaux"   => [ c::S_IFCHR(), 10, 1 ],
		   "random"  => [ c::S_IFCHR(), 1,  8 ],
		   "sbpcd"   => [ c::S_IFBLK(), 25, 0 ],
		   "sjcd"    => [ c::S_IFBLK(), 18, 0 ],
		   "tty"     => [ c::S_IFCHR(),  5, 0 ],
		   "usbmouse"=> [ c::S_IFCHR(), 10, 32], #- aka hidbp-mse-0
		   "zero"    => [ c::S_IFCHR(), 1,  5 ],		     
	       }}{$_} or die "unknown device $_" };
    }

    #- make a directory for this inode if needed.
    mkdir dirname($file), 0755;

    syscall_('mknod', $file, $type | 0600, makedev($major, $minor)) or die "mknod failed (dev $_): $!";

    $file;
}
/span>LOCALFILES) $(DEST)/usr/bin # cp -f $(LOCALFILES2) $(DEST)/usr/bin ln -s ../X11R6/lib/X11 $(DEST)/usr/lib/X11 ifeq (sparc,$(ARCH)) cp -a /usr/X11R6/lib/X11/xkb $(DEST)/usr/X11R6/lib/X11 rm -f $(DEST)/usr/X11R6/lib/X11/xkb/compiled ln -s /tmp $(DEST)/usr/X11R6/lib/X11/xkb/compiled ln -s /usr/X11R6/lib/X11/xkb/xkbcomp $(DEST)/usr/bin/xkbcomp endif cp -a /usr/X11R6/lib/X11/locale/{C,en_US.UTF-8,iso8859-1} $(DEST)/usr/X11R6/lib/X11/locale ifeq (y,$(USE_PCMCIA)) install -s /sbin/cardmgr $(DEST)/usr/bin endif for i in `cat $(TMPDIR)/list`; do \ if (echo $$i | grep -q "lib/[^/]*\.so"); then \ install -s $$i $(DEST)/lib; \ elif (echo $$i | grep -q "lib64/[^/]*\.so"); then \ install -s $$i $(DEST)/lib64; \ else \ d=$$i; \ (echo $$d | grep -q "^[^/]") && d="$(REP4PMS)/$$d"; \ d=`echo $(DEST)/$$d | sed 's/\/usr\/local\//\/usr\//'`; \ install -d `dirname $$d` && \ if (echo $$i | grep -q "\.pm"); then \ perl -pe '$$_ =~ /^__END__/ and exit(0);' $$i > $$d; \ elif (echo $$i | grep -q "\.so"); then \ install -s $$i $$d; \ else \ cp -f $$i $$d; \ fi; \ fi; \ done perl -pi -e 's/\s*use\s+(warnings|diagnostics|strict|vars|warnings).*//g' $(DEST)/usr/*/*/*/utf8_heavy.pl mv -f $(DEST)/bin/* $(DEST)/sbin/* $(DEST)/usr/bin cd $(DEST)/usr/bin ; mv insmod insmod_ rmdir $(DEST)/bin $(DEST)/sbin perl -pe 's!^echo!/usr/bin/echo!' /bin/unicode_start > $(DEST)/usr/bin/unicode_start chmod a+x $(DEST)/usr/bin/unicode_start perl -ane 'symlink "$$F[1]", "$(DEST)/usr/bin/$$F[0]"' share/aliases ifeq (i386,$(ARCH)) cp ../tools/i386/busybox $(DEST)/usr/bin endif ifeq (x86_64,$(ARCH)) cp ../tools/x86_64/busybox $(DEST)/usr/bin/ endif ifeq (ia64,$(ARCH)) ln -sf bash $(DEST)/usr/bin/sh else ln -sf ash $(DEST)/usr/bin/sh endif for i in fonts keyboards locales-skeleton keymaps; do tar xfj share/$$i.tar.bz2 -C $(DEST); done grep ChangeLog CVS/Entries > $(DEST)/usr/share/VERSION gzip -9f $(DEST)/usr/share/ldetect-lst/* cd share ; cp -a consolefonts devices $(DEST)/usr/share cat share/symlinks `../tools/specific_arch share/symlinks` > $(DEST)/usr/share/symlinks -cd share ; cp -f *.png $(DEST)/usr/share -cd pixmaps ; cp -af *.png *.xpm $(DEST)/usr/share ; rm -f $(DEST)/usr/share/wiz_* cp `perl -I. -Mlang -e 'lang::png_lang_files()'` $(DEST)/usr/share/langs cd share ; cp compssUsers.pl* rpmsrate $(MEDIA_INFO_DEST) perl -I. -Mlang -e 'symlink "UTF-8", "$(DEST)/usr/share/locale/$$_" foreach lang::list_langs()' clean-rpmsrate $(MEDIA_INFO_DEST)/rpmsrate $(MAIN_RPMS_DIR) for i in ../kernel/modules.description ../kernel/all.modules/modules.cz*; do cp -f $$i $(DEST)/lib/; done $(MAKE) -C share/po install SUDO= NAME=libDrakX LOCALEDIR=$(DEST)/usr/share/locale_special # ga and sl are disabled because too few messages are translated rm -rf $(DEST)/usr/share/locale_special/{ga,sl} ifeq (y,$(USE_PCMCIA)) cp -a /etc/pcmcia $(DEST)/etc ../tools/patch_pcmcia_config.pl $(DEST)/etc/pcmcia/config ../kernel/all.modules/`cat ../kernel/all.kernels/.main`/modules.dep endif cp -f $(STAGE1)/init-stage2 $(DEST)/usr/bin/init find $(DEST) -name CVS | xargs rm -rf full_stage2: $(MAKE) stage2 $(MAKE) mdkinst_stage2 mdkinst_stage2: $(MISC_DEST)/make_mdkinst_stage2 $(DEST) $(STAGE2_DEST)/mdkinst_stage2 stage2: if [ `id -u` = 0 ]; then rm -rf $(DEST); else $(SUDO) rm -rf $(DEST); fi mkdir -p $(DEST) $(MAKE) get_needed_files $(MAKE) install_pms find $(DEST)/usr -name "*.pm" | xargs gzip -9f cd $(DEST)/usr/lib/perl5 ; gunzip 5.*/{PerlIO,Exporter}.pm.gz 5.*/*-linux-thread-multi/{XSLoader,lib}.pm.gz vendor_perl/*/*-linux-thread-multi/PerlIO/gzip.pm.gz # rules to build a test rpm localrpm: localdist buildrpm localsrpm: spec_test localdist buildsrpm srpm: spec_test cvstag localsrpm localdist: cleandist localcopy tar cleandist: rm -rf ../$(PACKAGE)-$(PKGVERSION) ../$(PACKAGE)-$(PKGVERSION).tar.bz2 spec_test: @if [[ -z "$(PKGVERSION)" ]]; then echo "unable to get spec version"; exit 3;fi @if [[ -z "$(RELEASE)" ]]; then echo "unable to get spec release"; exit 2;fi tar: cd ../$(PACKAGE)-$(PKGVERSION) && perl -pi -e 's/^C_RPM.*/C_RPM=0/; s/^C_DRAKX.*/C_DRAKX=0/' c/Makefile cd ../$(PACKAGE)-$(PKGVERSION) && perl -pi -e 's/^all: help/all:/' share/po/Makefile cd ../$(PACKAGE)-$(PKGVERSION) && rm -rf install* pkgs.pm help.pm ftp.pm http.pm crypto.pm t.pm debug.log `find -name CVS` cd ../$(PACKAGE)-$(PKGVERSION) && mv -f Makefile.drakxtools Makefile cd ../$(PACKAGE)-$(PKGVERSION) && rm -f list_modules.pm && cp -f ../kernel/list_modules.pm . cd ..; tar cfj $(PACKAGE)-$(PKGVERSION).tar.bz2 $(patsubst %,$(PACKAGE)-$(PKGVERSION)/%,$(DISTFILES)) cd ..; rm -rf $(PACKAGE)-$(PKGVERSION) buildrpm: rpm -ta ../$(PACKAGE)-$(PKGVERSION).tar.bz2 buildsrpm: rpm -ts --nodeps ../$(PACKAGE)-$(PKGVERSION).tar.bz2 # rules to build a distributable rpm rpm: cvstag dist buildrpm slowsrpm: spec_test cvstag dist buildsrpm dist: cleandist export tar export: cd ..; cvs export -d $(PACKAGE)-$(PKGVERSION) -r $(TAG) $(PACKAGE) cd ../$(PACKAGE)-$(PKGVERSION) && rm -rf $(OTHERDIRS) && set -x && for f in $(OTHERDIRS); do cvs -d `cat ../CVS/Root` export -r $(TAG) -d `basename $$f` gi/$$f; done cd ..; set -x && for f in $(OTHERFILES); do cvs -d `cat ../CVS/Root` export -r $(TAG) -d $(PACKAGE)-$(PKGVERSION) gi/$$f; done @make nuke_perl cvstag: cvs tag $(CVSTAGOPT) $(TAG) cd ..; cvs tag $(CVSTAGOPT) $(TAG) $(OTHERS) nuke_perl: find ../$(PACKAGE)-$(PKGVERSION) -name '*.pm' | xargs perl -pi -e 's/\s*use\s+(diagnostics|strict|vars|warnings).*//g' find ../$(PACKAGE)-$(PKGVERSION)/standalone -type f | xargs perl -pi -e 's/\s*use\s+(diagnostics|strict|vars|warnings).*//g' dont_run_directly_stage2: echo -e '#!/bin/sh\n\nexec /usr/bin/busybox sh' > $(DEST)/usr/bin/runinstall2.sh chmod a+x $(DEST)/usr/bin/runinstall2.sh ln -sf runinstall2.sh $(DEST)/usr/bin/runinstall2 trace_stage2: eval `perl -V:vendorlib`; install -m 644 -D $$vendorlib/Devel/Trace.pm $(DEST)$$vendorlib/Devel/Trace.pm perl -pi -e 's|(#!/usr/bin/perl).*|$$1 -d:Trace|' $(DEST)/usr/bin/runinstall2