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

Diff of /trunk/build/Makefile

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

revision 579 by dwhedon, Sun Jul 15 02:50:59 2001 UTC revision 4608 by joeyh, Tue Oct 7 21:41:37 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-2003 by Joey Hess <joeyh@debian.org> and the d-i team.
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  # The version of the kernel to use.  # Include main config
16    include config/main
17    
18  ifeq "$(architecture)" "i386"  # Include arch configs
19  KVERS=2.4.6  include config/arch/$(DEB_HOST_GNU_SYSTEM)
20  FLAVOUR=386  include config/arch/$(DEB_HOST_GNU_SYSTEM)-$(DEB_HOST_GNU_CPU)
21  endif  
22    # Include type configs
23  # The type of system to build. Determines what udebs are unpacked into  -include config/type/$(TYPE)
24  # the system. See the .list files for various types. You may want to  -include config/type/$(TYPE)-$(DEB_HOST_GNU_SYSTEM)
25  # override this on the command line.  -include config/type/$(TYPE)-$(DEB_HOST_ARCH)
 TYPE=net  
   
 # 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  
 endif  
26    
27  # Add to PATH so dpkg will always work, and so local programs will  # Include directory config
28  # be found.  include config/dir
29    
30    # Local config override.
31    -include config/local
32    
33    # Add to PATH so dpkg will always work, and so local programs will be found.
34  PATH:=$(PATH):/usr/sbin:/sbin:.  PATH:=$(PATH):/usr/sbin:/sbin:.
35    
36  # All these options make apt read the right sources list, and  # All these options make apt read the right sources list, and use APTDIR for
37  # use APTDIR for everything so it need not run as root.  # everything so it need not run as root.
38  CWD:=$(shell pwd)/  CWD:=$(shell pwd)/
39  APT_GET=apt-get --assume-yes \  APT_GET=apt-get --assume-yes \
40          -o Dir::Etc::sourcelist=$(CWD)$(SOURCES_LIST) \          -o Dir::Etc::sourcelist=$(CWD)$(SOURCES_LIST) \
# Line 105  APT_GET=apt-get --assume-yes \ Line 42  APT_GET=apt-get --assume-yes \
42          -o Debug::NoLocking=true \          -o Debug::NoLocking=true \
43          -o Dir::Cache=$(CWD)$(APTDIR)/cache          -o Dir::Cache=$(CWD)$(APTDIR)/cache
44    
45  # Get the list of udebs to install. Comments are allowed in the lists.  # Get the list of udebs to install.
46  UDEBS=$(shell grep --no-filename -v ^\# lists/base lists/$(TYPE) | sed 's/$${kernel:Version}/$(KVERS)/g' | sed 's/$${kernel:Flavour}/$(FLAVOUR)/g') $(EXTRAS)  UDEBS = $(shell ./pkg-list $(TYPE) $(KERNELIMAGEVERSION)) $(EXTRAS)
47    
48  DPKGDIR=$(TREE)/var/lib/dpkg  ifeq ($(TYPE),floppy)
49  TEMP=./tmp  # List of additional udebs for driver floppys.
50  TMP_MNT=`pwd`/mnt/  DRIVERFD_UDEBS = \
51            $(shell for target in $(EXTRA_FLOPPIES) ; do \
52                    ./pkg-list $$target $(KERNELIMAGEVERSION); \
53            done)
54    endif
55    
56  # Build tree location.  # Sanity check TYPE against the list.
57  TREE=$(TEMP)/tree  ifeq (,$(filter $(TYPE),type $(TYPES_SUPPORTED)))
58    %:
59            @echo "unsupported type"
60            @echo "type: $(TYPE)"
61            $(MAKE) listtypes
62            @exit 1
63    endif
64    
65  # This is the kernel image that we will boot from.  # Include arch targets
66  KERNEL=$(TEMP)/vmlinuz  -include make/arch/$(DEB_HOST_GNU_SYSTEM)
67    include make/arch/$(DEB_HOST_GNU_SYSTEM)-$(DEB_HOST_GNU_CPU)
68    
69    build: tree_umount tree $(EXTRA_TARGETS) stats
70    
71    image: arch-image $(EXTRA_IMAGES)
72    
73    tree_mount: tree
74            -@sudo /bin/mount -t proc proc $(TREE)/proc
75    ifndef USERDEVFS
76            -@sudo /bin/mount -t devfs dev $(TREE)/dev
77    else
78            -@sudo chroot $(TREE) /usr/bin/update-dev
79    endif
80    
81  build: demo_clean tree stats  tree_umount:
82    ifndef USERDEVFS
83            -@if [ -L $(TREE)/dev/fd ] ; then sudo /bin/umount $(TREE)/dev 2>/dev/null ; fi
84    endif
85            -@if [ -L $(TREE)/proc/self ] ; then sudo /bin/umount $(TREE)/proc 2>/dev/null ; fi
86    
87  demo: tree  demo: tree
88          sudo chroot $(TREE) bin/sh -c "if ! mount | grep ^proc ; then bin/mount proc -t proc /proc; fi"          $(MAKE) tree_mount
89          -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"          -@[ -f questions.dat ] && cp -f questions.dat $(TREE)/var/lib/cdebconf/
90          $(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"
91            $(MAKE) tree_umount
92    
93  shell: tree  shell: tree
94          mkdir -p $(TREE)/proc          $(MAKE) tree_mount
95          sudo chroot $(TREE) bin/sh -c "if ! mount | grep ^proc ; then bin/mount proc -t proc /proc; fi"          -@sudo chroot $(TREE) bin/sh
96          sudo chroot $(TREE) bin/sh          $(MAKE) tree_umount
         $(MAKE) demo_clean  
   
 demo_clean:  
         -if [ -e $(TREE)/proc/self ]; then \  
                 sudo chroot $(TREE) bin/sh -c "if mount | grep ^proc ; then bin/umount /proc ; fi" &> /dev/null; \  
         fi  
97    
98  clean: demo_clean  uml: $(INITRD)
99            -linux initrd=$(INITRD) root=/dev/rd/0 ramdisk_size=8192 con=fd:0,fd:1 devfs=mount
100    
101    demo_clean: tree_umount
102    
103    clean: demo_clean tmp_mount debian/control
104            rm -rf $(TREE) || sudo rm -rf $(TREE)
105          dh_clean          dh_clean
106          rm -f *-stamp          rm -f *-stamp
107          rm -rf $(TREE) $(APTDIR) $(UDEBDIR) $(TEMP) $(DEST)          rm -rf $(UDEBDIR) $(EXTRAUDEBDIR) $(TMP_MNT) debian/build
108            rm -rf $(DEST)/$(TYPE)-* || sudo rm -rf $(DEST)/$(TYPE)-*
109            rm -f unifont-reduced-$(TYPE).bdf
110            $(foreach NAME,$(KERNELNAME), \
111                    rm -f $(TEMP)/$(NAME); )
112    
113    reallyclean: clean
114            rm -rf $(APTDIR) $(DEST) $(BASE_TMP) $(SOURCEDIR) $(DEBUGUDEBDIR)
115            rm -f diskusage*.txt missing.txt all-*.utf *.bdf
116            rm -f sources.list
117    
118    # Auto-generate a sources.list.
119    sources.list:
120            ( \
121            echo "# This file is automatically generated, edit sources.list.local instead."; \
122            if [ "$(MIRROR)x" != "x" ]; then \
123                    echo "deb $(MIRROR) $(SUITE) main/debian-installer"; \
124            else \
125            cat $(SYSTEM_SOURCES_LIST) | grep ^deb\  |grep -v file:/ | grep -v debian-non-US | grep ' main' | \
126                    awk '{print $$1 " " $$2}' | sed s/\\/*\ *$$/\ $(SUITE)\ main\\/debian-installer/ | uniq; \
127            fi; \
128            ) > sources.list
129    
130  # Get all required udebs and put in UDEBDIR.  # Get all required udebs and put in UDEBDIR.
131  get_udebs: get_udebs-stamp  get_udebs: $(TYPE)-get_udebs-stamp
132  get_udebs-stamp:  $(TYPE)-get_udebs-stamp: sources.list
133          mkdir -p $(APTDIR)/state/lists/partial          mkdir -p $(APTDIR)/state/lists/partial
134          mkdir -p $(APTDIR)/cache/archives/partial          mkdir -p $(APTDIR)/cache/archives/partial
135          $(APT_GET) update          -$(APT_GET) update
136          $(APT_GET) autoclean          $(APT_GET) autoclean
137          # 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
138          # get. Then get all the udebs that are left to get.          # get. Then get all the udebs that are left to get.
139          needed="$(UDEBS)"; \          # Note that the trailing blank on the next line is significant. It
140            # makes the sed below always work.
141            needed="$(UDEBS) $(DRIVERFD_UDEBS) "; \
142          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 \
143                  package=`echo $$file | cut -d _ -f 1`; \                  package=`echo $$file | cut -d _ -f 1`; \
144                  needed=`echo $$needed | sed "s/$$package *//"`; \                  needed=`echo " $$needed " | sed "s/ $$package / /"`; \
145          done; \          done; \
146          if [ $(DEBUG) = y ] ; then \          if [ "$(DEBUG)" = y ] ; then \
147                  mkdir -p $(DEBUGUDEBDIR); \                  mkdir -p $(DEBUGUDEBDIR); \
148                  cd $(DEBUGUDEBDIR); \                  cd $(DEBUGUDEBDIR); \
149                  export DEB_BUILD_OPTIONS="debug"; \                  export DEB_BUILD_OPTIONS="debug"; \
150                  $(APT_GET) source --build --yes $$needed; \                  $(APT_GET) source --build --yes $$needed; \
151                  cd ..; \                  cd ..; \
152          else \          else \
153                    echo Need to download : $$needed; \
154                    if [ -n "$$needed" ]; then \
155                  $(APT_GET) -dy install $$needed; \                  $(APT_GET) -dy install $$needed; \
156                    fi; \
157          fi; \          fi; \
158    
159          # Now the udebs are in APTDIR/cache/archives/ and maybe LOCALUDEBDIR,          # Now the udebs are in APTDIR/cache/archives/ and maybe LOCALUDEBDIR
160          # 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
161          # 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
162          # names.          # to more useful names. Watch out for duplicates and missing files
163            # while doing that.
164          rm -rf $(UDEBDIR)          rm -rf $(UDEBDIR)
165          mkdir -p $(UDEBDIR)          mkdir -p $(UDEBDIR)
166          for package in $(UDEBS); do \          rm -rf $(EXTRAUDEBDIR)
167                  if [ -e $(APTDIR)/cache/archives/$$package\_* ]; then \          mkdir -p $(EXTRAUDEBDIR)
168                          ln -f $(APTDIR)/cache/archives/$$package\_* \          lnpkg() { \
169                                  $(UDEBDIR)/$$package.udeb; \                  local pkg=$$1; local dir=$$2 debdir=$$3; \
170                    local L1="`echo $$dir/$$pkg\_*`"; \
171                    local L2="`echo $$L1 | sed -e 's, ,,g'`"; \
172                    if [ "$$L1" != "$$L2" ]; then \
173                            echo "Duplicate package $$pkg in $$dir/"; \
174                            exit 1; \
175                  fi; \                  fi; \
176                  if [ -e $(LOCALUDEBDIR)/$$package\_* ]; then \                  if [ -e $$L1 ]; then \
177                          ln -f $(LOCALUDEBDIR)/$$package\_* \                          ln -f $$dir/$$pkg\_* $$debdir/$$pkg.udeb; \
                                 $(UDEBDIR)/$$package.udeb; \  
178                  fi; \                  fi; \
179                  if [ -e $(DEBUGUDEBDIR)/$$package\_*.udeb ]; then \          }; \
180                          ln -f $(DEBUGUDEBDIR)/$$package\_*.udeb \          for package in $(UDEBS) ; do \
181                                  $(UDEBDIR)/$$package.udeb; \                  lnpkg $$package $(APTDIR)/cache/archives $(UDEBDIR); \
182                    lnpkg $$package $(LOCALUDEBDIR) $(UDEBDIR); \
183                    lnpkg $$package $(DEBUGUDEBDIR) $(UDEBDIR); \
184                    if ! [ -e $(UDEBDIR)/$$package.udeb ]; then \
185                            echo "Needed $$package not found (looked in $(APTDIR)/cache/archives/, $(LOCALUDEBDIR)/, $(DEBUGUDEBDIR)/)"; \
186                            exit 1; \
187                  fi; \                  fi; \
188          done          done ; \
189            for package in $(DRIVERFD_UDEBS) ; do \
190          touch get_udebs-stamp                  lnpkg $$package $(APTDIR)/cache/archives $(EXTRAUDEBDIR); \
191                    lnpkg $$package $(LOCALUDEBDIR) $(EXTRAUDEBDIR); \
192                    lnpkg $$package $(DEBUGUDEBDIR) $(EXTRAUDEBDIR); \
193                    if ! [ -e $(EXTRAUDEBDIR)/$$package.udeb ]; then \
194                            echo "Needed $$package not found (looked in $(APTDIR)/cache/archives/, $(LOCALUDEBDIR)/, $(DEBUGUDEBDIR)/)"; \
195                            exit 1; \
196                    fi; \
197            done
198    
199            touch $(TYPE)-get_udebs-stamp
200    
201  # Build the installer tree.  # Build the installer tree.
202  tree: get_udebs tree-stamp  tree: $(TYPE)-tree-stamp
203  tree-stamp:  $(TYPE)-tree-stamp: $(TYPE)-get_udebs-stamp debian/control
204          dh_testroot          dh_testroot
205    
206            dpkg-checkbuilddeps
207    
208          # This build cannot be restarted, because dpkg gets confused.          # This build cannot be restarted, because dpkg gets confused.
209          rm -rf $(TREE)          rm -rf $(TREE)
210          # Set up the basic files [u]dpkg needs.          # Set up the basic files [u]dpkg needs.
211          mkdir -p $(DPKGDIR)/info          mkdir -p $(DPKGDIR)/info
212          touch $(DPKGDIR)/status          touch $(DPKGDIR)/status
213            # Create a tmp tree
214            mkdir -p $(TREE)/tmp
215          # Only dpkg needs this stuff, so it can be removed later.          # Only dpkg needs this stuff, so it can be removed later.
216          mkdir -p $(DPKGDIR)/updates/          mkdir -p $(DPKGDIR)/updates/
217          touch $(DPKGDIR)/available          touch $(DPKGDIR)/available
218          # Unpack the udebs with dpkg. This command must run as root or fakeroot.  
219          dpkg --force-overwrite --root=$(TREE) --unpack $(UDEBDIR)/*.udeb          # Unpack the udebs with dpkg. This command must run as root
220            # or fakeroot.
221            echo -n > diskusage-$(TYPE).txt
222            oldsize=0; oldblocks=0; oldcount=0; for udeb in $(UDEBDIR)/*.udeb ; do \
223                    pkg=`basename $$udeb` ; \
224                    dpkg --force-overwrite --root=$(TREE) --unpack $$udeb ; \
225                    newsize=`du -bs $(TREE) | awk '{print $$1}'` ; \
226                    newblocks=`du -s $(TREE) | awk '{print $$1}'` ; \
227                    newcount=`find $(TREE) -type f | wc -l | awk '{print $$1}'` ; \
228                    usedsize=`echo $$newsize - $$oldsize | bc`; \
229                    usedblocks=`echo $$newblocks - $$oldblocks | bc`; \
230                    usedcount=`echo $$newcount - $$oldcount | bc`; \
231                    version=`dpkg-deb --info $$udeb | grep Version: | awk '{print $$2}'` ; \
232                    echo " $$usedsize B - $$usedblocks blocks - $$usedcount files used by pkg $$pkg (version $$version )" >>diskusage-$(TYPE).txt;\
233                    oldsize=$$newsize ; \
234                    oldblocks=$$newblocks ; \
235                    oldcount=$$newcount ; \
236            done
237            sort -n < diskusage-$(TYPE).txt > diskusage-$(TYPE).txt.new && \
238                    mv diskusage-$(TYPE).txt.new diskusage-$(TYPE).txt
239    
240          # Clean up after dpkg.          # Clean up after dpkg.
241          rm -rf $(DPKGDIR)/updates          rm -rf $(DPKGDIR)/updates
242          rm -f $(DPKGDIR)/available $(DPKGDIR)/*-old $(DPKGDIR)/lock          rm -f $(DPKGDIR)/available $(DPKGDIR)/*-old $(DPKGDIR)/lock
243          # Set up modules.dep  
244          mkdir -p $(TREE)/lib/modules/$(KVERS)-di/          # Set up modules.dep, ensure there is at least one standard dir (kernel
245          depmod -q -a -b $(TREE)/ $(KVERS)-di          # in this case), so depmod will use its prune list for archs with no
246            # modules.
247            $(foreach VERSION,$(KERNELVERSION), \
248                    mkdir -p $(TREE)/lib/modules/$(VERSION)/kernel; \
249                    depmod -q -a -b $(TREE)/ $(VERSION); )
250            # These files depmod makes are used by hotplug, and we shouldn't
251            # need them, yet anyway.
252            find $(TREE)/lib/modules/ -name 'modules*' \
253                    -not -name modules.dep -not -type d | xargs rm -f
254    
255            # Create a dev tree
256            mkdir -p $(TREE)/dev
257    ifdef USERDEVFS
258            # Create initial /dev entries -- only those that are absolutely
259            # required to boot sensibly, though.
260            mknod $(TREE)/dev/console c 5 1
261            mkdir -p $(TREE)/dev/vc
262            mknod $(TREE)/dev/vc/0 c 4 0
263            mknod $(TREE)/dev/vc/1 c 4 1
264            mknod $(TREE)/dev/vc/2 c 4 2
265            mknod $(TREE)/dev/vc/3 c 4 3
266            mknod $(TREE)/dev/vc/4 c 4 4
267            mknod $(TREE)/dev/vc/5 c 4 5
268            mkdir -p $(TREE)/dev/rd
269            mknod $(TREE)/dev/rd/0 b 1 0
270    endif
271    
272          # Move the kernel image out of the way, into a temp directory          # Move the kernel image out of the way, into a temp directory
273          # for use later. We don't need it bloating our image!          # for use later.
274          mv -f $(TREE)/boot/vmlinuz $(KERNEL)          $(foreach NAME,$(KERNELNAME), \
275                    mv -f $(TREE)/boot/$(NAME) $(TEMP); )
276          -rmdir $(TREE)/boot/          -rmdir $(TREE)/boot/
277    
278    ifndef NO_TERMINFO
279            # Copy terminfo files for slang frontend
280            # TODO: terminfo.udeb?
281            for file in /etc/terminfo/a/ansi /etc/terminfo/l/linux \
282                        /etc/terminfo/v/vt102; do \
283                    mkdir -p $(TREE)/`dirname $$file`; \
284                    cp -a $$file $(TREE)/$$file; \
285            done
286    endif
287    
288  ifdef EXTRAFILES  ifdef EXTRAFILES
289          # Copy in any extra files          # Copy in any extra files
290          for file in $(EXTRAFILES); do \          for file in $(EXTRAFILES); do \
291                  mkdir -p $(TREE)/`basename $$file`; \                  mkdir -p $(TREE)/`dirname $$file`; \
292                  cp -a $$file $(TREE)/$$file; \                  cp -a $$file $(TREE)/$$file; \
293          done          done
294  endif  endif
295    
         # Copy in any extra libs.  
296  ifdef EXTRALIBS  ifdef EXTRALIBS
297            # Copy in any extra libs.
298          cp -a $(EXTRALIBS) $(TREE)/lib/          cp -a $(EXTRALIBS) $(TREE)/lib/
299  endif  endif
300    
301    ifeq ($(TYPE),floppy)
302            # Unpack additional driver disks, so mklibs runs on them too.
303            rm -rf $(DRIVEREXTRASDIR)
304            mkdir -p $(DRIVEREXTRASDIR)
305            mkdir -p $(DRIVEREXTRASDPKGDIR)/info $(DRIVEREXTRASDPKGDIR)/updates
306            touch $(DRIVEREXTRASDPKGDIR)/status $(DRIVEREXTRASDPKGDIR)/available
307            for udeb in $(EXTRAUDEBDIR)/*.udeb ; do \
308                    dpkg --force-overwrite --root=$(DRIVEREXTRASDIR) --unpack $$udeb; \
309            done
310    endif
311    
312          # Library reduction.          # Library reduction.
313          mkdir -p $(TREE)/lib          mkdir -p $(TREE)/lib
314          mklibs.sh -v -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'`
315    
316            # Add missing symlinks for libraries
317            # (Needed for mklibs.py)
318            /sbin/ldconfig -n $(TREE)/lib $(TREE)/usr/lib
319    
320          # Remove any libraries that are present in both usr/lib and lib,          # Remove any libraries that are present in both usr/lib and lib,
321          # from lib. These were unnecessarily copied in by mklibs, and          # from lib. These were unnecessarily copied in by mklibs, and
# Line 240  endif Line 324  endif
324          for lib in `find $(TREE)/usr/lib/lib* -type f -printf "%f\n" | cut -d . -f 1 | sort | uniq`; do \          for lib in `find $(TREE)/usr/lib/lib* -type f -printf "%f\n" | cut -d . -f 1 | sort | uniq`; do \
325                  rm -f $(TREE)/lib/$$lib.*; \                  rm -f $(TREE)/lib/$$lib.*; \
326          done          done
327    
328          # Now we have reduced libraries installed .. but they are          # Now we have reduced libraries installed .. but they are
329          # not listed in the status file. This nasty thing puts them in,          # not listed in the status file. This nasty thing puts them in,
330          # and alters their names to end in -reduced to indicate that          # and alters their names to end in -reduced to indicate that
331          # they have been modified.          # they have been modified.
332          for package in $$(dpkg -S `find $(TREE)/lib -type f -not -name '*.o'| \          for package in $$(dpkg -S `find $(TREE)/lib -type f -not -name '*.o' -not -name '*.dep' | \
333                          sed s:$(TREE)::` | cut -d : -f 1 | \                          sed s:$(TREE)::` | cut -d : -f 1 | \
334                          sort | uniq); do \                          sort | uniq); do \
335                  dpkg -s $$package | sed "s/$$package/$$package-reduced/g" \                  dpkg -s $$package | sed "s/$$package/$$package-reduced/g" \
# Line 253  endif Line 337  endif
337          done          done
338    
339          # Reduce status file to contain only the elements we care about.          # Reduce status file to contain only the elements we care about.
340          egrep -i '^((Status|Provides|Depends|Package|Description|installer-menu-item):|$$)' \          egrep -i '^((Status|Provides|Depends|Package|Version|Description|installer-menu-item|Description-..):|$$)' \
341                  $(DPKGDIR)/status > $(DPKGDIR)/status.new                  $(DPKGDIR)/status > $(DPKGDIR)/status.udeb
342          mv -f $(DPKGDIR)/status.new $(DPKGDIR)/status          rm -f $(DPKGDIR)/status
343            ln -sf status.udeb $(DPKGDIR)/status
344    
345    ifdef NO_I18N
346            # Remove all internationalization from the templates.
347            # Not ideal, but useful if you're very tight on space.
348            for FILE in $$(find $(TREE) -name "*.templates"); do \
349                    perl -e 'my $$status = 0; while (<>) { if (/^[A-Z]/ || /^$$/) { if (/^(Choices|Description)-/) { $$status = 0; } else { $$status = 1; } } print if ($$status); }' < $$FILE > temp; \
350                    mv temp $$FILE; \
351            done
352    endif
353    
354          touch tree-stamp          # If the image has pcmcia, reduce the config file to list only
355            # entries that there are modules on the image. This saves ~30k.
356            if [ -e $(TREE)/etc/pcmcia/config ]; then \
357                    ./pcmcia-config-reduce.pl $(TREE)/etc/pcmcia/config \
358                            `if [ -d "$(DRIVEREXTRASDIR)" ]; then find $(DRIVEREXTRASDIR)/lib/modules -name \*.o; fi` \
359                            `find $(TREE)/lib/modules/ -name \*.o` > \
360                            $(TREE)/etc/pcmcia/config.reduced; \
361                    mv -f $(TREE)/etc/pcmcia/config.reduced $(TREE)/etc/pcmcia/config; \
362            fi
363    
364            # Strip all kernel modules, just in case they haven't already been
365            for module in `find $(TREE)/lib/modules/ -name '*.o'`; do \
366                strip -R .comment -R .note -g $$module; \
367            done
368    
369            # Remove some unnecessary dpkg files.
370            for file in `find $(TREE)/var/lib/dpkg/info -name '*.md5sums' -o \
371                -name '*.postrm' -o -name '*.prerm' -o -name '*.preinst' -o \
372                -name '*.list'`; do \
373                rm $$file; \
374            done
375    
376            # Collect the used UTF-8 strings, to know which glyphs to include in
377            # the font.  Using strings is not the best way, but no better
378            # suggestion has been made yet.
379            cp graphic.utf all-$(TYPE).utf
380    ifeq ($(TYPE),floppy)
381            if [ -n "`find $(DRIVEREXTRASDPKGDIR)/info/ -name \\*.templates`" ]; then \
382                    cat $(DRIVEREXTRASDPKGDIR)/info/*.templates >> all-$(TYPE).utf; \
383            fi
384    endif
385            if [ -n "`find $(DPKGDIR)/info/ -name \\*.templates`" ]; then \
386                    cat $(DPKGDIR)/info/*.templates >> all-$(TYPE).utf; \
387            fi
388            find $(TREE) -type f | xargs strings >> all-$(TYPE).utf
389    
390    ifeq ($(TYPE),floppy)
391            # Remove additional driver disk contents now that we're done with
392            # them.
393            rm -rf $(DRIVEREXTRASDIR)
394    endif
395    
396            # Tree target ends here. Whew!
397            touch $(TYPE)-tree-stamp
398    
399    unifont-reduced-$(TYPE).bdf: all-$(TYPE).utf
400            # Use the UTF-8 locale in rootskel-locale. This target shouldn't
401            # be called when it is not present anyway.
402            # reduce-font is part of package libbogl-dev
403            # unifont.bdf is part of package bf-utf-source
404            # The locale must be generated after installing the package locales
405            CHARMAP=`LOCPATH=$(LOCALE_PATH) LC_ALL=C.UTF-8 locale charmap`; \
406                if [ UTF-8 != "$$CHARMAP" ]; then \
407                    echo "error: Trying to build unifont.bgf without rootskel-locale!"; \
408                    exit 1; \
409                fi
410            LOCPATH=$(LOCALE_PATH) LC_ALL=C.UTF-8 reduce-font /usr/src/unifont.bdf < all-$(TYPE).utf > $@.tmp
411            mv $@.tmp $@
412    
413    $(TREE)/unifont.bgf: unifont-reduced-$(TYPE).bdf
414            # bdftobogl is part of package libbogl-dev
415            bdftobogl -b unifont-reduced-$(TYPE).bdf > $@.tmp
416            mv $@.tmp $@
417    
418    # Build the driver floppy image
419    $(EXTRA_TARGETS) : %-stamp : $(TYPE)-get_udebs-stamp
420            mkdir -p  ${TEMP}/$*
421            for file in $(shell grep --no-filename -v ^\#  pkg-lists/$*/common \
422                    `if [ -f pkg-lists/$*/$(DEB_HOST_ARCH) ]; then echo pkg-lists/$*/$(DEB_HOST_ARCH); fi` \
423                    | sed -e 's/^\(.*\)$${kernel:Version}\(.*\)$$/$(foreach VERSION,$(KERNELIMAGEVERSION),\1$(VERSION)\2\n)/g' ) ; do \
424                            cp $(EXTRAUDEBDIR)/$$file* ${TEMP}/$*  ; \
425                            echo $$file >> ${TEMP}/$*/udeb_include; \
426            done
427            touch $@
428    
429    $(EXTRA_IMAGES) : $(DEST)/%-image.img :  $(EXTRA_TARGETS)
430            rm -f $@
431            install -d $(TEMP)
432            install -d $(DEST)
433            set -e; if [ $(INITRD_FS) = ext2 ]; then \
434                    genext2fs -d $(TEMP)/$* -b $(FLOPPY_SIZE) -r 0  $@; \
435            elif [ $(INITRD_FS) = romfs ]; then \
436                    genromfs -d $(TEMP)/$* -f $@; \
437            else \
438                    echo "Unsupported filesystem type"; \
439                    exit 1; \
440            fi;
441    
442  tarball: tree  tarball: tree
443          tar czf $(DEST)/$(TYPE)-debian-installer.tar.gz $(TREE)          tar czf $(DEST)/$(TYPE)-debian-installer.tar.gz $(TREE)
444    
445  # Make sure that the temporary mountpoint exists and is not occupied.  # Make sure that the temporary mountpoint exists and is not occupied.
446  tmp_mount:  tmp_mount:
         dh_testroot  
447          if mount | grep -q $(TMP_MNT) && ! umount $(TMP_MNT) ; then \          if mount | grep -q $(TMP_MNT) && ! umount $(TMP_MNT) ; then \
448                  echo "Error unmounting $(TMP_MNT)" 2>&1 ; \                  echo "Error unmounting $(TMP_MNT)" 2>&1 ; \
449                  exit 1; \                  exit 1; \
450          fi          fi
451          mkdir -p $(TMP_MNT)          mkdir -p $(TMP_MNT)
452    
453  # Create a compressed image of the root filesystem.  # Create a compressed image of the root filesystem by way of genext2fs.
454  # 1. make a temporary file large enough to fit the filesystem.  initrd: $(INITRD)
 # 2. mount that file via the loop device, create a filesystem on it  
 # 3. copy over the root filesystem  
 # 4. unmount the file, compress it  
 #  
 initrd: Makefile tmp_mount tree $(INITRD)  
455  $(INITRD): TMP_FILE=$(TEMP)/image.tmp  $(INITRD): TMP_FILE=$(TEMP)/image.tmp
456  $(INITRD):  $(INITRD):  $(TYPE)-tree-stamp
457          dh_testroot          # Only build the font if we have rootskel-locale
458          umount $(TMP_MNT) || true          if [ -d "$(LOCALE_PATH)/C.UTF-8" ]; then \
459                $(MAKE) $(TREE)/unifont.bgf; \
460            fi
461          rm -f $(TMP_FILE)          rm -f $(TMP_FILE)
462          install -d $(TEMP)          install -d $(TEMP)
         dd if=/dev/zero of=$(TMP_FILE) bs=1k count=`expr $$(du -s $(TREE) | cut -f 1) + $$(expr $$(find $(TREE) | wc -l) \* 2)`  
         # FIXME: 2000 bytes/inode (choose that better?)  
         mke2fs -F -m 0 -i 2000 -O sparse_super $(TMP_FILE)  
         mount -t ext2 -o loop $(TMP_FILE) $(TMP_MNT)  
         cp -a $(TREE)/* $(TMP_MNT)/  
         umount $(TMP_MNT)  
463          install -d $(DEST)          install -d $(DEST)
         dd if=$(TMP_FILE) bs=1k | gzip -v9 > $(INITRD)  
464    
465  # Create a bootable floppy image. i386 specific. FIXME          if [ $(INITRD_FS) = ext2 ]; then \
466  # 1. make a dos filesystem image                  genext2fs -d $(TREE) -b `expr $$(du -s $(TREE) | cut -f 1) + $$(expr $$(find $(TREE) | wc -l) \* 2)` $(TMP_FILE); \
467  # 2. copy over kernel, initrd          elif [ $(INITRD_FS) = romfs ]; then \
468  # 3. install syslinux                  genromfs -d $(TREE) -f $(TMP_FILE); \
469  floppy_image: Makefile initrd tmp_mount $(FLOPPY_IMAGE)          else \
470  $(FLOPPY_IMAGE):                  echo "Unsupported filesystem type"; \
471          dh_testroot                  exit 1; \
472          install -d $(DEST)          fi;
473            gzip -vc9 $(TMP_FILE) > $(INITRD).tmp
474          dd if=/dev/zero of=$(FLOPPY_IMAGE) bs=1k count=$(FLOPPY_SIZE)          mv $(INITRD).tmp $(INITRD)
         mkfs.msdos -i deb00001 -n 'Debian Installer' $(FLOPPY_IMAGE)  
         mount -t msdos -o loop $(FLOPPY_IMAGE) $(TMP_MNT)  
   
         cp $(KERNEL) $(TMP_MNT)/LINUX  
         cp $(INITRD) $(TMP_MNT)/initrd.gz  
   
         cp syslinux.cfg $(TMP_MNT)/  
         todos $(TMP_MNT)/syslinux.cfg  
         umount $(TMP_MNT)  
         syslinux $(SYSLINUX_OPTS) $(FLOPPY_IMAGE)  
475    
476  # Write image to floppy  # Write image to floppy
477  boot_floppy: floppy_image  floppy: boot_floppy
478    boot_floppy: $(IMAGE)
479            install -d $(DEST)
480            dd if=$(IMAGE) of=$(FLOPPYDEV) bs=$(FLOPPY_SIZE)k
481    
482    # Write drivers  floppy
483    %_floppy: $(DEST)/%-image.img
484          install -d $(DEST)          install -d $(DEST)
485          dd if=$(FLOPPY_IMAGE) of=$(FLOPPYDEV)          dd if=$< of=$(FLOPPYDEV)
486    
487  # If you're paranoid (or things are mysteriously breaking..),  # If you're paranoid (or things are mysteriously breaking..),
488  # you can check the floppy to make sure it wrote properly.  # you can check the floppy to make sure it wrote properly.
489  # 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.
490  boot_floppy_check: floppy_image  boot_floppy_check: floppy_image
491          cmp $(FLOPPYDEV) $(FLOPPY_IMAGE)          cmp $(FLOPPYDEV) $(IMAGE)
492    
493    listtypes:
494            @echo "supported types: $(TYPES_SUPPORTED)"
495    
496    
497  COMPRESSED_SZ=$(shell expr $(shell tar cz $(TREE) | wc -c) / 1024)  stats: tree $(EXTRA_TARGETS) general-stats $(EXTRA_STATS)
498  KERNEL_SZ=$(shell expr $(shell du -b $(KERNEL) | cut -f 1) / 1024)  
499  stats: tree  COMPRESSED_SZ=$(shell expr $(shell tar czf - $(TREE) | wc -c) / 1024)
500    KERNEL_SZ=$(shell expr \( $(foreach NAME,$(KERNELNAME),$(shell du -b $(TEMP)/$(NAME) 2>/dev/null | cut -f 1) +) 0 \) / 1024)
501    general-stats:
502          @echo          @echo
503          @echo "System stats"          @echo "System stats for $(TYPE)"
504          @echo "------------"          @echo "-------------------------"
505          @echo "Installed udebs: $(UDEBS)"          @echo "Installed udebs: $(UDEBS)"
506          @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)"
507          @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, "
508          @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)"
509          @echo "Initrd size: $(COMPRESSED_SZ)k"          @echo "Initrd size: $(COMPRESSED_SZ)k"
510          @echo "Kernel size: $(KERNEL_SZ)k"          @echo "Kernel size: $(KERNEL_SZ)k"
511    ifneq (,$(FLOPPY_SIZE))
512          @echo "Free space: $(shell expr $(FLOPPY_SIZE) - $(KERNEL_SZ) - $(COMPRESSED_SZ))k"          @echo "Free space: $(shell expr $(FLOPPY_SIZE) - $(KERNEL_SZ) - $(COMPRESSED_SZ))k"
513    endif
514            @echo "Disk usage per package:"
515            @sed 's/^/  /' < diskusage-$(TYPE).txt
516  # Add your interesting stats here.  # Add your interesting stats here.
517    
518    SZ=$(shell expr $(shell du -b $(TEMP)/$*  | cut -f 1 ) / 1024)
519    $(EXTRA_STATS) : %-stats:
520            @echo
521            @echo "$* size: $(SZ)k"
522    ifneq (,$(FLOPPY_SIZE))
523            @echo "Free space: $(shell expr $(FLOPPY_SIZE) - $(SZ))k"
524    endif
525            @echo "Disk usage per package:"
526            @ls -l $(TEMP)/$*/*.udeb
527    
528  # Upload a daily build to klecker. If you're not Joey Hess, you probably  # These tagets build all available types.
529  # don't want to use this grungy code, at least not without overrideing  all_build:
530  # this:          set -e; for type in $(TYPES_SUPPORTED); do \
531  UPLOAD_DIR=klecker.debian.org:~/public_html/debian-installer/daily/                  $(MAKE) build TYPE=$$type; \
532  daily_build: clean          done
533          install -d $(DEST)  all_images:
534          fakeroot $(MAKE) tarball > $(DEST)/log 2>&1          set -e; for type in $(TYPES_SUPPORTED); do \
535          scp -q -B $(DEST)/log $(UPLOAD_DIR)                  $(MAKE) image TYPE=$$type; \
536          scp -q -B $(DEST)/$(TYPE)-debian-installer.tar.gz \          done
537                  $(UPLOAD_DIR)/$(TYPE)-debian-installer-$(shell date +%Y%m%d).tar.gz  # Suitable for a cron job, you'll only see the stats unless a build fails.
538    all_stats:
539  .PHONY: tree          @echo "Image size stats"
540            @echo
541            @(set -e; $(MAKE) all_build >tmp/log 2>&1 || \
542              (echo "build failure!"; cat tmp/log; false))
543            @rm -f tmp/log
544            @for type in $(TYPES_SUPPORTED); do \
545                    $(MAKE) -s stats TYPE=$$type; \
546            done

Legend:
Removed from v.579  
changed lines
  Added in v.4608

  ViewVC Help
Powered by ViewVC 1.1.5