summaryrefslogtreecommitdiffstats
path: root/perl-install/Makefile
blob: 178b3c15aab10db56e360ac6132acd304abd55fa (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
SO_FILES = c/blib/arch/auto/c/c.so
PMS = *.pm resize_fat/*.pm commands diskdrake
DEST = /tmp/t
DESTREP4PMS = $(DEST)/usr/bin/perl-install
PERL = ./perl
BINS = /bin/ash /sbin/mke2fs $(PERL)

.PHONY: all tags install clean verify_c

all: $(SO_FILES)

tags:
	etags -o - $(PMS) | perl2etags > TAGS

clean:
	test ! -e c/Makefile || $(MAKE) -C c clean
	rm -f c/c.xs
	find . -name "*~" -o -name "TAGS" -o -name "*.old" | xargs rm -f

tar: clean
	cd .. ; tar cfy perl-install.tar.bz2 --exclude perl-install/perl perl-install

c/c.xs: c/c.xs.pm
	chmod u+w $@
	perl $< > $@
	chmod a-w $@

$(SO_FILES): c/c.xs
	test -e c/Makefile || (cd c; perl Makefile.PL)
	$(MAKE) -C c

test_pms: verify_c
	perl2fcalls -excludec install2.pm
	(for i in $(PMS); do perl -cw -I. -Ic -Ic/blib/arch $$i || exit 1 ; done)

verify_c:
	./verify_c $(PMS)

install_pms: $(SO_FILES)
	for i in `perl -ne 's/sub (\w+?)_? {.*/$$1/ and print' commands.pm`; do ln -sf commands $(DEST)/usr/bin/$$i; done

	install -d $(DESTREP4PMS)
	for i in $(PMS); do \
		dest=$(DESTREP4PMS)/`dirname $$i`; \
		install -d $$dest; \
		perl -ne 'print #unless /^use (diagnostics|vars|strict)/' $$i > $(DESTREP4PMS)/$$i; \
	done
	@#	cp -f $$i $$dest; \
	cp diskdrake.rc $(DESTREP4PMS)
	ln -sf perl-install/install2.pm $(DEST)/usr/bin/install2
	ln -sf perl-install/commands $(DEST)/usr/bin/commands
	chmod a+x $(DESTREP4PMS)/install2.pm
	chmod a+x $(DESTREP4PMS)/commands

	cp -af */blib/arch/auto $(DESTREP4PMS)
	find $(DESTREP4PMS) -name "*.so" | xargs strip

full_tar:
	cp -af /usr/lib/perl5/site_perl/5.005/i386-linux/Gtk* $(DESTREP4PMS)
	cp -af /usr/lib/perl5/site_perl/5.005/i386-linux/auto/Gtk $(DESTREP4PMS)/auto
	find $(DESTREP4PMS) -name "*.so" | xargs strip
	cd $(DESTREP4PMS)/.. ; tar cfz /tmp/perl-install.tgz perl-install

get_needed_files: $(SO_FILES)
	export PERL_INSTALL_TEST=1 ; strace -f -e trace=file -o '| grep -v "(No such file or directory)" | sed -e "s/[^\"]*\"//" -e "s/\".*//" | grep "^/" | grep -v -e "^/tmp" -e "^/home" -e "^/proc" -e "^/var" -e "^/dev" -e "^/etc" -e "^/usr/lib/rpm" > /tmp/list ' $(PERL) -d install2.pm < /dev/null

	install -d $(DEST)/bin
	install -d $(DEST)/usr/bin
	for i in $(BINS) `grep "\.so" /tmp/list`; do \
		install -s $$i $(DEST)/usr/bin; \
		ldd $$i | sed -e 's/.*=> //' -e 's/ .*//' >> /tmp/list; \
	done
	for i in `sort /tmp/list | uniq`; do \
		install -d $(DEST)/`dirname $$i` && \
		if (echo $$i | grep "\.pm"); then \
		   perl -pe '$$_ eq "__END__" and exit(0);' $$i > $(DEST)/$$i; \
		else \
			cp -f $$i $(DEST)/$$i; \
		fi && \
		strip $(DEST)/$$i 2>/dev/null || true; \
	done
	mv $(DEST)/usr/lib/*.so* $(DEST)/lib

	ln -sf ../usr/bin/sh $(DEST)/bin/sh
	ln -sf ../usr/bin/tr $(DEST)/bin/tr
	ln -sf sh $(DEST)/bin/bash
	ln -sf ash $(DEST)/usr/bin/sh

	echo -e "#!/usr/bin/perl\n\nsymlink '/tmp/rhimage/usr/lib/perl5', '/usr/lib/perl5';\nexec '/bin/sh'" > $(DEST)/usr/bin/runinstall2
	chmod a+x $(DEST)/usr/bin/runinstall2

as_root:
	/bin/dd if=/dev/zero of=/tmp/initrd bs=1k count=4000
	echo y | /sbin/mke2fs /tmp/initrd
	losetup /dev/loop0 /tmp/initrd
	mount /dev/loop0 /mnt/initrd
	chmod a+w /mnt/initrd

full_stage2:
	rm -rf $(DEST)/[^M]*
	@#mkdir -p $(DEST)/Mandrake/base
	@#ln -s .. $(DEST)/Mandrake/instimage
	$(MAKE) get_needed_files 
	$(MAKE) stage2

stage2:
	$(MAKE) install_pms

	@#rm -rf /mnt/initrd/*
	@#cp -a $(DEST)/* /mnt/initrd
	@#sync
	@#dd if=/dev/loop0 | gzip -9 > /tmp/t/Mandrake/base/stage2.img


# function f() { grep "$*" /usr/include/*.h /usr/include/*/*.h; }