xz: Performance and compression tuning (V2) - fine tuning
[ipfire-2.x.git] / lfs / core-updates
1 ###############################################################################
2 #                                                                             #
3 # IPFire.org - A linux based firewall                                         #
4 # Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
5 #                                                                             #
6 # This program is free software: you can redistribute it and/or modify        #
7 # it under the terms of the GNU General Public License as published by        #
8 # the Free Software Foundation, either version 3 of the License, or           #
9 # (at your option) any later version.                                         #
10 #                                                                             #
11 # This program is distributed in the hope that it will be useful,             #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
14 # GNU General Public License for more details.                                #
15 #                                                                             #
16 # You should have received a copy of the GNU General Public License           #
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
18 #                                                                             #
19 ###############################################################################
20
21 ###############################################################################
22 # Definitions
23 ###############################################################################
24
25 include Config
26
27 VER = ipfire
28
29 THISAPP     = core-updates
30 TARGET      = $(DIR_INFO)/$(THISAPP)
31 TAR_OPTIONS = --xz
32
33 ###############################################################################
34 # Top-level Rules
35 ###############################################################################
36
37 install : $(TARGET)
38
39 check :
40
41 download :
42
43 md5 :
44
45 ###############################################################################
46 # Installation Details
47 ###############################################################################
48
49 CORE = $(patsubst $(DIR_SRC)/config/rootfiles/%,%,$(wildcard $(DIR_SRC)/config/rootfiles/core/*))
50
51 $(TARGET) : $(CORE)
52
53 .PHONY:
54 core/%:
55         rm -rf /install/packages/package
56         mkdir -p /install/packages/package
57         eval $$(cat /usr/src/config/rootfiles/$@/meta)
58
59         #Generate ROOTFILES from filelists
60         BUILD_ARCH=$(BUILD_ARCH) BUILDTARGET=$(BUILDTARGET) KVER=$(KVER) \
61                 $(DIR_SRC)/src/scripts/archive.files \
62                 $(DIR_SRC)/config/rootfiles/$@/filelists \
63                 $(DIR_SRC)/config/rootfiles/$@/files \
64                 $(DIR_SRC)/config/rootfiles/$@/files.$(BUILD_ARCH) \
65                 > /tmp/ROOTFILES.tmp
66
67         #remove excluded files from ROOTFILES
68         grep -f $(DIR_SRC)/config/rootfiles/$@/exclude -v /tmp/ROOTFILES.tmp > /tmp/ROOTFILES
69         rm -rf /tmp/ROOTFILES.tmp
70         
71         #Change KVER to Kernelversion
72         sed -e "s/KVER/$(KVER)/g" -i /tmp/ROOTFILES
73
74         #Remove doubled files with tar/untar/tar to save space
75         tar -c -C / --files-from=/tmp/ROOTFILES \
76                 -f /$(SNAME).tar --exclude='#*' --exclude='dev/pts/*' \
77                 --exclude='proc/*' --exclude='tmp/ROOTFILES' \
78                 --exclude-from=$(DIR_SRC)/config/rootfiles/$@/exclude
79         mv -f /tmp/ROOTFILES /install/packages/package/ROOTFILES
80         tar -p --numeric-owner -x  -C /tmp -f /$(SNAME).tar
81         rm -f /$(SNAME).tar
82         cd /tmp && XZ_OPT="$(XZ_OPT)" tar cJf /install/packages/package/files.tar.xz $(TAR_OPTIONS) * && rm -rf *
83         cat /install/packages/package/ROOTFILES | grep -v "#" > /install/packages/package/ROOTFILES.tmp
84         rm /install/packages/package/ROOTFILES
85         mv /install/packages/package/ROOTFILES.tmp /install/packages/package/ROOTFILES
86
87         #build package
88         cp -f $(DIR_SRC)/config/rootfiles/$@/update.sh /install/packages/package
89         chmod 755 /install/packages/package/update.sh
90         #Change xxxKVERxxx to Kernelversion
91         sed -e "s/xxxKVERxxx/$(KVER)/g" -i /install/packages/package/update.sh
92
93         cd /install/packages/package && XZ_OPT="$(XZ_OPT)" tar cf ../core-upgrade-$(VERSION)-$$(basename $@).ipfire $(TAR_OPTIONS) \
94                 update.sh files.tar.xz ROOTFILES
95         rm -rf /install/packages/package
96         sed -e "s/NAME/core-upgrade/g" \
97                 -e "s/VER/$(VERSION)/g" \
98                 -e "s/RELEASE/$$(basename $@)/g" \
99                 -e "s/DEPS/$(DEPS)/g" \
100                 -e "s/SIZE/`ls -l \/install\/packages\/core-upgrade-$(VERSION)-$$(basename $@).ipfire | awk '{ print $$5 }'`/g" \
101                 < /usr/src/src/pakfire/meta > /install/packages/meta-core-upgrade-$$(basename $@)