French translation improvements.
[tails-test.git] / auto / build
blobec42e37febce537bb35b2707c158951107e5951f
1 #!/bin/bash
3 # set -x
5 umask 022
7 ### functions
9 fatal () {
10 echo "$*" >&2
11 exit 1
14 ### Main
16 # we require building from git
17 git rev-parse --is-inside-work-tree &> /dev/null \
18 || fatal "${PWD} is not a Git tree."
20 . config/amnesia
21 if [ -e config/amnesia.local ] ; then
22 . config/amnesia.local
25 # a clean starting point
26 rm -rf cache/stages_rootfs
28 # get LB_BINARY_IMAGES
29 . config/binary
31 # get LB_ARCHITECTURE and LB_DISTRIBUTION
32 . config/bootstrap
34 # build the doc wiki
35 ./build-wiki
37 # refresh translations of our programs
38 ./refresh-translations || fatal "refresh-translations failed ($?)."
40 # save variables that are needed by chroot_local-hooks
41 echo "LB_DISTRIBUTION=${LB_DISTRIBUTION}" >> config/chroot_local-includes/usr/share/amnesia/build/variables
42 echo "AMNESIA_SUPPORTED_LANGUAGES='${AMNESIA_SUPPORTED_LANGUAGES}'" >> config/chroot_local-includes/usr/share/amnesia/build/variables
43 echo "POTFILES_DOT_IN='$(
44 /bin/grep -E --no-filename '[^ #]*\.in$' po/POTFILES.in \
45 | sed -e 's,^config/chroot_local-includes,,' | tr "\n" ' '
46 )'" \
47 >> config/chroot_local-includes/usr/share/amnesia/build/variables
49 # fix permissions on some source files that will be copied as is to the chroot.
50 # they may be wrong, e.g. if the Git repository was cloned with a strict umask.
51 chmod -R go+rX config/binary_local-includes/
52 chmod -R go+rX config/chroot_local-includes/etc
53 chmod 0440 config/chroot_local-includes/etc/sudoers.d/*
54 chmod go+rX config/chroot_local-includes/lib
55 chmod go+rX config/chroot_local-includes/lib/live
56 chmod -R go+rx config/chroot_local-includes/lib/live/config
57 chmod go+rX config/chroot_local-includes/live
58 chmod -R go+rX config/chroot_local-includes/usr
59 chmod -R go+rx config/chroot_local-includes/usr/local/bin
60 chmod -R go+rx config/chroot_local-includes/usr/local/sbin
61 chmod -R go+rX config/chroot_local-includes/usr/share/doc/tails
62 chmod -R go+rX config/chroot_apt
63 chmod -R go+rX config/chroot_sources
65 # build the image
67 : ${MKSQUASHFS_OPTIONS:='-comp xz'}
68 MKSQUASHFS_OPTIONS="${MKSQUASHFS_OPTIONS} -wildcards -ef chroot/usr/share/amnesia/build/mksquashfs-excludes"
69 export MKSQUASHFS_OPTIONS
71 # get git branch or tag so we can set the basename appropriately, i.e.:
72 # * if we build from a tag: tails-$ARCH-$TAG.iso
73 # * if we build from a branch: tails-$ARCH-$BRANCH-$VERSION-$DATE.iso
74 if GIT_REF="$(git symbolic-ref HEAD)"; then
75 GIT_BRANCH="${GIT_REF#refs/heads/}"
76 CLEAN_GIT_BRANCH=$(echo "$GIT_BRANCH" | sed 's,/,_,g')
77 BUILD_BASENAME="tails-${LB_ARCHITECTURE}-${CLEAN_GIT_BRANCH}-${AMNESIA_VERSION}-${AMNESIA_TODAY}"
78 else
79 GIT_CURRENT_COMMIT="$(git rev-parse HEAD)"
80 if GIT_TAG="$(git describe --tags --exact-match ${GIT_CURRENT_COMMIT})"; then
81 CLEAN_GIT_TAG=$(echo "$GIT_TAG" | sed 's,/,_,g')
82 BUILD_BASENAME="tails-${LB_ARCHITECTURE}-${CLEAN_GIT_TAG}"
83 else
84 # this shouldn't reasonably happen (e.g. only if you checkout a
85 # tag, remove the tag and then build)
86 fatal "Neither a Git branch nor a tag, exiting."
90 case "$LB_BINARY_IMAGES" in
91 iso)
92 BUILD_FILENAME_EXT=iso
93 BUILD_FILENAME=binary
95 iso-hybrid)
96 BUILD_FILENAME_EXT=iso
97 BUILD_FILENAME=binary-hybrid
99 tar)
100 BUILD_FILENAME_EXT=tar.gz
101 BUILD_FILENAME=binary-tar
103 usb-hdd)
104 BUILD_FILENAME_EXT=img
105 BUILD_FILENAME=binary
108 fatal "Image type ${LB_BINARY_IMAGES} is not supported."
110 esac
111 BUILD_DEST_FILENAME="${BUILD_BASENAME}.${BUILD_FILENAME_EXT}"
112 BUILD_MANIFEST="${BUILD_DEST_FILENAME}.list"
113 BUILD_PACKAGES="${BUILD_DEST_FILENAME}.packages"
114 BUILD_LOG="${BUILD_DEST_FILENAME}.buildlog"
116 echo "Building $LB_BINARY_IMAGES image ${BUILD_BASENAME}..."
117 set -o pipefail
118 if time eatmydata lb build noauto ${@} 2>&1 | tee "${BUILD_LOG}" ; then
119 echo "Image was successfully created"
120 echo "Renaming generated files..."
121 mv -i "${BUILD_FILENAME}.${BUILD_FILENAME_EXT}" "${BUILD_DEST_FILENAME}"
122 mv -i binary.packages "${BUILD_PACKAGES}"
123 else
124 fatal "lb build failed ($?)."