7 # we require building from git
8 if ! git rev-parse
--is-inside-work-tree &> /dev
/null
; then
9 echo "${PWD} is not a Git tree."
14 if [ -e config
/amnesia.
local ] ; then
15 . config
/amnesia.
local
18 # a clean starting point
19 rm -rf cache
/stages_rootfs
21 # get LB_BINARY_IMAGES
24 # get LB_ARCHITECTURE and LB_DISTRIBUTION
30 # refresh translations of our programs
31 .
/refresh-translations
33 # save variables that are needed by chroot_local-hooks
34 echo "LB_DISTRIBUTION=${LB_DISTRIBUTION}" >> config
/chroot_local-includes
/usr
/share
/amnesia
/build
/variables
35 echo "AMNESIA_SUPPORTED_LANGUAGES='${AMNESIA_SUPPORTED_LANGUAGES}'" >> config
/chroot_local-includes
/usr
/share
/amnesia
/build
/variables
37 # fix permissions on some source files that will be copied as is to the chroot.
38 # they may be wrong, e.g. if the Git repository was cloned with a strict umask.
39 chmod -R go
+rX config
/binary_local-includes
/
40 chmod -R go
+rX config
/chroot_local-includes
/etc
41 chmod 0440 config
/chroot_local-includes
/etc
/sudoers.d
/*
42 chmod go
+rX config
/chroot_local-includes
/lib
43 chmod go
+rX config
/chroot_local-includes
/lib
/live
44 chmod -R go
+rx config
/chroot_local-includes
/lib
/live
/config
45 chmod go
+rX config
/chroot_local-includes
/live
46 chmod -R go
+rX config
/chroot_local-includes
/usr
47 chmod -R go
+rx config
/chroot_local-includes
/usr
/local
/bin
48 chmod -R go
+rx config
/chroot_local-includes
/usr
/local
/sbin
49 chmod -R go
+rX config
/chroot_local-includes
/usr
/share
/doc
/tails
50 chmod -R go
+rX config
/chroot_apt
51 chmod -R go
+rX config
/chroot_sources
55 : ${MKSQUASHFS_OPTIONS:='-comp xz'}
56 MKSQUASHFS_OPTIONS
="${MKSQUASHFS_OPTIONS} -wildcards -ef chroot/usr/share/amnesia/build/mksquashfs-excludes"
57 export MKSQUASHFS_OPTIONS
59 # get git branch or tag so we can set the basename appropriately, i.e.:
60 # * if we build from a tag: tails-$ARCH-$TAG.iso
61 # * if we build from a branch: tails-$ARCH-$BRANCH-$VERSION-$DATE.iso
62 if GIT_REF
="$(git symbolic-ref HEAD)"; then
63 GIT_BRANCH
="${GIT_REF#refs/heads/}"
64 CLEAN_GIT_BRANCH
=$
(echo "$GIT_BRANCH" |
sed 's,/,_,g')
65 BUILD_BASENAME
="tails-${LB_ARCHITECTURE}-${CLEAN_GIT_BRANCH}-${AMNESIA_VERSION}-${AMNESIA_TODAY}"
67 GIT_CURRENT_COMMIT
="$(git rev-parse HEAD)"
68 if GIT_TAG
="$(git describe --tags --exact-match ${GIT_CURRENT_COMMIT})"; then
69 CLEAN_GIT_TAG
=$
(echo "$GIT_TAG" |
sed 's,/,_,g')
70 BUILD_BASENAME
="tails-${LB_ARCHITECTURE}-${CLEAN_GIT_TAG}"
72 # this shouldn't reasonably happen (e.g. only if you checkout a
73 # tag, remove the tag and then build)
74 echo "Neither a Git branch nor a tag, exiting."
79 case "$LB_BINARY_IMAGES" in
81 BUILD_FILENAME_EXT
=iso
85 BUILD_FILENAME_EXT
=iso
86 BUILD_FILENAME
=binary-hybrid
89 BUILD_FILENAME_EXT
=tar.gz
90 BUILD_FILENAME
=binary-tar
93 BUILD_FILENAME_EXT
=img
97 echo "Image type ${LB_BINARY_IMAGES} is not supported." >&2
101 BUILD_DEST_FILENAME
="${BUILD_BASENAME}.${BUILD_FILENAME_EXT}"
102 BUILD_MANIFEST
="${BUILD_DEST_FILENAME}.list"
103 BUILD_PACKAGES
="${BUILD_DEST_FILENAME}.packages"
104 BUILD_LOG
="${BUILD_DEST_FILENAME}.buildlog"
106 echo "Building $LB_BINARY_IMAGES image ${BUILD_BASENAME}..."
108 if time eatmydata lb build noauto
${@} 2>&1 |
tee "${BUILD_LOG}" ; then
109 echo "Image was successfully created"
110 echo "Renaming generated files..."
111 mv -i "${BUILD_FILENAME}.${BUILD_FILENAME_EXT}" "${BUILD_DEST_FILENAME}"
112 mv -i binary.packages
"${BUILD_PACKAGES}"
114 echo "lb build failed." >&2