| 1 |
#!/usr/bin/make -f
|
| 2 |
#
|
| 3 |
# Debian Installer system makefile.
|
| 4 |
# Copyright 2001-2003 by Joey Hess <joeyh@debian.org> and the d-i team.
|
| 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 |
#
|
| 12 |
# General layout of our build directory hierarchy
|
| 13 |
#
|
| 14 |
# build/config/[<subarch>/][<medium>/][<flavour>/]<leaf-config>
|
| 15 |
# build/tmp/[<subarch>/][<medium>/][<flavour>/]<build-area>
|
| 16 |
# build/dest/[<subarch>/][<medium>/][<flavour>-]<images>
|
| 17 |
#
|
| 18 |
# Items in brackets can be left out if they are superfluous.
|
| 19 |
#
|
| 20 |
# These following <image> names are conventional.
|
| 21 |
#
|
| 22 |
# For small changeable media (floppies and the like):
|
| 23 |
# - boot.img, root.img, driver.img
|
| 24 |
#
|
| 25 |
# For single bootable images (e.g. tftp boot images):
|
| 26 |
# - boot.img
|
| 27 |
#
|
| 28 |
# For compressed single bootable images (harddisk or hd emulation):
|
| 29 |
# - boot.img.gz
|
| 30 |
#
|
| 31 |
# If those are not bootable:
|
| 32 |
# - root.img.gz
|
| 33 |
#
|
| 34 |
# Raw kernel images:
|
| 35 |
# - vmlinux or vmlinuz
|
| 36 |
#
|
| 37 |
# Example:
|
| 38 |
#
|
| 39 |
# dest/
|
| 40 |
# |-- cdrom-boot.img
|
| 41 |
# |-- floppy
|
| 42 |
# | |-- access
|
| 43 |
# | | |-- boot.img
|
| 44 |
# | | |-- drivers.img
|
| 45 |
# | | `-- root.img
|
| 46 |
# | |-- boot.img
|
| 47 |
# | |-- cd-drivers.img
|
| 48 |
# | |-- net-drivers.img
|
| 49 |
# | `-- root.img
|
| 50 |
# |-- hd-media-boot.img.gz
|
| 51 |
# `-- netboot
|
| 52 |
# |-- initrd.gz
|
| 53 |
# `-- vmlinuz
|
| 54 |
#
|
| 55 |
|
| 56 |
# Add to PATH so dpkg will always work, and so local programs will be found.
|
| 57 |
PATH := util:$(PATH):/usr/sbin:/sbin
|
| 58 |
|
| 59 |
# We don't want this to be run each time we re-enter.
|
| 60 |
ifndef DEB_HOST_ARCH
|
| 61 |
DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
|
| 62 |
DEB_HOST_GNU_CPU = $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
|
| 63 |
DEB_HOST_GNU_SYSTEM = $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
|
| 64 |
export DEB_HOST_ARCH DEB_HOST_GNU_CPU DEB_HOST_GNU_SYSTEM
|
| 65 |
endif
|
| 66 |
|
| 67 |
# We loop over all needed combinations of ARCH, SUBARCH, MEDIUM, FLAVOUR
|
| 68 |
# via recursive make calls. ARCH is constant, we don't support
|
| 69 |
# crosscompiling.
|
| 70 |
ARCH = $(DEB_HOST_ARCH)
|
| 71 |
|
| 72 |
# By default, we just advertise what we can do.
|
| 73 |
.PHONY: all
|
| 74 |
all: list
|
| 75 |
|
| 76 |
# Globally useful variables.
|
| 77 |
targetstring = $(patsubst _%,%,$(if $(SUBARCH),_$(SUBARCH),)$(if $(MEDIUM),_$(MEDIUM),)$(if $(FLAVOUR),_$(FLAVOUR),))
|
| 78 |
targetdirs = $(subst _,/,$(targetstring))
|
| 79 |
|
| 80 |
|
| 81 |
# Configurations for the varying ARCH, SUBARCH, MEDIUM, FLAVOUR.
|
| 82 |
# For simplicity, we use a similiar tree layout for config/, tmp/
|
| 83 |
# and dest/.
|
| 84 |
#
|
| 85 |
# Cheap trick: if one of the variables isn't defined, we run in
|
| 86 |
# a non-existing file and ignore it.
|
| 87 |
include config/common
|
| 88 |
include config/dir
|
| 89 |
-include config/local
|
| 90 |
-include config/$(ARCH).cfg
|
| 91 |
-include config/$(ARCH)/$(SUBARCH).cfg
|
| 92 |
-include config/$(ARCH)/$(SUBARCH)/$(MEDIUM).cfg
|
| 93 |
-include config/$(ARCH)/$(SUBARCH)/$(MEDIUM)/$(FLAVOUR).cfg
|
| 94 |
|
| 95 |
export KEYRING
|
| 96 |
|
| 97 |
# Useful command sequences
|
| 98 |
define submake
|
| 99 |
$(MAKE) --no-print-directory
|
| 100 |
endef
|
| 101 |
|
| 102 |
define recurse_once
|
| 103 |
@set -e; $(submake) $(1)_$(2)
|
| 104 |
endef
|
| 105 |
|
| 106 |
define recurse_many
|
| 107 |
@set -e; $(foreach var,$($(1)_SUPPORTED),$(submake) $(2)_$(3) $(1)=$(var);)
|
| 108 |
endef
|
| 109 |
|
| 110 |
define recurse
|
| 111 |
$(if $($(1)_SUPPORTED),$(call recurse_many,$(1),$(2),$(3)),$(call recurse_once,$(2),$(3)))
|
| 112 |
endef
|
| 113 |
|
| 114 |
define genext2fs
|
| 115 |
genext2fs -d $(TREE) -b `expr $$(du -s $(TREE) | cut -f 1) + $$(expr $$(find $(TREE) | wc -l) \* 2)` -r 0
|
| 116 |
endef
|
| 117 |
|
| 118 |
define mkinitramfs
|
| 119 |
(cd $(TREE) && find . | cpio --quiet -o -H newc) >
|
| 120 |
endef
|
| 121 |
|
| 122 |
define e2fsck
|
| 123 |
e2fsck -fy
|
| 124 |
endef
|
| 125 |
|
| 126 |
define mkcramfs
|
| 127 |
mkcramfs -z $(TREE)
|
| 128 |
endef
|
| 129 |
|
| 130 |
# Define MKFS_JFFS2 in the config file for your target.
|
| 131 |
# For example: MKFS_JFFS2 = mkfs.jffs2 -f -p -b -e 0x20000
|
| 132 |
define mkjffs2
|
| 133 |
$(MKFS_JFFS2) -d $(TREE) -o
|
| 134 |
endef
|
| 135 |
|
| 136 |
# A generic recursion rule
|
| 137 |
.PHONY: all_%
|
| 138 |
all_%:
|
| 139 |
@install -d $(STAMPS)
|
| 140 |
$(call recurse,SUBARCH,subarch,$*)
|
| 141 |
|
| 142 |
.PHONY: subarch_%
|
| 143 |
subarch_%:
|
| 144 |
$(call recurse,MEDIUM,medium,$*)
|
| 145 |
|
| 146 |
.PHONY: medium_%
|
| 147 |
medium_%:
|
| 148 |
$(call recurse,FLAVOUR,flavour,$*)
|
| 149 |
|
| 150 |
.PHONY: flavour_%
|
| 151 |
flavour_%:
|
| 152 |
$(if $(targetstring),@$(submake) _$*)
|
| 153 |
|
| 154 |
# Validate a targetstring, echo env variables for valid ones
|
| 155 |
.PHONY: validate_%
|
| 156 |
validate_%:
|
| 157 |
@set -e; \
|
| 158 |
SUBARCH= var='$(subst _, ,$(subst validate_,,$@))'; \
|
| 159 |
tmp=$$(echo $$var |sed 's/[ ].*$$//'); \
|
| 160 |
[ -z '$(SUBARCH_SUPPORTED)' ] || [ -z "$$tmp" ] || [ -z "$$(echo $(SUBARCH_SUPPORTED) |grep -w $$tmp)" ] || SUBARCH=$$tmp; \
|
| 161 |
$(submake) medium_validate SUBARCH=$$SUBARCH var="$$var"
|
| 162 |
|
| 163 |
.PHONY: medium_validate
|
| 164 |
medium_validate:
|
| 165 |
@set -e; \
|
| 166 |
MEDIUM= var="$(strip $(patsubst $(SUBARCH)%,%,$(var)))"; \
|
| 167 |
tmp=$$(echo $$var |sed 's/[ ].*$$//'); \
|
| 168 |
[ -z '$(MEDIUM_SUPPORTED)' ] || [ -z "$$tmp" ] || [ -z "$$(echo $(MEDIUM_SUPPORTED) |grep -w $$tmp)" ] || MEDIUM=$$tmp; \
|
| 169 |
$(submake) flavour_validate MEDIUM=$$MEDIUM var="$$var"
|
| 170 |
|
| 171 |
.PHONY: flavour_validate
|
| 172 |
flavour_validate:
|
| 173 |
@set -e; \
|
| 174 |
FLAVOUR= var="$(strip $(patsubst $(MEDIUM)%,%,$(var)))"; \
|
| 175 |
tmp=$$(echo $$var |sed 's/[ ].*$$//'); \
|
| 176 |
[ -z '$(FLAVOUR_SUPPORTED)' ] || [ -z "$$tmp" ] || [ -z "$$(echo $(FLAVOUR_SUPPORTED) |grep -w $$tmp)" ] || FLAVOUR=$$tmp; \
|
| 177 |
$(submake) finish_validate FLAVOUR=$$FLAVOUR var="$$var"
|
| 178 |
|
| 179 |
.PHONY: finish_validate
|
| 180 |
finish_validate:
|
| 181 |
@set -e; \
|
| 182 |
var="$(strip $(patsubst $(FLAVOUR)%,%,$(var)))"; \
|
| 183 |
if [ -z "$$var" ]; then \
|
| 184 |
echo SUBARCH=$$SUBARCH MEDIUM=$$MEDIUM FLAVOUR=$$FLAVOUR; \
|
| 185 |
else \
|
| 186 |
echo SUBARCH= MEDIUM= FLAVOUR=; \
|
| 187 |
fi;
|
| 188 |
|
| 189 |
|
| 190 |
# List all targets useful for direct invocation.
|
| 191 |
.PHONY: list
|
| 192 |
list:
|
| 193 |
@echo "Useful targets:"
|
| 194 |
@echo
|
| 195 |
@echo "list"
|
| 196 |
@echo "all_build"
|
| 197 |
@echo "all_rebuild"
|
| 198 |
@echo "stats"
|
| 199 |
@echo "all_clean"
|
| 200 |
@echo "reallyclean"
|
| 201 |
@echo
|
| 202 |
@$(submake) all_list
|
| 203 |
|
| 204 |
.PHONY: _list
|
| 205 |
_list:
|
| 206 |
@set -e; \
|
| 207 |
echo build_$(targetstring); \
|
| 208 |
echo stats_$(targetstring); \
|
| 209 |
$(if $(findstring $(MEDIUM),$(WRITE_MEDIA)),echo write_$(targetstring);) \
|
| 210 |
echo clean_$(targetstring); \
|
| 211 |
echo rebuild_$(targetstring); \
|
| 212 |
echo demo_$(targetstring); \
|
| 213 |
echo shell_$(targetstring); \
|
| 214 |
echo uml_$(targetstring); \
|
| 215 |
echo qemu_$(targetstring); \
|
| 216 |
echo
|
| 217 |
|
| 218 |
|
| 219 |
# Clean all targets.
|
| 220 |
.PHONY: reallyclean
|
| 221 |
reallyclean: all_clean
|
| 222 |
rm -rf $(APTDIR) $(APTDIR).udeb $(APTDIR).deb $(BASE_DEST) $(BASE_TMP) $(SOURCEDIR) $(DEBUGUDEBDIR)
|
| 223 |
rm -f sources.list sources.list.udeb $(LOCALUDEBDIR)/Packages.gz $(LOCALUDEBDIR)/Packages
|
| 224 |
rm -rf $(UDEBDIR) $(STAMPS)
|
| 225 |
|
| 226 |
# For manual invocation, we provide a generic clean rule.
|
| 227 |
.PHONY: clean_%
|
| 228 |
clean_%:
|
| 229 |
@$(submake) _clean $(shell $(submake) $(subst clean_,validate_,$@))
|
| 230 |
update-manifest
|
| 231 |
|
| 232 |
# The general clean rule.
|
| 233 |
.PHONY: _clean
|
| 234 |
_clean: tree_umount
|
| 235 |
@[ -n "$(SUBARCH) $(MEDIUM) $(FLAVOUR)" ] || { echo "invalid target"; false; }
|
| 236 |
-rm -f $(STAMPS)tree-unpack-$(targetstring)-stamp $(STAMPS)tree-$(targetstring)-stamp $(STAMPS)extra-$(targetstring)-stamp $(STAMPS)get_udebs-$(targetstring)-stamp
|
| 237 |
rm -f $(TEMP)/diskusage.txt
|
| 238 |
rm -f $(TEMP)/all.utf
|
| 239 |
rm -f $(TEMP)/unifont.bdf $(TREE)/lib/unifont.bgf
|
| 240 |
rm -f pkg-lists/standard-udebs pkg-lists/kernel-module-udebs
|
| 241 |
rm -rf $(TARGET)
|
| 242 |
rm -rf $(TEMP)
|
| 243 |
|
| 244 |
# all_build is provided automagically, but for manual invocation
|
| 245 |
# we provide a generic build rule.
|
| 246 |
.PHONY: build_%
|
| 247 |
build_%:
|
| 248 |
@install -d $(STAMPS)
|
| 249 |
@$(submake) _build $(shell $(submake) $(subst build_,validate_,$@))
|
| 250 |
|
| 251 |
# The general build rule.
|
| 252 |
.PHONY: _build
|
| 253 |
_build:
|
| 254 |
@[ -n "$(SUBARCH) $(MEDIUM) $(FLAVOUR)" ] || { echo "invalid target"; false; }
|
| 255 |
@$(submake) tree_umount $(EXTRATARGETS) $(TARGET)
|
| 256 |
|
| 257 |
# Convenience rules to clean and build.
|
| 258 |
.PHONY: rebuild_%
|
| 259 |
rebuild_%:
|
| 260 |
@$(submake) clean_$(subst rebuild_,,$@) build_$(subst rebuild_,,$@)
|
| 261 |
|
| 262 |
.PHONY: _rebuild
|
| 263 |
_rebuild:
|
| 264 |
@$(submake) _clean _build
|
| 265 |
|
| 266 |
# Run before releasing built files.
|
| 267 |
release:
|
| 268 |
egrep '^[[:space:]]' $(BASE_DEST)/MANIFEST.udebs | \
|
| 269 |
sed 's/^[[:space:]]*//' | sort | uniq > $(BASE_DEST)/udeb.list
|
| 270 |
rm -f $(BASE_DEST)/MD5SUMS
|
| 271 |
cd $(BASE_DEST) && md5sum `find . -type f` > MD5SUMS
|
| 272 |
|
| 273 |
# The general tree target.
|
| 274 |
$(STAMPS)tree-unpack-$(targetstring)-stamp: $(STAMPS)get_udebs-$(targetstring)-stamp
|
| 275 |
dh_testroot
|
| 276 |
cd .. && dpkg-checkbuilddeps
|
| 277 |
@rm -f $@
|
| 278 |
|
| 279 |
# This build cannot be restarted, because dpkg gets confused.
|
| 280 |
rm -rf $(TREE)
|
| 281 |
# Set up the basic files [u]dpkg needs.
|
| 282 |
mkdir -p $(DPKGDIR)/info
|
| 283 |
touch $(DPKGDIR)/status
|
| 284 |
# Create a tmp tree
|
| 285 |
mkdir -p $(TREE)/tmp
|
| 286 |
# Only dpkg needs this stuff, so it can be removed later.
|
| 287 |
mkdir -p $(DPKGDIR)/updates/
|
| 288 |
touch $(DPKGDIR)/available
|
| 289 |
|
| 290 |
# Unpack the udebs with dpkg. This command must run as root
|
| 291 |
# or fakeroot.
|
| 292 |
echo -n > $(TEMP)/diskusage.txt
|
| 293 |
set -e; \
|
| 294 |
oldsize=0; oldblocks=0; oldcount=0; for udeb in $(UDEBDIR)/*.udeb ; do \
|
| 295 |
if [ -f "$$udeb" ]; then \
|
| 296 |
pkg=`basename $$udeb` ; \
|
| 297 |
dpkg $(DPKG_UNPACK_OPTIONS) --log=/dev/null --root=$(TREE) --unpack $$udeb ; \
|
| 298 |
newsize=`du -bs $(TREE) | awk '{print $$1}'` ; \
|
| 299 |
newblocks=`du -s $(TREE) | awk '{print $$1}'` ; \
|
| 300 |
newcount=`find $(TREE) -type f | wc -l | awk '{print $$1}'` ; \
|
| 301 |
usedsize=`echo $$newsize - $$oldsize | bc`; \
|
| 302 |
usedblocks=`echo $$newblocks - $$oldblocks | bc`; \
|
| 303 |
usedcount=`echo $$newcount - $$oldcount | bc`; \
|
| 304 |
version=`dpkg-deb --info $$udeb | grep '^ *Version:' | sed 's/^ *//' | awk '{print $$2}'` ; \
|
| 305 |
echo " $$usedsize B - $$usedblocks blocks - $$usedcount files from $$pkg (version $$version)" >>$(TEMP)/diskusage.txt;\
|
| 306 |
oldsize=$$newsize ; \
|
| 307 |
oldblocks=$$newblocks ; \
|
| 308 |
oldcount=$$newcount ; \
|
| 309 |
fi; \
|
| 310 |
done
|
| 311 |
sort -n < $(TEMP)/diskusage.txt > $(TEMP)/diskusage.txt.new && \
|
| 312 |
mv $(TEMP)/diskusage.txt.new $(TEMP)/diskusage.txt
|
| 313 |
grep-dctrl -nsPackage,Version,Architecture '' $(TREE)/var/lib/dpkg/status | \
|
| 314 |
perl -nle '$$p = $$_; $$v = <>; chomp $$v; $$a = <>; chomp $$a; <>; print "$$p $$v $$a"' | \
|
| 315 |
sort > $(TEMP_UDEB_LIST)
|
| 316 |
|
| 317 |
# Clean up after dpkg.
|
| 318 |
rm -rf $(DPKGDIR)/updates
|
| 319 |
rm -f $(DPKGDIR)/available $(DPKGDIR)/*-old $(DPKGDIR)/lock
|
| 320 |
|
| 321 |
ifdef EXTRAFILES
|
| 322 |
# Copy in any extra files.
|
| 323 |
set -e; \
|
| 324 |
for file in $(EXTRAFILES); do \
|
| 325 |
mkdir -p $(TREE)/`dirname $$file`; \
|
| 326 |
cp -a $$file $(TREE)/$$file; \
|
| 327 |
done
|
| 328 |
endif
|
| 329 |
|
| 330 |
ifdef KERNELVERSION
|
| 331 |
# Set up modules.dep, ensure there is at least one standard dir (kernel
|
| 332 |
# in this case), so depmod will use its prune list for archs with no
|
| 333 |
# modules.
|
| 334 |
set -e; \
|
| 335 |
$(foreach VERSION,$(KERNELVERSION), \
|
| 336 |
sysmap_name=; sysmap_opt=; \
|
| 337 |
if [ -n "$(VERSIONED_SYSTEM_MAP)" ]; then \
|
| 338 |
[ ! -e $(TREE)/boot/System.map-$(VERSION) ] || sysmap_name="$(TREE)/boot/System.map-$(VERSION)"; \
|
| 339 |
else \
|
| 340 |
[ ! -e $(TREE)/boot/System.map ] || sysmap_name="$(TREE)/boot/System.map"; \
|
| 341 |
fi; \
|
| 342 |
[ -z "$$sysmap_name" ] || sysmap_opt="-F $$sysmap_name"; \
|
| 343 |
if [ -d $(TREE)/lib/modules/$(VERSION) ]; then \
|
| 344 |
mkdir -p $(TREE)/lib/modules/$(VERSION)/kernel; \
|
| 345 |
$(shell choose-subarch-env $(VERSION)) depmod $$sysmap_opt -q -a -b $(TREE)/ $(VERSION); \
|
| 346 |
fi; \
|
| 347 |
[ -z "$$sysmap_name" ] || mv $$sysmap_name $(TEMP);)
|
| 348 |
|
| 349 |
# These files depmod makes are used by hotplug, if it's being used;
|
| 350 |
# otherwise, we shouldn't need them. Some files aren't even used by
|
| 351 |
# hotplug, so never include them.
|
| 352 |
if [ -d $(TREE)/etc/udev ] || [ -d $(TREE)/etc/hotplug ]; then \
|
| 353 |
find $(TREE)/lib/modules/ -name 'modules*' \
|
| 354 |
-not -name modules.dep -not -name modules.alias \
|
| 355 |
-not -name 'modules.*map' \
|
| 356 |
-not -type d | xargs rm -f; \
|
| 357 |
else \
|
| 358 |
find $(TREE)/lib/modules/ -name 'modules*' \
|
| 359 |
-not -name modules.dep -not -type d | xargs rm -f; \
|
| 360 |
fi
|
| 361 |
|
| 362 |
# These files are used to build special kernel images for some
|
| 363 |
# subarchitectures. Move them out of the way.
|
| 364 |
$(foreach VERSION,$(KERNELVERSION), \
|
| 365 |
if [ -d $(TREE)/usr/lib/kernel-image-$(VERSION) ]; then \
|
| 366 |
mv $(TREE)/usr/lib/kernel-image-$(VERSION) \
|
| 367 |
$(TEMP)/lib; \
|
| 368 |
fi; \
|
| 369 |
if [ -d $(TREE)/usr/lib/linux-image-$(VERSION) ]; then \
|
| 370 |
mv $(TREE)/usr/lib/linux-image-$(VERSION) \
|
| 371 |
$(TEMP)/lib; \
|
| 372 |
fi;)
|
| 373 |
endif
|
| 374 |
|
| 375 |
ifdef KERNELNAME
|
| 376 |
# Move the kernel image out of the way.
|
| 377 |
$(foreach name,$(KERNELNAME), \
|
| 378 |
mv -f $(TREE)/boot/$(name) $(TEMP)/$(name);)
|
| 379 |
rmdir $(TREE)/boot/
|
| 380 |
endif
|
| 381 |
|
| 382 |
ifdef PRESEED
|
| 383 |
# Copy in preseed file.
|
| 384 |
cp -a $(PRESEED) $(TREE)/preseed.cfg
|
| 385 |
endif
|
| 386 |
ifdef PRESEED_SUITE
|
| 387 |
# Add suite preseed file.
|
| 388 |
if [ -e "$(TREE)/preseed.cfg" ]; then \
|
| 389 |
cat $(PRESEED_SUITE) >> $(TREE)/preseed.cfg; \
|
| 390 |
else \
|
| 391 |
cp -a $(PRESEED_SUITE) $(TREE)/preseed.cfg; \
|
| 392 |
fi
|
| 393 |
endif
|
| 394 |
|
| 395 |
ifneq (,$(wildcard $(KEYRING)))
|
| 396 |
mkdir -p $(TREE)/usr/share/keyrings
|
| 397 |
cp -a $(KEYRING) $(TREE)/usr/share/keyrings/archive.gpg
|
| 398 |
endif
|
| 399 |
|
| 400 |
# Create an lsb release file.
|
| 401 |
if [ ! -e $(TREE)/etc/lsb-release ]; then \
|
| 402 |
set -e; \
|
| 403 |
mkdir -p $(TREE)/etc; \
|
| 404 |
echo 'DISTRIB_ID=$(LSB_DISTRIB_ID)' > $(TREE)/etc/lsb-release; \
|
| 405 |
echo 'DISTRIB_DESCRIPTION=$(LSB_DISTRIB_DESCRIPTION)' >> $(TREE)/etc/lsb-release; \
|
| 406 |
echo 'DISTRIB_RELEASE=$(LSB_DISTRIB_RELEASE)' >> $(TREE)/etc/lsb-release; \
|
| 407 |
echo 'X_INSTALLATION_MEDIUM=$(MEDIUM)' >> $(TREE)/etc/lsb-release; \
|
| 408 |
fi
|
| 409 |
|
| 410 |
@touch $@
|
| 411 |
|
| 412 |
|
| 413 |
$(STAMPS)tree-$(targetstring)-stamp: $(STAMPS)tree-unpack-$(targetstring)-stamp
|
| 414 |
# Create a dev tree.
|
| 415 |
mkdir -p $(TREE)/dev
|
| 416 |
# Always needed, in case devfs is not mounted on boot.
|
| 417 |
mknod $(TREE)/dev/console c 5 1
|
| 418 |
mknod $(TREE)/dev/null c 1 3
|
| 419 |
|
| 420 |
mkdir -p $(EXTRAUDEBSDIR)
|
| 421 |
mkdir -p $(EXTRAUDEBSDPKGDIR)/info $(EXTRAUDEBSDPKGDIR)/updates
|
| 422 |
touch $(EXTRAUDEBSDPKGDIR)/status $(EXTRAUDEBSDPKGDIR)/available
|
| 423 |
ifdef EXTRADRIVERS
|
| 424 |
# Unpack the udebs of additional driver disks, so mklibs runs on them too.
|
| 425 |
dpkg $(DPKG_UNPACK_OPTIONS) --log=/dev/null --root=$(EXTRAUDEBSDIR) --unpack \
|
| 426 |
$(wildcard $(foreach dir,$(EXTRADRIVERS),$(dir)/*.udeb))
|
| 427 |
endif
|
| 428 |
ifdef EXTRAUDEBS
|
| 429 |
# Get and unpack extra udebs too.
|
| 430 |
get-packages udeb $(EXTRAUDEBS)
|
| 431 |
dpkg $(DPKG_UNPACK_OPTIONS) --log=/dev/null --root=$(EXTRAUDEBSDIR) --unpack \
|
| 432 |
$(foreach udeb,$(EXTRAUDEBS),$(UDEBDIR)/$(udeb).udeb)
|
| 433 |
endif
|
| 434 |
|
| 435 |
# Library reduction. Existing libs from udebs are put in the udeblibs
|
| 436 |
# directory and mklibs is made to use those in preference to the
|
| 437 |
# system libs.
|
| 438 |
rm -rf $(TEMP)/udeblibs
|
| 439 |
ifndef ONLY_KLIBC
|
| 440 |
mkdir -p $(TEMP)/udeblibs
|
| 441 |
-cp -a `find $(EXTRAUDEBSDIR)/lib -name '*.so.*'` $(TEMP)/udeblibs
|
| 442 |
-cp -a `find $(TREE)/lib -name '*.so.*'` $(TEMP)/udeblibs
|
| 443 |
mkdir -p $(TREE)/lib
|
| 444 |
$(MKLIBS) -L $(TREE)/usr/lib -L $(TEMP)/udeblibs -v -d $(TREE)/lib --root=$(TREE) \
|
| 445 |
`find $(TEMP) -type f -a \( -perm +0111 -o -name '*.so' -o -name '*.so.*' \) | grep -v udeblibs`
|
| 446 |
rm -rf $(TEMP)/udeblibs
|
| 447 |
endif
|
| 448 |
|
| 449 |
# Add missing symlinks for libraries
|
| 450 |
/sbin/ldconfig -n $(TREE)/lib $(TREE)/usr/lib
|
| 451 |
|
| 452 |
# Remove any libraries that are present in both usr/lib and lib,
|
| 453 |
# from lib. These were unnecessarily copied in by mklibs, and
|
| 454 |
# we want to use the ones in usr/lib instead since they came
|
| 455 |
# from udebs. Only libdebconfclient0 has this problem so far.
|
| 456 |
set -e; \
|
| 457 |
for lib in `find $(TREE)/usr/lib/ -name "lib*" -type f -printf "%f\n" | cut -d . -f 1 | sort | uniq`; do \
|
| 458 |
rm -f $(TREE)/lib/$$lib.*; \
|
| 459 |
done
|
| 460 |
|
| 461 |
# Reduce status file to contain only the elements we care about.
|
| 462 |
egrep -i '^((Status|Provides|Depends|Package|Version|Description|installer-menu-item|Description-..):|$$)' \
|
| 463 |
$(DPKGDIR)/status > $(DPKGDIR)/status.new
|
| 464 |
mv $(DPKGDIR)/status.new $(DPKGDIR)/status
|
| 465 |
|
| 466 |
# Add a dummy entry for the debian installer itself to the status
|
| 467 |
# file, giving the overall version of this build.
|
| 468 |
echo "Package: debian-installer" >> $(DPKGDIR)/status
|
| 469 |
echo "Status: install ok installed" >> $(DPKGDIR)/status
|
| 470 |
echo "Version: $(subst _,-,$(targetstring))-$(BUILD_DATE)" >> $(DPKGDIR)/status
|
| 471 |
echo "Description: debian installation image" >> $(DPKGDIR)/status
|
| 472 |
echo >> $(DPKGDIR)/status
|
| 473 |
|
| 474 |
ifdef DROP_LANG
|
| 475 |
# Remove languages from the templates.
|
| 476 |
# Not ideal, but useful if you're very tight on space.
|
| 477 |
set -e; \
|
| 478 |
for FILE in $$(find $(TREE)/var/lib/dpkg -name "*.templates"); do \
|
| 479 |
perl -e 'my $$status=0; my $$drop=shift; while (<>) { if (/^[A-Z]/ || /^$$/) { if (/^(Choices|Description|Indices|Default)-($$drop)/) { $$status = 0 } else { $$status = 1 } } print if ($$status); }' ${DROP_LANG} < $$FILE > temp; \
|
| 480 |
mv temp $$FILE; \
|
| 481 |
done
|
| 482 |
endif
|
| 483 |
|
| 484 |
# Strip all kernel modules, just in case they haven't already been
|
| 485 |
set -e; \
|
| 486 |
for module in `find $(TREE)/lib/modules/ -name '*.o' -o -name '*.ko'`; do \
|
| 487 |
strip -R .comment -R .note -g $$module; \
|
| 488 |
done
|
| 489 |
|
| 490 |
# Remove some unnecessary dpkg files.
|
| 491 |
set -e; \
|
| 492 |
for file in `find $(TREE)/var/lib/dpkg/info -name '*.md5sums' -o \
|
| 493 |
-name '*.postrm' -o -name '*.prerm' -o -name '*.preinst' -o \
|
| 494 |
-name '*.list'`; do \
|
| 495 |
if echo $$file | grep -qv '\.list'; then \
|
| 496 |
echo "** Removing unnecessary control file $$file"; \
|
| 497 |
fi; \
|
| 498 |
rm $$file; \
|
| 499 |
done
|
| 500 |
|
| 501 |
# Collect the used UTF-8 strings, to know which glyphs to include in
|
| 502 |
# the font.
|
| 503 |
cat needed-characters/*.utf > $(TEMP)/all.utf
|
| 504 |
if [ -n "`find $(EXTRAUDEBSDPKGDIR)/info/ -name \\*.templates`" ]; then \
|
| 505 |
cat $(EXTRAUDEBSDPKGDIR)/info/*.templates >> $(TEMP)/all.utf; \
|
| 506 |
fi
|
| 507 |
if [ -n "`find $(DPKGDIR)/info/ -name \\*.templates`" ]; then \
|
| 508 |
cat $(DPKGDIR)/info/*.templates >> $(TEMP)/all.utf; \
|
| 509 |
fi
|
| 510 |
|
| 511 |
# Remove extra udebs now that we're done with them.
|
| 512 |
rm -rf $(EXTRAUDEBSDIR)
|
| 513 |
|
| 514 |
# Tree target ends here. Whew!
|
| 515 |
@touch $@
|
| 516 |
|
| 517 |
# Get the list of udebs to install.
|
| 518 |
# HACK Alert: pkg-lists/ is still sorted by TYPE instead of a dir hierarchy.
|
| 519 |
UDEBS = $(shell set -e; get-packages udeb update >&2; pkg-list $(TYPE) "$(DRIVER_FOR)" $(KERNEL_FLAVOUR) $(KERNELMAJOR) "$(SUBARCH)" $(KERNELIMAGEVERSION)) $(EXTRAS)
|
| 520 |
|
| 521 |
# Get all required udebs and put them in UDEBDIR.
|
| 522 |
$(STAMPS)get_udebs-$(targetstring)-stamp: sources.list.udeb
|
| 523 |
dh_testroot
|
| 524 |
@rm -f $@
|
| 525 |
get-packages udeb $(UDEBS)
|
| 526 |
@touch $@
|
| 527 |
|
| 528 |
# Auto-generate a sources.list.type
|
| 529 |
sources.list.udeb:
|
| 530 |
(set -e; \
|
| 531 |
echo "# This file is automatically generated, edit $@.local instead."; \
|
| 532 |
echo "deb copy:$(shell pwd)/ $(LOCALUDEBDIR)/"; \
|
| 533 |
if [ "$(MIRROR)x" != "x" ]; then \
|
| 534 |
echo "deb $(MIRROR) $(SUITE) $(UDEB_COMPONENTS)"; \
|
| 535 |
else \
|
| 536 |
grep '^deb[ \t]' $(SYSTEM_SOURCES_LIST) \
|
| 537 |
|grep -v '^deb[ \t]cdrom:' \
|
| 538 |
|grep -v '\(non-US\|non-us.debian.org\|security.debian.org\)' \
|
| 539 |
|grep '[ \t]main' \
|
| 540 |
|awk '{print $$1 " " $$2}' \
|
| 541 |
|sed "s,/* *$$, $(SUITE) $(UDEB_COMPONENTS)," \
|
| 542 |
|sed "s,^deb file,deb copy," \
|
| 543 |
|perl -ne 'print unless $$seen{$$_}; $$seen{$$_}=1' ; \
|
| 544 |
fi) > $@
|
| 545 |
|
| 546 |
|
| 547 |
# Font generation.
|
| 548 |
#
|
| 549 |
# Use the UTF-8 locale in installation-locale. This target shouldn't
|
| 550 |
# be called when it is not present anyway.
|
| 551 |
# The locale must be generated after installing the package locales
|
| 552 |
$(TREE)/lib/unifont.bgf: $(TEMP)/all.utf
|
| 553 |
set -e; \
|
| 554 |
CHARMAP=`LOCPATH=$(LOCALE_PATH) LC_ALL=C.UTF-8 locale charmap`; \
|
| 555 |
if [ UTF-8 != "$$CHARMAP" ]; then \
|
| 556 |
echo "error: Trying to build unifont.bgf without installation-locale!"; \
|
| 557 |
echo "(Alternatively, installation-locale may have been built against"; \
|
| 558 |
echo "a version of glibc with a different locale data format.)"; \
|
| 559 |
exit 1; \
|
| 560 |
fi
|
| 561 |
LOCPATH=$(LOCALE_PATH) LC_ALL=C.UTF-8 reduce-font /usr/src/unifont.bdf < $(TEMP)/all.utf > $(TEMP)/unifont.bdf
|
| 562 |
bdftobogl -b $(TEMP)/unifont.bdf > $@.tmp
|
| 563 |
mv $@.tmp $@
|
| 564 |
|
| 565 |
# Create a compressed image of the root filesystem.
|
| 566 |
$(TEMP_INITRD): $(STAMPS)tree-$(targetstring)-stamp arch_tree
|
| 567 |
# Only build the font if we have installation-locale
|
| 568 |
if [ -d "$(LOCALE_PATH)/C.UTF-8" ] && [ -e /usr/src/unifont.bdf ]; then \
|
| 569 |
$(submake) $(TREE)/lib/unifont.bgf; \
|
| 570 |
fi
|
| 571 |
install -d $(TEMP)
|
| 572 |
|
| 573 |
case $(INITRD_FS) in \
|
| 574 |
ext2) \
|
| 575 |
$(genext2fs) $(TEMP)/initrd; \
|
| 576 |
$(e2fsck) $(TEMP)/initrd || true; \
|
| 577 |
gzip -v9f $(TEMP)/initrd; \
|
| 578 |
;; \
|
| 579 |
cramfs) \
|
| 580 |
$(mkcramfs) $(TEMP)/initrd; \
|
| 581 |
gzip -v9f $(TEMP)/initrd; \
|
| 582 |
;; \
|
| 583 |
initramfs) \
|
| 584 |
$(mkinitramfs) $(TEMP)/initrd; \
|
| 585 |
gzip -v9f $(TEMP)/initrd; \
|
| 586 |
;; \
|
| 587 |
jffs2) \
|
| 588 |
$(mkjffs2) $(TEMP_INITRD); \
|
| 589 |
;; \
|
| 590 |
*) \
|
| 591 |
echo "Unsupported filesystem type"; \
|
| 592 |
exit 1 ;; \
|
| 593 |
esac
|
| 594 |
|
| 595 |
# Create the images for dest/. Those are the targets called from config.
|
| 596 |
|
| 597 |
$(INITRD): $(TEMP_INITRD)
|
| 598 |
install -m 644 -D $< $@
|
| 599 |
update-manifest $@ $(MANIFEST-INITRD) $(UDEB_LISTS)
|
| 600 |
|
| 601 |
$(RAMDISK): $(TEMP_INITRD)
|
| 602 |
install -m 644 -D $< $@
|
| 603 |
update-manifest $@ $(MANIFEST-RAMDISK) $(UDEB_LISTS)
|
| 604 |
|
| 605 |
# raw kernel images
|
| 606 |
$(KERNEL): TEMP_REAL_KERNEL = $(TEMP)/$(shell echo ./$@ |sed 's,$(SOME_DEST)/$(EXTRANAME),,')
|
| 607 |
$(KERNEL):
|
| 608 |
@$(MAKE) $(STAMPS)tree-unpack-$(targetstring)-stamp $(TEMP_REAL_KERNEL)
|
| 609 |
install -m 644 -D $(TEMP_REAL_KERNEL) $@
|
| 610 |
update-manifest $@ $(MANIFEST-KERNEL)
|
| 611 |
|
| 612 |
# bootable images
|
| 613 |
$(BOOT): $(TEMP_BOOT)
|
| 614 |
install -m 644 -D $(TEMP_BOOT)$(GZIPPED) $@
|
| 615 |
update-manifest $@ $(MANIFEST-BOOT) $(UDEB_LISTS)
|
| 616 |
|
| 617 |
$(TEMP_KERNEL): $(STAMPS)tree-unpack-$(targetstring)-stamp
|
| 618 |
|
| 619 |
$(TEMP_BOOT): $(TEMP_INITRD) $(TEMP_KERNEL) $(TEMP_BOOT_SCREENS) arch_boot
|
| 620 |
|
| 621 |
# non-bootable root images
|
| 622 |
$(ROOT): $(TEMP_ROOT)
|
| 623 |
install -m 644 -D $(TEMP_ROOT)$(GZIPPED) $@
|
| 624 |
update-manifest $@ $(MANIFEST-ROOT) $(UDEB_LISTS)
|
| 625 |
|
| 626 |
$(TEMP_ROOT): $(TEMP_INITRD) arch_root
|
| 627 |
|
| 628 |
# miniature ISOs with only a boot image
|
| 629 |
$(MINIISO): $(TEMP_MINIISO)
|
| 630 |
install -m 644 -D $(TEMP_MINIISO) $@
|
| 631 |
update-manifest $@ $(MANIFEST-MINIISO) $(UDEB_LISTS)
|
| 632 |
|
| 633 |
$(TEMP_MINIISO): $(TEMP_BOOT_SCREENS) arch_miniiso
|
| 634 |
|
| 635 |
# various kinds of information, for use on debian-cd isos
|
| 636 |
$(DEBIAN_CD_INFO): $(TEMP_BOOT_SCREENS) $(TEMP_CD_INFO_DIR)
|
| 637 |
(cd $(TEMP_CD_INFO_DIR); tar czf - .) > $@
|
| 638 |
update-manifest $@ $(MANIFEST-DEBIAN_CD_INFO)
|
| 639 |
|
| 640 |
# a directory full of files for netbooting
|
| 641 |
$(NETBOOT_DIR): $(NETBOOT_DIR_TARGETS) $(TEMP_BOOT_SCREENS) $(TEMP_NETBOOT_DIR)
|
| 642 |
rm -rf $(SOME_DEST)/$(EXTRANAME)/debian-installer
|
| 643 |
mkdir -p $(SOME_DEST)/$(EXTRANAME)/debian-installer
|
| 644 |
cp -a $(TEMP_NETBOOT_DIR)/debian-installer/* $@
|
| 645 |
$(foreach link,$(NETBOOT_DIR_LINKS), \
|
| 646 |
rm -f $@/../$(link); \
|
| 647 |
cp -a $(TEMP_NETBOOT_DIR)/$(link) $@/..; \
|
| 648 |
)
|
| 649 |
update-manifest $@ $(MANIFEST-NETBOOT_DIR) $(UDEB_LISTS)
|
| 650 |
|
| 651 |
# a tarball for netbooting
|
| 652 |
$(NETBOOT_TAR): $(TEMP_NETBOOT_DIR)
|
| 653 |
(cd $(TEMP_NETBOOT_DIR); tar czf - .) > $@
|
| 654 |
update-manifest $@ $(MANIFEST-NETBOOT_TAR) $(UDEB_LISTS)
|
| 655 |
|
| 656 |
$(TEMP_BOOT_SCREENS): arch_boot_screens
|
| 657 |
$(TEMP_CD_INFO_DIR): arch_cd_info_dir
|
| 658 |
$(TEMP_NETBOOT_DIR): arch_netboot_dir
|
| 659 |
|
| 660 |
$(MISC): TEMP_REAL_MISC = $(shell echo ./$@ |sed 's,$(SOME_DEST)/$(EXTRANAME),,')
|
| 661 |
$(MISC):
|
| 662 |
install -m 644 $(TEMP_REAL_MISC) $(SOME_DEST)/$(EXTRANAME)
|
| 663 |
update-manifest \
|
| 664 |
$(SOME_DEST)/$(EXTRANAME)$(shell basename $(TEMP_REAL_MISC)) \
|
| 665 |
$(MANIFEST-MISC)
|
| 666 |
|
| 667 |
# Other images, e.g. driver floppies. Those are simply handled as flavours
|
| 668 |
$(EXTRA): $(TEMP_EXTRA)
|
| 669 |
install -m 644 -D $(TEMP_EXTRA)$(GZIPPED) $@
|
| 670 |
update-manifest $@ $(MANIFEST-EXTRA) $(UDEB_LISTS)
|
| 671 |
|
| 672 |
$(TEMP_EXTRA): $(STAMPS)extra-$(targetstring)-stamp
|
| 673 |
install -d $(shell dirname $@)
|
| 674 |
install -d $(TREE)
|
| 675 |
set -e; case $(INITRD_FS) in \
|
| 676 |
ext2) \
|
| 677 |
genext2fs -d $(TREE) -b $(IMAGE_SIZE) -r 0 $@ ; \
|
| 678 |
$(e2fsck) $@ || true ;; \
|
| 679 |
cramfs) \
|
| 680 |
$(mkcramfs) $@ ;; \
|
| 681 |
*) \
|
| 682 |
echo "Unsupported filesystem type"; \
|
| 683 |
exit 1 ;; \
|
| 684 |
esac
|
| 685 |
$(if $(GZIPPED),gzip -v9f $(TEMP_EXTRA))
|
| 686 |
|
| 687 |
$(STAMPS)extra-$(targetstring)-stamp: $(STAMPS)get_udebs-$(targetstring)-stamp
|
| 688 |
@rm -f $@
|
| 689 |
mkdir -p $(TREE)
|
| 690 |
echo -n > $(TEMP)/diskusage.txt
|
| 691 |
echo -n > $(TEMP_UDEB_LIST)
|
| 692 |
|
| 693 |
set -e; \
|
| 694 |
for file in $(UDEBS); do \
|
| 695 |
cp $(UDEBDIR)/$$file* $(TREE) ; \
|
| 696 |
done
|
| 697 |
for udeb in $(TREE)/*.udeb ; do \
|
| 698 |
if [ -f "$$udeb" ]; then \
|
| 699 |
pkg=`basename $$udeb` ; \
|
| 700 |
usedsize=`du -bs $$udeb | awk '{print $$1}'` ; \
|
| 701 |
usedblocks=`du -s $$udeb | awk '{print $$1}'` ; \
|
| 702 |
usedcount=1 ; \
|
| 703 |
version=`dpkg-deb --info $$udeb | grep '^Version:' | awk '{print $$2}'` ; \
|
| 704 |
arch=`dpkg-deb --info $$udeb | grep Architecture: | awk '{print $$2}'` ; \
|
| 705 |
echo " $$usedsize B - $$usedblocks blocks - $$usedcount files used by pkg $$pkg (version $$version)" >>$(TEMP)/diskusage.txt; \
|
| 706 |
echo "$$pkg $$version $$arch" >> $(TEMP_UDEB_LIST); \
|
| 707 |
fi; \
|
| 708 |
done
|
| 709 |
sort -n < $(TEMP)/diskusage.txt > $(TEMP)/diskusage.txt.new && \
|
| 710 |
mv $(TEMP)/diskusage.txt.new $(TEMP)/diskusage.txt
|
| 711 |
echo $(UDEBS) > $(TREE)/udeb_include
|
| 712 |
makelabel $(DISK_LABEL) $(BUILD_DATE) > $(TREE)/disk.lbl
|
| 713 |
@touch $@
|
| 714 |
|
| 715 |
# Get a list of all the standard priority udebs, excluding kernel stuff.
|
| 716 |
pkg-lists/standard-udebs:
|
| 717 |
get-packages udeb update
|
| 718 |
grep-dctrl -FPriority -e 'required|standard|important' \
|
| 719 |
-sPackage apt.udeb/state/lists/*_Packages* | \
|
| 720 |
grep -v kernel-image | grep -v -- -modules | \
|
| 721 |
cut -d " " -f 2 > $@
|
| 722 |
|
| 723 |
# Get a list of all kernel modules matching the kernel version.
|
| 724 |
pkg-lists/kernel-module-udebs:
|
| 725 |
get-packages udeb update
|
| 726 |
> $@
|
| 727 |
$(foreach VERSION,$(KERNELVERSION), \
|
| 728 |
grep-dctrl -P -e '.*-modules-$(VERSION)-$(KERNEL_FLAVOUR)' \
|
| 729 |
-sPackage apt.udeb/state/lists/*_Packages* | \
|
| 730 |
cut -d " " -f 2 >> $@;)
|
| 731 |
|
| 732 |
# The kernel version changes from build to build, so always regen the file.
|
| 733 |
.PHONY: pkg-lists/kernel-module-udebs
|
| 734 |
|
| 735 |
# Write (floppy) images
|
| 736 |
.PHONY: write_%
|
| 737 |
write_%:
|
| 738 |
@install -d $(STAMPS)
|
| 739 |
@$(submake) _write $(shell $(submake) $(subst write_,validate_,$@))
|
| 740 |
|
| 741 |
.PHONY: _write
|
| 742 |
_write: _build
|
| 743 |
sudo dd if=$(TARGET) of=$(FLOPPYDEV) bs=$(FLOPPY_SIZE)k
|
| 744 |
|
| 745 |
# If you're paranoid (or things are mysteriously breaking..),
|
| 746 |
# you can check the floppy to make sure it wrote properly.
|
| 747 |
.PHONY: checkedwrite_%
|
| 748 |
checkedwrite_%:
|
| 749 |
@install -d $(STAMPS)
|
| 750 |
@$(submake) _checkedwrite $(shell $(submake) $(subst checkedwrite_,validate_,$@))
|
| 751 |
|
| 752 |
.PHONY: _checkedwrite
|
| 753 |
_checkedwrite: _write
|
| 754 |
sudo cmp $(FLOPPYDEV) $(TARGET)
|
| 755 |
|
| 756 |
|
| 757 |
# Generate statistics for all previously built images.
|
| 758 |
.PHONY: stats
|
| 759 |
stats:
|
| 760 |
@echo "Image size stats"
|
| 761 |
@echo
|
| 762 |
$(submake) all_stats
|
| 763 |
|
| 764 |
# For manual invocation we provide a generic stats rule.
|
| 765 |
.PHONY: stats_%
|
| 766 |
stats_%:
|
| 767 |
@$(submake) _stats $(shell $(submake) $(subst stats_,validate_,$@))
|
| 768 |
|
| 769 |
.PHONY: _stats
|
| 770 |
_stats:
|
| 771 |
@[ ! -f $(TEMP)/diskusage.txt ] || $(submake) general-stats
|
| 772 |
|
| 773 |
TOTAL_SZ = $(shell expr $(shell du -bs $(TREE) | cut -f 1) / 1024)
|
| 774 |
LIBS_SZ = $(shell [ -d $(TREE)/lib ] && du -hs --exclude=modules $(TREE)/lib |cut -f 1)
|
| 775 |
MODULES_SZ = $(shell [ -d $(TREE)/lib/modules ] && du -hs $(TREE)/lib/modules |cut -f 1)
|
| 776 |
ifeq ($(TEMP_INITRD),)
|
| 777 |
INITRD_SZ = 0
|
| 778 |
else
|
| 779 |
INITRD_SZ = $(shell expr \( $(shell [ -f $(TEMP_INITRD) ] && du -bs $(TEMP_INITRD) |cut -f 1) + 0 \) / 1024)
|
| 780 |
endif
|
| 781 |
ifeq ($(TEMP_KERNEL),)
|
| 782 |
KERNEL_SZ = 0
|
| 783 |
else
|
| 784 |
KERNEL_SZ = $(shell expr \( $(foreach kern,$(TEMP_KERNEL),$(shell [ -f $(kern) ] && du -bs $(kern) |cut -f 1)) + 0 \) / 1024)
|
| 785 |
endif
|
| 786 |
ifeq ($(TARGET),$(ROOT))
|
| 787 |
# image without a kernel
|
| 788 |
KERNEL_SZ = 0
|
| 789 |
endif
|
| 790 |
.PHONY: general-stats
|
| 791 |
general-stats:
|
| 792 |
@echo "System stats for $(targetstring)"
|
| 793 |
@echo "-------------------------"
|
| 794 |
@printf "Total system size: $(TOTAL_SZ)k"
|
| 795 |
ifneq ($(LIBS_SZ)$(MODULES_SZ),)
|
| 796 |
@echo " ($(LIBS_SZ) libs, $(MODULES_SZ) kernel modules)"
|
| 797 |
else
|
| 798 |
@echo
|
| 799 |
endif
|
| 800 |
@echo "Initrd size: $(INITRD_SZ)k"
|
| 801 |
@echo "Kernel size: $(KERNEL_SZ)k"
|
| 802 |
ifdef FLOPPY_SIZE
|
| 803 |
ifneq ($(INITRD_SZ),0)
|
| 804 |
@echo "Free space: $(shell expr $(FLOPPY_SIZE) - $(KERNEL_SZ) - $(INITRD_SZ))k"
|
| 805 |
else
|
| 806 |
@echo "Free space: $(shell expr $(FLOPPY_SIZE) - $(KERNEL_SZ) - $(TOTAL_SZ))k"
|
| 807 |
endif
|
| 808 |
endif
|
| 809 |
@echo "Disk usage per package:"
|
| 810 |
@sed 's/^/ /' < $(TEMP)/diskusage.txt
|
| 811 |
|
| 812 |
.PHONY: tree_mount
|
| 813 |
tree_mount: $(STAMPS)tree-$(targetstring)-stamp
|
| 814 |
-@sudo /bin/mount -t proc proc $(TREE)/proc
|
| 815 |
-@if [ -e $(TREE)/usr/bin/update-dev ]; then \
|
| 816 |
sudo chroot $(TREE) /usr/bin/update-dev; \
|
| 817 |
else \
|
| 818 |
sudo /bin/mount -t devfs dev $(TREE)/dev; \
|
| 819 |
fi
|
| 820 |
|
| 821 |
.PHONY: tree_umount
|
| 822 |
tree_umount:
|
| 823 |
-@[ ! -L $(TREE)/proc/self ] || [ ! -c $(TREE)/dev/tty ] || sudo /bin/umount $(TREE)/proc
|
| 824 |
|
| 825 |
# For manual invocation, we provide a demo rule. This starts the
|
| 826 |
# d-i demo from the tree in tmp.
|
| 827 |
.PHONY: demo_%
|
| 828 |
demo_%:
|
| 829 |
@set -e; \
|
| 830 |
export SUBARCH=; \
|
| 831 |
export FLAVOUR=; \
|
| 832 |
export MEDIUM=$(subst demo_,,$@); \
|
| 833 |
$(submake) _demo
|
| 834 |
|
| 835 |
.PHONY: _demo
|
| 836 |
_demo: $(TARGET)
|
| 837 |
@$(submake) tree_mount; \
|
| 838 |
[ -f questions.dat ] && cp -f questions.dat $(TREE)/var/lib/cdebconf/ ; \
|
| 839 |
sudo chroot $(TREE) bin/sh -c "export DEBCONF_DEBUG=5 ; /usr/bin/debconf-loadtemplate debian /var/lib/dpkg/info/*.templates; exec /usr/share/debconf/frontend /usr/bin/main-menu" ; \
|
| 840 |
$(submake) tree_umount
|
| 841 |
|
| 842 |
# For a shell into a d-i chroot.
|
| 843 |
.PHONY: shell_%
|
| 844 |
shell_%:
|
| 845 |
@export SUBARCH=; \
|
| 846 |
export FLAVOUR=; \
|
| 847 |
export MEDIUM=$(subst shell_,,$@); \
|
| 848 |
$(submake) _shell
|
| 849 |
|
| 850 |
.PHONY: _shell
|
| 851 |
_shell: $(TREE)
|
| 852 |
@$(submake) tree_mount; \
|
| 853 |
sudo chroot $(TREE) bin/sh; \
|
| 854 |
$(submake) tree_umount
|
| 855 |
|
| 856 |
# For running a d-i image in UML.
|
| 857 |
.PHONY: uml_%
|
| 858 |
uml_%:
|
| 859 |
@set -e; \
|
| 860 |
export SUBARCH=; \
|
| 861 |
export FLAVOUR=; \
|
| 862 |
export MEDIUM=$(subst uml_,,$@); \
|
| 863 |
$(submake) _uml
|
| 864 |
|
| 865 |
.PHONY: _uml
|
| 866 |
_uml: $(TARGET)
|
| 867 |
-linux initrd=$(INITRD) root=/dev/rd/0 ramdisk_size=8192 con=fd:0,fd:1 devfs=mount
|
| 868 |
|
| 869 |
# For running a d-i image in qemu.
|
| 870 |
.PHONY: qemu_%
|
| 871 |
qemu_%:
|
| 872 |
@set -e; \
|
| 873 |
export SUBARCH=; \
|
| 874 |
export FLAVOUR=; \
|
| 875 |
export MEDIUM=$(subst qemu_,,$@); \
|
| 876 |
$(submake) _qemu $(shell $(submake) $(subst qemu_,validate_,$@))
|
| 877 |
|
| 878 |
.PHONY: _qemu
|
| 879 |
_qemu: $(TARGET)
|
| 880 |
@case "$(MEDIA_TYPE)" in \
|
| 881 |
floppy) \
|
| 882 |
$(QEMU) -fda $(BOOT); \
|
| 883 |
;; \
|
| 884 |
CD-ROM) \
|
| 885 |
$(QEMU) -cdrom $(BOOT); \
|
| 886 |
;; \
|
| 887 |
*) \
|
| 888 |
echo "Sorry, don't know how to handle media type '$(MEDIA_TYPE)'" >&2; \
|
| 889 |
exit 1; \
|
| 890 |
esac
|