summaryrefslogtreecommitdiff
path: root/debian/cron.daily
blob: 633cc2569f20e0cd130fb83b0442e6c1e96e63cf (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
#!/bin/sh -x

set -e

BUILD="daily"

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

# Check 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

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

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

for ARCHITECTURE in ${AUTOBUILD_ARCHITECTURES}
do
	for DISTRIBUTION in ${AUTOBUILD_DISTRIBUTIONS}
	do
		for PACKAGES_LIST in ${AUTOBUILD_PACKAGES_LISTS}
		do
			if [ ! -f "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${AUTOBUILD_DATE}-iso-log.txt ]
		then
			# Generating images
			mkdir -p "${AUTOBUILD_TEMPDIR}"/debian-live
			cd "${AUTOBUILD_TEMPDIR}"
			echo "Begin: `date -R`" > "${AUTOBUILD_TEMPDIR}"/debian-live/log.txt
			make-live -b iso -s generic --distribution ${DISTRIBUTION} --packages-lists ${PACKAGES_LIST} --mirror-build ${AUTOBUILD_MIRROR} --mirror-build-security ${AUTOBUILD_MIRROR_SECURITY} --source enabled ${AUTOBUILD_OPTIONS} >> "${AUTOBUILD_TEMPDIR}"/debian-live/log.txt 2>&1
			echo "End: `date -R`" >> "${AUTOBUILD_TEMPDIR}"/debian-live/log.txt
		fi

		if [ -f "${AUTOBUILD_TEMPDIR}"/debian-live/binary.iso ] && [ -f "${AUTOBUILD_TEMPDIR}"/debian-live/source.tar ]
		then
			# Moving logs
			mkdir -p "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/log
			mv "${AUTOBUILD_TEMPDIR}"/debian-live/log.txt "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${AUTOBUILD_DATE}-iso-log.txt
			mv "${AUTOBUILD_TEMPDIR}"/debian-live/packages.txt "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${AUTOBUILD_DATE}-iso-packages.txt

			# Moving images
			mkdir -p "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/${ARCHITECTURE}
			mv "${AUTOBUILD_TEMPDIR}"/debian-live/binary.iso "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/${ARCHITECTURE}/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}.iso

			mkdir -p "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/source
			mv "${AUTOBUILD_TEMPDIR}"/debian-live/source.tar "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/source/debian-live-${DISTRIBUTION}-source-${PACKAGES_LIST}.tar
		fi

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

			# Generating images
			mkdir -p "${AUTOBUILD_TEMPDIR}"/debian-live
			cd "${AUTOBUILD_TEMPDIR}"
			echo "Begin: `date -R`" > "${AUTOBUILD_TEMPDIR}"/debian-live/log.txt
			make-live -b usb -s generic --distribution ${DISTRIBUTION} --packages-lists ${PACKAGES_LIST} --mirror-build ${AUTOBUILD_MIRROR} --mirror-build-security ${AUTOBUILD_MIRROR_SECURITY} --source disabled ${AUTOBUILD_OPTIONS} >> "${AUTOBUILD_TEMPDIR}"/debian-live/log.txt 2>&1
			echo "End: `date -R`" >> "${AUTOBUILD_TEMPDIR}"/debian-live/log.txt
		fi

		if [ -f "${AUTOBUILD_TEMPDIR}"/debian-live/binary.img ]
		then
			# Moving logs
			mkdir -p "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/log
			mv "${AUTOBUILD_TEMPDIR}"/debian-live/log.txt "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${AUTOBUILD_DATE}-usb-log.txt
			cp "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${AUTOBUILD_DATE}-iso-packages.txt "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/log/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}_${AUTOBUILD_DATE}-usb-packages.txt

			# Moving images
			mkdir -p "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/${ARCHITECTURE}
			mv "${AUTOBUILD_TEMPDIR}"/debian-live/binary.img "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/${AUTOBUILD_DATE}/${ARCHITECTURE}/debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${PACKAGES_LIST}.img
		fi

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

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

# Cleanup
if [ -e "${AUTOBUILD_TEMPDIR}"/debian-live/chroot/proc/version ]
then
	umount "${AUTOBUILD_TEMPDIR}"/debian-live/chroot/proc
fi

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

rm -rf "${AUTOBUILD_TEMPDIR}"

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

# Current symlink
rm -f "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/current
ln -s ${AUTOBUILD_DATE} "${AUTOBUILD_DESTDIR}"/"${BUILD}"-builds/current