/[d-i]/trunk/build/Makefile
ViewVC logotype

Contents of /trunk/build/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 563 - (show annotations) (download)
Mon Mar 26 04:28:34 2001 UTC (12 years, 1 month ago) by joeyh
File size: 11405 byte(s)
revamped the stats
1 #!/usr/bin/make -f
2 #
3 # Debian Installer system makefile.
4 # Copyright 2001 by Joey Hess <joeyh@debian.org>.
5 # Licensed under the terms of the GPL.
6 #
7 # This makefile builds a debian-installer system and bootable images from
8 # a collection of udebs which it downloads from a Debian archive. See
9 # README for details.
10
11 # The version of the kernel to use.
12 KVERS=2.4.2
13
14 # The type of system to build. Determines what udebs are unpacked into
15 # the system. See the .list files for various types. You may want to
16 # override this on the command line.
17 TYPE=net
18
19 # List here any libraries that need to be put on the system. Generally
20 # this is not needed except for libnss_* libraries, which will not be
21 # automatically pulled in by the library reduction code. Wildcards are
22 # allowed.
23 # TODO: this really needs to be determined on a per TYPE basis.
24 # libnss_nns is needed for many, but not all, install scenarios
25 EXTRALIBS=/lib/libnss_dns*
26
27 # List here any extra udebs that are not in the list file but that
28 # should still be included on the system.
29 EXTRAS=""
30
31 # This variable can be used to copy in additional files from the system
32 # that is doing the build. Useful if you need to include strace, or gdb,
33 # or just something extra on a floppy.
34 #EXTRAFILES=/usr/bin/strace
35
36 # set DEBUG to y if you want to get the source for and compile
37 # debug versions of the needed udebs
38 DEBUG=n
39
40 # All output files will go here.
41 DEST=dest
42
43 # Filename of initrd to create.
44 INITRD=$(DEST)/$(TYPE)-initrd.gz
45
46 # How big a floppy image should I make? (in kilobytes)
47 FLOPPY_SIZE=1440
48
49 # The floppy image to create.
50 FLOPPY_IMAGE=$(DEST)/$(TYPE)-$(FLOPPY_SIZE).img
51
52 # What device to write floppies on
53 FLOPPYDEV=/dev/fd0
54
55 # May be needed in rare cases.
56 #SYSLINUX_OPTS=-s
57
58 # Directory apt uses for stuff.
59 APTDIR=apt
60
61 # Directory udebs are placed in.
62 UDEBDIR=udebs
63
64 # Local directory that is searched for udebs, to avoid downloading.
65 # (Or for udebs that are not yet available for download.)
66 LOCALUDEBDIR=localudebs
67
68 # Directory where debug versions of udebs will be built.
69 DEBUGUDEBDIR=debugudebs
70
71 # The beta version of upx can be used to make the kernel a lot smaller
72 # it shaved 75k off our kernel. That allows us to put a lot more on
73 # a single floppy. binaries are at:
74 # http://wildsau.idv.uni-linz.ac.at/mfx/download/upx/unstable/upx-1.11-linux.tar.gz
75 # or source at:
76 # http://sourceforge.net/projects/upx/
77 #UPX=~davidw/bin/upx
78 UPX=
79
80 # Figure out which sources.list to use. The .local one is preferred,
81 # so you can set up a locally preferred one (and not accidentially cvs
82 # commit it).
83 ifeq ($(wildcard sources.list.local),sources.list.local)
84 SOURCES_LIST=sources.list.local
85 else
86 SOURCES_LIST=sources.list
87 endif
88
89 # Add to PATH so dpkg will always work, and so local programs will
90 # be found.
91 PATH:=$(PATH):/usr/sbin:/sbin:.
92
93 # All these options make apt read the right sources list, and
94 # use APTDIR for everything so it need not run as root.
95 CWD:=$(shell pwd)/
96 APT_GET=apt-get --assume-yes \
97 -o Dir::Etc::sourcelist=$(CWD)$(SOURCES_LIST) \
98 -o Dir::State=$(CWD)$(APTDIR)/state \
99 -o Debug::NoLocking=true \
100 -o Dir::Cache=$(CWD)$(APTDIR)/cache
101
102 # Get the list of udebs to install. Comments are allowed in the lists.
103 UDEBS=$(shell grep --no-filename -v ^\# lists/base lists/$(TYPE) | sed 's/$${kernel:Version}/$(KVERS)/g') $(EXTRAS)
104
105 DPKGDIR=$(TREE)/var/lib/dpkg
106 TEMP=./tmp
107 TMP_MNT=`pwd`/mnt/
108
109 # Build tree location.
110 TREE=$(TEMP)/tree
111
112 # This is the kernel image that we will boot from.
113 KERNEL=$(TEMP)/vmlinuz
114
115 build: demo_clean tree stats
116
117 demo: tree
118 sudo chroot $(TREE) bin/sh -c "if ! mount | grep ^proc ; then bin/mount proc -t proc /proc; fi"
119 -sudo chroot $(TREE) bin/sh -c "export DEBCONF_FRONTEND=text DEBCONF_DEBUG=5; /usr/bin/debconf-loadtemplate debian /var/lib/dpkg/info/*.templates; /usr/share/debconf/frontend /usr/bin/main-menu"
120 $(MAKE) demo_clean
121
122 shell: tree
123 mkdir -p $(TREE)/proc
124 sudo chroot $(TREE) bin/sh -c "if ! mount | grep ^proc ; then bin/mount proc -t proc /proc; fi"
125 sudo chroot $(TREE) bin/sh
126 $(MAKE) demo_clean
127
128 demo_clean:
129 -if [ -e $(TREE)/proc/self ]; then \
130 sudo chroot $(TREE) bin/sh -c "if mount | grep ^proc ; then bin/umount /proc ; fi" &> /dev/null; \
131 fi
132
133 clean: demo_clean
134 dh_clean
135 rm -f *-stamp
136 rm -rf $(TREE) $(APTDIR) $(UDEBDIR) $(TEMP) $(DEST)
137
138 # Get all required udebs and put in UDEBDIR.
139 get_udebs: get_udebs-stamp
140 get_udebs-stamp:
141 mkdir -p $(APTDIR)/state/lists/partial
142 mkdir -p $(APTDIR)/cache/archives/partial
143 $(APT_GET) update
144 $(APT_GET) autoclean
145 # If there are local udebs, remove them from the list of things to
146 # get. Then get all the udebs that are left to get.
147 needed="$(UDEBS)"; \
148 for file in `find $(LOCALUDEBDIR) -name "*_*" -printf "%f\n" 2>/dev/null`; do \
149 package=`echo $$file | cut -d _ -f 1`; \
150 needed=`echo $$needed | sed "s/$$package *//"`; \
151 done; \
152 if [ $(DEBUG) = y ] ; then \
153 mkdir -p $(DEBUGUDEBDIR); \
154 cd $(DEBUGUDEBDIR); \
155 export DEB_BUILD_OPTIONS="debug"; \
156 $(APT_GET) source --build --yes $$needed; \
157 cd ..; \
158 else \
159 $(APT_GET) -dy install $$needed; \
160 fi; \
161
162 # Now the udebs are in APTDIR/cache/archives/ and maybe LOCALUDEBDIR,
163 # but there may be other udebs there too besides those we asked for.
164 # So link those we asked for to UDEBDIR, renaming them to more useful
165 # names.
166 rm -rf $(UDEBDIR)
167 mkdir -p $(UDEBDIR)
168 for package in $(UDEBS); do \
169 if [ -e $(APTDIR)/cache/archives/$$package\_* ]; then \
170 ln -f $(APTDIR)/cache/archives/$$package\_* \
171 $(UDEBDIR)/$$package.udeb; \
172 fi; \
173 if [ -e $(LOCALUDEBDIR)/$$package\_* ]; then \
174 ln -f $(LOCALUDEBDIR)/$$package\_* \
175 $(UDEBDIR)/$$package.udeb; \
176 fi; \
177 if [ -e $(DEBUGUDEBDIR)/$$package\_*.udeb ]; then \
178 ln -f $(DEBUGUDEBDIR)/$$package\_*.udeb \
179 $(UDEBDIR)/$$package.udeb; \
180 fi; \
181 done
182
183 touch get_udebs-stamp
184
185
186 # Build the installer tree.
187 tree: get_udebs tree-stamp
188 tree-stamp:
189 dh_testroot
190
191 # This build cannot be restarted, because dpkg gets confused.
192 rm -rf $(TREE)
193 # Set up the basic files [u]dpkg needs.
194 mkdir -p $(DPKGDIR)/info
195 touch $(DPKGDIR)/status
196 # Only dpkg needs this stuff, so it can be removed later.
197 mkdir -p $(DPKGDIR)/updates/
198 touch $(DPKGDIR)/available
199 # Unpack the udebs with dpkg. This command must run as root or fakeroot.
200 dpkg --force-overwrite --root=$(TREE) --unpack $(UDEBDIR)/*.udeb
201 # Clean up after dpkg.
202 rm -rf $(DPKGDIR)/updates
203 rm -f $(DPKGDIR)/available $(DPKGDIR)/*-old $(DPKGDIR)/lock
204 # Set up modules.dep
205 mkdir -p $(TREE)/lib/modules/$(KVERS)-di/
206 depmod -q -a -b $(TREE)/ $(KVERS)-di
207
208 # Move the kernel image out of the way, into a temp directory
209 # for use later. We don't need it bloating our image!
210 mv -f $(TREE)/boot/vmlinuz $(KERNEL)
211 -rmdir $(TREE)/boot/
212
213 ifdef EXTRAFILES
214 # Copy in any extra files
215 for file in $(EXTRAFILES); do \
216 mkdir -p $(TREE)/`basename $$file`; \
217 cp -a $$file $(TREE)/$$file; \
218 done
219 endif
220
221 # Copy in any extra libs.
222 ifdef EXTRALIBS
223 cp -a $(EXTRALIBS) $(TREE)/lib/
224 endif
225
226 # Library reduction.
227 mkdir -p $(TREE)/lib
228 mklibs.sh -v -d $(TREE)/lib `find $(TREE) -type f -perm +0111 -o -name '*.so'`
229
230 # Remove any libraries that are present in both usr/lib and lib,
231 # from lib. These were unnecessarily copied in by mklibs, and
232 # we want to use the ones in usr/lib instead since they came
233 # from udebs. Only libdebconf has this problem so far.
234 for lib in `find $(TREE)/usr/lib/lib* -type f -printf "%f\n" | cut -d . -f 1 | sort | uniq`; do \
235 rm $(TREE)/lib/$$lib.*; \
236 done
237
238 # Now we have reduced libraries installed .. but they are
239 # not listed in the status file. This nasty thing puts them in,
240 # and alters their names to end in -reduced to indicate that
241 # they have been modified.
242 for package in $$(dpkg -S `find $(TREE)/lib -type f -not -name '*.o'| \
243 sed s:$(TREE)::` | cut -d : -f 1 | \
244 sort | uniq); do \
245 dpkg -s $$package | sed "s/$$package/$$package-reduced/g" \
246 >> $(DPKGDIR)/status; \
247 done
248
249 # Reduce status file to contain only the elements we care about.
250 egrep -i '^((Status|Provides|Depends|Package|Description|installer-menu-item):|$$)' \
251 $(DPKGDIR)/status > $(DPKGDIR)/status.new
252 mv -f $(DPKGDIR)/status.new $(DPKGDIR)/status
253
254 touch tree-stamp
255
256 tarball: tree
257 tar czf $(DEST)/$(TYPE)-debian-installer.tar.gz $(TREE)
258
259 # Make sure that the temporary mountpoint exists and is not occupied.
260 tmp_mount:
261 dh_testroot
262 if mount | grep -q $(TMP_MNT) && ! umount $(TMP_MNT) ; then \
263 echo "Error unmounting $(TMP_MNT)" 2>&1 ; \
264 exit 1; \
265 fi
266 mkdir -p $(TMP_MNT)
267
268 # Create a compressed image of the root filesystem.
269 # 1. make a temporary file large enough to fit the filesystem.
270 # 2. mount that file via the loop device, create a filesystem on it
271 # 3. copy over the root filesystem
272 # 4. unmount the file, compress it
273 #
274 initrd: Makefile tmp_mount tree $(INITRD)
275 $(INITRD): TMP_FILE=$(TEMP)/image.tmp
276 $(INITRD):
277 dh_testroot
278 umount $(TMP_MNT) || true
279 rm -f $(TMP_FILE)
280 install -d $(TEMP)
281 dd if=/dev/zero of=$(TMP_FILE) bs=1k count=`expr $$(du -s $(TREE) | cut -f 1) + $$(expr $$(find $(TREE) | wc -l) \* 2)`
282 # FIXME: 2000 bytes/inode (choose that better?)
283 mke2fs -F -m 0 -i 2000 -O sparse_super $(TMP_FILE)
284 mount -t ext2 -o loop $(TMP_FILE) $(TMP_MNT)
285 cp -a $(TREE)/* $(TMP_MNT)/
286 umount $(TMP_MNT)
287 install -d $(DEST)
288 dd if=$(TMP_FILE) bs=1k | gzip -v9 > $(INITRD)
289
290 # Create a bootable floppy image. i386 specific. FIXME
291 # 1. make a dos filesystem image
292 # 2. copy over kernel, initrd
293 # 3. install syslinux
294 floppy_image: Makefile initrd tmp_mount $(FLOPPY_IMAGE)
295 $(FLOPPY_IMAGE):
296 dh_testroot
297 install -d $(DEST)
298
299 dd if=/dev/zero of=$(FLOPPY_IMAGE) bs=1k count=$(FLOPPY_SIZE)
300 mkfs.msdos -i deb00001 -n 'Debian Installer' $(FLOPPY_IMAGE)
301 mount -t msdos -o loop $(FLOPPY_IMAGE) $(TMP_MNT)
302
303 cp $(KERNEL) $(TMP_MNT)/LINUX
304 cp $(INITRD) $(TMP_MNT)/initrd.gz
305
306 cp syslinux.cfg $(TMP_MNT)/
307 todos $(TMP_MNT)/syslinux.cfg
308 umount $(TMP_MNT)
309 syslinux $(SYSLINUX_OPTS) $(FLOPPY_IMAGE)
310
311 # Write image to floppy
312 boot_floppy: floppy_image
313 install -d $(DEST)
314 dd if=$(FLOPPY_IMAGE) of=$(FLOPPYDEV)
315
316 # If you're paranoid (or things are mysteriously breaking..),
317 # you can check the floppy to make sure it wrote properly.
318 # This target will fail if the floppy doesn't match the floppy image.
319 boot_floppy_check: floppy_image
320 cmp $(FLOPPYDEV) $(FLOPPY_IMAGE)
321
322 COMPRESSED_SZ=$(shell expr $(shell tar cz $(TREE) | wc -c) / 1024)
323 KERNEL_SZ=$(shell expr $(shell du -b $(KERNEL) | cut -f 1) / 1024)
324 stats: tree
325 @echo
326 @echo "System stats"
327 @echo "------------"
328 @echo "Installed udebs: $(UDEBS)"
329 @echo -n "Total system size: $(shell du -h -s $(TREE) | cut -f 1)"
330 @echo -n " ($(shell du -h --exclude=modules -s $(TREE)/lib | cut -f 1) libs, "
331 @echo "$(shell du -h -s $(TREE)/lib/modules | cut -f 1) kernel modules)"
332 @echo "Initrd size: $(COMPRESSED_SZ)k"
333 @echo "Kernel size: $(KERNEL_SZ)k"
334 @echo "Free space: $(shell expr $(FLOPPY_SIZE) - $(KERNEL_SZ) - $(COMPRESSED_SZ))k"
335 # Add your interesting stats here.
336
337
338 # Upload a daily build to klecker. If you're not Joey Hess, you probably
339 # don't want to use this grungy code, at least not without overrideing
340 # this:
341 UPLOAD_DIR=klecker.debian.org:~/public_html/debian-installer/daily/
342 daily_build: clean
343 install -d $(DEST)
344 fakeroot $(MAKE) tarball > $(DEST)/log 2>&1
345 scp -q -B $(DEST)/log $(UPLOAD_DIR)
346 scp -q -B $(DEST)/$(TYPE)-debian-installer.tar.gz \
347 $(UPLOAD_DIR)/$(TYPE)-debian-installer-$(shell date +%Y%m%d).tar.gz
348
349 .PHONY: tree

  ViewVC Help
Powered by ViewVC 1.1.5