3 # Darik's Boot & Nuke build script.
5 # Note that this script does not compile DBAN components. If you wish to
6 # recompile something, then you must do it manually and install it to the
7 # in.boot folder or to the in.root folder.
9 # DBAN will not have a proper build system until the work is sponsored.
12 # Load the version information.
15 # Load the build options.
21 echo -e "\nBuild failed."
23 if [ "${DBAN_MOUNTFLAG}" == "yes" ]; then
24 echo -e "\nUnmounting filesystem... "
25 umount
-v ${DBAN_MOUNT}
28 if [ "${DBAN_LOOPFLAG}" == "yes" ]; then
29 echo -en "\nReleasing loopback device... "
30 losetup
-d ${DBAN_LOOP} && echo -e "done."
33 echo -e "\nRemoving build directory... "
35 echo -e "\nFinished.\n"
40 function signalhandler
()
42 echo -e "\n\nCaught signal."
48 echo -e "\n\nCaught intermediate failure or user break."
52 trap signalhandler ERR
54 trap errhandler SIGHUP SIGINT SIGQUIT SIGTERM
56 #if [ `id -u` -ne 0 ]; then
57 # echo -e "\nWarning: You may need root privileges to run this script."
61 echo -e "\nBuilding Darik's Boot & Nuke... "
64 echo -e "\nChecking utilities... "
66 # The number of utilities that are missing.
71 DBAN_MISSING
=$
(($DBAN_MISSING + $?
))
75 DBAN_MISSING
=$
(($DBAN_MISSING + $?
))
79 DBAN_MISSING
=$
(($DBAN_MISSING + $?
))
83 DBAN_MISSING
=$
(($DBAN_MISSING + $?
))
87 DBAN_MISSING
=$
(($DBAN_MISSING + $?
))
91 DBAN_MISSING
=$
(($DBAN_MISSING + $?
))
93 echo -n " mkdiskimage: "
95 DBAN_MISSING
=$
(($DBAN_MISSING + $?
))
99 DBAN_MISSING
=$
(($DBAN_MISSING + $?
))
103 DBAN_MISSING
=$
(($DBAN_MISSING + $?
))
107 DBAN_MISSING
=$
(($DBAN_MISSING + $?
))
109 if [ $DBAN_MISSING -gt 0 ]; then
110 echo -e "\nUtilities that are required to build DBAN are missing."
114 echo -e "\nClearing temporary directory... "
115 rm -rf ${DBAN_TMP} && mkdir
-v ${DBAN_TMP} || dbanfail
117 echo -e "\nClearing out directories..."
118 rm -rf .
/out.zip
/ && mkdir
-v .
/out.
zip || dbanfail
120 echo -e "\nCreating the root image..."
122 # Copy the version file.
123 cp -v etc
/version
in.root
/ || dbanfail
125 # The kernel will not execute the rc if it is not owned by root.
126 fakeroot mkcramfs
in.root
${DBAN_TMP}/initrd || dbanfail
128 echo -e "\nCompressing the root image..."
129 gzip -v9 ${DBAN_TMP}/initrd || dbanfail
131 echo -e "\nCreating the boot image... "
132 mkdosfs
-C -f 1 -n "${DBAN_BOOTLABEL}" "${DBAN_BOOTFILE}" ${DBAN_BOOTSIZE} || dbanfail
134 echo -e "\nPopulating the boot filesystem...
"
135 mcopy -s -v -i ${DBAN_BOOTFILE} in.boot/* ${DBAN_TMP}/initrd.gz :: || dbanfail
137 echo -en "\nInstalling the boot loader...
"
138 syslinux ${DBAN_BOOTFILE} && echo -e "done.
" || dbanfail
140 echo -e "\nMaking ZIP package...
"
141 cp -v -r ./in.zip/* ./out.zip/
142 cp -v -r ./etc/config ./out.zip/
143 cp -v ./etc/changelog.txt ./out.zip/
144 cp -v ./etc/notes.txt ./out.zip/
145 cp -v "${DBAN_BOOTFILE}" ".
/out.zip
/${DBAN_FLPNAME}"
148 # Archive order affects the behavior of the WinImage SFX module.
149 dos2unix <readme.txt | zip -9 -z "..
/${DBAN_ZIPNAME}" ${DBAN_FLPNAME} || dbanfail
150 zip -9 -r -u "..
/${DBAN_ZIPNAME}" * || dbanfail
153 echo -e "\nMaking ISO package...
"
154 mkisofs -l -V"${DBAN_BOOTLABEL}" -b "${DBAN_FLPNAME}" -o "${DBAN_ISONAME}" ./out.zip/ || dbanfail
156 echo -en "\nRemoving build directory...
"
157 rm -rf ${DBAN_TMP} && echo -e "done.
"
159 echo -e "\nBuild succeeded.
\n"