summaryrefslogtreecommitdiff
path: root/debian/cron.daily
blob: c26168a31993c47caf73a8aa23393e08d09d40b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/sh

set -e

BUILD="daily"

# Checking for live-helper availability
if [ ! -x /usr/bin/lh_config ]
then
	exit 0
fi

# Checking for live-helper defaults
if [ -r /etc/default/live-helper ]
then
	. /etc/default/live-helper
else
	echo "E: /etc/default/live-helper missing."
	exit 1
fi

# Checking for autobuild
if [ "${AUTOBUILD}" != "enabled" ]
then
	exit 0
fi

# Checking for build directory
if [ ! -d "${TEMPDIR}" ]
then
	mkdir -p "${TEMPDIR}"/debian-live
else
	# FIXME: maybe we should just remove the left overs.
	echo "E: ${TEMPDIR} needs cleanup."
	exit 1
fi

echo "$(date +%b\ %d\ %H:%M:%S) ${HOSTNAME} live-helper: begin daily build." >> /var/log/live

for ARCHITECTURE in ${ARCHITECTURES}
do
	for DISTRIBUTION in ${DISTRIBUTIONS}
	do
		for PACKAGES_LIST in ${PACKAGES_LISTS}
		do
			if [ ! -f "${DESTDIR}"/"${BUILD}"-builds/${DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${DATE}-iso-log.txt ]
			then
				# Creating build directory
				mkdir -p "${TEMPDIR}"/debian-live

				cd "${TEMPDIR}"/debian-live
				echo "Begin: $(date -R)" > "${TEMPDIR}"/debian-live/log.txt

				# Generating images
				lh_config -b iso -s tar --distribution ${DISTRIBUTION} --packages-lists ${PACKAGES_LIST} --mirror-bootstrap ${MIRROR_BOOTSTRAP} --mirror-bootstrap-security ${MIRROR_BOOTSTRAP_SECURITY} --mirror-binary ${MIRROR_BINARY} --mirror-binary-security ${MIRROR_BINARY_SECURITY} --source enabled ${OPTIONS}
				lh_build >> "${TEMPDIR}"/debian-live/log.txt 2>&1

				echo "End: $(date -R)" >> "${TEMPDIR}"/debian-live/log.txt
			fi

			if [ -f "${TEMPDIR}"/debian-live/binary.iso ] && [ -f "${TEMPDIR}"/debian-live/source.tar ]
			then
				# Creating log directory
				mkdir -p "${DESTDIR}"/"${BUILD}"-builds/${DATE}/log

				# Moving logs
				mv "${TEMPDIR}"/debian-live/log.txt "${DESTDIR}"/"${BUILD}"-builds/${DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${DATE}-iso-log.txt
				mv "${TEMPDIR}"/debian-live/packages.txt "${DESTDIR}"/"${BUILD}"-builds/${DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${DATE}-iso-packages.txt

				# Creating images directory
				mkdir -p "${DESTDIR}"/"${BUILD}"-builds/${DATE}/${ARCHITECTURE}
				mkdir -p "${DESTDIR}"/"${BUILD}"-builds/${DATE}/source

				# Moving images
				mv "${TEMPDIR}"/debian-live/binary.iso "${DESTDIR}"/"${BUILD}"-builds/${DATE}/${ARCHITECTURE}/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}.iso
				mv "${TEMPDIR}"/debian-live/source.tar "${DESTDIR}"/"${BUILD}"-builds/${DATE}/source/debian-live-${DISTRIBUTION}-source-${PACKAGES_LIST}.tar
			fi

			if [ ! -f "${DESTDIR}"/"${BUILD}"-builds/${DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${DATE}-usb-hdd-log.txt ]
			then
				# Workaround of missing multi-binary support in live-helper
				mv "${TEMPDIR}"/debian-live/binary/casper "${TEMPDIR}"/debian-live/casper.tmp
				rm -rf "${TEMPDIR}"/debian-live/binary* "${TEMPDIR}"/debian-live/.stage/binary_*
				mkdir "${TEMPDIR}"/debian-live/binary
				mv "${TEMPDIR}"/debian-live/casper.tmp "${TEMPDIR}"/debian-live/binary/casper
				touch "${TEMPDIR}"/debian-live/.stage/binary_chroot
				touch "${TEMPDIR}"/debian-live/.stage/binary_rootfs

				# Creating build directory
				mkdir -p "${TEMPDIR}"/debian-live

				cd "${TEMPDIR}"/debian-live
				echo "Begin: $(date -R)" > "${TEMPDIR}"/debian-live/log.txt

				# Generating images
				lh_config -b usb-hdd -s tar --distribution ${DISTRIBUTION} --packages-lists ${PACKAGES_LIST} --mirror-bootstrap ${MIRROR_BOOTSTRAP} --mirror-bootstrap-security ${MIRROR_BOOTSTRAP_SECURITY} --mirror-binary ${MIRROR_BINARY} --mirror-binary-security ${MIRROR_BINARY_SECURITY} --source disabled ${OPTIONS}
				lh_build >> "${TEMPDIR}"/debian-live/log.txt 2>&1

				echo "End: $(date -R)" >> "${TEMPDIR}"/debian-live/log.txt
			fi

			if [ -f "${TEMPDIR}"/debian-live/binary.img ]
			then
				# Creating log directory
				mkdir -p "${DESTDIR}"/"${BUILD}"-builds/${DATE}/log

				# Moving logs
				mv "${TEMPDIR}"/debian-live/log.txt "${DESTDIR}"/"${BUILD}"-builds/${DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${DATE}-usb-hdd-log.txt
				cp "${DESTDIR}"/"${BUILD}"-builds/${DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${DATE}-iso-packages.txt "${DESTDIR}"/"${BUILD}"-builds/${DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${DATE}-usb-hdd-packages.txt

				# Creating image directory
				mkdir -p "${DESTDIR}"/"${BUILD}"-builds/${DATE}/${ARCHITECTURE}

				# Moving images
				mv "${TEMPDIR}"/debian-live/binary.img "${DESTDIR}"/"${BUILD}"-builds/${DATE}/${ARCHITECTURE}/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}.img
			fi

			# Cleanup
			cd "${TEMPDIR}"/debian-live
			lh_clean
		done

		# Cleanup
		cd "${TEMPDIR}"/debian-live
		lh_clean purge
	done
done

# Cleaning up
if [ -f "${TEMPDIR}"/debian-live/chroot/proc/version ]
then
	umount "${TEMPDIR}"/debian-live/chroot/proc
fi

if [ -d "${TEMPDIR}"/debian-live/chroot/sys/kernel ]
then
	umount "${TEMPDIR}"/debian-live/chroot/sys
fi

# Removing build directory
rm -rf "${TEMPDIR}"

# Creating md5sums
for DIRECTORY in "${DESTDIR}"/"${BUILD}"-builds/${DATE}/*
do
	cd "${DIRECTORY}"
	md5sum * > MD5SUMS
done

# Creating current symlink
rm -f "${DESTDIR}"/"${BUILD}"-builds/current
ln -s ${DATE} "${DESTDIR}"/"${BUILD}"-builds/current

echo "$(date +%b\ %d\ %H:%M:%S) ${HOSTNAME} live-helper: end daily build." >> /var/log/live