binary_disk 5.08 KB
Newer Older
Daniel Baumann's avatar
Daniel Baumann committed
1
2
#!/bin/sh

3
## live-build(7) - System Build Scripts
4
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
5
##
6
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7
8
9
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.

Daniel Baumann's avatar
Daniel Baumann committed
10
11
12
13

set -e

# Including common functions
14
[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
Daniel Baumann's avatar
Daniel Baumann committed
15
16

# Setting static variables
17
DESCRIPTION="$(Echo 'install disk information into binary')"
Daniel Baumann's avatar
Daniel Baumann committed
18
19
20
21
22
23
HELP=""
USAGE="${PROGRAM} [--force]"

Arguments "${@}"

# Reading configuration files
24
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
Daniel Baumann's avatar
Daniel Baumann committed
25
26
Set_defaults

27
case "${LIVE_IMAGE_TYPE}" in
28
	iso*|hdd*)
29
30
31
32
33
		;;
	*)
		exit 0
		;;
esac
Daniel Baumann's avatar
Daniel Baumann committed
34
35
36
37

Echo_message "Begin installing disk information..."

# Requiring stage file
38
Require_stagefile .build/config .build/bootstrap
Daniel Baumann's avatar
Daniel Baumann committed
39
40

# Checking stage file
41
Check_stagefile .build/binary_disk
Daniel Baumann's avatar
Daniel Baumann committed
42
43
44
45
46
47
48
49
50

# Checking lock file
Check_lockfile .lock

# Creating lock file
Create_lockfile .lock

mkdir -p binary/.disk

51
ARCHITECTURE="$(echo ${LB_ARCHITECTURES} | sed -e 's| |/|g')"
52
53
54
DISTRIBUTION="$(echo ${LB_DISTRIBUTION} | cut -b 1 | tr '[a-z]' '[A-Z]')"
DISTRIBUTION="${DISTRIBUTION}$(echo ${LB_DISTRIBUTION} | cut -b 2-)"
eval VERSION="$`echo RELEASE_${LB_DISTRIBUTION}`"
Daniel Baumann's avatar
Daniel Baumann committed
55

56
case "${LB_MODE}" in
57
	debian)
58
		TITLE="Debian GNU/Linux"
59
		STRING="Official Snapshot ${ARCHITECTURE}"
60
		TRACE="project/trace/ftp-master.debian.org"
61
62
		;;

Cody A.W. Somerville's avatar
Cody A.W. Somerville committed
63
	ubuntu)
64
		TITLE="Ubuntu"
Cody A.W. Somerville's avatar
Cody A.W. Somerville committed
65
		STRING="Build ${ARCHITECTURE}"
66
		TRACE=""
Cody A.W. Somerville's avatar
Cody A.W. Somerville committed
67
68
		;;

69
	progress-linux)
70
71
72
73
74
		TITLE="Progress Linux"
		STRING="${VERSION} (${DISTRIBUTION}) - ${ARCHITECTURE}"
		TRACE="project/trace/archive-master.progress-linux.org"
		;;

75
	*)
76
		TITLE="Debian GNU/Linux"
77
		STRING="Snapshot ${ARCHITECTURE}"
78
		TRACE=""
79
80
		;;
esac
81

82
83
if [ -n "${TRACE}" ]
then
84
85
86
87
88
89
90
91
92
93
94
95
96
97
	case "${LB_DERIVATIVE}" in
		true)
			echo "$(echo ${LB_PARENT_MIRROR_BOOTSTRAP} | awk -F:// '{ print $2 }'): $(wget -q ${LB_PARENT_MIRROR_BOOTSTRAP}/${TRACE} -O - | head -n 1)" \
			> binary/.disk/archive_trace

			echo "$(echo ${LB_MIRROR_BOOTSTRAP} | awk -F:// '{ print $2 }'): $(wget -q ${LB_MIRROR_BOOTSTRAP}/${TRACE} -O - | head -n 1)" \
			>> binary/.disk/archive_trace
			;;

		false)
			echo "$(wget -q ${LB_PARENT_MIRROR_BOOTSTRAP}/${TRACE} -O - | head -n 1)" \
			> binary/.disk/archive_trace
			;;
	esac
98
99
fi

100
case "${LB_INITRAMFS}" in
101
	casper)
102
		for INITRD in binary/casper/initrd.img*
103
		do
104
105
			mkdir -p binary/uuid
			cd binary/uuid
106

107
108
109
110
111
112
113
114
115
116
			case "${LB_INITRAMFS_COMPRESSION}" in
				gzip)
					zcat "../../${INITRD}" | cpio --quiet -id conf/uuid.conf
					;;

				bzip2)
					bzcat "../../${INITRD}" | cpio --quiet -id conf/uuid.conf
					;;

				lzma)
117
					lzcat -S "" "../../${INITRD}" | cpio --quiet -id conf/uuid.conf
118
119
					;;
			esac
120
121
122

			if [ -e conf/uuid.conf ]
			then
123
				mv conf/uuid.conf "../.disk/casper-uuid${INITRD#binary/casper/initrd.img}"
124
125
126
127
			else
				Echo_warning "Failed to find casper uuid.conf in '${INITRD}'"
			fi

128
129
			cd ${OLDPWD}
			rm -rf binary/uuid
130
131
132
133
		done
		;;
esac

134
case "${LB_DEBIAN_INSTALLER}" in
Daniel Baumann's avatar
Daniel Baumann committed
135
136
	cdrom)
		echo "main" > binary/.disk/base_components
Daniel Baumann's avatar
Daniel Baumann committed
137

Daniel Baumann's avatar
Daniel Baumann committed
138
		touch binary/.disk/base_installable
Daniel Baumann's avatar
Daniel Baumann committed
139

Daniel Baumann's avatar
Daniel Baumann committed
140
		echo "full_cd" > binary/.disk/cd_type
Daniel Baumann's avatar
Daniel Baumann committed
141

Cody A.W. Somerville's avatar
Cody A.W. Somerville committed
142
		echo "${TITLE} ${VERSION} \"${DISTRIBUTION}\" - ${STRING} LIVE/CD Binary $(date +%Y%m%d-%H:%M)" > binary/.disk/info
Daniel Baumann's avatar
Daniel Baumann committed
143

144
145
146
147
		for LOCATION in "${LIVE_BUILD}/data/debian-cd" /usr/share/live/build/data/debian-cd
		do
			if [ -e "${LOCATION}" ]
			then
148
				cp "${LOCATION}/${LB_PARENT_DISTRIBUTION}/${LB_ARCHITECTURES}_udeb_include" binary/.disk/udeb_include
149
150
151
152

				continue
			fi
		done
Daniel Baumann's avatar
Daniel Baumann committed
153
		;;
Daniel Baumann's avatar
Daniel Baumann committed
154

155
	true|netinst|live)
Daniel Baumann's avatar
Daniel Baumann committed
156
		echo "main" > binary/.disk/base_components
Daniel Baumann's avatar
Daniel Baumann committed
157

Daniel Baumann's avatar
Daniel Baumann committed
158
		touch binary/.disk/base_installable
Daniel Baumann's avatar
Daniel Baumann committed
159

160
		if [ "${LB_DEBIAN_INSTALLER}" = "live" ]
161
		then
162
			echo "live" > binary/.disk/cd_type
Cody A.W. Somerville's avatar
Cody A.W. Somerville committed
163
			echo "${TITLE} ${VERSION} \"${DISTRIBUTION}\" - ${STRING} LIVE/INSTALL Binary $(date +%Y%m%d-%H:%M)" > binary/.disk/info
164
		else
165
			echo "not_complete" > binary/.disk/cd_type
Cody A.W. Somerville's avatar
Cody A.W. Somerville committed
166
			echo "${TITLE} ${VERSION} \"${DISTRIBUTION}\" - ${STRING} LIVE/NETINST Binary $(date +%Y%m%d-%H:%M)" > binary/.disk/info
167
		fi
168

169
170
171
172
		for LOCATION in "${LIVE_BUILD}/data/debian-cd" /usr/share/live/build/data/debian-cd
		do
			if [ -e "${LOCATION}" ]
			then
173
				cp "${LOCATION}/${LB_PARENT_DISTRIBUTION}/${LB_ARCHITECTURES}_netinst_udeb_include" binary/.disk/udeb_include
174
175
176
177

				continue
			fi
		done
Daniel Baumann's avatar
Daniel Baumann committed
178

179
		if [ "${LB_DEBIAN_INSTALLER}" = "live" ]
Daniel Baumann's avatar
Daniel Baumann committed
180
181
182
183
		then
			echo "live-installer" >> binary/.disk/udeb_include
		fi
		;;
Daniel Baumann's avatar
Daniel Baumann committed
184

Daniel Baumann's avatar
Daniel Baumann committed
185
186
	businesscard)
		echo "main" > binary/.disk/base_components
Daniel Baumann's avatar
Daniel Baumann committed
187

Daniel Baumann's avatar
Daniel Baumann committed
188
		echo "not_complete" > binary/.disk/cd_type
Daniel Baumann's avatar
Daniel Baumann committed
189

Cody A.W. Somerville's avatar
Cody A.W. Somerville committed
190
		echo "${TITLE} ${VERSION} \"${DISTRIBUTION}\" - ${STRING} LIVE/BC Binary $(date +%Y%m%d-%H:%M)" > binary/.disk/info
Daniel Baumann's avatar
Daniel Baumann committed
191

192
193
194
195
		for LOCATION in "${LIVE_BUILD}/data/debian-cd" /usr/share/live/build/data/debian-cd
		do
			if [ -e "${LOCATION}" ]
			then
196
				cp "${LOCATION}/${LB_PARENT_DISTRIBUTION}/${LB_ARCHITECTURES}_businesscard_udeb_include" binary/.disk/udeb_include
197
198
199
200

				continue
			fi
		done
Daniel Baumann's avatar
Daniel Baumann committed
201
202
		;;

203
	false)
Cody A.W. Somerville's avatar
Cody A.W. Somerville committed
204
		echo "${TITLE} ${VERSION} \"${DISTRIBUTION}\" - ${STRING} LIVE Binary $(date +%Y%m%d-%H:%M)" > binary/.disk/info
Daniel Baumann's avatar
Daniel Baumann committed
205
206
207
		;;
esac

Daniel Baumann's avatar
Daniel Baumann committed
208
# Creating stage file
209
Create_stagefile .build/binary_disk