1 | #!/usr/bin/make -f |
---|
2 | |
---|
3 | include /usr/share/cdbs/1/rules/debhelper.mk |
---|
4 | |
---|
5 | APT_CACHE = $(CURDIR)/debian/apt-cache |
---|
6 | APT_FILE_CACHE = $(CURDIR)/debian/apt-file-cache |
---|
7 | TMPEXTRACT = $(CURDIR)/debian/tmpextract |
---|
8 | TMPCONTROL = $(CURDIR)/debian/tmpcontrol |
---|
9 | |
---|
10 | APTITUDE_LOCKFILE = $(CURDIR)/debian/aptitude-lockfile |
---|
11 | APTITUDE_STATE = $(CURDIR)/debian/aptitude-state |
---|
12 | APTITUDE = aptitude -o 'Aptitude::LockFile=$(APTITUDE_LOCKFILE)' -o 'Dir::Cache=$(APT_CACHE)' -o 'Dir::Aptitude::state=$(APTITUDE_STATE)' -o "Debug::NoLocking=yes" |
---|
13 | |
---|
14 | ATHENA_SHLIBS = $(shell ATHENA_SYS=$$(machtype -S) ATHENA_SYS_COMPAT=$$(machtype -C) athdir . shlibs) |
---|
15 | |
---|
16 | LIBDIRS := $(patsubst %/,%,$(strip \ |
---|
17 | $(shell strings /lib*/ld-linux*.so.2 | grep '^/.*lib') \ |
---|
18 | $(shell grep -h '^/' /etc/ld.so.conf /etc/ld.so.conf.d/*.conf) \ |
---|
19 | )) |
---|
20 | |
---|
21 | $(APT_FILE_CACHE): |
---|
22 | mkdir -p $@ |
---|
23 | apt-file -c $@ update |
---|
24 | |
---|
25 | empty = |
---|
26 | |
---|
27 | $(APT_CACHE): $(ATHENA_SHLIBS) $(APT_FILE_CACHE) $(APTITUDE_STATE) |
---|
28 | mkdir -p $@ $@/archives $@/archives/partial |
---|
29 | apt-file --verbose -y -c $(APT_FILE_CACHE) -F -l -x search "^(?:$(subst $(empty) /,|, $(LIBDIRS)))/(?:$$( \ |
---|
30 | perl -0pe 's/ .*//mg; s/(\W)/\\$$1/g; s/\\\n$$//; s/\\\n/|/g' < $< \ |
---|
31 | ))" | \ |
---|
32 | sort -u | \ |
---|
33 | perl -pe 'chomp; s/(\W)/\\$$1/g; s/^(.*)$$/~n^$$1\$$!~Rconflicts:(~Dreplaces:(~n^$$1\$$~VCANDIDATE)~Dconflicts:(~n^$$1\$$~VCANDIDATE))/; s/$$/\0/' | \ |
---|
34 | xargs -0 -r -t $(APTITUDE) -F '%p' search | \ |
---|
35 | (cd $@/archives; xargs -r -t $(APTITUDE) download) |
---|
36 | |
---|
37 | $(APTITUDE_STATE): |
---|
38 | mkdir -p $@ |
---|
39 | |
---|
40 | debian/libs: $(ATHENA_SHLIBS) $(APT_CACHE) |
---|
41 | : >| $@ |
---|
42 | for pkg in $(APT_CACHE)/archives/*.deb; do \ |
---|
43 | echo "$$(basename $$pkg)" >&2; \ |
---|
44 | rm -rf $(TMPCONTROL) $(TMPEXTRACT); \ |
---|
45 | mkdir -p $(TMPCONTROL) $(TMPEXTRACT); \ |
---|
46 | dpkg-deb -e "$$pkg" $(TMPCONTROL)/; \ |
---|
47 | [ -e $(TMPCONTROL)/shlibs ] || continue; \ |
---|
48 | dpkg-deb -x "$$pkg" $(TMPEXTRACT)/; \ |
---|
49 | perl -pe 's/^((\S+)\.so\.(\S+))\s+(\S+)$$/$$1 $$4 $$2 $$3/ or s/^((\S+)-(\S+)\.so)\s+(\S+)$$/$$1 $$4 $$2 $$3/ or $$_ = ""' < $< | \ |
---|
50 | while read lib format libname soname; do \ |
---|
51 | for dir in $(LIBDIRS); do \ |
---|
52 | if [ -e "$(TMPEXTRACT)/$$dir/$$lib" ] && \ |
---|
53 | [ "$$(objdump -a -- "$(TMPEXTRACT)/$$dir/$$lib" | \ |
---|
54 | sed -n 's/^.*file format *\(.*\)$$/\1/ p')" = "$$format" ]; then \ |
---|
55 | if grep -q "^\\($$libname\\)[[:space:]]\\+\\($$soname\)[[:space:]]\\+" $(TMPCONTROL)/shlibs; then \ |
---|
56 | sed -n "s/^\\($$libname\\)[[:space:]]\\+\\($$soname\)[[:space:]]\\+/\\1 \\2 / p" $(TMPCONTROL)/shlibs; \ |
---|
57 | else \ |
---|
58 | echo "Warning: fabricating shlibs line for $$libname $$soname" >&2; \ |
---|
59 | echo "$$libname $$soname $$(sed -n 's/^Package:[[:space:]]*// p' $(TMPCONTROL)/control)"; \ |
---|
60 | fi | \ |
---|
61 | sed -e 's/ BROKEN_DEP_ON_OBSOLETE_DB2$$/ libdb2 (>= 2:2.7.7.0-1)/' \ |
---|
62 | -e 's/ libgl1.*$$/ libgl1/' >> $@; \ |
---|
63 | break; \ |
---|
64 | fi \ |
---|
65 | done \ |
---|
66 | done; \ |
---|
67 | rm -rf $(TMPCONTROL) $(TMPEXTRACT); \ |
---|
68 | done |
---|
69 | |
---|
70 | common-build-arch:: debian/libs |
---|
71 | |
---|
72 | debathena-athena-libraries-substvars: debian/libs |
---|
73 | ( \ |
---|
74 | echo -n "debathena-athena-libraries:Recommends="; \ |
---|
75 | cat $< | sed 's/^[^[:space:]]\+[[:space:]]\+[^[:space:]]\+[[:space:]]\+//' | sort -u | tr '\n' ','; \ |
---|
76 | echo; \ |
---|
77 | ) >> debian/debathena-athena-libraries.substvars |
---|
78 | |
---|
79 | binary-predeb/debathena-athena-libraries:: debathena-athena-libraries-substvars |
---|
80 | |
---|
81 | clean:: |
---|
82 | rm -f debian/libs $(APTITUDE_LOCKFILE) |
---|
83 | rm -rf $(APT_CACHE) $(APT_FILE_CACHE) $(TMPCONTROL) $(TMPEXTRACT) $(APTITUDE_STATE) |
---|