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

Contents of /trunk/build/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 439 - (show annotations) (download)
Thu Feb 1 04:53:15 2001 UTC (12 years, 4 months ago) by joeyh
File size: 9897 byte(s)
cleaned up clean rule
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 from a collection of
8 # udebs.
9
10 # The type of system to build. Determines what udebs are unpacked into
11 # the system. See the .list files for various types. You may want to
12 # override this on the command line.
13 TYPE=net
14
15 # List here any extra udebs that are not in the list file but that
16 # should still be included on the system.
17 EXTRAS=""
18
19 # set DEBUG to y if you want to get the source for and compile
20 # debug versions of the needed udebs
21 DEBUG=n
22
23 # Build tree location.
24 DEST=debian-installer
25
26 CWD:=$(shell pwd)/
27 # Directory apt uses for stuff.
28 APTDIR=apt
29
30 # Directory udebs are placed in.
31 UDEBDIR=udebs
32
33 # Local directory that is searched for udebs, to avoid downloading.
34 # (Or for udebs that are not yet available for download.)
35 LOCALUDEBDIR=localudebs
36
37 # Directory where debug versions of udebs will be built.
38 DEBUGUDEBDIR=debugudebs
39
40 # Figure out which sources.list to use. The .local one is preferred,
41 # so you can set up a locally preferred one (and not accidentially cvs
42 # commit it).
43 ifeq ($(wildcard sources.list.local),sources.list.local)
44 SOURCES_LIST=sources.list.local
45 else
46 SOURCES_LIST=sources.list
47 endif
48
49 # Add to PATH so dpkg will always work
50 PATH:=$(PATH):/usr/sbin:/sbin:.
51
52 # All these options makes apt read the right sources list, and
53 # use APTDIR for everything so it need not run as root.
54 APT_GET=apt-get --assume-yes \
55 -o Dir::Etc::sourcelist=$(CWD)$(SOURCES_LIST) \
56 -o Dir::State=$(CWD)$(APTDIR)/state \
57 -o Debug::NoLocking=true \
58 -o Dir::Cache=$(CWD)$(APTDIR)/cache \
59
60
61 # Comments are allowed in the lists.
62 UDEBS=$(shell grep --no-filename -v ^\# lists/base lists/$(TYPE)) $(EXTRAS)
63
64 DPKGDIR=$(DEST)/var/lib/dpkg
65 TMPDIR=./tmp
66
67 build: demo_clean tree lib_reduce status_reduce stats
68
69 # For now, just build a demo tarball. Later, this should build actual bootable
70 # images.
71 image: build
72 tar czf ../debian-installer.tar.gz $(DEST)
73
74 demo:
75 sudo chroot $(DEST) bin/sh -c "if ! mount | grep ^proc ; then bin/mount proc -t proc /proc; fi"
76 sudo chroot $(DEST) 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"
77 $(MAKE) demo_clean
78
79 shell:
80 mkdir -p $(DEST)/proc
81 sudo chroot $(DEST) bin/sh -c "if ! mount | grep ^proc ; then bin/mount proc -t proc /proc; fi"
82 sudo chroot $(DEST) bin/sh
83
84 demo_clean:
85 -if [ -e $(DEST)/proc/self ]; then \
86 sudo chroot $(DEST) bin/sh -c "if mount | grep ^proc ; then bin/umount /proc ; fi" &> /dev/null; \
87 sudo chroot $(DEST) bin/sh -c "rm -rf /etc /var"; \
88 fi
89
90
91 clean:
92 dh_clean
93 rm -f $(FLOPPY_IMAGE) $(INITRD)
94 rm -rf $(DEST) $(APTDIR) $(UDEBDIR) $(TMPDIR)
95
96 # Get all required udebs and put in UDEBDIR.
97 get_udebs:
98 mkdir -p $(APTDIR)/state/lists/partial
99 mkdir -p $(APTDIR)/cache/archives/partial
100 $(APT_GET) update
101 $(APT_GET) autoclean
102 # If there are local udebs, remove them from the list of things to
103 # get. Then get all the udebs that are left to get.
104 needed="$(UDEBS)"; \
105 for file in `find $(LOCALUDEBDIR) -name "*_*" -printf "%f\n" 2>/dev/null`; do \
106 package=`echo $$file | cut -d _ -f 1`; \
107 needed=`echo $$needed | sed "s/$$package *//"`; \
108 done; \
109 if [ $(DEBUG) = y ] ; then \
110 mkdir -p $(DEBUGUDEBDIR); \
111 cd $(DEBUGUDEBDIR); \
112 export DEB_BUILD_OPTIONS="debug"; \
113 $(APT_GET) source --build --yes $$needed; \
114 cd ..; \
115 else \
116 $(APT_GET) -dy install $$needed; \
117 fi; \
118
119 # Now the udebs are in APTDIR/cache/archives/ and maybe LOCALUDEBDIR,
120 # but there may be other udebs there too besides those we asked for.
121 # So link those we asked for to UDEBDIR, renaming them to more useful
122 # names.
123 rm -rf $(UDEBDIR)
124 mkdir -p $(UDEBDIR)
125 for package in $(UDEBS); do \
126 if [ -e $(APTDIR)/cache/archives/$$package\_* ]; then \
127 ln -f $(APTDIR)/cache/archives/$$package\_* \
128 $(UDEBDIR)/$$package.udeb; \
129 fi; \
130 if [ -e $(LOCALUDEBDIR)/$$package\_* ]; then \
131 ln -f $(LOCALUDEBDIR)/$$package\_* \
132 $(UDEBDIR)/$$package.udeb; \
133 fi; \
134 if [ -e $(DEBUGUDEBDIR)/$$package\_*.udeb ]; then \
135 ln -f $(DEBUGUDEBDIR)/$$package\_*.udeb \
136 $(UDEBDIR)/$$package.udeb; \
137 fi; \
138 done
139
140 # This is a list of the devices we want to create
141 DEVS=console kmem mem null ram0 ram tty1 tty2 tty3 tty4 hda hdb hdc hdd fd0
142 PROTOTYPE_ROOTFS=rootfs
143
144 # Build the installer tree.
145 tree: get_udebs
146 dh_testroot
147
148 # This build cannot be restarted, because dpkg gets confused.
149 rm -rf $(DEST)
150 # Set up the basic files [u]dpkg needs.
151 mkdir -p $(DPKGDIR)/info
152 touch $(DPKGDIR)/status
153 # Only dpkg needs this stuff, so it can be removed later.
154 mkdir -p $(DPKGDIR)/updates/
155 touch $(DPKGDIR)/available
156 # Unpack the udebs with dpkg. This command must run as root or fakeroot.
157 dpkg --root=$(DEST) --unpack $(UDEBDIR)/*.udeb
158 # Clean up after dpkg.
159 rm -rf $(DPKGDIR)/updates
160 rm -f $(DPKGDIR)/available $(DPKGDIR)/*-old $(DPKGDIR)/lock
161 mkdir -p $(DEST)/dev $(DEST)/proc $(DEST)/mnt $(DEST)/var/log
162 cp -dpR $(PROTOTYPE_ROOTFS)/* $(DEST)/
163 find $(DEST) -depth -type d -path "*CVS*" -exec rm -rf {} \;
164 $(foreach DEV, $(DEVS), \
165 (cp -dpR /dev/$(DEV) $(DEST)/dev/ ) ; )
166 mkdir -p $(DEST)/lib/modules/$(KVER)/
167 depmod -q -a -b $(DEST)/ $(KVER)
168 # TODO: configure some of the packages?
169
170 UPX=
171 #UPX=~davidw/bin/upx
172 # the beta version of upx can be used to make the kernel a lot smaller
173 # it shaved 75k off our kernel. That allows us to put a lot more on
174 # a single floppy. binaries are at:
175 #http://wildsau.idv.uni-linz.ac.at/mfx/download/upx/unstable/upx-1.11-linux.tar.gz
176 # or source at:
177 # http://sourceforge.net/projects/upx/
178
179 KVER=2.4.0-di
180 # FIXME, KERNEL_DEB, need to handle the version number intelligently
181 KDEB=../kernel-image-$(KVER)_0.003_i386.deb
182 KTREE=kernel_tree
183 # Take a kernel-image-*.deb and extract needed information
184 kernel:
185 mkdir -p $(KTREE)
186 dpkg-deb -X $(KDEB) $(KTREE)
187 if [ "$(UPX)" ]; then \
188 $(UPX) $(KTREE)/boot/vmlinux-$(KVER); \
189 fi
190
191 TMP_MNT=./mnt/$(DEST)
192
193 # Make sure that the temporary mountpoint is not occupied,
194 # and make it.
195 tmp_mount:
196 dh_testroot
197 if mount | grep $(TMP_MNT) && ! umount $(TMP_MNT) ; then \
198 echo "Error unmounting $(TMP_MNT)" 2>&1 ; \
199 exit 1; \
200 fi
201 mkdir -p $(TMP_MNT)
202
203 # Create a compressed image of the root filesystem.
204 # 1. make a temporary file large enough to fit the filesystem.
205 # 2. mount that file via the loop device, create a filesystem on it
206 # 3. copy over the root filesystem
207 # 4. unmount the file, compress it
208
209 INITRD=initrd.gz
210 TMP_FILE=$(TMPDIR)/$(DEST)
211
212 # TODO: get rid of this damned fuzz factor!
213 FUZZ=127
214
215 initrd: tmp_mount
216 dh_testroot
217 rm -f $(TMP_FILE)
218 install -d $(TMPDIR)
219 dd if=/dev/zero of=$(TMP_FILE) bs=1k count=`expr $$(du -s $(DEST) | cut -f 1) + $(FUZZ)`
220 # FIXME: 2000 bytes/inode (choose that better?)
221 mke2fs -F -m 0 -i 2000 -O sparse_super $(TMP_FILE)
222 mount -t ext2 -o loop $(TMP_FILE) $(TMP_MNT)
223 cp -a $(DEST)/* $(TMP_MNT)/
224 umount $(TMP_MNT)
225 dd if=$(TMP_FILE) bs=1k | gzip -v9 > $(INITRD)
226
227 # This is the kernel which will be used on the boot disk.
228 KERNEL=$(KTREE)/boot/vmlinuz-$(KVER)
229
230 # How big a floppy image should I make? (in kilobytes)
231 FLOPPY_SIZE=1440
232 # The floppy image to create.
233 FLOPPY_IMAGE=floppy.img
234
235 # Create a bootable floppy image. i386 specific. FIXME
236 # 1. make a dos filesystem image
237 # 2. copy over kernel, initrd
238 # 3. install syslinux
239
240 floppy_image: initrd kernel tmp_mount
241 dh_testroot
242
243 dd if=/dev/zero of=$(FLOPPY_IMAGE) bs=1k count=$(FLOPPY_SIZE)
244 mkfs.msdos -i deb00001 -n 'Debian Installer' $(FLOPPY_IMAGE)
245 mount -t msdos -o loop $(FLOPPY_IMAGE) $(TMP_MNT)
246
247 cp $(KERNEL) $(TMP_MNT)/LINUX
248 cp initrd.gz $(TMP_MNT)/
249
250 cp syslinux.cfg $(TMP_MNT)/
251 todos $(TMP_MNT)/syslinux.cfg
252 # This number is used later for stats. There's gotta be a better way.
253 df -h $(TMP_MNT) | tail -1 | sed 's/[^ ]* //' | awk 'END { print $$3 }' > $(TMPDIR)/.floppy_free_stat
254 umount $(TMP_MNT)
255 syslinux $(FLOPPY_IMAGE)
256
257 # Library reduction.
258 lib_reduce:
259 mkdir -p $(DEST)/lib
260 mklibs.sh -v -d $(DEST)/lib `find $(DEST) -type f -perm +0111 -o -name '*.so'`
261 # Now we have reduced libraries installed .. but they are
262 # not listed in the status file. This nasty thing puts them in,
263 # and alters their names to end in -reduced to indicate that
264 # they have been modified.
265 for package in $$(dpkg -S `find debian-installer/lib -type f -not -name '*.o'| \
266 sed s:debian-installer::` | cut -d : -f 1 | \
267 sort | uniq); do \
268 dpkg -s $$package >> $(DPKGDIR)/status; \
269 sed "s/$$package/$$package-reduced/g" \
270 < $(DPKGDIR)/status > $(DPKGDIR)/status-new; \
271 mv -f $(DPKGDIR)/status-new $(DPKGDIR)/status; \
272 done
273
274 # Reduce a status file to contain only the elements we care about.
275 status_reduce:
276 egrep -i '^((Status|Provides|Depends|Package|Description|installer-menu-item):|$$)' \
277 $(DPKGDIR)/status > $(DPKGDIR)/status.new
278 mv -f $(DPKGDIR)/status.new $(DPKGDIR)/status
279
280
281 COMPRESSED_SZ=$(shell expr $(shell tar cz $(DEST) | wc -c) / 1024)
282 stats:
283 @echo
284 @echo System stats
285 @echo ------------
286 @echo Installed udebs: $(UDEBS)
287 @echo Total system size: $(shell du -h -s $(DEST) | cut -f 1)
288 @echo Compresses to: $(COMPRESSED_SZ)k
289 @echo Single Floppy kernel must be less than: ~$(shell expr $(FLOPPY_SIZE) - $(COMPRESSED_SZ) )k
290 @if [ -e $(TMPDIR)/.floppy_free_stat ]; then \
291 echo Single net floppy currently has `cat $(TMPDIR)/.floppy_free_stat` free!; \
292 fi
293 # Add your interesting stats here.
294
295
296 # Upload a daily build to klecker. If you're not Joey Hess, you probably
297 # don't want to use this grungy code, at least not without overrideing
298 # this:
299 UPLOAD_DIR=klecker.debian.org:~/public_html/debian-installer/daily/
300 daily_build:
301 fakeroot $(MAKE) image > log 2>&1
302 scp -q -B log $(UPLOAD_DIR)
303 scp -q -B ../debian-installer.tar.gz \
304 $(UPLOAD_DIR)/debian-installer-$(shell date +%Y%m%d).tar.gz
305 rm -f log
306

  ViewVC Help
Powered by ViewVC 1.1.5