Moving partial python rewrite to separate branch, let's do it in the jessie+1 cycle...
[debian-live-build.git] / scripts / build / source_checksums
blobc78c4dfef357e1a8a19b2b6d4a152622f2860290
1 #!/bin/sh
3 ## live-build(7) - System Build Scripts
4 ## Copyright (C) 2006-2014 Daniel Baumann <mail@daniel-baumann.ch>
5 ##
6 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7 ## This is free software, and you are welcome to redistribute it
8 ## under certain conditions; see COPYING for details.
11 set -e
13 # Including common functions
14 [ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
16 # Setting static variables
17 DESCRIPTION="$(Echo 'create source checksums')"
18 HELP=""
19 USAGE="${PROGRAM} [--force]"
21 Arguments "${@}"
23 # Reading configuration files
24 Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
25 Set_defaults
27 if [ "${LB_CHECKSUMS}" = "none" ] || [ "${LB_SOURCE}" != "true" ]
28 then
29 exit 0
32 # Requiring stage file
33 Require_stagefile .build/config .build/source_debian
35 # Checking stage file
36 Check_stagefile .build/source_checksums
38 # Checking lock file
39 Check_lockfile .lock
41 # Creating lock file
42 Create_lockfile .lock
44 for DIRECTORY in source/debian source/live
46 if [ ! -d ${DIRECTORY} ]
47 then
48 continue
51 for CHECKSUM in ${LB_CHECKSUMS}
53 case "${LB_MODE}" in
54 progress-linux)
55 CHECKSUMS="$(echo ${CHECKSUM} | tr [a-z] [A-Z])SUMS"
59 CHECKSUMS="${CHECKSUM}sum.txt"
61 esac
63 Echo_message "Begin creating source ${CHECKSUMS}..."
65 # Remove old checksums
66 if [ -f ${DIRECTORY}/${CHECKSUMS} ]
67 then
68 rm -f ${DIRECTORY}/${CHECKSUMS}
71 # Calculating checksums
72 cd ${DIRECTORY}
73 find . -type f \
74 \! -path './*SUMS' \
75 \! -path './*sum.txt' \
76 -print0 | sort -z | xargs -0 ${CHECKSUM}sum > ../${CHECKSUMS}
78 cat > ${CHECKSUMS} << EOF
79 ## This file contains the list of ${CHECKSUM} checksums of all files on this
80 ## medium.
82 ## You can verify them automatically with the 'verify-checksums' boot parameter,
83 ## or, manually with: '${CHECKSUM}sum -c ${CHECKSUMS}'.
86 EOF
88 cat ../${CHECKSUMS} >> ${CHECKSUMS}
89 rm -f ../${CHECKSUMS}
91 cd "${OLDPWD}"
92 done
94 # File list
95 cd ${DIRECTORY}
96 find . | sed -e 's|^.||g' | grep "^/" | sort > ../../${LIVE_IMAGE_NAME}-source.$(basename ${DIRECTORY}).contents
97 cd "${OLDPWD}"
98 done
100 # Creating stage file
101 Create_stagefile .build/source_checksums