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

Diff of /trunk/build/Makefile

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 629 by tfheen, Thu Mar 21 02:00:49 2002 UTC revision 4371 by waldi, Sun Sep 28 19:53:20 2003 UTC
# Line 1  Line 1 
1  #!/usr/bin/make -f  #!/usr/bin/make -f
2  #  #
3  # Debian Installer system makefile.  # Debian Installer system makefile.
4  # Copyright 2001 by Joey Hess <joeyh@debian.org>.  # Copyright 2001, 2002 by Joey Hess <joeyh@debian.org>.
5  # Licensed under the terms of the GPL.  # Licensed under the terms of the GPL.
6  #  #
7  # This makefile builds a debian-installer system and bootable images from  # This makefile builds a debian-installer system and bootable images from
8  # a collection of udebs which it downloads from a Debian archive. See  # a collection of udebs which it downloads from a Debian archive. See
9  # README for details.  # README for details.
10    
11  architecture    := $(shell dpkg-architecture -qDEB_HOST_ARCH)  DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
12    DEB_HOST_GNU_CPU = $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
13    DEB_HOST_GNU_SYSTEM = $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
14    
15    # Include main config
16    include config/main
17    
18    # Include arch configs
19    include config/arch/$(DEB_HOST_GNU_SYSTEM)
20    include config/arch/$(DEB_HOST_GNU_SYSTEM)-$(DEB_HOST_GNU_CPU)
21    
22    # Include type configs
23    -include config/type/$(TYPE)
24    -include config/type/$(TYPE)-$(DEB_HOST_GNU_SYSTEM)
25    -include config/type/$(TYPE)-$(DEB_HOST_ARCH)
26    
27  # The version of the kernel to use.  # Include directory config
28    include config/dir
29    
30  ifeq "$(architecture)" "i386"  ifeq (,$(filter $(TYPE),type $(TYPES_SUPPORTED)))
31  KVERS=2.4.18  ERROR_TYPE = 1
 FLAVOUR=386  
 endif  
   
 # The type of system to build. Determines what udebs are unpacked into  
 # the system. See the .list files for various types. You may want to  
 # override this on the command line.  
 TYPE=net  
   
 # The library reducer to use. Can be mklibs.sh or mklibs.py.  
 MKLIBS=./mklibs.sh  
   
 # List here any libraries that need to be put on the system. Generally  
 # this is not needed except for libnss_* libraries, which will not be  
 # automatically pulled in by the library reduction code. Wildcards are  
 # allowed.  
 # TODO: this really needs to be determined on a per TYPE basis.  
 #       libnss_nns is needed for many, but not all, install scenarios  
 EXTRALIBS=/lib/libnss_dns*  
   
 # List here any extra udebs that are not in the list file but that  
 # should still be included on the system.  
 EXTRAS=""  
   
 # This variable can be used to copy in additional files from the system  
 # that is doing the build. Useful if you need to include strace, or gdb,  
 # or just something extra on a floppy.  
 #EXTRAFILES=/usr/bin/strace  
   
 # set DEBUG to y if you want to get the source for and compile  
 # debug versions of the needed udebs  
 DEBUG=n  
   
 # All output files will go here.  
 DEST=dest  
   
 # Filename of initrd to create.  
 INITRD=$(DEST)/$(TYPE)-initrd.gz  
   
 # How big a floppy image should I make? (in kilobytes)  
 FLOPPY_SIZE=1440  
   
 # The floppy image to create.  
 FLOPPY_IMAGE=$(DEST)/$(TYPE)-$(FLOPPY_SIZE).img  
   
 # What device to write floppies on  
 FLOPPYDEV=/dev/fd0  
   
 # May be needed in rare cases.  
 #SYSLINUX_OPTS=-s  
   
 # Directory apt uses for stuff.  
 APTDIR=apt  
   
 # Directory udebs are placed in.  
 UDEBDIR=udebs  
   
 # Local directory that is searched for udebs, to avoid downloading.  
 # (Or for udebs that are not yet available for download.)  
 LOCALUDEBDIR=localudebs  
   
 # Directory where debug versions of udebs will be built.  
 DEBUGUDEBDIR=debugudebs  
   
 # The beta version of upx can be used to make the kernel a lot smaller  
 # it shaved 75k off our kernel. That allows us to put a lot more on  
 # a single floppy. binaries are at:  
 # http://wildsau.idv.uni-linz.ac.at/mfx/download/upx/unstable/upx-1.11-linux.tar.gz  
 # or source at:  
 # http://sourceforge.net/projects/upx/  
 #UPX=~davidw/bin/upx  
 UPX=  
   
 # Figure out which sources.list to use. The .local one is preferred,  
 # so you can set up a locally preferred one (and not accidentially cvs  
 # commit it).  
 ifeq ($(wildcard sources.list.local),sources.list.local)  
 SOURCES_LIST=sources.list.local  
 else  
 SOURCES_LIST=sources.list  
32  endif  endif
33    
34  # Add to PATH so dpkg will always work, and so local programs will  # Add to PATH so dpkg will always work, and so local programs will
# Line 109  APT_GET=apt-get --assume-yes \ Line 45  APT_GET=apt-get --assume-yes \
45          -o Dir::Cache=$(CWD)$(APTDIR)/cache          -o Dir::Cache=$(CWD)$(APTDIR)/cache
46    
47  # Get the list of udebs to install. Comments are allowed in the lists.  # Get the list of udebs to install. Comments are allowed in the lists.
48  UDEBS=$(shell grep --no-filename -v ^\# lists/base lists/$(TYPE) | sed 's/$${kernel:Version}/$(KVERS)/g' | sed 's/$${kernel:Flavour}/$(FLAVOUR)/g') $(EXTRAS)  UDEBS = \
49            $(shell (\
50                    if [ ! "${NO_KERNEL}" ]; then echo 'kernel-image-$${kernel:Version}-udeb'; fi; \
51                    grep --no-filename -v ^\# \
52                            `if [ ! "${NO_BASE}" ]; then echo pkg-lists/base; fi` \
53                            pkg-lists/$(TYPE)/common \
54                            `if [ -f pkg-lists/$(TYPE)/$(DEB_HOST_ARCH) ]; then echo pkg-lists/$(TYPE)/$(DEB_HOST_ARCH); fi` \
55                    ) | sed -e 's/^\(.*\)$${kernel:Version}\(.*\)$$/$(foreach VERSION,$(KERNELIMAGEVERSION),\1$(VERSION)\2\n)/g' \
56            ) $(EXTRAS)
57    
58    ifeq ($(TYPE),floppy)
59    # List of additional udebs for driver floppys.
60    DRIVERFD_UDEBS = \
61            $(shell for target in $(EXTRA_FLOPPIES) ; do  grep --no-filename -v ^\# \
62                    pkg-lists/$$target/common \
63                    `if [ -f pkg-lists/$$target/$(DEB_HOST_ARCH) ]; then echo pkg-lists/$$target/$(DEB_HOST_ARCH); fi` \
64                    | sed -e 's/^\(.*\)$${kernel:Version}\(.*\)$$/$(foreach VERSION,$(KERNELIMAGEVERSION),\1$(VERSION)\2\n)/g'  ; done )
65    endif
66    
67  DPKGDIR=$(TREE)/var/lib/dpkg  # Scratch directory.
68  TEMP=./tmp  BASE_TMP=./tmp/
69  TMP_MNT=`pwd`/mnt/  # Per-type scratch directory.
70    TEMP=$(BASE_TMP)$(TYPE)
71    
72  # Build tree location.  # Build tree location.
73  TREE=$(TEMP)/tree  TREE=$(TEMP)/tree
74    
75  # This is the kernel image that we will boot from.  LOCALE_PATH=$(TREE)/usr/lib/locale
76  KERNEL=$(TEMP)/vmlinuz  
77    # CD Image tree location
78    CD_IMAGE_TREE=$(TEMP)/cd_image_tree
79    
80  build: demo_clean tree stats  DPKGDIR=$(TREE)/var/lib/dpkg
81    DRIVEREXTRASDIR=$(TREE)/driver-tmp
82    DRIVEREXTRASDPKGDIR=$(DRIVEREXTRASDIR)/var/lib/dpkg
83    
84    TMP_MNT:=$(shell pwd)/mnt
85    
86    ifdef ERROR_TYPE
87    %:
88            @echo "unsupported type"
89            @echo "type: $(TYPE)"
90            @echo "supported types: $(TYPES_SUPPORTED)"
91            @exit 1
92    endif
93    
94    build: tree_umount tree $(EXTRA_TARGETS) stats
95    
96    image: arch-image $(EXTRA_IMAGES)
97    
98    # Include arch targets
99    -include make/arch/$(DEB_HOST_GNU_SYSTEM)
100    include make/arch/$(DEB_HOST_GNU_SYSTEM)-$(DEB_HOST_GNU_CPU)
101    
102    tree_mount: tree
103            -@sudo /bin/mount -t proc proc $(TREE)/proc
104    ifndef USERDEVFS
105            -@sudo /bin/mount -t devfs dev $(TREE)/dev
106    else
107            -@sudo chroot $(TREE) /usr/bin/update-dev
108    endif
109    
110    tree_umount:
111    ifndef USERDEVFS
112            -@if [ -L $(TREE)/dev/fd ] ; then sudo /bin/umount $(TREE)/dev 2>/dev/null ; fi
113    endif
114            -@if [ -L $(TREE)/proc/self ] ; then sudo /bin/umount $(TREE)/proc 2>/dev/null ; fi
115    
116  demo: tree  demo: tree
117          sudo chroot $(TREE) bin/sh -c "if ! mount | grep ^proc ; then bin/mount proc -t proc /proc; fi"          $(MAKE) tree_mount
118          -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"          -@[ -f questions.dat ] && cp -f questions.dat $(TREE)/var/lib/cdebconf/
119          $(MAKE) demo_clean          -@sudo chroot $(TREE) bin/sh -c "export TERM=linux; export DEBCONF_DEBUG=5; /usr/bin/debconf-loadtemplate debian /var/lib/dpkg/info/*.templates; exec /usr/share/debconf/frontend /usr/bin/main-menu"
120            $(MAKE) tree_umount
121    
122  shell: tree  shell: tree
123          mkdir -p $(TREE)/proc          $(MAKE) tree_mount
124          sudo chroot $(TREE) bin/sh -c "if ! mount | grep ^proc ; then bin/mount proc -t proc /proc; fi"          -@sudo chroot $(TREE) bin/sh
125          sudo chroot $(TREE) bin/sh          $(MAKE) tree_umount
126          $(MAKE) demo_clean  
127    uml: $(INITRD)
128  demo_clean:          -linux initrd=$(INITRD) root=/dev/rd/0 ramdisk_size=8192 con=fd:0,fd:1 devfs=mount
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; \  demo_clean: tree_umount
131    
132    clean: demo_clean tmp_mount debian/control
133            if [ "$(USER_MOUNT_HACK)" ] ; then \
134                if mount | grep -q "$(USER_MOUNT_HACK)"; then \
135                    umount "$(USER_MOUNT_HACK)";\
136                fi ; \
137          fi          fi
138            rm -rf $(TREE) $(TEMP)/modules $(NETDRIVERS) || sudo rm -rf $(TREE)
 clean: demo_clean  
139          dh_clean          dh_clean
140          rm -f *-stamp          rm -f *-stamp
141          rm -rf $(TREE) $(APTDIR) $(UDEBDIR) $(TEMP) $(DEST)          rm -rf $(UDEBDIR) $(EXTRAUDEBDIR) $(TMP_MNT) debian/build
142            rm -rf $(DEST)/$(TYPE)-* || sudo rm -rf $(DEST)/$(TYPE)-*
143            rm -f unifont-reduced-$(TYPE).bdf
144            $(foreach NAME,$(KERNELNAME), \
145                    rm -f $(TEMP)/$(NAME); )
146    
147    reallyclean: clean
148            rm -rf $(APTDIR) $(DEST) $(BASE_TMP) wget-cache $(SOURCEDIR)
149            rm -f diskusage*.txt missing.txt all-*.utf *.bdf
150    
151    # prefetch udebs
152    # If we are building a correct debian-installer source tree, we will want all the
153    # sources. So go fetch.
154    fetch-sources: $(SOURCEDIR)/udeb-sources-stamp
155    $(SOURCEDIR)/udeb-sources-stamp:
156            mkdir -p $(APTDIR)/state/lists/partial
157            mkdir -p $(APTDIR)/cache/archives/partial
158            $(APT_GET) update
159            $(APT_GET) autoclean
160            needed="$(UDEBS) $(DRIVERFD_UDEBS)"; \
161            for file in `find $(LOCALUDEBDIR) -name "*_*" -printf "%f\n" 2>/dev/null`; do \
162                    package=`echo $$file | cut -d _ -f 1`; \
163                    needed=`echo " $$needed " | sed "s/ $$package */ /"` ; \
164            done; \
165            mkdir -p $(SOURCEDIR); \
166            cd $(SOURCEDIR); \
167            $(APT_GET) source --yes $$needed; \
168            rm -f *.dsc *.gz ; \
169            touch udeb-sources-stamp ; \
170            cd ..
171    
172    
173    #  From the sources,
174    #  Compile up all the udebs and place them in udebs
175    #  This is used by build-installer to avoid downloading from net.
176    compile-udebs: compiled-stamp
177    compiled-stamp: $(SOURCEDIR)/udeb-sources-stamp
178            mkdir -p $(APTDIR)/cache/archives
179            for d in ` ls $(SOURCEDIR) | grep -v stamp ` ; do  \
180                     ( unset MAKEFLAGS ; unset MAKELEVEL ; cd $(SOURCEDIR)/$$d ; dpkg-buildpackage -uc -us || true  ) ; \
181            done
182            mv $(SOURCEDIR)/*.udeb $(APTDIR)/cache/archives
183            touch compiled-stamp
184    
185    #
186  # Get all required udebs and put in UDEBDIR.  # Get all required udebs and put in UDEBDIR.
187  get_udebs: get_udebs-stamp  get_udebs: $(TYPE)-get_udebs-stamp
188  get_udebs-stamp:  $(TYPE)-get_udebs-stamp:
189          mkdir -p $(APTDIR)/state/lists/partial          mkdir -p $(APTDIR)/state/lists/partial
190          mkdir -p $(APTDIR)/cache/archives/partial          mkdir -p $(APTDIR)/cache/archives/partial
191          $(APT_GET) update          $(APT_GET) update
192          $(APT_GET) autoclean          $(APT_GET) autoclean
193          # If there are local udebs, remove them from the list of things to          # If there are local udebs, remove them from the list of things to
194          # get. Then get all the udebs that are left to get.          # get. Then get all the udebs that are left to get.
195          needed="$(UDEBS)"; \          # Note that the trailing blank on the next line is significant. It
196            # makes the sed below always work.
197            needed="$(UDEBS) $(DRIVERFD_UDEBS) "; \
198          for file in `find $(LOCALUDEBDIR) -name "*_*" -printf "%f\n" 2>/dev/null`; do \          for file in `find $(LOCALUDEBDIR) -name "*_*" -printf "%f\n" 2>/dev/null`; do \
199                  package=`echo $$file | cut -d _ -f 1`; \                  package=`echo $$file | cut -d _ -f 1`; \
200                  needed=`echo $$needed | sed "s/$$package *//"`; \                  needed=`echo " $$needed " | sed "s/ $$package / /"`; \
201          done; \          done; \
202          if [ $(DEBUG) = y ] ; then \          if [ "$(DEBUG)" = y ] ; then \
203                  mkdir -p $(DEBUGUDEBDIR); \                  mkdir -p $(DEBUGUDEBDIR); \
204                  cd $(DEBUGUDEBDIR); \                  cd $(DEBUGUDEBDIR); \
205                  export DEB_BUILD_OPTIONS="debug"; \                  export DEB_BUILD_OPTIONS="debug"; \
# Line 171  get_udebs-stamp: Line 212  get_udebs-stamp:
212                  fi; \                  fi; \
213          fi; \          fi; \
214    
215          # Now the udebs are in APTDIR/cache/archives/ and maybe LOCALUDEBDIR,          # Now the udebs are in APTDIR/cache/archives/ and maybe LOCALUDEBDIR
216          # but there may be other udebs there too besides those we asked for.          # or DEBUGUDEBDIR, but there may be other udebs there too besides those
217          # So link those we asked for to UDEBDIR, renaming them to more useful          # we asked for.  So link those we asked for to UDEBDIR, renaming them
218          # names.          # to more useful names. Watch out for duplicates and missing files
219            # while doing that.
220          rm -rf $(UDEBDIR)          rm -rf $(UDEBDIR)
221          mkdir -p $(UDEBDIR)          mkdir -p $(UDEBDIR)
222          for package in $(UDEBS); do \          rm -rf $(EXTRAUDEBDIR)
223                  if [ -e $(APTDIR)/cache/archives/$$package\_* ]; then \          mkdir -p $(EXTRAUDEBDIR)
224                          ln -f $(APTDIR)/cache/archives/$$package\_* \          lnpkg() { \
225                                  $(UDEBDIR)/$$package.udeb; \                  local pkg=$$1; local dir=$$2 debdir=$$3; \
226                    local L1="`echo $$dir/$$pkg\_*`"; \
227                    local L2="`echo $$L1 | sed -e 's, ,,g'`"; \
228                    if [ "$$L1" != "$$L2" ]; then \
229                            echo "Duplicate package $$pkg in $$dir/"; \
230                            exit 1; \
231                  fi; \                  fi; \
232                  if [ -e $(LOCALUDEBDIR)/$$package\_* ]; then \                  if [ -e $$L1 ]; then \
233                          ln -f $(LOCALUDEBDIR)/$$package\_* \                          ln -f $$dir/$$pkg\_* $$debdir/$$pkg.udeb; \
                                 $(UDEBDIR)/$$package.udeb; \  
234                  fi; \                  fi; \
235                  if [ -e $(DEBUGUDEBDIR)/$$package\_*.udeb ]; then \          }; \
236                          ln -f $(DEBUGUDEBDIR)/$$package\_*.udeb \          for package in $(UDEBS) ; do \
237                                  $(UDEBDIR)/$$package.udeb; \                  lnpkg $$package $(APTDIR)/cache/archives $(UDEBDIR); \
238                    lnpkg $$package $(LOCALUDEBDIR) $(UDEBDIR); \
239                    lnpkg $$package $(DEBUGUDEBDIR) $(UDEBDIR); \
240                    if ! [ -e $(UDEBDIR)/$$package.udeb ]; then \
241                            echo "Needed $$package not found (looked in $(APTDIR)/cache/archives/, $(LOCALUDEBDIR)/, $(DEBUGUDEBDIR)/)"; \
242                            exit 1; \
243                  fi; \                  fi; \
244          done          done ; \
245            for package in $(DRIVERFD_UDEBS) ; do \
246                    lnpkg $$package $(APTDIR)/cache/archives $(EXTRAUDEBDIR); \
247                    lnpkg $$package $(LOCALUDEBDIR) $(EXTRAUDEBDIR); \
248                    lnpkg $$package $(DEBUGUDEBDIR) $(EXTRAUDEBDIR); \
249                    if ! [ -e $(EXTRAUDEBDIR)/$$package.udeb ]; then \
250                            echo "Needed $$package not found (looked in $(APTDIR)/cache/archives/, $(LOCALUDEBDIR)/, $(DEBUGUDEBDIR)/)"; \
251                            exit 1; \
252                    fi; \
253            done
254    
255          touch get_udebs-stamp          touch $(TYPE)-get_udebs-stamp
256    
257    
258  # Build the installer tree.  # Build the installer tree.
259  tree: get_udebs tree-stamp  tree: $(TYPE)-tree-stamp
260  tree-stamp:  $(TYPE)-tree-stamp: $(TYPE)-get_udebs-stamp debian/control
261          dh_testroot          dh_testroot
262    
263          dpkg-checkbuilddeps          dpkg-checkbuilddeps
264    
265          # This build cannot be restarted, because dpkg gets confused.          # This build cannot be restarted, because dpkg gets confused.
266          rm -rf $(TREE)          rm -rf $(TREE) $(TEMP)/modules
267          # Set up the basic files [u]dpkg needs.          # Set up the basic files [u]dpkg needs.
268          mkdir -p $(DPKGDIR)/info          mkdir -p $(DPKGDIR)/info
269          touch $(DPKGDIR)/status          touch $(DPKGDIR)/status
# Line 212  tree-stamp: Line 272  tree-stamp:
272          # Only dpkg needs this stuff, so it can be removed later.          # Only dpkg needs this stuff, so it can be removed later.
273          mkdir -p $(DPKGDIR)/updates/          mkdir -p $(DPKGDIR)/updates/
274          touch $(DPKGDIR)/available          touch $(DPKGDIR)/available
275          # Unpack the udebs with dpkg. This command must run as root or fakeroot.  
276          dpkg --force-overwrite --root=$(TREE) --unpack $(UDEBDIR)/*.udeb          # Unpack the udebs with dpkg. This command must run as root
277            # or fakeroot.
278            echo -n > diskusage-$(TYPE).txt
279            oldsize=0; oldblocks=0; oldcount=0; for udeb in $(UDEBDIR)/*.udeb ; do \
280                    pkg=`basename $$udeb` ; \
281                    dpkg --force-overwrite --root=$(TREE) --unpack $$udeb ; \
282                    newsize=`du -bs $(TREE) | awk '{print $$1}'` ; \
283                    newblocks=`du -s $(TREE) | awk '{print $$1}'` ; \
284                    newcount=`find $(TREE) -type f | wc -l | awk '{print $$1}'` ; \
285                    usedsize=`echo $$newsize - $$oldsize | bc`; \
286                    usedblocks=`echo $$newblocks - $$oldblocks | bc`; \
287                    usedcount=`echo $$newcount - $$oldcount | bc`; \
288                    version=`dpkg-deb --info $$udeb | grep Version: | awk '{print $$2}'` ; \
289                    echo " $$usedsize B - $$usedblocks blocks - $$usedcount files used by pkg $$pkg (version $$version )" >>diskusage-$(TYPE).txt;\
290                    oldsize=$$newsize ; \
291                    oldblocks=$$newblocks ; \
292                    oldcount=$$newcount ; \
293            done
294            sort -n < diskusage-$(TYPE).txt > diskusage-$(TYPE).txt.new && \
295                    mv diskusage-$(TYPE).txt.new diskusage-$(TYPE).txt
296    
297          # Clean up after dpkg.          # Clean up after dpkg.
298          rm -rf $(DPKGDIR)/updates          rm -rf $(DPKGDIR)/updates
299          rm -f $(DPKGDIR)/available $(DPKGDIR)/*-old $(DPKGDIR)/lock          rm -f $(DPKGDIR)/available $(DPKGDIR)/*-old $(DPKGDIR)/lock
300          # Set up modules.dep  ifdef USERDEVFS
301          mkdir -p $(TREE)/lib/modules/$(KVERS)-$(FLAVOUR)/          # Create initial /dev entries -- only those that are absolutely
302          depmod -q -a -b $(TREE)/ $(KVERS)-$(FLAVOUR)          # required to boot sensibly, though.
303            mknod $(TREE)/dev/console c 5 1
304            mkdir -p $(TREE)/dev/vc
305            mknod $(TREE)/dev/vc/0 c 4 0
306            mknod $(TREE)/dev/vc/1 c 4 1
307            mknod $(TREE)/dev/vc/2 c 4 2
308            mknod $(TREE)/dev/vc/3 c 4 3
309            mknod $(TREE)/dev/vc/4 c 4 4
310            mknod $(TREE)/dev/vc/5 c 4 5
311            mkdir -p $(TREE)/dev/rd
312            mknod $(TREE)/dev/rd/0 b 1 0
313    endif
314            # Set up modules.dep, ensure there is at least one standard dir (kernel
315            # in this case), so depmod will use its prune list for archs with no
316            # modules.
317            $(foreach VERSION,$(KERNELVERSION), \
318                    mkdir -p $(TREE)/lib/modules/$(VERSION)/kernel; \
319                    depmod -q -a -b $(TREE)/ $(VERSION); )
320          # These files depmod makes are used by hotplug, and we shouldn't          # These files depmod makes are used by hotplug, and we shouldn't
321          # need them, yet anyway.          # need them, yet anyway.
322          find $(TREE)/lib/modules/$(KVERS)-$(FLAVOUR)/ -name 'modules*' \          find $(TREE)/lib/modules/ -name 'modules*' \
323                  -not -name modules.dep | xargs rm -f                  -not -name modules.dep -not -type d | xargs rm -f
324          # Install /dev devices (but not too much)          # Create a dev tree
325          mkdir -p $(TREE)/dev          mkdir -p $(TREE)/dev
         cd $(TREE)/dev && /sbin/MAKEDEV std console  
         rm $(TREE)/dev/vcs*  
         rm $(TREE)/dev/tty[1-9][0-9]  
         if [ ! -c $(TREE)/dev/console ]; then \  
             echo "WARNING: $(TREE)/dev/console isn't a character device as it should."; \  
             echo "This does probably mean that you should start again with root rights."; \  
         fi  
326    
327    ifndef NO_KERNEL
328          # Move the kernel image out of the way, into a temp directory          # Move the kernel image out of the way, into a temp directory
329          # for use later. We don't need it bloating our image!          # for use later. We don't need it bloating our image!
330          mv -f $(TREE)/boot/vmlinuz $(KERNEL)          $(foreach NAME,$(KERNELNAME), \
331                    mv -f $(TREE)/boot/$(NAME) $(TEMP); )
332          -rmdir $(TREE)/boot/          -rmdir $(TREE)/boot/
333    endif
334    
335          # Copy terminfo files for slang frontend          # Copy terminfo files for slang frontend
336          # TODO: terminfo.udeb?          # TODO: terminfo.udeb?
# Line 260  ifdef EXTRALIBS Line 353  ifdef EXTRALIBS
353          cp -a $(EXTRALIBS) $(TREE)/lib/          cp -a $(EXTRALIBS) $(TREE)/lib/
354  endif  endif
355    
356    ifeq ($(TYPE),floppy)
357            # Unpack additional driver disks, so mklibs runs on them too.
358            rm -rf $(DRIVEREXTRASDIR)
359            mkdir -p $(DRIVEREXTRASDIR)
360            mkdir -p $(DRIVEREXTRASDPKGDIR)/info $(DRIVEREXTRASDPKGDIR)/updates
361            touch $(DRIVEREXTRASDPKGDIR)/status $(DRIVEREXTRASDPKGDIR)/available
362            for udeb in $(EXTRAUDEBDIR)/*.udeb ; do \
363                    dpkg --force-overwrite --root=$(DRIVEREXTRASDIR) --unpack $$udeb; \
364            done
365    endif
366            # If the image has pcmcia, reduce the config file to list only
367            # entries that there are modules on the image. This saves ~30k.
368            if [ -e $(TREE)/etc/pcmcia/config ]; then \
369                    ./pcmcia-config-reduce.pl $(TREE)/etc/pcmcia/config \
370                            `if [ -d "$(DRIVEREXTRASDIR)" ]; then find $(DRIVEREXTRASDIR)/lib/modules -name \*.o; fi` \
371                            `find $(TREE)/lib/modules/ -name \*.o` > \
372                            $(TREE)/etc/pcmcia/config.reduced; \
373                    mv -f $(TREE)/etc/pcmcia/config.reduced $(TREE)/etc/pcmcia/config; \
374            fi
375    
376          # Library reduction.          # Library reduction.
377          mkdir -p $(TREE)/lib          mkdir -p $(TREE)/lib
378          $(MKLIBS) -d $(TREE)/lib `find $(TREE) -type f -perm +0111 -o -name '*.so'`          $(MKLIBS) -v -d $(TREE)/lib --root=$(TREE) `find $(TEMP) -type f -perm +0111 -o -name '*.so'`
379    
380          # Add missing symlinks for libraries          # Add missing symlinks for libraries
381          # (Needed for mklibs.py)          # (Needed for mklibs.py)
382  #       /sbin/ldconfig -n $(TREE)/lib $(TREE)/usr/lib          /sbin/ldconfig -n $(TREE)/lib $(TREE)/usr/lib
383    
384          # Remove any libraries that are present in both usr/lib and lib,          # Remove any libraries that are present in both usr/lib and lib,
385          # from lib. These were unnecessarily copied in by mklibs, and          # from lib. These were unnecessarily copied in by mklibs, and
# Line 288  endif Line 401  endif
401          done          done
402    
403          # Reduce status file to contain only the elements we care about.          # Reduce status file to contain only the elements we care about.
404          egrep -i '^((Status|Provides|Depends|Package|Description|installer-menu-item|Description-..):|$$)' \          egrep -i '^((Status|Provides|Depends|Package|Version|Description|installer-menu-item|Description-..):|$$)' \
405                  $(DPKGDIR)/status > $(DPKGDIR)/status.udeb                  $(DPKGDIR)/status > $(DPKGDIR)/status.udeb
406          rm -f $(DPKGDIR)/status          rm -f $(DPKGDIR)/status
407          ln -sf status.udeb $(DPKGDIR)/status          ln -sf status.udeb $(DPKGDIR)/status
408    
409    ifdef NO_I18N
410            # Remove all internationalization from the templates.
411            # Not ideal, but useful if you're very tight on space.
412            for FILE in $$(find $(TREE) -name "*.templates"); do \
413                    perl -e 'my $$status = 0; while (<>) { if (/^[A-Z]/ || /^$$/) { if (/^(Choices|Description)-/) { $$status = 0; } else { $$status = 1; } } print if ($$status); }' < $$FILE > temp; \
414                    mv temp $$FILE; \
415            done
416    endif
417    
418          # Strip all kernel modules, just in case they haven't already been          # Strip all kernel modules, just in case they haven't already been
419          for module in `find $(TREE)/lib/modules/ -name '*.o'`; do \          for module in `find $(TREE)/lib/modules/ -name '*.o'`; do \
420              strip -R .comment -R .note -g -x $$module; \              strip -R .comment -R .note -g $$module; \
421          done          done
422    
423          # Remove some unnecessary dpkg files.          # Remove some unnecessary dpkg files.
# Line 305  endif Line 427  endif
427              rm $$file; \              rm $$file; \
428          done          done
429    
430          touch tree-stamp          touch $(TYPE)-tree-stamp
431    
432            # Collect the used UTF-8 strings, to know which glyphs to include in
433            # the font.  Using strings is not the best way, but no better suggestion
434            # has been made yet.
435            cp graphic.utf all-$(TYPE).utf
436    ifeq ($(TYPE),floppy)
437            if [ -n "`find $(DRIVEREXTRASDPKGDIR)/info/ -name \\*.templates`" ]; then \
438                    cat $(DRIVEREXTRASDPKGDIR)/info/*.templates >> all-$(TYPE).utf; \
439            fi
440    endif
441            if [ -n "`find $(DPKGDIR)/info/ -name \\*.templates`" ]; then \
442                    cat $(DPKGDIR)/info/*.templates >> all-$(TYPE).utf; \
443            fi
444            find $(TREE) -type f | xargs strings >> all-$(TYPE).utf
445    
446    ifeq ($(TYPE),floppy)
447            # Remove additional driver disk contents now that we're done with
448            # them.
449            rm -rf $(DRIVEREXTRASDIR)
450    endif
451            # Tree target ends here. Whew!
452    
453    
454    unifont-reduced-$(TYPE).bdf: all-$(TYPE).utf
455            # Use the UTF-8 locale in rootskel-locale. This target shouldn't
456            # be called when it is not present anyway.
457            # reduce-font is part of package libbogl-dev
458            # unifont.bdf is part of package bf-utf-source
459            # The locale must be generated after installing the package locales
460            CHARMAP=`LOCPATH=$(LOCALE_PATH) LC_ALL=C.UTF-8 locale charmap`; \
461                if [ UTF-8 != "$$CHARMAP" ]; then \
462                    echo "error: Trying to build unifont.bgf without rootskel-locale!"; \
463                    exit 1; \
464                fi
465            LOCPATH=$(LOCALE_PATH) LC_ALL=C.UTF-8 reduce-font /usr/src/unifont.bdf < all-$(TYPE).utf > $@.tmp
466            mv $@.tmp $@
467    
468    $(TREE)/unifont.bgf: unifont-reduced-$(TYPE).bdf
469            # bdftobogl is part of package libbogl-dev
470            bdftobogl -b unifont-reduced-$(TYPE).bdf > $@.tmp
471            mv $@.tmp $@
472    
473    # Build the driver floppy image
474    $(EXTRA_TARGETS) : %-stamp : $(TYPE)-get_udebs-stamp
475            mkdir -p  ${TEMP}/$*
476            for file in $(shell grep --no-filename -v ^\#  pkg-lists/$*/common \
477                    `if [ -f pkg-lists/$*/$(DEB_HOST_ARCH) ]; then echo pkg-lists/$*/$(DEB_HOST_ARCH); fi` \
478                    | sed -e 's/^\(.*\)$${kernel:Version}\(.*\)$$/$(foreach VERSION,$(KERNELIMAGEVERSION),\1$(VERSION)\2\n)/g' ) ; do \
479                            cp $(EXTRAUDEBDIR)/$$file* ${TEMP}/$*  ; \
480                            echo $$file >> ${TEMP}/$*/udeb_include; \
481            done
482            touch $@
483    
484    
485    $(EXTRA_IMAGES) : $(DEST)/%-image.img :  $(EXTRA_TARGETS)
486            rm -f $@
487            install -d $(TEMP)
488            install -d $(DEST)
489            set -e; if [ $(INITRD_FS) = ext2 ]; then \
490                    genext2fs -d $(TEMP)/$* -b $(FLOPPY_SIZE) -r 0  $@; \
491            elif [ $(INITRD_FS) = romfs ]; then \
492                    genromfs -d $(TEMP)/$* -f $@; \
493            else \
494                    echo "Unsupported filesystem type"; \
495                    exit 1; \
496            fi;
497    
498    
499  tarball: tree  tarball: tree
500          tar czf $(DEST)/$(TYPE)-debian-installer.tar.gz $(TREE)          tar czf $(DEST)/$(TYPE)-debian-installer.tar.gz $(TREE)
501    
502  # Make sure that the temporary mountpoint exists and is not occupied.  # Make sure that the temporary mountpoint exists and is not occupied.
503  tmp_mount:  tmp_mount:
         dh_testroot  
504          if mount | grep -q $(TMP_MNT) && ! umount $(TMP_MNT) ; then \          if mount | grep -q $(TMP_MNT) && ! umount $(TMP_MNT) ; then \
505                  echo "Error unmounting $(TMP_MNT)" 2>&1 ; \                  echo "Error unmounting $(TMP_MNT)" 2>&1 ; \
506                  exit 1; \                  exit 1; \
# Line 320  tmp_mount: Line 508  tmp_mount:
508          mkdir -p $(TMP_MNT)          mkdir -p $(TMP_MNT)
509    
510  # Create a compressed image of the root filesystem by way of genext2fs.  # Create a compressed image of the root filesystem by way of genext2fs.
511    initrd: $(INITRD)
 initrd: Makefile tmp_mount tree $(INITRD)  
512  $(INITRD): TMP_FILE=$(TEMP)/image.tmp  $(INITRD): TMP_FILE=$(TEMP)/image.tmp
513  $(INITRD):  $(INITRD):  $(TYPE)-tree-stamp
514          dh_testroot  # Only build the font if we have rootskel-locale
515            if [ -d "$(LOCALE_PATH)/C.UTF-8" ]; then \
516                $(MAKE) $(TREE)/unifont.bgf; \
517            fi
518          rm -f $(TMP_FILE)          rm -f $(TMP_FILE)
519          install -d $(TEMP)          install -d $(TEMP)
520          install -d $(DEST)          install -d $(DEST)
         genext2fs -d $(TREE) -b `expr $$(du -s $(TREE) | cut -f 1) + $$(expr $$(find $(TREE) | wc -l) \* 2)` $(TMP_FILE)  
         dd if=$(TMP_FILE) bs=1k | gzip -v9 > $(INITRD)  
   
 # Create a bootable floppy image. i386 specific. FIXME  
 # 1. make a dos filesystem image  
 # 2. copy over kernel, initrd  
 # 3. install syslinux  
 floppy_image: Makefile initrd tmp_mount $(FLOPPY_IMAGE)  
 $(FLOPPY_IMAGE):  
         dh_testroot  
         install -d $(DEST)  
521    
522          dd if=/dev/zero of=$(FLOPPY_IMAGE) bs=1k count=$(FLOPPY_SIZE)          if [ $(INITRD_FS) = ext2 ]; then \
523          mkfs.msdos -i deb00001 -n 'Debian Installer' -C $(FLOPPY_IMAGE) $(FLOPPY_SIZE)                  genext2fs -d $(TREE) -b `expr $$(du -s $(TREE) | cut -f 1) + $$(expr $$(find $(TREE) | wc -l) \* 2)` $(TMP_FILE); \
524          mount -t vfat -o loop $(FLOPPY_IMAGE) $(TMP_MNT)          elif [ $(INITRD_FS) = romfs ]; then \
525                    genromfs -d $(TREE) -f $(TMP_FILE); \
526          cp $(KERNEL) $(TMP_MNT)/linux          else \
527          cp $(INITRD) $(TMP_MNT)/initrd.gz                  echo "Unsupported filesystem type"; \
528                    exit 1; \
529          cp syslinux.cfg $(TMP_MNT)/          fi;
530          todos $(TMP_MNT)/syslinux.cfg          gzip -vc9 $(TMP_FILE) > $(INITRD).tmp
531          umount $(TMP_MNT)          mv $(INITRD).tmp $(INITRD)
         syslinux $(SYSLINUX_OPTS) $(FLOPPY_IMAGE)  
532    
533  # Write image to floppy  # Write image to floppy
534  boot_floppy: floppy_image  floppy: boot_floppy
535    boot_floppy: $(IMAGE)
536            install -d $(DEST)
537            dd if=$(IMAGE) of=$(FLOPPYDEV) bs=$(FLOPPY_SIZE)k
538    
539    # Write drivers  floppy
540    %_floppy: $(DEST)/%-image.img
541          install -d $(DEST)          install -d $(DEST)
542          dd if=$(FLOPPY_IMAGE) of=$(FLOPPYDEV)          dd if=$< of=$(FLOPPYDEV)
543    
544  # If you're paranoid (or things are mysteriously breaking..),  # If you're paranoid (or things are mysteriously breaking..),
545  # you can check the floppy to make sure it wrote properly.  # you can check the floppy to make sure it wrote properly.
546  # This target will fail if the floppy doesn't match the floppy image.  # This target will fail if the floppy doesn't match the floppy image.
547  boot_floppy_check: floppy_image  boot_floppy_check: floppy_image
548          cmp $(FLOPPYDEV) $(FLOPPY_IMAGE)          cmp $(FLOPPYDEV) $(IMAGE)
549    
550  COMPRESSED_SZ=$(shell expr $(shell tar cz $(TREE) | wc -c) / 1024)  stats: tree $(EXTRA_TARGETS) general-stats $(EXTRA_STATS)
551  KERNEL_SZ=$(shell expr $(shell du -b $(KERNEL) | cut -f 1) / 1024)  
552  stats: tree  COMPRESSED_SZ=$(shell expr $(shell tar czf - $(TREE) | wc -c) / 1024)
553    KERNEL_SZ=$(shell expr \( $(foreach NAME,$(KERNELNAME),$(shell du -b $(TEMP)/$(NAME) 2>/dev/null | cut -f 1) +) 0 \) / 1024)
554    general-stats:
555          @echo          @echo
556          @echo "System stats"          @echo "System stats for $(TYPE)"
557          @echo "------------"          @echo "-------------------------"
558          @echo "Installed udebs: $(UDEBS)"          @echo "Installed udebs: $(UDEBS)"
559          @echo -n "Total system size: $(shell du -h -s $(TREE) | cut -f 1)"          @echo -n "Total system size: $(shell du -h -s $(TREE) | cut -f 1)"
560          @echo -n " ($(shell du -h --exclude=modules -s $(TREE)/lib | cut -f 1) libs, "          @echo -n " ($(shell du -h --exclude=modules -s $(TREE)/lib | cut -f 1) libs, "
561          @echo "$(shell du -h -s $(TREE)/lib/modules | cut -f 1) kernel modules)"          @echo "$(shell du -h -s $(TREE)/lib/modules | cut -f 1) kernel modules)"
562          @echo "Initrd size: $(COMPRESSED_SZ)k"          @echo "Initrd size: $(COMPRESSED_SZ)k"
563          @echo "Kernel size: $(KERNEL_SZ)k"          @echo "Kernel size: $(KERNEL_SZ)k"
564    ifneq (,$(FLOPPY_SIZE))
565          @echo "Free space: $(shell expr $(FLOPPY_SIZE) - $(KERNEL_SZ) - $(COMPRESSED_SZ))k"          @echo "Free space: $(shell expr $(FLOPPY_SIZE) - $(KERNEL_SZ) - $(COMPRESSED_SZ))k"
566    endif
567            @echo "Disk usage per package:"
568            @sed 's/^/  /' < diskusage-$(TYPE).txt
569  # Add your interesting stats here.  # Add your interesting stats here.
570    
571    SZ=$(shell expr $(shell du -b $(TEMP)/$*  | cut -f 1 ) / 1024)
572    $(EXTRA_STATS) : %-stats:
573            @echo
574            @echo "$* size: $(SZ)k"
575    ifneq (,$(FLOPPY_SIZE))
576            @echo "Free space: $(shell expr $(FLOPPY_SIZE) - $(SZ))k"
577    endif
578            @echo "Disk usage per package:"
579            @ls -l $(TEMP)/$*/*.udeb
580    
581    # These tagets build all available types.
582    all_build:
583            set -e; for type in $(TYPES_SUPPORTED); do \
584                    $(MAKE) build TYPE=$$type; \
585            done
586    all_images:
587            set -e; for type in $(TYPES_SUPPORTED); do \
588                    $(MAKE) image TYPE=$$type; \
589            done
590    # Suitable for a cron job, you'll only see the stats unless a build fails.
591    all_stats:
592            @echo "Image size stats"
593            @echo
594            @(set -e; $(MAKE) all_build >tmp/log 2>&1 || \
595              (echo "build failure!"; cat tmp/log; false))
596            @rm -f tmp/log
597            @for type in $(TYPES_SUPPORTED); do \
598                    $(MAKE) -s stats TYPE=$$type; \
599            done
600    
601  # Upload a daily build to klecker. If you're not Joey Hess, you probably  # Upload a daily build to peope.debian.org. If you're not Joey Hess,
602  # don't want to use this grungy code, at least not without overrideing  # you probably don't want to use this grungy code, at least not without
603  # this:  # overriding this:
604  UPLOAD_DIR=klecker.debian.org:~/public_html/debian-installer/daily/  UPLOAD_DIR=people.debian.org:~/public_html/debian-installer/daily/
605    ALL_TYPES=$(shell find pkg-lists -type d -maxdepth 1 -mindepth 1 -not -name CVS -printf '%f\n')
606  daily_build:  daily_build:
607          -cvs update          -cvs update
608            dpkg-checkbuilddeps
609          $(MAKE) clean          $(MAKE) clean
610    
611          install -d $(DEST)          install -d $(DEST)
612          fakeroot $(MAKE) tarball > $(DEST)/log 2>&1          rm -f $(DEST)/info
613          $(MAKE) stats > $(DEST)/$(TYPE).info          touch $(DEST)/info
614            set -e; \
615            for type in $(ALL_TYPES); do \
616                    $(MAKE) sub_daily_build TYPE=$$type USER_MOUNT_HACK=$(shell pwd)/$(DEST)/tmp-mnt.img; \
617            done
618            scp -q -B $(KERNEL) $(UPLOAD_DIR)/images/
619            mail $(shell whoami) -s "today's build info" < $(DEST)/info
620    
621    sub_daily_build:
622            fakeroot $(MAKE) tarball > $(DEST)/$(TYPE).log 2>&1
623            $(MAKE) image >> $(DEST)/$(TYPE).log 2>&1
624            $(MAKE) stats | grep -v ^make > $(DEST)/$(TYPE).info
625          echo "Tree comparison" >> $(DEST)/$(TYPE).info          echo "Tree comparison" >> $(DEST)/$(TYPE).info
626          echo "" >> $(DEST)/$(TYPE).info          echo "" >> $(DEST)/$(TYPE).info
627          ./treecompare $(TYPE)-oldtree $(TREE) >> $(DEST)/$(TYPE).info          if [ -d $(TYPE)-oldtree ]; then \
628          scp -q -B $(DEST)/log $(UPLOAD_DIR)                  ./treecompare $(TYPE)-oldtree $(TREE) >> $(DEST)/$(TYPE).info; \
629            fi
630            scp -q -B $(DEST)/$(TYPE).log $(UPLOAD_DIR)
631          scp -q -B $(DEST)/$(TYPE)-debian-installer.tar.gz \          scp -q -B $(DEST)/$(TYPE)-debian-installer.tar.gz \
632                  $(UPLOAD_DIR)/$(TYPE)-debian-installer-$(shell date +%Y%m%d).tar.gz                  $(UPLOAD_DIR)/$(TYPE)-debian-installer-$(shell date +%Y%m%d).tar.gz
633            scp -q -B $(IMAGE) $(INITRD) $(UPLOAD_DIR)/images/
634          scp -q -B $(DEST)/$(TYPE).info \          scp -q -B $(DEST)/$(TYPE).info \
635                  $(UPLOAD_DIR)/$(TYPE).info-$(shell date +%Y%m%d)                  $(UPLOAD_DIR)/$(TYPE).info-$(shell date +%Y%m%d)
636            echo "Type: $(TYPE)" >> $(DEST)/info
637            cat $(DEST)/$(TYPE).info >> $(DEST)/info
638          rm -rf $(TYPE)-oldtree          rm -rf $(TYPE)-oldtree
639          -mv $(TREE) $(TYPE)-oldtree && rm -f tree-stamp          -mv $(TREE) $(TYPE)-oldtree && rm -f $(TYPE)-tree-stamp
         mail $(shell whoami) -s "today's build info" < $(DEST)/$(TYPE).info  
640    
 .PHONY: tree  

Legend:
Removed from v.629  
changed lines
  Added in v.4371

  ViewVC Help
Powered by ViewVC 1.1.5