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 ###--------------------------------------------------------------------------
41 ## Level of pickiness to aspire to.
44 ## Volume group from which to allocate chroot volumes and snapshots.
45 CONFIG_VARS
+= VG LVPREFIX
46 VG
:= vg-
$(shell hostname
)
49 ## Logical volume size, as an LVM option.
50 CONFIG_VARS
+= LVSZ SNAPOPT
55 CONFIG_VARS
+= DEBMIRROR
56 DEBMIRROR
= http
://deb.debian.org
/debian
/
58 ## APT sources configurations. (Also, $($d_APTSRC) for each $d in $(DISTS).)
60 APTSRC
= etc
/aptsrc.conf
$(wildcard etc
/aptsrc.local.conf
)
62 ## APT configuration fragment names. These will be linked into
63 ## `/etc/apt/apt.conf.d' in each chroot. To put a fragment f in a surprising
64 ## place, set $(_$f_APTCONFSRC).
65 CONFIG_VARS
+= APTCONF
$(foreach f
,$(APTCONF
),_
$f_APTCONFSRC)
66 APTCONF
= $(notdir $(wildcard etc
/apt-conf.d
/[0-9]*[!~
]))
71 eval
$$(apt-config
$(foreach a
,$(APTCONF
),-cetc
/apt-conf.d
/$a) \
72 shell proxy Acquire
::http
::proxy
); \
73 case
$${proxy
+t
} in
(t
) echo
"$$proxy" ;; (*) echo nil
;; esac
)
75 ## Debian distributions to support.
76 CONFIG_VARS
+= PRIMARY_DIST DISTS
77 PRIMARY_DIST
= stretch
78 DISTS
= $(PRIMARY_DIST
) buster bullseye bookworm sid
80 ## Host's native architecture(s).
81 CONFIG_VARS
+= MYARCH NATIVE_ARCHS
82 MYARCH
:= $(shell dpkg
--print-architecture
)
83 OTHERARCHS
:= $(shell dpkg
--print-foreign-architectures
)
84 NATIVE_ARCHS
= $(MYARCH
) $(OTHERARCHS
)
86 ## Foreign (emulated) architectures to support.
87 CONFIG_VARS
+= FOREIGN_ARCHS
90 ## Master lists of chroots to build and maintain.
91 CONFIG_VARS
+= NATIVE_CHROOTS FOREIGN_CHROOTS
92 NATIVE_CHROOTS
= $(foreach a
,$(NATIVE_ARCHS
), \
93 $(foreach d
,$(or
$($a_DISTS) $(DISTS
)), \
95 FOREIGN_CHROOTS
= $(foreach a
,$(FOREIGN_ARCHS
), \
96 $(foreach d
,$(or
$($a_DISTS) $(DISTS
)), \
99 ## Extra packages to be installed in chroots. `BASE_PACKAGES' are installed
100 ## through `debootstrap'; `EXTRA_PACKAGES' are installed later, using Apt,
101 ## which is faster in foreign chroots.
102 CONFIG_VARS
+= BASE_PACKAGES EXTRA_PACKAGES
103 BASE_PACKAGES
= eatmydata
104 EXTRA_PACKAGES
= build-essential
105 EXTRA_PACKAGES
+= ccache
106 EXTRA_PACKAGES
+= fakeroot
107 EXTRA_PACKAGES
+= libfile-fcntllock-perl
108 EXTRA_PACKAGES
+= locales
110 ## Extra packages from which to install the cross tools.
111 CONFIG_VARS
+= CROSS_PACKAGES
112 CROSS_PACKAGES
= bash coreutils dash findutils
113 CROSS_PACKAGES
+= gzip m4 mawk sed
tar xz-utils
114 CROSS_PACKAGES
+= apt ccache eatmydata fakeroot make
115 CROSS_PACKAGES
+= qemu-user-static
116 CROSS_PACKAGES
+= $(foreach a
,$(FOREIGN_GNUARCHS
),\
117 gcc-
$a g
++-$a binutils-
$a)
119 ## Native files to install in place of the foreign versions. `MULTI' here
120 ## stands for the donor's GNU multiarch name.
121 CONFIG_VARS
+= CROSS_PATHS
123 $(addprefix /usr
/bin
/, \
124 apt apt-cache apt-config apt-get apt-key apt-mark
) \
125 $(addprefix /usr
/lib
/apt
/, \
128 cat chgrp chown cp date dd df
dir echo false ln ls mkdir \
129 mknod mktemp mv pwd readlink
rm rmdir sleep stty sync touch \
131 $(addprefix /usr
/bin
/, \
132 [ arch b2sum base32 base64
basename chcon cksum comm \
133 csplit cut dircolors dirname du env expand expr factor fmt \
134 fold groups head hostid id
install join link logname md5sum \
135 mkfifo nice nl nohup nproc numfmt od paste pathchk pinky pr \
136 printenv printf ptx realpath runcon seq sha1sum sha224sum \
137 sha256sum sha384sum sha512sum shred shuf
sort split stat \
138 stdbuf sum tac tail tee
test timeout tr truncate tsort tty \
139 unexpand uniq unlink users wc who whoami yes
) \
140 ?
/usr
/lib
/MULTI
/coreutils
/ \
141 $(addprefix /lib
/MULTI
/, \
142 libnsl.so.
* libnss_
*.so.
*) \
144 /usr
/bin
/qemu-
*-static \
146 bash dash gzip sed
tar) \
147 $(addprefix /usr
/bin
/, \
148 ccache find m4 make mawk xargs xz
) \
149 $(addprefix /usr
/lib
/MULTI
/, \
150 libeatmydata.so
* libfakeroot
/) \
151 $(addprefix /etc
/ld.so.conf.d
/, \
152 MULTI.conf fakeroot
*.conf
) \
153 $(foreach a
,$(FOREIGN_GNUARCHS
), \
154 $(addprefix /usr
/bin
/$a-, \
155 addr2line
ar as c
++filt dwp elfedit gprof
ld ld.
* \
156 nm objcopy objdump ranlib readelf size strings \
158 $(addprefix /usr
/bin
/$a-, \
159 cpp gcc g
++ gcov gcov-dump gcov-tool gprof \
160 gcc-ar gcc-nm gcc-ranlib
) \
161 /usr
/lib
/gcc-cross
/$a/ \
164 ## Local packages to be compiled and installed in chroots. Archives can be
166 CONFIG_VARS
+= LOCALPKGS
$(foreach p
,$(LOCALPKGS
),$p_DEPS)
167 LOCALPKGS
= mLib checkpath
169 checkpath_DEPS
= mLib
171 ## Which host architecture to use for foreign architectures. It turns out
172 ## that it's best to use a Qemu with the same host bitness as the target
173 ## architecture; otherwise it has to do a difficult job of converting
174 ## arguments and results between kernel ABI flavours.
175 32BIT_QEMUHOST
= $(or
$(filter i386
,$(NATIVE_ARCHS
)),$(TOOLSARCH
))
176 64BIT_QEMUHOST
= $(or
$(filter amd64
,$(NATIVE_ARCHS
)),$(TOOLSARCH
))
178 CONFIG_VARS
+= $(foreach a
,$(FOREIGN_ARCHS
),$a_QEMUHOST)
179 armel_QEMUHOST
= $(32BIT_QEMUHOST
)
180 armhf_QEMUHOST
= $(32BIT_QEMUHOST
)
181 arm64_QEMUHOST
= $(64BIT_QEMUHOST
)
182 i386_QEMUHOST
= $(32BIT_QEMUHOST
)
183 amd64_QEMUHOST
= $(64BIT_QEMUHOST
)
185 ## Which distribution of Qemu to use.
186 CONFIG_VARS
+= $(foreach d
,$(DISTS
),$d_QEMUDIST)
187 stretch_QEMUDIST
= buster
189 ## Qemu architecture names. These tell us which Qemu binary to use for a
190 ## particular Debian architecture.
191 CONFIG_VARS
+= $(foreach a
,$(FOREIGN_ARCHS
),$a_QEMUARCH)
194 arm64_QEMUARCH
= aarch64
196 amd64_QEMUARCH
= x86_64
198 ## Alias mapping for chroots.
199 CONFIG_VARS
+= $(foreach d
,$(DISTS
),$d_ALIASES)
200 stretch_ALIASES
= oldstable
201 buster_ALIASES
= stable
202 bullseye_ALIASES
= testing
203 sid_ALIASES
= unstable
205 ## Which host architecture to use for commonly used tools in foreign chroots.
206 CONFIG_VARS
+= TOOLSARCH
207 TOOLSARCH
= $(MYARCH
)
209 ## A directory in which we can maintain private files and state.
213 ## A directory which will be spliced into chroots as `/usr/local.schroot/'.
214 ## This will be our primary point of contact with the chroot.
215 CONFIG_VARS
+= LOCAL ABSLOCAL
216 LOCAL
= local.schroot
217 ABSLOCAL
= $(abspath
$(LOCAL
))
219 ## How to run a command as a privileged user.
220 CONFIG_VARS
+= ROOTLY
223 ## Files to be copied into a chroot from the host.
224 SCHROOT_COPYFILES
= /etc
/resolv.conf
225 SCHROOT_NSSDATABASES
= passwd shadow group gshadow
227 ## Local configuration hook.
231 CONFIG_VARS
+= ALL_ARCHS ALL_CHROOTS
232 ALL_ARCHS
= $(NATIVE_ARCHS
) $(FOREIGN_ARCHS
)
233 ALL_CHROOTS
= $(NATIVE_CHROOTS
) $(FOREIGN_CHROOTS
)
235 ## GNU names for foreign architectures.
236 CONFIG_VARS
+= FOREIGN_GNUARCHS
237 FOREIGN_GNUARCHS
:= $(foreach a
,$(FOREIGN_ARCHS
),\
238 $(shell dpkg-architecture
-A
$a \
239 -qDEB_TARGET_GNU_TYPE
))
241 ###--------------------------------------------------------------------------
244 ## Hack to force rebuilding.
248 ## Hack to not delimit function arguments. (Ugh!)
251 ## Silent-rules machinery.
254 v_print
= $(call v_print_
$V,$1,$2)
255 v_print_0
= printf
" %-8s %s\n" "$1" $(call squote
,$2);
256 v_tag
= $(V_AT
)$(call v_print
,$1,$@
)
257 v_log
= $(call v_log_
$V,$1,$2)
258 v_log_
= $(call v_log_1
,$1,$2)
259 v_log_0
= $2 >log
/$1.log
2>&1
260 v_log_1
= $(call catchrc
,$(call throwrc
,$2) 2>&1 | tee log
/$1.log
)
261 v_echo
= $(call v_echo_
$V,$1)
263 v_echo_1
= printf
"%s\n" $1
264 CLEANFILES
+= log
/*.log
268 LVM_SUPPRESS_FD_WARNINGS
=1; export LVM_SUPPRESS_FD_WARNINGS
270 ## $(call file-name,PATH)
272 ## Strip any trailing `/' from the PATH.
275 ## $(call base-name,PATH)
277 ## Expand to the last component of PATH, whether or not it's a directory
278 ## name with a trailing `/'.
279 base-name
= $(notdir $(call file-name
,$1))
281 ## $(call parent-dir,PATH)
283 ## Expand to the parent directory of PATH, whether or not it's a directory
284 ## name with a trailing `/'.
286 parent-dir
= $(dir $(call file-name
,$1))
288 ## $(call definedp,VAR)
290 ## Expand non-empty if and only if VAR is defined (but possibly empty).
291 definedp
= $(filter-out undefined
,$(origin $1))
293 ## $(call catchrc,...$(call throwrc,CMD)...)
295 ## Catch the exit status of some subpart of a complicated shell rune.
296 catchrc
= (exec
3>&1; exit
$$({ $1; } 4>&1 >&3 3>&-))
297 throwrc
= { $1; echo
$$?
>&4; }
299 ## $(call squote,TXT)
302 squote
= '$(subst ','\'',$1)'
305 ## $(call chroot-dist,D-A) -> D
306 ## $(call chroot-arch,D-A) -> A
308 ## Parse chroot descriptions.
309 chroot-dist
= $(patsubst %/,%,$(dir $(subst -,/,$1)))
310 chroot-arch
= $(notdir $(subst -,/,$1))
312 ## $(call package-dir-name,P-V) -> P
313 ## $(call package-dir-version,P-V) -> V
315 ## Parse (source) package directory names.
316 package-dir-name
= $(sort $(foreach p
,$(LOCALPKGS
),$(if
$(filter $p-$($p_VERSION),$1),$p)))
317 package-dir-version
= $($(call package-dir-name
,$1)_VERSION
)
319 ## $(call package-dir,P-V.A) -> P-V
320 ## $(call package-name,P-V.A) -> P
321 ## $(call package-version,P-V.A) -> V
322 ## $(call package-arch,P-V.A) -> A
324 ## Parse package stamp names.
325 package-dir
= $(basename $1)
326 package-name
= $(call package-dir-name
,$(call package-dir
,$1))
327 package-version
= $(call package-dir-version
,$(call package-dir
,$1))
328 package-arch
= $(patsubst .
%,%,$(suffix $1))
330 ## $(call native-chroot-p,D-A) -> D | <empty>
332 ## Answer whether D-A is a native chroot.
333 native-chroot-p
= $(filter $(call chroot-arch
,$1),$(NATIVE_ARCHS
))
335 ## $(call chroot-qemuhost,D-A) -> AA
337 ## Answer the apporopriate Qemu host architecture for foreign chroot D-A.
338 chroot-qemuhost
= $($(call chroot-arch
,$1)_QEMUHOST
)
340 ## $(call chroot-deps,PRE,D-A) -> PREDD-AA ... | <empty>
342 ## Answer a list of additional dependencies for the chroot D-A: specifically,
343 ## if D-A is foreign then include PRE/DD-AA entries for the tools
344 ## architecture, and Qemu host architecture (if that's different).
345 chroot-deps
= $(if
$(call native-chroot-p
,$2),, \
346 $(addprefix $1$(call chroot-dist
,$2)-,\
347 $(sort $(TOOLSARCH
) \
348 $(call chroot-qemuhost
,$2))))
350 ## Substituting placeholders in files.
351 SUBSTITUTIONS
:= local
=$(shell realpath
$(LOCAL
))
352 SUBSTITUTIONS
+= primary-dist
=$(PRIMARY_DIST
)
354 echo
"$1 GENERATED by distorted-chroot: do not edit"; \
356 for v in
$(SUBSTITUTIONS
); do \
357 var
=$${v
%%=*} value
=$${v\
#*=}; \
358 substs
="$$substs s\a@$$var@\a$$value\ag;"; \
363 ### $(call symlink-ok-p,LINK,DEST)
365 ### Expand to `t' if LINK is a symbolic link to DEST, and empty otherwise.
366 symlink-ok-p
= $(shell \
367 case
$$(readlink
2>/dev
/null
$(patsubst %/,%,$1)) in
($2) echo t
;; esac
)
369 ### $(call general-notify,SEV,COLOUR,PREFIX,MSG)
371 ### Report a message, highlighted in the right way, and maybe fail
373 echo
"$$(tput bold; tput setaf $2)$3 "$4"$$(tput sgr0; tput op)"; \
374 if
[ "$1" -le
"$(NOTIFY_FATAL)" ]; then exit
2; fi
; \
377 ### $(call report/SEV,MSG)
379 ### Report a notification of a particular severity.
380 notify
/INFO
= $(call general-notify
,3,6,---,$1)
381 notify
/WARN
= $(call general-notify
,2,5,???
,$1)
382 notify
/ERR
= $(call general-notify
,1,1,!!!,$1)
384 ## $(call check,SEV,MSG,UNLESS)
386 ## If UNLESS completes successfully, all is OK; otherwise print MSG to stderr
389 $(call v_echo
,'check: '$(call squote
,$3)''); \
390 if
! { $3; }; then
$(call notify
/$1,$2); fi
; \
393 ## $(call check-executable,SEV,PATH)
395 ## Verify that PATH is an executable program.
396 check-executable
= $(call
check,$1,"\`$2' is not an executable", \
399 ## $(call check-mountpoint,SEV,DIR)
401 ## Verify that DIR is a mountpoint.
402 check-mountpoint
= $(call
check,$1,"\`$2' is not a mount point", \
405 ## $(call check-symlink,SEV,LINK,DEST)
407 ## Verify that LINK is a symbolic link pointing to DEST.
408 check-symlink
= $(call
check,$1,"\`$2' is not a link to \`$3'", \
409 [ -L
"$2" ] && [ "$$(readlink "$2")" = "$3" ])
413 ## Make a directory. Use as an order-only dependency.
414 %/:; $(V_AT
)mkdir
-p
$@
416 ###--------------------------------------------------------------------------
417 ### Python extensions.
420 CFLAGS
= -O2
-g
-Wall
425 c-source
= $(foreach c
,$1,src
/$c)
426 c-object
= $(foreach c
,$1,$(STATE
)/obj
/$(basename $c).o
)
428 PYEXT_PKGFLAGS
:= $(shell pkg-config
--cflags python2
)
429 PYEXT_CFLAGS
= -fPIC
-fno-strict-aliasing
$(PYEXT_PKGFLAGS
)
430 PYEXT_LDFLAGS
= -shared
433 jobclient_SOURCES
= jobclient.c
435 PYEXT_ALLSRC
= $(foreach x
,$(PYEXTS
),\
436 $(call c-source
,$($x_SOURCES)))
437 PYEXT_ALLOBJ
= $(foreach x
,$(PYEXTS
),\
438 $(call c-object
,$($x_SOURCES)))
439 $(PYEXT_ALLOBJ
): $(STATE
)/obj
/%.o
: src
/%.c |
$$(dir $$@
)
440 $(call v_tag
,CC
)$(CC
) -c
$(CFLAGS
) $(PYEXT_CFLAGS
) -o
$@
$<
442 PYMODULES
= $(foreach x
,$(PYEXTS
),$(STATE
)/lib
/python
/$x.so
)
444 $(PYMODULES
): $(STATE
)/lib
/python
/%.so
: \
445 $$(call c-object
,$$($$*_SOURCES
)) |
$$(dir $$@
)
446 $(call v_tag
,LD
)$(LD
) $(LDFLAGS
) $(PYEXT_LDFLAGS
) -o
$@
$^
448 ###--------------------------------------------------------------------------
451 SCRIPTS
+= chroot-maint
452 SCRIPTS
+= mkchrootconf
454 SUBST_SCRIPTS
= $(addprefix $(STATE
)/bin
/,$(SCRIPTS
))
455 all: $(SUBST_SCRIPTS
)
456 $(SUBST_SCRIPTS
): $(STATE
)/bin
/%: bin
/% $(STATE
)/config.sh |
$$(dir $$@
)
457 $(call v_tag
,SUBST
){ \
459 -e
'2i### GENERATED by distorted-chroot: do not edit' \
460 -e
'/@@@config@@@/ {' \
461 -e
'r $(STATE)/config.sh' \
464 } >$@.new
&& chmod
+x
$@.new
&& mv
$@.new
$@
466 ###--------------------------------------------------------------------------
467 ### APT configuration.
469 ## In a chroot, `/etc/apt/sources.list' links to
470 ## `/usr/local.schroot/etc/apt/sources.$d' for the appropriate distribution.
471 APT_SOURCES
= $(foreach d
,$(DISTS
),$(LOCAL
)/etc
/apt
/sources.
$d)
474 $(foreach d
,$(DISTS
),$(STATE
)/etc
/apt
/aptsrc.
$d): \
475 $(STATE
)/etc
/apt
/aptsrc.
%: |
$$(dir $$@
)
477 echo
"### -*-conf-*- GENERATED by distorted-chroot: do not edit"; \
479 echo
" debian : $*"; \
480 } >$@.new
&& mv
$@.new
$@
482 $(APT_SOURCES
): $(LOCAL
)/etc
/apt
/sources.
%: \
483 $$(APTSRC
) $$($$*_APTSRC
) $$(STATE
)/etc
/apt
/aptsrc.
$$* \
485 $(call v_tag
,GEN
)bin
/mkaptsrc \
486 $(APTSRC
) $($*_APTSRC
) $(STATE
)/etc
/apt
/aptsrc.
$* \
487 >$@.new
&& mv
$@.new
$@
488 CLEANFILES
+= $(APT_SOURCES
)
490 ## In a chroot, a link `/etc/apt/apt.conf.d/FOO' is created for each file in
491 ## `/usr/local.schroot/etc/apt/apt.conf.d/FOO'.
492 APT_CONFIGS
= $(addprefix $(LOCAL
)/etc
/apt
/apt.conf.d
/,$(APTCONF
))
494 $(APT_CONFIGS
): $(LOCAL
)/etc
/apt
/apt.conf.d
/%: \
495 $$(or
$$(_
$$*_APTCONFSRC
) etc
/apt-conf.d
/$$*) |
$$(dir $$@
)
496 $(call v_tag
,COPY
)cp
$< $@.new
&& mv
$@.new
$@
497 clean::; rm -f
$(APT_CONFIGS
)
499 ###--------------------------------------------------------------------------
502 check::; $(call check-executable
,ERR
,/usr
/bin
/eatmydata
)
504 EATMYDATA_HACKS
+= apt-get aptitude dpkg
505 SYMLINK_EATMYDATA_HACKS
= $(addprefix $(LOCAL
)/hacks
/,$(EATMYDATA_HACKS
))
506 all: $(SYMLINK_EATMYDATA_HACKS
)
507 $(SYMLINK_EATMYDATA_HACKS
): $(LOCAL
)/hacks
/%: \
508 $$(if
$$(call symlink-ok-p
,$$@
,/usr
/bin
/eatmydata
),,_force
) \
510 $(call v_tag
,SYMLINK
)ln
-sf
/usr
/bin
/eatmydata
$@.new
&& mv
$@.new
$@
511 clean::; rm -f
$(SYMLINK_EATMYDATA_HACKS
)
513 SCRIPT_HACKS
+= buildwrap
514 COPY_SCRIPT_HACKS
= $(addprefix $(LOCAL
)/hacks
/,$(SCRIPT_HACKS
))
515 all: $(COPY_SCRIPT_HACKS
)
516 $(COPY_SCRIPT_HACKS
): $(LOCAL
)/hacks
/%: bin
/% |
$$(dir $$@
)
517 $(call v_tag
,COPY
)cp
$< $@.new
&& mv
$@.new
$@
518 clean::; rm -f
$(COPY_SCRIPT_HACKS
)
520 ###--------------------------------------------------------------------------
521 ### `schroot' and `sbuild' configuration.
525 .PHONY
: schroot-config
527 check::; $(call check-mountpoint
,WARN
,/var
/lib
/sbuild
/build
)
528 check::; $(call check-symlink
,WARN
,/build
,/var
/lib
/sbuild
/build
)
529 check::; $(call check-symlink
,ERR
,/schroot
,/run
/schroot
/mount
)
532 echo
"\#\#\# -*-sh-*- GENERATED by distorted-chroot: do not edit"; \
533 $(foreach v
,$1,$(if
$(call definedp
,$v),\
534 echo
$v=\'$(call squote
,$($v))\';)) \
536 schroot-config_HASH
:= \
537 $(shell $(call
%print-varlist
,$(CONFIG_VARS
)) | \
538 sha256sum | cut
-c1-32
)
539 schroot-config_FILE
= $(STATE
)/config.sh-
$(schroot-config_HASH
)
540 $(schroot-config_FILE
): |
$(STATE
)/
541 $(V_AT
)rm -f
$(STATE
)/config.sh-
*
542 $(call v_tag
,GEN
)$(call
%print-varlist
,$(CONFIG_VARS
)) \
543 >$@.new
&& mv
$@.new
$@
545 schroot-config
: $(STATE
)/config.sh
546 $(STATE
)/config.sh
: $(schroot-config_FILE
)
547 $(call v_tag
,SYMLINK
)ln
-sf
$(call base-name
,$<) $@
549 schroot-config
: $(LOCAL
)/etc
/schroot
/sbuild.schroot
550 $(LOCAL
)/etc
/schroot
/sbuild.schroot
: $(STATE
)/bin
/mkchrootconf |
$$(dir $$@
)
551 $(call v_tag
,GEN
)$(STATE
)/bin
/mkchrootconf
>$@.new
&& \
552 $(ROOTLY
) chown root
:root
$@.new
&& mv
$@.new
$@
553 CLEANFILES
+= $(LOCAL
)/etc
/schroot
/sbuild.schroot
554 check::; $(call check-symlink
,WARN
,/etc
/schroot
/chroot.d
/sbuild
,$(ABSLOCAL
)/etc
/schroot
/sbuild.schroot
)
556 schroot-config
: $(LOCAL
)/etc
/schroot
/sbuild.profile
/copyfiles
557 $(LOCAL
)/etc
/schroot
/sbuild.profile
/copyfiles
: \
558 $(schroot-config_STAMP
) |
$$(dir $$@
)
560 echo
"### -*-conf-*- GENERATED by distorted-chroot: do not edit"; \
561 for i in
$(SCHROOT_COPYFILES
); do echo
"$$i"; done
; \
562 } >$@.new
&& mv
$@.new
$@
563 CLEANFILES
+= $(LOCAL
)/etc
/schroot
/sbuild.profile
/copyfiles
565 schroot-config
: $(LOCAL
)/etc
/schroot
/sbuild.profile
/nssdatabases
566 $(LOCAL
)/etc
/schroot
/sbuild.profile
/nssdatabases
: \
567 $(schroot-config_STAMP
) |
$$(dir $$@
)
569 echo
"### -*-conf-*- GENERATED by distorted-chroot: do not edit"; \
570 for i in
$(SCHROOT_NSSDATABASES
); do echo
"$$i"; done
; \
571 } >$@.new
&& mv
$@.new
$@
572 CLEANFILES
+= $(LOCAL
)/etc
/schroot
/sbuild.profile
/nssdatabases
574 schroot-config
: $(LOCAL
)/etc
/schroot
/sbuild.profile
/fstab
575 $(LOCAL
)/etc
/schroot
/sbuild.profile
/fstab
: \
576 etc
/sbuild.fstab.in
$(schroot-config_STAMP
) |
$$(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 \
585 $(schroot-config_STAMP
) |
$$(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
/% \
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
: \
616 etc
/ccache.conf |
$$(dir $$@
)
617 $(call v_tag
,COPY
)cp
$< $@.new
&& mv
$@.new
$@
619 ###--------------------------------------------------------------------------
620 ### `/usr/local/' structure.
622 LOCAL_COMMON_DIRS
= share
/ src
/
623 LOCAL_EXTRA_DIRS
= share
/man
/
624 all: $(foreach d
,$(LOCAL_COMMON_DIRS
) $(LOCAL_EXTRA_DIRS
),$(LOCAL
)/$d)
626 LOCAL_ARCH_DIRS
= bin
/ etc
/ games
/ include/ include.aside
/
627 LOCAL_ARCH_DIRS
+= lib
/ libexec
/ sbin
/
628 LOCAL_ARCH_LINKS
= man
629 man_LINKDEST
= share
/man
630 all: $(foreach a
,$(ALL_ARCHS
),\
632 $(foreach d
,$(LOCAL_ARCH_DIRS
),$(LOCAL
)/$a/$d) \
633 $(foreach d
,$(LOCAL_ARCH_LINKS
),$(LOCAL
)/$a/$d) \
634 $(foreach d
,$(LOCAL_COMMON_DIRS
),$(LOCAL
)/$a/$d))
636 $(foreach a
,$(ALL_ARCHS
),\
637 $(foreach d
,$(LOCAL_ARCH_LINKS
),$(LOCAL
)/$a/$d)): \
638 $$(if
$$(call symlink-ok-p
,$$@
,$$($$(call base-name
,$$@
)_LINKDEST
)),,_force
) \
640 $(call v_tag
,SYMLINK
)ln
-sf
$($(call base-name
,$@
)_LINKDEST
) $@
641 $(foreach a
,$(ALL_ARCHS
),\
642 $(foreach d
,$(LOCAL_COMMON_DIRS
),$(LOCAL
)/$a/$d)): \
643 $$(if
$$(call symlink-ok-p
,$$@
,..
/$$(call base-name
,$$@
)),,_force
) \
644 |
$$(call parent-dir
,$$@
)
645 $(call v_tag
,SYMLINK
)ln
-sf ..
/$(call base-name
,$@
) $(call file-name
,$@
)
647 ###--------------------------------------------------------------------------
648 ### Main chroot maintenance.
652 JOBS
= chroot cross-tools pkg-build
656 MAINT
= +$(call v_tag
,MAINT
)\
657 PYTHONPATH
=$(STATE
)/lib
/python
$(STATE
)/bin
/chroot-maint \
661 $(MAINT
) -f
$(FRESH
) $(JOBS
)
664 ###--------------------------------------------------------------------------
665 ### Running random commands.
668 subst-command
= $(subst %d
,$(call chroot-dist
,$1), \
669 $(subst %a
,$(call chroot-arch
,$1), \
670 $(subst %r
,$1, $(CMD
))))
672 run
: $(foreach c
,$(ALL_CHROOTS
),run
/$c)
673 $(foreach c
,$(ALL_CHROOTS
),run
/$c): run
/%:
674 $(V_AT
)$(call v_print
,RUN
,$(call subst-command
,$*))\
675 $(call subst-command
,$*)
677 ###--------------------------------------------------------------------------
678 ### Other maintenance targets.
689 ###----- That's all, folks --------------------------------------------------