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

Contents of /trunk/build/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.5