3 ### Main maintenance script for chroots
5 ### (c) 2018 Mark Wooding
8 ###----- Licensing notice ---------------------------------------------------
10 ### This file is part of the distorted.org.uk chroot maintenance tools.
12 ### distorted-chroot is free software: you can redistribute it and/or
13 ### modify it under the terms of the GNU General Public License as
14 ### published by the Free Software Foundation; either version 2 of the
15 ### License, or (at your option) any later version.
17 ### distorted-chroot is distributed in the hope that it will be useful,
18 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ### General Public License for more details.
22 ### You should have received a copy of the GNU General Public License
23 ### along with distorted-chroot. If not, write to the Free Software
24 ### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
30 .PHONY
: all clean check
31 .SECONDEXPANSION
: #sorry
33 ###--------------------------------------------------------------------------
38 ## Level of pickiness to aspire to.
41 ## Volume group from which to allocate chroot volumes and snapshots.
42 CONFIG_VARS
+= VG LVPREFIX
43 VG
:= vg-
$(shell hostname
)
46 ## Logical volume size, as an LVM option.
47 CONFIG_VARS
+= LVSZ SNAPOPT
52 CONFIG_VARS
+= DEBMIRROR
53 DEBMIRROR
= http
://deb.debian.org
/debian
/
55 ## APT sources configurations. (Also, $($d_APTSRC) for each $d in $(DISTS).)
57 APTSRC
= etc
/aptsrc.conf
$(wildcard etc
/aptsrc.local.conf
)
59 ## APT configuration fragment names. These will be linked into
60 ## `/etc/apt/apt.conf.d' in each chroot. To put a fragment f in a surprising
61 ## place, set $(_$f_APTCONFSRC).
62 CONFIG_VARS
+= APTCONF
$(foreach f
,$(APTCONF
),_
$f_APTCONFSRC)
63 APTCONF
= $(notdir $(wildcard etc
/apt-conf.d
/[0-9]*[!~
]))
68 eval
$$(apt-config
$(foreach a
,$(APTCONF
),-cetc
/apt-conf.d
/$a) \
69 shell proxy Acquire
::http
::proxy
); \
70 case
$${proxy
+t
} in
(t
) echo
"$$proxy" ;; (*) echo nil
;; esac
)
72 ## Debian distributions to support.
73 CONFIG_VARS
+= PRIMARY_DIST DISTS
74 PRIMARY_DIST
= stretch
75 DISTS
= $(PRIMARY_DIST
) buster bullseye sid
77 ## Host's native architecture(s).
78 CONFIG_VARS
+= MYARCH NATIVE_ARCHS
79 MYARCH
:= $(shell dpkg
--print-architecture
)
80 OTHERARCHS
:= $(shell dpkg
--print-foreign-architectures
)
81 NATIVE_ARCHS
= $(MYARCH
) $(OTHERARCHS
)
83 ## Foreign (emulated) architectures to support.
84 CONFIG_VARS
+= FOREIGN_ARCHS
87 ## Master lists of chroots to build and maintain.
88 CONFIG_VARS
+= NATIVE_CHROOTS FOREIGN_CHROOTS
89 NATIVE_CHROOTS
= $(foreach a
,$(NATIVE_ARCHS
), \
90 $(foreach d
,$(or
$($a_DISTS) $(DISTS
)), \
92 FOREIGN_CHROOTS
= $(foreach a
,$(FOREIGN_ARCHS
), \
93 $(foreach d
,$(or
$($a_DISTS) $(DISTS
)), \
96 ## Extra packages to be installed in chroots. `BASE_PACKAGES' are installed
97 ## through `debootstrap'; `EXTRA_PACKAGES' are installed later, using Apt,
98 ## which is faster in foreign chroots.
99 CONFIG_VARS
+= BASE_PACKAGES EXTRA_PACKAGES
100 BASE_PACKAGES
= eatmydata
101 EXTRA_PACKAGES
= build-essential
102 EXTRA_PACKAGES
+= ccache
103 EXTRA_PACKAGES
+= fakeroot
104 EXTRA_PACKAGES
+= libfile-fcntllock-perl
105 EXTRA_PACKAGES
+= locales
107 ## Extra packages from which to install the cross tools.
108 CONFIG_VARS
+= CROSS_PACKAGES
109 CROSS_PACKAGES
= bash coreutils dash findutils
110 CROSS_PACKAGES
+= gzip m4 mawk sed
tar xz-utils
111 CROSS_PACKAGES
+= apt ccache eatmydata fakeroot make
112 CROSS_PACKAGES
+= qemu-user-static
113 CROSS_PACKAGES
+= $(foreach a
,$(FOREIGN_GNUARCHS
),\
114 gcc-
$a g
++-$a binutils-
$a)
116 ## Native files to install in place of the foreign versions. `MULTI' here
117 ## stands for the donor's GNU multiarch name.
118 CONFIG_VARS
+= CROSS_PATHS
120 $(addprefix /usr
/bin
/, \
121 apt apt-cache apt-config apt-get apt-key apt-mark
) \
122 $(addprefix /usr
/lib
/apt
/, \
125 cat chgrp chown cp date dd df
dir echo false ln ls mkdir \
126 mknod mktemp mv pwd readlink
rm rmdir sleep stty sync touch \
128 $(addprefix /usr
/bin
/, \
129 [ arch b2sum base32 base64
basename chcon cksum comm \
130 csplit cut dircolors dirname du env expand expr factor fmt \
131 fold groups head hostid id
install join link logname md5sum \
132 mkfifo nice nl nohup nproc numfmt od paste pathchk pinky pr \
133 printenv printf ptx realpath runcon seq sha1sum sha224sum \
134 sha256sum sha384sum sha512sum shred shuf
sort split stat \
135 stdbuf sum tac tail tee
test timeout tr truncate tsort tty \
136 unexpand uniq unlink users wc who whoami yes
) \
137 ?
/usr
/lib
/MULTI
/coreutils
/ \
138 $(addprefix /lib
/MULTI
/, \
139 libnsl.so.
* libnss_
*.so.
*) \
141 /usr
/bin
/qemu-
*-static \
143 bash dash gzip sed
tar) \
144 $(addprefix /usr
/bin
/, \
145 ccache find m4 make mawk xargs xz
) \
146 $(addprefix /usr
/lib
/MULTI
/, \
147 libeatmydata.so
* libfakeroot
/) \
148 $(addprefix /etc
/ld.so.conf.d
/, \
149 MULTI.conf fakeroot
*.conf
) \
150 $(foreach a
,$(FOREIGN_GNUARCHS
), \
151 $(addprefix /usr
/bin
/$a-, \
152 addr2line
ar as c
++filt dwp elfedit gprof
ld ld.
* \
153 nm objcopy objdump ranlib readelf size strings \
155 $(addprefix /usr
/bin
/$a-, \
156 cpp gcc g
++ gcov gcov-dump gcov-tool gprof \
157 gcc-ar gcc-nm gcc-ranlib
) \
158 /usr
/lib
/gcc-cross
/$a/ \
161 ## Local packages to be compiled and installed in chroots. Archives can be
163 CONFIG_VARS
+= LOCALPKGS
$(foreach p
,$(LOCALPKGS
),$p_DEPS)
164 LOCALPKGS
= mLib checkpath
166 checkpath_DEPS
= mLib
168 ## Which host architecture to use for foreign architectures. It turns out
169 ## that it's best to use a Qemu with the same host bitness as the target
170 ## architecture; otherwise it has to do a difficult job of converting
171 ## arguments and results between kernel ABI flavours.
172 32BIT_QEMUHOST
= $(or
$(filter i386
,$(NATIVE_ARCHS
)),$(TOOLSARCH
))
173 64BIT_QEMUHOST
= $(or
$(filter amd64
,$(NATIVE_ARCHS
)),$(TOOLSARCH
))
175 CONFIG_VARS
+= $(foreach a
,$(FOREIGN_ARCHS
),$a_QEMUHOST)
176 armel_QEMUHOST
= $(32BIT_QEMUHOST
)
177 armhf_QEMUHOST
= $(32BIT_QEMUHOST
)
178 arm64_QEMUHOST
= $(64BIT_QEMUHOST
)
179 i386_QEMUHOST
= $(32BIT_QEMUHOST
)
180 amd64_QEMUHOST
= $(64BIT_QEMUHOST
)
182 ## Which distribution of Qemu to use.
183 CONFIG_VARS
+= $(foreach d
,$(DISTS
),$d_QEMUDIST)
184 stretch_QEMUDIST
= buster
186 ## Qemu architecture names. These tell us which Qemu binary to use for a
187 ## particular Debian architecture.
188 CONFIG_VARS
+= $(foreach a
,$(FOREIGN_ARCHS
),$a_QEMUARCH)
191 arm64_QEMUARCH
= aarch64
193 amd64_QEMUARCH
= x86_64
195 ## Alias mapping for chroots.
196 CONFIG_VARS
+= $(foreach d
,$(DISTS
),$d_ALIASES)
197 stretch_ALIASES
= oldstable
198 buster_ALIASES
= stable
199 bullseye_ALIASES
= testing
200 sid_ALIASES
= unstable
202 ## Which host architecture to use for commonly used tools in foreign chroots.
203 CONFIG_VARS
+= TOOLSARCH
204 TOOLSARCH
= $(MYARCH
)
206 ## A directory in which we can maintain private files and state.
210 ## A directory which will be spliced into chroots as `/usr/local.schroot/'.
211 ## This will be our primary point of contact with the chroot.
212 CONFIG_VARS
+= LOCAL ABSLOCAL
213 LOCAL
= local.schroot
214 ABSLOCAL
= $(abspath
$(LOCAL
))
216 ## How to run a command as a privileged user.
217 CONFIG_VARS
+= ROOTLY
220 ## Files to be copied into a chroot from the host.
221 SCHROOT_COPYFILES
= /etc
/resolv.conf
222 SCHROOT_NSSDATABASES
= passwd shadow group gshadow
224 ## Local configuration hook.
228 CONFIG_VARS
+= ALL_ARCHS ALL_CHROOTS
229 ALL_ARCHS
= $(NATIVE_ARCHS
) $(FOREIGN_ARCHS
)
230 ALL_CHROOTS
= $(NATIVE_CHROOTS
) $(FOREIGN_CHROOTS
)
232 ## GNU names for foreign architectures.
233 CONFIG_VARS
+= FOREIGN_GNUARCHS
234 FOREIGN_GNUARCHS
:= $(foreach a
,$(FOREIGN_ARCHS
),\
235 $(shell dpkg-architecture
-A
$a \
236 -qDEB_TARGET_GNU_TYPE
))
238 ###--------------------------------------------------------------------------
241 ## Hack to force rebuilding.
245 ## Hack to not delimit function arguments. (Ugh!)
248 ## Silent-rules machinery.
252 v_print
= $(call v_print_
$V,$1,$2)
253 v_print_0
= printf
" %-8s %s\n" "$1" $(call squote
,$2);
254 v_tag
= $(V_AT
)$(call v_print
,$1,$@
)
255 v_log
= $(call v_log_
$V,$1,$2)
256 v_log_
= $(call v_log_1
,$1,$2)
257 v_log_0
= $2 >log
/$1.log
2>&1
258 v_log_1
= $(call catchrc
,$(call throwrc
,$2) 2>&1 | tee log
/$1.log
)
259 v_echo
= $(call v_echo_
$V,$1)
261 v_echo_1
= printf
"%s\n" $1
262 CLEANFILES
+= log
/*.log
266 LVM_SUPPRESS_FD_WARNINGS
=1; export LVM_SUPPRESS_FD_WARNINGS
268 ## $(call file-name,PATH)
270 ## Strip any trailing `/' from the PATH.
273 ## $(call base-name,PATH)
275 ## Expand to the last component of PATH, whether or not it's a directory
276 ## name with a trailing `/'.
277 base-name
= $(notdir $(call file-name
,$1))
279 ## $(call parent-dir,PATH)
281 ## Expand to the parent directory of PATH, whether or not it's a directory
282 ## name with a trailing `/'.
284 parent-dir
= $(dir $(call file-name
,$1))
286 ## $(call definedp,VAR)
288 ## Expand non-empty if and only if VAR is defined (but possibly empty).
289 definedp
= $(filter-out undefined
,$(origin $1))
291 ## $(call catchrc,...$(call throwrc,CMD)...)
293 ## Catch the exit status of some subpart of a complicated shell rune.
294 catchrc
= (exec
3>&1; exit
$$({ $1; } 4>&1 >&3 3>&-))
295 throwrc
= { $1; echo
$$?
>&4; }
297 ## $(call squote,TXT)
300 squote
= '$(subst ','\'',$1)'
303 ## $(call chroot-dist,D-A) -> D
304 ## $(call chroot-arch,D-A) -> A
306 ## Parse chroot descriptions.
307 chroot-dist
= $(patsubst %/,%,$(dir $(subst -,/,$1)))
308 chroot-arch
= $(notdir $(subst -,/,$1))
310 ## $(call package-dir-name,P-V) -> P
311 ## $(call package-dir-version,P-V) -> V
313 ## Parse (source) package directory names.
314 package-dir-name
= $(sort $(foreach p
,$(LOCALPKGS
),$(if
$(filter $p-$($p_VERSION),$1),$p)))
315 package-dir-version
= $($(call package-dir-name
,$1)_VERSION
)
317 ## $(call package-dir,P-V.A) -> P-V
318 ## $(call package-name,P-V.A) -> P
319 ## $(call package-version,P-V.A) -> V
320 ## $(call package-arch,P-V.A) -> A
322 ## Parse package stamp names.
323 package-dir
= $(basename $1)
324 package-name
= $(call package-dir-name
,$(call package-dir
,$1))
325 package-version
= $(call package-dir-version
,$(call package-dir
,$1))
326 package-arch
= $(patsubst .
%,%,$(suffix $1))
328 ## $(call native-chroot-p,D-A) -> D | <empty>
330 ## Answer whether D-A is a native chroot.
331 native-chroot-p
= $(filter $(call chroot-arch
,$1),$(NATIVE_ARCHS
))
333 ## $(call chroot-qemuhost,D-A) -> AA
335 ## Answer the apporopriate Qemu host architecture for foreign chroot D-A.
336 chroot-qemuhost
= $($(call chroot-arch
,$1)_QEMUHOST
)
338 ## $(call chroot-deps,PRE,D-A) -> PREDD-AA ... | <empty>
340 ## Answer a list of additional dependencies for the chroot D-A: specifically,
341 ## if D-A is foreign then include PRE/DD-AA entries for the tools
342 ## architecture, and Qemu host architecture (if that's different).
343 chroot-deps
= $(if
$(call native-chroot-p
,$2),, \
344 $(addprefix $1$(call chroot-dist
,$2)-,\
345 $(sort $(TOOLSARCH
) \
346 $(call chroot-qemuhost
,$2))))
348 ## Substituting placeholders in files.
349 SUBSTITUTIONS
:= local
=$(shell realpath
$(LOCAL
))
350 SUBSTITUTIONS
+= primary-dist
=$(PRIMARY_DIST
)
352 echo
"$1 GENERATED by distorted-chroot: do not edit"; \
354 for v in
$(SUBSTITUTIONS
); do \
355 var
=$${v
%%=*} value
=$${v\
#*=}; \
356 substs
="$$substs s\a@$$var@\a$$value\ag;"; \
361 ### $(call symlink-ok-p,LINK,DEST)
363 ### Expand to `t' if LINK is a symbolic link to DEST, and empty otherwise.
364 symlink-ok-p
= $(shell \
365 case
$$(readlink
2>/dev
/null
$(patsubst %/,%,$1)) in
($2) echo t
;; esac
)
367 ### $(call general-notify,SEV,COLOUR,PREFIX,MSG)
369 ### Report a message, highlighted in the right way, and maybe fail
371 echo
"$$(tput bold; tput setaf $2)$3 "$4"$$(tput sgr0; tput op)"; \
372 if
[ "$1" -le
"$(NOTIFY_FATAL)" ]; then exit
2; fi
; \
375 ### $(call report/SEV,MSG)
377 ### Report a notification of a particular severity.
378 notify
/INFO
= $(call general-notify
,3,6,---,$1)
379 notify
/WARN
= $(call general-notify
,2,5,???
,$1)
380 notify
/ERR
= $(call general-notify
,1,1,!!!,$1)
382 ## $(call check,SEV,MSG,UNLESS)
384 ## If UNLESS completes successfully, all is OK; otherwise print MSG to stderr
387 $(call v_echo
,'check: '$(call squote
,$3)''); \
388 if
! { $3; }; then
$(call notify
/$1,$2); fi
; \
391 ## $(call check-executable,SEV,PATH)
393 ## Verify that PATH is an executable program.
394 check-executable
= $(call
check,$1,"\`$2' is not an executable", \
397 ## $(call check-mountpoint,SEV,DIR)
399 ## Verify that DIR is a mountpoint.
400 check-mountpoint
= $(call
check,$1,"\`$2' is not a mount point", \
403 ## $(call check-symlink,SEV,LINK,DEST)
405 ## Verify that LINK is a symbolic link pointing to DEST.
406 check-symlink
= $(call
check,$1,"\`$2' is not a link to \`$3'", \
407 [ -L
"$2" ] && [ "$$(readlink "$2")" = "$3" ])
409 ###--------------------------------------------------------------------------
410 ### Python extensions.
413 CFLAGS
= -O2
-g
-Wall
418 c-source
= $(foreach c
,$1,src
/$c)
419 c-object
= $(foreach c
,$1,$(STATE
)/obj
/$(basename $c).o
)
421 PYEXT_PKGFLAGS
:= $(shell pkg-config
--cflags python2
)
422 PYEXT_CFLAGS
= -fPIC
-fno-strict-aliasing
$(PYEXT_PKGFLAGS
)
423 PYEXT_LDFLAGS
= -shared
426 jobclient_SOURCES
= jobclient.c
428 PYEXT_ALLSRC
= $(foreach x
,$(PYEXTS
),\
429 $(call c-source
,$($x_SOURCES)))
430 PYEXT_ALLOBJ
= $(foreach x
,$(PYEXTS
),\
431 $(call c-object
,$($x_SOURCES)))
432 $(PYEXT_ALLOBJ
): $(STATE
)/obj
/%.o
: src
/%.c
433 $(V_AT
)mkdir
-p
$(dir $@
)
434 $(call v_tag
,CC
)$(CC
) -c
$(CFLAGS
) $(PYEXT_CFLAGS
) -o
$@
$<
436 PYMODULES
= $(foreach x
,$(PYEXTS
),$(STATE
)/lib
/python
/$x.so
)
438 $(PYMODULES
): $(STATE
)/lib
/python
/%.so
: $$(call c-object
,$$($$*_SOURCES
))
439 $(V_AT
)mkdir
-p
$(dir $@
)
440 $(call v_tag
,LD
)$(LD
) $(LDFLAGS
) $(PYEXT_LDFLAGS
) -o
$@
$^
442 ###--------------------------------------------------------------------------
445 SCRIPTS
+= chroot-maint
446 SCRIPTS
+= mkchrootconf
448 SUBST_SCRIPTS
= $(addprefix $(STATE
)/bin
/,$(SCRIPTS
))
449 all: $(SUBST_SCRIPTS
)
450 $(SUBST_SCRIPTS
): $(STATE
)/bin
/%: bin
/% $(STATE
)/config.sh
451 $(V_AT
)mkdir
-p
$(dir $@
)
452 $(call v_tag
,SUBST
){ \
454 -e
'2i### GENERATED by distorted-chroot: do not edit' \
455 -e
'/@@@config@@@/ {' \
456 -e
'r $(STATE)/config.sh' \
459 } >$@.new
&& chmod
+x
$@.new
&& mv
$@.new
$@
461 ###--------------------------------------------------------------------------
462 ### APT configuration.
464 ## In a chroot, `/etc/apt/sources.list' links to
465 ## `/usr/local.schroot/etc/apt/sources.$d' for the appropriate distribution.
466 APT_SOURCES
= $(foreach d
,$(DISTS
),$(LOCAL
)/etc
/apt
/sources.
$d)
469 $(foreach d
,$(DISTS
),$(STATE
)/etc
/apt
/aptsrc.
$d): $(STATE
)/etc
/apt
/aptsrc.
%:
470 $(V_AT
)mkdir
-p
$(dir $@
)
472 echo
"### -*-conf-*- GENERATED by distorted-chroot: do not edit"; \
474 echo
" debian : $*"; \
475 } >$@.new
&& mv
$@.new
$@
477 $(APT_SOURCES
): $(LOCAL
)/etc
/apt
/sources.
%: \
478 $$(APTSRC
) $$($$*_APTSRC
) $$(STATE
)/etc
/apt
/aptsrc.
$$*
479 $(V_AT
)mkdir
-p
$(dir $@
)
480 $(call v_tag
,GEN
)bin
/mkaptsrc \
481 $(APTSRC
) $($*_APTSRC
) $(STATE
)/etc
/apt
/aptsrc.
$* \
482 >$@.new
&& mv
$@.new
$@
483 CLEANFILES
+= $(APT_SOURCES
)
485 ## In a chroot, a link `/etc/apt/apt.conf.d/FOO' is created for each file in
486 ## `/usr/local.schroot/etc/apt/apt.conf.d/FOO'.
487 APT_CONFIGS
= $(addprefix $(LOCAL
)/etc
/apt
/apt.conf.d
/,$(APTCONF
))
489 $(APT_CONFIGS
): $(LOCAL
)/etc
/apt
/apt.conf.d
/%: \
490 $$(or
$$(_
$$*_APTCONFSRC
) etc
/apt-conf.d
/$$*)
491 $(V_AT
)mkdir
-p
$(dir $@
)
492 $(call v_tag
,COPY
)cp
$< $@.new
&& mv
$@.new
$@
493 clean::; rm -f
$(APT_CONFIGS
)
495 ###--------------------------------------------------------------------------
498 check::; $(call check-executable
,ERR
,/usr
/bin
/eatmydata
)
500 EATMYDATA_HACKS
+= apt-get aptitude dpkg
501 SYMLINK_EATMYDATA_HACKS
= $(addprefix $(LOCAL
)/hacks
/,$(EATMYDATA_HACKS
))
502 all: $(SYMLINK_EATMYDATA_HACKS
)
503 $(SYMLINK_EATMYDATA_HACKS
): $(LOCAL
)/hacks
/%: \
504 $$(if
$$(call symlink-ok-p
,$$@
,/usr
/bin
/eatmydata
),,_force
)
505 $(V_AT
)mkdir
-p
$(dir $@
)
506 $(call v_tag
,SYMLINK
)ln
-sf
/usr
/bin
/eatmydata
$@.new
&& mv
$@.new
$@
507 clean::; rm -f
$(SYMLINK_EATMYDATA_HACKS
)
509 SCRIPT_HACKS
+= buildwrap
510 COPY_SCRIPT_HACKS
= $(addprefix $(LOCAL
)/hacks
/,$(SCRIPT_HACKS
))
511 all: $(COPY_SCRIPT_HACKS
)
512 $(COPY_SCRIPT_HACKS
): $(LOCAL
)/hacks
/%: bin
/%
513 $(V_AT
)mkdir
-p
$(dir $@
)
514 $(call v_tag
,COPY
)cp
$< $@.new
&& mv
$@.new
$@
515 clean::; rm -f
$(COPY_SCRIPT_HACKS
)
517 ###--------------------------------------------------------------------------
518 ### `schroot' and `sbuild' configuration.
522 .PHONY
: schroot-config
524 check::; $(call check-mountpoint
,WARN
,/var
/lib
/sbuild
/build
)
525 check::; $(call check-symlink
,WARN
,/build
,/var
/lib
/sbuild
/build
)
526 check::; $(call check-symlink
,ERR
,/schroot
,/run
/schroot
/mount
)
529 echo
"\#\#\# -*-sh-*- GENERATED by distorted-chroot: do not edit"; \
530 $(foreach v
,$1,$(if
$(call definedp
,$v),\
531 echo
$v=\'$(call squote
,$($v))\';)) \
533 schroot-config_HASH
:= \
534 $(shell $(call
%print-varlist
,$(CONFIG_VARS
)) | \
535 sha256sum | cut
-c1-32
)
536 schroot-config_FILE
= $(STATE
)/config.sh-
$(schroot-config_HASH
)
537 $(schroot-config_FILE
):
538 $(V_AT
)mkdir
-p
$(STATE
)
539 $(V_AT
)rm -f
$(STATE
)/config.sh-
*
540 $(call v_tag
,GEN
)$(call
%print-varlist
,$(CONFIG_VARS
)) \
541 >$@.new
&& mv
$@.new
$@
543 schroot-config
: $(STATE
)/config.sh
544 $(STATE
)/config.sh
: $(schroot-config_FILE
)
545 $(call v_tag
,SYMLINK
)ln
-sf
$(notdir $<) $@
547 schroot-config
: $(LOCAL
)/etc
/schroot
/sbuild.schroot
548 $(LOCAL
)/etc
/schroot
/sbuild.schroot
: $(STATE
)/bin
/mkchrootconf
549 $(V_AT
)mkdir
-p
$(dir $@
)
550 $(call v_tag
,GEN
)$(STATE
)/bin
/mkchrootconf
>$@.new
&& \
551 $(ROOTLY
) chown root
:root
$@.new
&& mv
$@.new
$@
552 CLEANFILES
+= $(LOCAL
)/etc
/schroot
/sbuild.schroot
553 check::; $(call check-symlink
,WARN
,/etc
/schroot
/chroot.d
/sbuild
,$(ABSLOCAL
)/etc
/schroot
/sbuild.schroot
)
555 schroot-config
: $(LOCAL
)/etc
/schroot
/sbuild.profile
/copyfiles
556 $(LOCAL
)/etc
/schroot
/sbuild.profile
/copyfiles
: $(schroot-config_STAMP
)
557 $(V_AT
)mkdir
-p
$(dir $@
)
559 echo
"### -*-conf-*- GENERATED by distorted-chroot: do not edit"; \
560 for i in
$(SCHROOT_COPYFILES
); do echo
"$$i"; done
; \
561 } >$@.new
&& mv
$@.new
$@
562 CLEANFILES
+= $(LOCAL
)/etc
/schroot
/sbuild.profile
/copyfiles
564 schroot-config
: $(LOCAL
)/etc
/schroot
/sbuild.profile
/nssdatabases
565 $(LOCAL
)/etc
/schroot
/sbuild.profile
/nssdatabases
: $(schroot-config_STAMP
)
566 $(V_AT
)mkdir
-p
$(dir $@
)
568 echo
"### -*-conf-*- GENERATED by distorted-chroot: do not edit"; \
569 for i in
$(SCHROOT_NSSDATABASES
); do echo
"$$i"; done
; \
570 } >$@.new
&& mv
$@.new
$@
571 CLEANFILES
+= $(LOCAL
)/etc
/schroot
/sbuild.profile
/nssdatabases
573 schroot-config
: $(LOCAL
)/etc
/schroot
/sbuild.profile
/fstab
574 $(LOCAL
)/etc
/schroot
/sbuild.profile
/fstab
: \
575 etc
/sbuild.fstab.in
$(schroot-config_STAMP
)
576 $(V_AT
)mkdir
-p
$(dir $@
)
577 $(call v_tag
,SUBST
)$(call subst-file
,### -*-conf-*-) \
578 <$< >$@.new
&& mv
$@.new
$@
579 CLEANFILES
+= $(LOCAL
)/etc
/schroot
/sbuild.profile
/fstab
581 check::; $(call check-symlink
,WARN
,/etc
/schroot
/sbuild
,$(ABSLOCAL
)/etc
/schroot
/sbuild.profile
)
583 schroot-config
: $(LOCAL
)/etc
/sbuild.conf
584 $(LOCAL
)/etc
/sbuild.conf
: etc
/sbuild.conf.in
$(schroot-config_STAMP
)
585 $(V_AT
)mkdir
-p
$(dir $@
)
586 $(call v_tag
,SUBST
)$(call subst-file
,### -*-perl-*-) \
587 <$< >$@.new
&& mv
$@.new
$@
588 CLEANFILES
+= $(LOCAL
)/etc
/sbuild.conf
589 check::; $(call check-symlink
,WARN
,/etc
/sbuild
/sbuild.conf
,$(ABSLOCAL
)/etc
/sbuild.conf
)
590 check::; $(call check-executable
,WARN
,/usr
/local.schroot
/hacks
/apt-get
)
592 SCHROOT_SCRIPTS
+= 11private
593 SCHROOT_SCRIPTS
+= 15binfmt
594 SCHROOT_SCRIPTS
+= 51chrootenv
595 COPY_SCHROOT_SCRIPTS
= $(addprefix $(LOCAL
)/etc
/schroot
/setup.d
/,$(SCHROOT_SCRIPTS
))
596 schroot-config
: $(COPY_SCHROOT_SCRIPTS
)
597 $(COPY_SCHROOT_SCRIPTS
): \
598 $(LOCAL
)/etc
/schroot
/setup.d
/%: etc
/schroot-scripts
/%
599 $(V_AT
)mkdir
-p
$(dir $@
)
600 $(call v_tag
,COPY
)cp
$< $@.new
&& mv
$@.new
$@
601 CLEANFILES
+= $(COPY_SCHROOT_SCRIPTS
)
603 CHECK_SCHROOT_SCRIPTS
= $(addprefix check-script
/,$(SCHROOT_SCRIPTS
))
604 check:: $(CHECK_SCHROOT_SCRIPTS
)
605 $(CHECK_SCHROOT_SCRIPTS
): check-script
/%:
606 $(call check-symlink
,WARN
,/etc
/schroot
/setup.d
/$*,$(ABSLOCAL
)/etc
/schroot
/setup.d
/$*)
607 .PHONY
: $(addprefix check-script
/,$(SCHROOT_SCRIPTS
))
609 ###--------------------------------------------------------------------------
612 CCACHE_CONFIGS
= $(foreach r
,$(ALL_CHROOTS
), \
613 /var
/lib
/sbuild
/build
/.ccache
/$(LVPREFIX
)$r/ccache.conf
)
614 all: $(CCACHE_CONFIGS
)
615 $(CCACHE_CONFIGS
): /var
/lib
/sbuild
/build
/.ccache
/$(LVPREFIX
)%/ccache.conf
: \
617 $(V_AT
)mkdir
-p
$(dir $@
)
618 $(call v_tag
,COPY
)cp
$< $@.new
&& mv
$@.new
$@
620 ###--------------------------------------------------------------------------
621 ### `/usr/local/' structure.
623 LOCAL_COMMON_DIRS
= share
/ src
/
624 LOCAL_EXTRA_DIRS
= share
/man
/
625 all: $(foreach d
,$(LOCAL_COMMON_DIRS
) $(LOCAL_EXTRA_DIRS
),$(LOCAL
)/$d)
626 $(foreach d
,$(LOCAL_COMMON_DIRS
) $(LOCAL_EXTRA_DIRS
),$(LOCAL
)/$d):
627 $(V_AT
)mkdir
-p
$(call parent-dir
$@
)
628 $(call v_tag
,MKDIR
)mkdir
$@
630 LOCAL_ARCH_DIRS
= bin
/ etc
/ games
/ include/ include.aside
/
631 LOCAL_ARCH_DIRS
+= lib
/ libexec
/ sbin
/
632 LOCAL_ARCH_LINKS
= man
633 man_LINKDEST
= share
/man
634 all: $(foreach a
,$(ALL_ARCHS
),\
636 $(foreach d
,$(LOCAL_ARCH_DIRS
),$(LOCAL
)/$a/$d) \
637 $(foreach d
,$(LOCAL_ARCH_LINKS
),$(LOCAL
)/$a/$d) \
638 $(foreach d
,$(LOCAL_COMMON_DIRS
),$(LOCAL
)/$a/$d))
640 $(foreach a
,$(ALL_ARCHS
),$(LOCAL
)/$a/):
641 $(call v_tag
,MKDIR
)mkdir
$@
642 $(foreach a
,$(ALL_ARCHS
),\
643 $(foreach d
,$(LOCAL_ARCH_DIRS
),$(LOCAL
)/$a/$d)):
644 $(V_AT
)mkdir
-p
$(call parent-dir
,$@
)
645 $(call v_tag
,MKDIR
)mkdir
$@
646 $(foreach a
,$(ALL_ARCHS
),\
647 $(foreach d
,$(LOCAL_ARCH_LINKS
),$(LOCAL
)/$a/$d)): \
648 $$(if
$$(call symlink-ok-p
,$$@
,$$($$(call base-name
,$$@
)_LINKDEST
)),,_force
) \
649 $(V_AT
)mkdir
-p
$(call parent-dir
,$@
)
650 $(call v_tag
,SYMLINK
)ln
-sf
$($(call base-name
,$@
)_LINKDEST
) $@
651 $(foreach a
,$(ALL_ARCHS
),\
652 $(foreach d
,$(LOCAL_COMMON_DIRS
),$(LOCAL
)/$a/$d)): \
653 $$(if
$$(call symlink-ok-p
,$$@
,..
/$$(call base-name
,$$@
)),,_force
) \
654 $(V_AT
)mkdir
-p
$(call parent-dir
,$@
)
655 $(call v_tag
,SYMLINK
)ln
-sf ..
/$(call base-name
,$@
) $(call file-name
,$@
)
657 ###--------------------------------------------------------------------------
658 ### Main chroot maintenance.
662 JOBS
= chroot cross-tools pkg-build
666 MAINT
= +$(call v_tag
,MAINT
)\
667 PYTHONPATH
=$(STATE
)/lib
/python
$(STATE
)/bin
/chroot-maint \
671 $(MAINT
) -f
$(FRESH
) $(JOBS
)
674 ###--------------------------------------------------------------------------
675 ### Running random commands.
678 subst-command
= $(subst %d
,$(call chroot-dist
,$1), \
679 $(subst %a
,$(call chroot-arch
,$1), \
680 $(subst %r
,$1, $(CMD
))))
682 run
: $(foreach c
,$(ALL_CHROOTS
),run
/$c)
683 $(foreach c
,$(ALL_CHROOTS
),run
/$c): run
/%:
684 $(V_AT
)$(call v_print
,RUN
,$(call subst-command
,$*))\
685 $(call subst-command
,$*)
687 ###--------------------------------------------------------------------------
688 ### Other maintenance targets.
699 ###----- That's all, folks --------------------------------------------------