$alt_rules_file = "/usr/share/kernel-package/ruleset/minimal.mk";
$main::Version = '13.018+nmu2';
$rules_file = "debian/rules";
my $alt_cmd = "make kpkg_version=$main::Version -f $alt_rules_file ";
$alt_cmd .= "debian";
my $command = "$rules_file ";
make-kpkg大流程
2条线:
- alt_cmd
- command
Known Targets are:
===============================================================================
| Targets | Automatically builds |
===============================================================================
| clean | |
| buildpackage | Builds the whole package |
|* binary | Builds kernel_{source,headers,image,doc} |
|* binary-indep | |
| kernel_source | |
| kernel_doc | |
| kernel_manual | |
|* binary-arch | |
| kernel_headers | |
| kernel_debug | |
| kernel_image | Builds build |
| build | |
| modules | |
| modules_image | |
| modules_config | |
| modules_clean | |
| configure | If you wish to edit files |
| debian | generated by make config |
| debian | Creates ./debian dir |
===============================================================================
alt_cmd
make kpkg_version=13.018+nmu2 -f /usr/share/kernel-package/ruleset/minimal.mk debian
执行/usr/share/kernel-package/ruleset/minimal.mk
的debian
目标。
在此之前执行rmtree( ['debian'], 0, 1 );
minimal.mk
37 # Where the package libs are stored
38 LIBLOC :=/usr/share/kernel-package
39
40 define which_debdir
41 DEBDIR=$(shell if test -f ./debian/ruleset/kernel_version.mk; then echo ./debian; \
42 ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ else echo $(LIBLOC); fi)
43 endef
44 $(eval $(which_debdir))
45
46 include $(DEBDIR)/ruleset/common/archvars.mk
47 include $(DEBDIR)/ruleset/common/install_cmds.mk
48 include $(DEBDIR)/ruleset/misc/defaults.mk
49 include $(DEBDIR)/ruleset/misc/version_vars.mk
50 include $(DEBDIR)/ruleset/misc/kernel_arch.mk
51 include $(DEBDIR)/ruleset/misc/pkg_names.mk
52 -include $(CONFLOC)
53 include $(DEBDIR)/ruleset/misc/config.mk
加载头文件
92 debian/stamp/conf/minimal_debian:
93 $(REASON)
94 @echo "This is kernel package version $(kpkg_version)."
95 test -d debian || mkdir debian
96 @test -d debian/stamp || mkdir debian/stamp
97 @test -d debian/stamp/conf || mkdir debian/stamp/conf
98 test ! -e stamp-building || rm -f stamp-building
99 install -p -m 755 $(LIBLOC)/rules debian/rules
100 for file in $(DEBIAN_FILES); do \
101 ¦ ¦ cp -f $(LIBLOC)/$$file ./debian/; \
102 ¦ done
103 for dir in $(DEBIAN_DIRS); do \
104 ¦ ¦ cp -af $(LIBLOC)/$$dir ./debian/; \
105 ¦ done
106 test -f debian/control || sed -e 's/=V/$(version)/g' \
107 ¦ ¦ ¦ -e 's/=D/$(debian)/g' -e 's/=A/$(DEB_HOST_ARCH)/g' \
108 -e 's/=SA/$(INT_SUBARCH)/g' \
109 -e 's/=I/$(initrddep)/g' \
110 -e 's/=CV/$(VERSION).$(PATCHLEVEL)/g' \
111 -e 's/=M/$(maintainer) <$(email)>/g' \
112 -e 's/=ST/$(INT_STEM)/g' -e 's/=B/$(KERNEL_ARCH)/g' \
113 ¦ ¦ ¦ -e 's/=R/$(RAMFS_DEPS)/g' $(CONTROL) > debian/control
114 test -f debian/changelog || sed -e 's/=V/$(version)/g' \
115 ¦ ¦ -e 's/=D/$(debian)/g' -e 's/=A/$(DEB_HOST_ARCH)/g' \
116 ¦ ¦ -e 's/=ST/$(INT_STEM)/g' -e 's/=B/$(KERNEL_ARCH)/g' \
117 ¦ ¦ -e 's/=M/$(maintainer) <$(email)>/g' \
118 ¦ ¦ ¦$(LIBLOC)/changelog > debian/changelog
141 chmod 0644 debian/control debian/changelog
142 test -d ./debian/stamp || mkdir debian/stamp
143 $(MAKE) -f debian/rules debian/stamp/conf/kernel-conf
144 $(MAKE) -f debian/rules debian/stamp/conf/full-changelog
145 echo done > $@
146
147 debian: debian/stamp/conf/minimal_debian
第一部分:生成./debian目录以及目录下的内容(rules等),修改debian/control、changelog文件内容。最后调用 make -f debian/rules,
目标为debian/stamp/conf/kernel-conf、debian/stamp/conf/full-changelog
debian/stamp/conf/kernel-conf
195 @test -d debian/stamp || mkdir debian/stamp
196 @test -d debian/stamp/conf || mkdir debian/stamp/conf
DEB_HOST_ARCH_OS = $(dpkg-architecture -qDEB_HOST_ARCH_OS) = linux
207 ifeq ($(DEB_HOST_ARCH_OS), linux)
208 $(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) \
209 ¦ ¦ ¦ ¦ $(config_target);
210 ifeq ($(shell if [ $(VERSION) -gt 2 ]; then \
211 ¦ echo new; \
212 elif [ $(VERSION) -ge 2 ] && [ $(PATCHLEVEL) -ge 5 ]; then \
213 ¦ echo new; \
214 fi),)
215 +$(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) \
216 ¦ARCH=$(KERNEL_ARCH) $(fast_dep) dep
217 $(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) clean
218 else
219 ifeq ($(strip $(MAKING_VIRTUAL_IMAGE)),)
220 $(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) prepare
221 endif
222 endif
223 else
- $(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) ARCH=$(KERNEL_ARCH) $(config_target)
只看最重要的参数$(config_target),这个默认值为oldconfig,help信息的解释:Change the type of configure done from the default oldconfig.
。简单理解就是make oldconfig
,对内核做配置。 - 判断${VERSION},这里的VERSION取自kernel的Makefile,目前的值是5,执行:
make dep; make clean; 或者 make prepare;
debian/stamp/conf/full-changelog
231 debian/control debian/changelog debian/rules debian/stamp/conf/full-changelog:
232 $(REASON)
233 @test -f $(LIBLOC)/rules || echo Error: Could not find $(LIBLOC)/rules
234 @test -f $(LIBLOC)/rules || exit 4
235 @test -d debian/stamp || mkdir debian/stamp
236 @test -d debian/stamp/conf || mkdir debian/stamp/conf
237 for file in $(DEBIAN_FILES); do \
238 ¦ ¦cp -f $(LIBLOC)/$$file ./debian/; \
239 done
240 for dir in $(DEBIAN_DIRS); do \
241 ¦ cp -af $(LIBLOC)/$$dir ./debian/; \
242 done
243 install -p -m 755 $(LIBLOC)/rules debian/rules
244 sed -e 's/=V/$(KERNELRELEASE)/g' \
245 ¦ ¦ ¦ -e 's/=D/$(debian)/g' -e 's/=A/$(DEB_HOST_ARCH)/g' \
246 -e 's/=SA/$(INT_SUBARCH)/g' \
247 -e 's/=I/$(initrddep)/g' \
248 -e 's/=CV/$(VERSION).$(PATCHLEVEL)/g' \
249 -e 's/=M/$(maintainer) <$(email)>/g' \
250 -e 's/=ST/$(INT_STEM)/g' -e 's/=B/$(KERNEL_ARCH)/g' \
251 ¦ ¦ ¦ -e 's/=R/$(RAMFS_DEPS)/g' $(CONTROL) > debian/control
252 sed -e 's/=V/$(KERNELRELEASE)/g' -e 's/=D/$(debian)/g' \
253 ¦ -e 's/=A/$(DEB_HOST_ARCH)/g' -e 's/=M/$(maintainer) <$(email)>/g' \
254 ¦ -e 's/=ST/$(INT_STEM)/g' -e 's/=B/$(KERNEL_ARCH)/g' \
255 $(LIBLOC)/changelog > debian/changelog
256 ifneq (,$(strip $(KPKG_OVERLAY_DIR)))
257 +-- 20 行: test ! -d $(strip $(KPKG_OVERLAY_DIR)) || \--------------------------------------------------------------------------------------------------------------------------------
277 endif
278 chmod 0644 debian/control debian/changelog
279 $(MAKE) -f debian/rules debian/stamp/conf/kernel-conf
280 @echo done > debian/stamp/conf/full-changelog
这个不少步骤都重复了,主要是构造./debbian目录,填充debian/control、changelog文件,然后再调用(MAKE) -f debian/rules debian/stamp/conf/kernel-conf
,这个上面说过了。
小结:alt_cmd构造./debian目录,并且调用 make oldconfig;make dep; make clean; 或者 make prepare;实测在当前内核下,只有prepare这个,所以alt_cmd执行的就是make oldconfig;make prepare; prepare是内核在开始编译之前,需要做的事儿。
包名定义
164 ifneq ($(strip $(KPKG_STEM)),)
165 INT_STEM := $(KPKG_STEM)
166 else
167 INT_STEM := $(DEB_HOST_ARCH_OS)
168 endif
INT_STEM 如果make-kpkg
传入参数 stem=?
,则直接赋值;否则等于DEB_HOST_ARCH_OS。
export DEB_HOST_ARCH_OS := $(shell $(DPKG_ARCH) $(ha) -qDEB_HOST_ARCH_OS
DPKG_ARCH := dpkg-architecture
所以这里INT_STRM=linux
70 TEST :=$(call doit,$(MAKE) $(CROSS_ARG) $(K_ARG) --no-print-directory \
71 ¦ ¦ ¦ ¦ -sf $(DEBDIR)/ruleset/kernel_version.mk debian_VERSION \
72 ¦ ¦ ¦ ¦ 2>/dev/null )
73 VERSION :=$(call doit,$(MAKE) $(CROSS_ARG) $(K_ARG) --no-print-directory \
74 ¦ ¦ ¦ ¦ -sf $(DEBDIR)/ruleset/kernel_version.mk debian_VERSION \
75 ¦ ¦ ¦ ¦ 2>/dev/null | tail -n 1)
76 PATCHLEVEL :=$(call doit,$(MAKE) $(CROSS_ARG) $(K_ARG) --no-print-directory \
77 ¦ ¦ ¦ ¦ -sf $(DEBDIR)/ruleset/kernel_version.mk debian_PATCHLEVEL \
78 ¦ ¦ ¦ ¦ 2>/dev/null | tail -n 1)
79 SUBLEVEL :=$(call doit,$(MAKE) $(CROSS_ARG) $(K_ARG) --no-print-directory \
80 ¦ ¦ ¦ ¦ -sf $(DEBDIR)/ruleset/kernel_version.mk debian_SUBLEVEL \
81 ¦ ¦ ¦ ¦ 2>/dev/null | tail -n 1)
82 EXTRA_VERSION:=$(call doit,$(MAKE) $(CROSS_ARG) $(K_ARG) --no-print-directory \
83 ¦ ¦ ¦ ¦ -sf $(DEBDIR)/ruleset/kernel_version.mk debian_EXTRAVERSION \
84 ¦ ¦ ¦ ¦ 2>/dev/null | tail -n 1)
85 LOCALVERSION :=$(call doit,$(MAKE) $(CROSS_ARG) $(K_ARG) --no-print-directory \
86 ¦ ¦ ¦ ¦ -sf $(DEBDIR)/ruleset/kernel_version.mk debian_LOCALVERSION \
87 ¦ ¦ ¦ ¦ 2>/dev/null | tail -n 1)
133 ifneq ($(strip $(APPEND_TO_VERSION)),)
134 iatv := $(strip $(APPEND_TO_VERSION))
135 EXTRAV_ARG := EXTRAVERSION=${EXTRA_VERSION}${iatv}
136 else
137 iatv :=
138 EXTRAV_ARG :=
139 endif
361 --append_to_version foo an additional kernel sub-version. ([-a-z.+0-9])
362 ¦ ¦ ¦ ¦ ¦ ¦Does not require editing the kernel Makefile
363 ¦ ¦ ¦ ¦ ¦ ¦over rides env var APPEND_TO_VERSION.
364 ¦ ¦ ¦ ¦ ¦ ¦requires a make-kpkg clean
if ($append_to_version) {
$alt_cmd .= " APPEND_TO_VERSION=$append_to_version ";
}
155 version = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(iatv)$(LOCALVERSION)
181 KERNELRELEASE = $(strip $(call doit,if [ -f include/config/kernel.release ]; then \
182 ¦ ¦ ¦ ¦ ¦ ¦ cat include/config/kernel.release 2> /dev/null;\
183 ¦ ¦ ¦ ¦ ¦ elif [ -f .kernelrelease ]; then \
184 ¦ ¦ ¦ ¦ ¦ ¦ cat .kernelrelease 2> /dev/null ; \
185 ¦ ¦ ¦ ¦ ¦ else \
186 ¦ ¦ ¦ ¦ ¦ ¦ echo "$(version)"; \
187 ¦ ¦ ¦ ¦ ¦ fi;))
KERNELRELEASE的值,先看include/config/kernel.release
,没有了再看.kernelrelease
,如果都没有,则直接等于version。
TEST VERSION PATCHLEVEL SUBLEVEL EXTRA_VERSION LOCALVERSION这些变量都来自kernel的Makefile:
1 # SPDX-License-Identifier: GPL-2.0
2 VERSION = 5
3 PATCHLEVEL = 4
4 SUBLEVEL = 232
5 EXTRAVERSION =
6 NAME = Kleptomaniac Octopus
最简单的情况 KERNELRELEASE = 5.4.232。
861 if ($arch) {
862 $command .= " KPKG_ARCH=$arch ";
863 $alt_cmd .= " KPKG_ARCH=$arch ";
864 }
165 =item B<--arch> foo
166
167 =over 2
168
169 Sets the architecture. This is mostly useful when cross compiling.
export DEB_HOST_ARCH_CPU := $(shell $(DPKG_ARCH) $(ha) -qDEB_HOST_ARCH_CPU
export DEB_HOST_GNU_CPU := $(shell $(DPKG_ARCH) $(ha) -qDEB_HOST_GNU_CPU)
113 ifneq ($(strip $(KPKG_ARCH)),)
114 architecture:=$(KPKG_ARCH)
115 else
116 #architecture:=$(shell CC=$(HOSTCC) dpkg --print-gnu-build-architecture)
117 #architecture:=$(DEB_HOST_ARCH)
118 ifeq (,$(DEB_HOST_ARCH_CPU))
119 architecture:=$(DEB_HOST_GNU_CPU)
120 else
121 architecture:=$(DEB_HOST_ARCH_CPU)
122 endif
123 endif
zhangsong@zhangsong-ThinkPad-W541:~/work/about_kernel_any/focal$ dpkg-architecture -qDEB_HOST_ARCH_CPU
amd64
zhangsong@zhangsong-ThinkPad-W541:~/work/about_kernel_any/focal$ dpkg-architecture -qDEB_HOST_GNU_CPU
x86_64
zhangsong@zhangsong-ThinkPad-W541:~/work/about_kernel_any/focal$
从这里看出,architecture最优先是用户输入,其次是从设备上获取,以我的及其为例,优先是amd64,其次是x86_64。
183 =item B<--subarch> foo
184
185 =over 2
186
187 Some architectures (the Alpha, and the m68k) require a different
188 kernel for each subarchitecture. This option provides a way of
189 specifying it as an argument to make-kpkg. Please note that additional
190 support for subarchitectures may be required in the kernel sources to
191 actually make this do anything.
873 if ($subarch) {
874 $command .= " KPKG_SUBARCH=$subarch ";
875 $alt_cmd .= " KPKG_SUBARCH=$subarch ";
876 }
46 ifneq ($(strip $(ARCH_IN_NAME)),)
47 ifneq ($(strip $(KPKG_SUBARCH)),)
48 INT_SUBARCH := -$(KPKG_SUBARCH)
49 endif
50 endif
这个INT_SUBARCH代表了cpu,可以是传入的参数,或者是类似xen i386 i486 i586 i686
的。
40 KERNEL_ARCH:=$(architecture)
41 ifeq ($(architecture), amd64)
42 KERNEL_ARCH:=x86_64
43 endif
44 ifeq ($(architecture), mipsel)
45 KERNEL_ARCH:=mips
46 endif
47 ifeq ($(architecture), s390x)
48 KERNEL_ARCH:=s390
49 endif
50
51 ifneq (,$(filter mips64%,$(KPKG_SUBARCH)))
52 KERNEL_ARCH = mips64
53 endif
54 ifneq (,$(filter %-64,$(KPKG_SUBARCH)))
55 KERNEL_ARCH = mips64
56 endif
57
58 ifeq ($(strip $(architecture)),arm64)
59 KERNEL_ARCH := arm64
60 endif
61
62 ifeq ($(strip $(architecture)),armeb)
63 KERNEL_ARCH := arm
64 endif
65
66 ifeq ($(strip $(architecture)),armhf)
67 KERNEL_ARCH := arm
68 endif
69
70 ifeq ($(strip $(architecture)),hppa)
71 KERNEL_ARCH := parisc
72 endif
52 # The name of the packages
53 s_package = $(INT_STEM)-source-$(KERNELRELEASE)
54 h_package = $(INT_STEM)-headers-$(KERNELRELEASE)$(INT_SUBARCH)
55 ifeq ($(strip $(KERNEL_ARCH)),um)
56 i_package = $(INT_STEM)-uml-$(KERNELRELEASE)$(INT_SUBARCH)
57 b_package = $(INT_STEM)-uml-$(KERNELRELEASE)$(INT_SUBARCH)-dbg
58 else
59 i_package = $(INT_STEM)-image-$(KERNELRELEASE)$(INT_SUBARCH)
60 b_package = $(INT_STEM)-image-$(KERNELRELEASE)$(INT_SUBARCH)-dbg
61 endif
62 d_package = $(INT_STEM)-doc-$(KERNELRELEASE)
63 m_package = $(INT_STEM)-manual-$(KERNELRELEASE)
最后得到包名:
- s_package = linux-source-5.4.232
- h_package = linux-headers-5.4.232(i386)
- i_package = linux-image-5.4.232(i386)
- b_package = linux-image-5.4.232(i386)-dbg
- d_package = linux-doc-5.4.232
- m_package = linux-manual-5.4.232
command
debian/rules $Target
Known Targets are:
===============================================================================
| Targets | Automatically builds |
===============================================================================
| clean | |
| buildpackage | Builds the whole package |
|* binary | Builds kernel_{source,headers,image,doc} |
|* binary-indep | |
| kernel_source | |
| kernel_doc | |
| kernel_manual | |
|* binary-arch | |
| kernel_headers | |
| kernel_debug | |
| kernel_image | Builds build |
| build | |
| modules | |
| modules_image | |
| modules_config | |
| modules_clean | |
| configure | If you wish to edit files |
| debian | generated by make config |
| debian | Creates ./debian dir |
===============================================================================
就是 ./debian/rules
,跟上targets(见上面的表格),看2个target。
PS:这里尝试过从‘根’target去分析,但是整个体系非常庞大,放弃了;从最小/最关键的target进行分析。
kernel_image
i_package = linux-image-5.4.232(i386)#见上面
104 linux-image linux_image kernel-image kernel_image: debian/stamp/build/kernel
105 $(eval $(deb_rule))
106 $(root_run_command) debian/stamp/binary/pre-$(i_package)
再往下不再这样分析,直接把结果列出来:
1 1:====== making target debian/stamp/conf/minimal_debian [new prereqs: ]======
2 29:====== making target debian/stamp/conf/kernel-conf [new prereqs: ]======
3 48:====== making target debian/stamp/conf/full-changelog [new prereqs: ]======
4 75:====== making target debian/stamp/conf/vars [new prereqs: ]======
5 77:====== making target debian/stamp/build/kernel [new prereqs: vars]======
6 3197:====== making target debian/stamp/install/linux-image-5.4.232+ [new prereqs: ]======
7 3345:====== making target debian/stamp/binary/pre-linux-image-5.4.232+ [new prereqs: linux-image-5.4.232+]======
8 3350:====== making target debian/stamp/binary/linux-image-5.4.232+ [new prereqs: ]======
这里编译内核:
294 debian/stamp/build/kernel: debian/stamp/conf/vars
323 ifeq ($(DEB_HOST_ARCH_OS), linux)
324 $(restore_upstream_debianization)
325 ifeq ($(strip $(USE_KBUILD)),yes)
326 $(MAKE) $(do_parallel) $(EXTRAV_ARG) $(FLAV_ARG) ARCH=$(KERNEL_ARCH) \
327 ¦ $(CROSS_ARG) $(KPKG_KBUILD_DEFAULT_TARGET)
328 else
329 $(MAKE) $(do_parallel) $(EXTRAV_ARG) $(FLAV_ARG) ARCH=$(KERNEL_ARCH) \
330 ¦ $(CROSS_ARG) $(target)
331 ifneq ($(strip $(shell grep -E '^[^\#]*CONFIG_MODULES[^_]' $(CONFIG_FILE))),)
332 $(MAKE) $(do_parallel) $(EXTRAV_ARG) $(FLAV_ARG) ARCH=$(KERNEL_ARCH) \
333 ¦ $(CROSS_ARG) modules
334 endif
335 endif
336 ifneq ($(strip $(shell grep -E ^[^\#]*CONFIG_LGUEST $(CONFIG_FILE))),)
337 ifeq ($(LGUEST_SUBDIR),)
338 $(error Cannot find lguest tools)
339 endif
340 $(MAKE) $(do_parallel) $(EXTRAV_ARG) $(FLAV_ARG) ARCH=$(KERNEL_ARCH) \
341 ¦ $(CROSS_ARG) -C $(LGUEST_SUBDIR)
342 endif
343 else
这里将所有的东西安装到 ${SRCTOP}/debian/${package}目录中
debian/stamp/install/$(i_package):
....
代码太长,下面看效果~
....
zhangsong@zhangsong-ThinkPad-W541:~/work/about_kernel_any/focal/debian/linux-image-5.4.232+$ tree -L 2
.
├── boot
│ ├── config-5.4.232+
│ ├── System.map-5.4.232+
│ └── vmlinuz-5.4.232+
├── DEBIAN
│ ├── config
│ ├── control
│ ├── md5sums
│ ├── postinst
│ ├── postrm
│ ├── preinst
│ ├── prerm
│ └── templates
├── etc
│ └── kernel
├── lib
│ └── modules
└── usr
├── lib
└── share
这里打包deb:
238 debian/stamp/binary/$(i_package):
...
309 sed -e 's/=V/$(KERNELRELEASE)/g' -e 's/=IB/$(link_in_boot)/g' \
310 ¦ -e 's/=ST/$(INT_STEM)/g' -e 's/=R/$(reverse_symlink)/g' \
311 ¦ ¦ -e 's/=KPV/$(kpkg_version)/g' \
312 ¦ -e 's/=K/$(kimage)/g' \
313 ¦ -e 's/=I/$(INITRD)/g' -e 's,=D,$(IMAGEDIR),g' \
314 ¦ -e 's/=MD/$(initrddep)/g' \
315 ¦ -e 's@=MK@$(initrdcmd)@g' -e 's@=A@$(DEB_HOST_ARCH)@g' \
316 ¦ -e 's@=M@$(MKIMAGE)@g' -e 's@=B@$(KERNEL_ARCH)@g' \
317 ¦ -e 's/=S/$(no_symlink)/g' -e 's/=OF/$(AM_OFFICIAL)/g' \
318 ¦ $(DEBDIR)/pkg/virtual/um/postinst > $(TMPTOP)/DEBIAN/postinst
319 chmod 755 $(TMPTOP)/DEBIAN/postinst
320 sed -e 's/=V/$(KERNELRELEASE)/g' -e 's/=IB/$(link_in_boot)/g' \
321 ¦ -e 's/=ST/$(INT_STEM)/g' -e 's/=R/$(reverse_symlink)/g' \
322 ¦ ¦ -e 's/=KPV/$(kpkg_version)/g' \
323 ¦ -e 's/=K/$(kimage)/g' \
324 ¦ -e 's/=I/$(INITRD)/g' -e 's,=D,$(IMAGEDIR),g' \
325 ¦ -e 's/=MD/$(initrddep)/g' \
326 ¦ -e 's@=MK@$(initrdcmd)@g' -e 's@=A@$(DEB_HOST_ARCH)@g' \
327 ¦ -e 's@=M@$(MKIMAGE)@g' -e 's/=OF/$(AM_OFFICIAL)/g' \
328 ¦ -e 's/=S/$(no_symlink)/g' -e 's@=B@$(KERNEL_ARCH)@g' \
329 ¦ $(DEBDIR)/pkg/virtual/um/prerm > $(TMPTOP)/DEBIAN/prerm
330 chmod 755 $(TMPTOP)/DEBIAN/prerm
...
335 dpkg-gencontrol -DArchitecture=$(GENCONTROL_ARCH) -isp \
336 -p$(package) -P$(TMPTOP)/
337 $(create_md5sum) $(TMPTOP)
338 chmod -R og=rX $(TMPTOP)
339 test ! -e $(kimagedest) || chmod og-rx $(kimagedest)
340 test ! -e $(TMPTOP)/$(IMAGEDIR)/System.map-$(KERNELRELEASE) || \
341 ¦ ¦ chmod og-rx $(TMPTOP)/$(IMAGEDIR)/System.map-$(KERNELRELEASE) $(kimagedest)
342 chown -R root:root $(TMPTOP)
343 dpkg --build $(TMPTOP) $(DEB_DEST)
至此 deb包出来了 dpkg --build $(TMPTOP) $(DEB_DEST)
展开就是
dpkg --build $(SRCTOP)/debian/$(package) DEB_DEST ?= ..
这里生成的deb名称张这样:linux-image-5.4.232+_5.4.232+-10.00.Custom_amd64.deb linux-image-5.4.232+_1.0.custom_amd64.deb linux-image-5.4.232+_1.0.zhangsong_amd64.deb
,但是control中Package=linux-image-5.4.232+
;探索发现包名后面的2部分分别为 revision和Architecture。
buildpackage
最终展开
DEB_BUILD_OPTIONS="$(SERIAL_BUILD_OPTIONS)" CONCURRENCY_LEVEL=1 \
dpkg-buildpackage $(strip $(int_root_cmd)) $(strip $(int_us)) $(strip $(int_uc)) \
-j1 -k"$(pgp)" -m"$(maintainer) <$(email)>"