build.sh 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. #!/bin/bash
  2. # originally by Iguleder
  3. # hacked to DEATH by 01micko
  4. # see /usr/share/doc/legal NO WARRANTY, NO resposibility accepted
  5. CWD=`pwd`
  6. if [ "$1" = "clean" ];then
  7. echo -en "\033[1;35m""WARNING" #purple?
  8. echo -en "\033[0m" #reset
  9. echo ": This will delete all builds and sources but wont touch configs."
  10. echo "Hit CTRL+C and save your stuff manually if you don't want to clean."
  11. echo "Hit ENTER to clean"
  12. read clean
  13. echo "Please wait..."
  14. rm -rf ./{dist,aufs*,kernel*,build.log*,linux-*}
  15. echo "Cleaning complete"
  16. exit 0
  17. fi
  18. if [ -d ./dist ];then
  19. echo "This is not a clean kit. Hit ENTER to continue"
  20. echo "or CTRL+C to quit and run './build.sh clean'"
  21. read notcleango
  22. fi
  23. # read config
  24. [ -f ./build.conf ] && . ./build.conf
  25. FW_URL=${FW_URL:-http://distro.ibiblio.org/puppylinux/firmware}
  26. package_name_suffix=$package_name_suffix
  27. custom_suffix=$custom_suffix
  28. kernel_version=$kernel_version
  29. kernel_mirror=$kernel_mirror
  30. # depcheck
  31. echo "Dependency check..."
  32. if git --version &>/dev/null
  33. then echo -e "\033[1;32m""git is installed" #green
  34. else echo -e "\033[1;31m""git is not installed""\033[0m" && exit #red
  35. fi
  36. if gcc --version &>/dev/null
  37. then echo -e "\033[1;32m""gcc is installed"
  38. else
  39. echo -e "\033[1;31m""gcc is not installed""\033[0m" && exit
  40. fi
  41. MKSQ="$(which mksquashfs)"
  42. if [ "$MKSQ" ]
  43. then
  44. echo -e "\033[1;32m""mksquashfs is installed"
  45. else #yellow
  46. echo -e "\033[1;30m""mksquashfs is not installed but you can continue"
  47. fi
  48. echo -e "\033[0m" #reset to original
  49. # .configs
  50. [ -f /tmp/kernel_configs ] && rm -f /tmp/kernel_configs
  51. CONFIGS=$(ls ./configs_extra)
  52. # list
  53. echo "Choose a number of the config you want to try"
  54. NUM=1
  55. for C in $CONFIGS
  56. do echo "${NUM}. $C" >> /tmp/kernel_configs
  57. NUM=$(($NUM + 1))
  58. done
  59. echo "z. Custom DOTconfig" >> /tmp/kernel_configs
  60. echo "d. Default DOTconfig" >> /tmp/kernel_configs
  61. cat /tmp/kernel_configs
  62. echo -n "Enter choice: "
  63. read Chosen
  64. if [ ! $Chosen ];then
  65. echo -e "\033[1;31m""ERROR: you didn't choose, start again!""\033[0m" \
  66. && exit
  67. else
  68. Choice=$(grep "^$Chosen\." /tmp/kernel_configs|cut -d ' ' -f2)
  69. [ ! $Choice ] && \
  70. echo -e "\033[1;31m""ERROR: your choice is not sane ..quiting""\033[0m" \
  71. && exit
  72. echo -e "You chose $Choice. If this is ok hit ENTER, \
  73. \nif not hit CTRL|C to quit"
  74. read oknow
  75. if [[ "$Choice" = "Default" || "$Choice" = "Custom" ]];then
  76. echo $Choice
  77. else
  78. cp -af configs_extra/$Choice DOTconfig
  79. fi
  80. fi
  81. [ ! -f DOTconfig ] && echo -e \
  82. "\033[1;31m""ERROR: No DOTconfig found ..quiting""\033[0m" \
  83. && exit
  84. # the aufs major version
  85. #aufs_version=${kernel_version%.*.*} #
  86. aufs_version=${kernel_version%%.*}
  87. # fail-safe switch in case someone clicks the script in ROX (real story! not
  88. # fun at all!!!!) :p
  89. read -p "Press ENTER to begin" dummy
  90. # get the major version (2.6.32 in the case of 2.6.32.40)
  91. kernel_series=${kernel_version:0:1}
  92. kernel_major_version=${kernel_version%.*}
  93. kernel_minor_version=${kernel_version##*.}
  94. # get the kernel branch (32 in the case of 2.6.32.40; needed to download Aufs)
  95. kernel_branch=`echo $kernel_major_version | cut -f 2 -d .` #3.x kernels
  96. # get the minor version (40 in the case of 2.6.32.40)
  97. #case $kernel_version in
  98. #*.*.*.*) kernel_minor_version=`echo $kernel_version | cut -f 4 -d .` ;;
  99. #esac
  100. # old 2 series info
  101. # the package name suffix (-40 in the case of 2.6.32.40); Woof assumes the
  102. # package version is identical to the kernel version and uses paths that
  103. # contain the package version, so use $kernel_major version as the version and
  104. # "-$kernel_minor_version" as the suffix
  105. #case "$kernel_minor_version" in
  106. #*) package_name_suffix="-$kernel_minor_version";;
  107. #esac
  108. # create directories for the results
  109. [ ! -d dist/sources/vanilla ] && mkdir -p dist/sources/{patches,vanilla}
  110. # get today's date
  111. today=`date +%d%m%y`
  112. # delete the previous log
  113. [ -f build.log ] && rm -f build.log
  114. [ -f build.log.tar.bz2 ] && mv -f build.log.${today}.tar.bz2
  115. # download the kernel
  116. echo ${kernel_version##*-}|grep -q "rc"
  117. [ "$?" -eq 0 ] && testing=testing||testing=
  118. if [ ! -f dist/sources/vanilla/linux-$kernel_version.tar.* ]; then
  119. echo "Downloading the kernel sources"
  120. wget -P dist/sources/vanilla $kernel_mirror/$testing/linux-$kernel_version.tar.xz --no-check-certificate > build.log 2>&1
  121. if [ $? -ne 0 ]; then
  122. echo "Error: failed to download the kernel sources."
  123. exit 1
  124. fi
  125. fi
  126. # download Linux-libre scripts
  127. if [ $LIBRE -eq 1 ]; then
  128. minor_version=${kernel_version##*.}
  129. for i in deblob-$kernel_major_version deblob-check; do
  130. if [ ! -f dist/sources/vanilla/$i ]; then
  131. wget -O dist/sources/vanilla/$i http://linux-libre.fsfla.org/pub/linux-libre/releases/LATEST-$kernel_major_version.N/$i
  132. if [ $? -ne 0 ]; then
  133. echo "Error: failed to download $i."
  134. exit 1
  135. fi
  136. fi
  137. done
  138. fi
  139. # download Aufs
  140. if [ ! -f dist/sources/vanilla/aufs$aufs_version-$kernel_branch-git$today.tar.bz2 ]; then
  141. echo "Downloading the Aufs sources"
  142. #git clone http://git.c3sl.ufpr.br/pub/scm/aufs/aufs2-standalone.git aufs$aufs_version-$kernel_branch-git$today >> build.log 2>&1
  143. #git clone git://aufs.git.sourceforge.net/gitroot/aufs/aufs3-standalone.git aufs$aufs_version-$kernel_branch-git$today >> build.log 2>&1
  144. #git clone git://github.com/sfjro/aufs3-linux.git aufs$aufs_version-$kernel_branch-git$today >> build.log 2>&1
  145. git clone $aufs_git aufs$aufs_version-$kernel_branch-git$today >> build.log 2>&1
  146. if [ $? -ne 0 ]; then
  147. echo "Error: failed to download the Aufs sources."
  148. exit 1
  149. fi
  150. cd aufs$aufs_version-$kernel_branch-git$today
  151. if [ "$aufsv" ];then #new far for new kernels
  152. git checkout origin/aufs$aufsv >> ../build.log 2>&1
  153. else
  154. git checkout origin/aufs$aufs_version.$kernel_branch >> ../build.log 2>&1
  155. fi
  156. if [ $? -ne 0 ]; then
  157. echo "Error: failed to download the Aufs sources."
  158. exit 1
  159. fi
  160. rm -rf .git
  161. cd ..
  162. echo "Creating the Aufs sources tarball"
  163. tar -c aufs$aufs_version-$kernel_branch-git$today | bzip2 -9 > dist/sources/vanilla/aufs$aufs_version-$kernel_branch-git$today.tar.bz2
  164. else
  165. echo "Extracting the Aufs sources"
  166. tar xf dist/sources/vanilla/aufs$aufs_version-$kernel_branch-git$today.tar.bz2 >> build.log 2>&1
  167. if [ $? -ne 0 ]; then
  168. echo "Error: failed to extract the Aufs sources."
  169. exit 1
  170. fi
  171. fi
  172. # patch Aufs
  173. if [ -f aufs-allow-sfs.patch ];then #removed for K3.9 experiment
  174. echo "Patching the Aufs sources"
  175. patch -d aufs$aufs_version-$kernel_branch-git$today -p1 < aufs-allow-sfs.patch >> build.log 2>&1
  176. if [ $? -ne 0 ]; then
  177. echo "Error: failed to patch the Aufs sources."
  178. exit 1
  179. fi
  180. cp aufs-allow-sfs.patch dist/sources/patches
  181. fi
  182. if [ -f aufs-kconfig.patch ];then #special for K3.9
  183. echo "Patching the Aufs sources"
  184. patch -d aufs$aufs_version-$kernel_branch-git$today -p1 < aufs-kconfig.patch >> build.log 2>&1
  185. if [ $? -ne 0 ]; then
  186. echo "Error: failed to patch the Aufs sources for kconfig."
  187. exit 1
  188. fi
  189. cp aufs-kconfig.patch dist/sources/patches
  190. fi
  191. # extract the kernel
  192. echo "Extracting the kernel sources"
  193. tar xf dist/sources/vanilla/linux-$kernel_version.tar.* >> build.log 2>&1
  194. if [ $? -ne 0 ]; then
  195. echo "Error: failed to extract the kernel sources."
  196. exit 1
  197. fi
  198. cd linux-$kernel_version
  199. echo "Adding Aufs to the kernel sources"
  200. if [ "$kernel_major_version" = "3.14" ] && [ "$kernel_minor_version" -ge 21 ];then
  201. # hack - Aufs adds this file in the mmap patch, but it's already in mainline
  202. rm -f mm/prfile.c
  203. fi
  204. for i in kbuild base standalone mmap; do
  205. patch -N -p1 < ../aufs$aufs_version-$kernel_branch-git$today/aufs$aufs_version-$i.patch >> ../build.log 2>&1
  206. if [ $? -ne 0 ]; then
  207. #echo "Error: failed to add Aufs to the kernel sources."
  208. #exit 1
  209. echo "WARNING: failed to add some Aufs patches to the kernel sources."
  210. echo "Check it manually and either CRTL+C to bail or hit enter to go on"
  211. read goon
  212. fi
  213. done
  214. cp -r ../aufs$aufs_version-$kernel_branch-git$today/{fs,Documentation} .
  215. cp ../aufs$aufs_version-$kernel_branch-git$today/include/linux/aufs_type.h include/linux 2>/dev/null
  216. cp ../aufs$aufs_version-$kernel_branch-git$today/include/uapi/linux/aufs_type.h include/linux 2>/dev/null
  217. [ -d ../aufs$aufs_version-$kernel_branch-git$today/include/uapi ] && \
  218. cp -r ../aufs$aufs_version-$kernel_branch-git$today/include/uapi/linux/aufs_type.h include/uapi/linux
  219. #cat ../aufs$aufs_version-1-git$today/include/linux/Kbuild >> include/Kbuild
  220. ################################################################################
  221. # deblob the kernel
  222. if [ $LIBRE -eq 1 ]; then
  223. cd ..
  224. cp -r linux-$kernel_version linux-$kernel_version-orig
  225. cd linux-$kernel_version
  226. sh ../dist/sources/vanilla/deblob-$kernel_major_version 2>&1 | tee -a ../build.log
  227. cd ..
  228. diff -rupN linux-$kernel_version-orig linux-$kernel_version > dist/sources/patches/deblob.patch
  229. rm -rf linux-$kernel_version-orig
  230. cd linux-$kernel_version
  231. fi
  232. kernel_srcsfs_version=$kernel_version
  233. echo "Resetting the minor version number"
  234. cp Makefile Makefile-orig
  235. if [ "$sublevel" = "yes" ];then
  236. sed -i "s/^SUBLEVEL =.*/SUBLEVEL = 0/" Makefile
  237. kernel_srcsfs_version=${kernel_major_version}.0
  238. fi
  239. if [ -n "$custom_suffix" ] || [ $LIBRE -eq 1 ]; then
  240. sed -i "s/^EXTRAVERSION =.*/EXTRAVERSION = $custom_suffix/" Makefile
  241. fi
  242. diff -up Makefile-orig Makefile > ../dist/sources/patches/version.patch
  243. rm Makefile-orig
  244. echo "Reducing the number of consoles"
  245. if [ $kernel_series -gt 3 ] || [ $kernel_series -eq 3 -a $kernel_branch -ge 12 ];then
  246. if [ $kernel_series -gt 3 ] || [ $kernel_series -eq 3 -a $kernel_branch -ge 16 ];then
  247. echo "Reducing the verbosity level"
  248. cp -f include/linux/printk.h include/linux/printk.h.orig
  249. sed -i s/'#define CONSOLE_LOGLEVEL_DEFAULT 7 \/\* anything MORE serious than KERN_DEBUG \*\/'/'#define CONSOLE_LOGLEVEL_DEFAULT 3 \/\* anything MORE serious than KERN_ERR \*\/'/ include/linux/printk.h
  250. diff -up include/linux/printk.h.orig include/linux/printk.h > ../dist/sources/patches/lower-verbosity.patch
  251. else
  252. cp kernel/printk/printk.c kernel/printk/printk.c.orig
  253. sed -i s/'#define MAX_CMDLINECONSOLES 8'/'#define MAX_CMDLINECONSOLES 5'/ kernel/printk/printk.c
  254. diff -up kernel/printk/printk.c.orig kernel/printk/printk.c > ../dist/sources/patches/less-consoles.patch
  255. echo "Reducing the verbosity level"
  256. cp -f kernel/printk/printk.c kernel/printk/printk.c.orig
  257. sed -i s/'#define DEFAULT_CONSOLE_LOGLEVEL 7 \/\* anything MORE serious than KERN_DEBUG \*\/'/'#define DEFAULT_CONSOLE_LOGLEVEL 3 \/\* anything MORE serious than KERN_ERR \*\/'/ kernel/printk/printk.c
  258. diff -up kernel/printk/printk.c.orig kernel/printk/printk.c > ../dist/sources/patches/lower-verbosity.patch
  259. fi
  260. else
  261. cp kernel/printk.c kernel/printk.c.orig
  262. sed -i s/'#define MAX_CMDLINECONSOLES 8'/'#define MAX_CMDLINECONSOLES 5'/ kernel/printk.c
  263. diff -up kernel/printk.c.orig kernel/printk.c > ../dist/sources/patches/less-consoles.patch
  264. echo "Reducing the verbosity level"
  265. cp -f kernel/printk.c kernel/printk.c.orig
  266. sed -i s/'#define DEFAULT_CONSOLE_LOGLEVEL 7 \/\* anything MORE serious than KERN_DEBUG \*\/'/'#define DEFAULT_CONSOLE_LOGLEVEL 3 \/\* Puppy linux hack \*\/'/ kernel/printk.c
  267. diff -up kernel/printk.c.orig kernel/printk.c > ../dist/sources/patches/lower-verbosity.patch
  268. fi
  269. for patch in ../patches/*; do
  270. echo "Applying $patch"
  271. patch -p1 < $patch >> ../build.log 2>&1
  272. if [ $? -ne 0 ]; then
  273. echo "Error: failed to apply $patch on the kernel sources."
  274. exit 1
  275. fi
  276. cp $patch ../dist/sources/patches
  277. done
  278. echo "Cleaning the kernel sources"
  279. make clean
  280. make mrproper
  281. find . -name '*.orig' -delete
  282. find . -name '*.rej' -delete
  283. find . -name '*~' -delete
  284. cp ../DOTconfig .config
  285. #echo "exiting for config" #uncomment this to change .config #nah, pause routine
  286. #exit #uncomment this to change .config
  287. #pause to configure
  288. echo -en "You now should configure your kernel. The supplied .config\nis \
  289. already configured but you may want to make changes, plus the date \
  290. \nshould be updated. You can choose to run \"make menuconfig\" for \
  291. \nan ncurses based gui (recommended if you don't change stuff or\
  292. \nfor advanced users) or run \"make gconfig\" for a gtk based gui \
  293. \nor if you have qt installed \"make xconfig\" is nice.\
  294. \nHit a number or s to skip\
  295. \n1. make menuconfig\
  296. \n2. make gconfig\
  297. \n3. make xconfig \n"
  298. echo
  299. read kernelconfig
  300. case $kernelconfig in
  301. 1)make menuconfig ;;
  302. 2)make gconfig ;;
  303. 3)make xconfig
  304. [ "$?" -ne "0" ] && echo "woops.. no qt? exiting" && exit ;;
  305. s)echo "skipping" ;;
  306. esac
  307. echo
  308. echo "Ok, kernel is configured. hit ENTER to continue, CTRL+C to quit"
  309. read goon
  310. [ ! -d ../dist/packages ] && mkdir -p ../dist/packages
  311. echo "Creating the kernel headers package"
  312. make headers_check >> ../build.log 2>&1
  313. make INSTALL_HDR_PATH=kernel_headers-$kernel_version-$package_name_suffix/usr headers_install >> ../build.log 2>&1
  314. find kernel_headers-$kernel_version-$package_name_suffix/usr/include \( -name .install -o -name ..install.cmd \) -delete
  315. mv kernel_headers-$kernel_version-$package_name_suffix ../dist/packages
  316. echo "Compiling the kernel"
  317. make ${JOBS} bzImage modules >> ../build.log 2>&1
  318. if [[ ! -f arch/x86/boot/bzImage || ! -f System.map ]]; then
  319. echo "Error: failed to compile the kernel sources."
  320. exit 1
  321. fi
  322. cp .config ../dist/sources/DOTconfig-$kernel_version-$today
  323. echo "Creating the kernel package"
  324. make INSTALL_MOD_PATH=linux_kernel-$kernel_version-$package_name_suffix modules_install >> ../build.log 2>&1
  325. rm -f linux_kernel-$kernel_version-$package_name_suffix/lib/modules/${kernel_srcsfs_version}$custom_suffix/{build,source}
  326. #(cd linux_kernel-$kernel_version-$package_name_suffix/lib/modules/; ln -s ${kernel_major_version}$custom_suffix $kernel_major_version)
  327. mkdir -p linux_kernel-$kernel_version-$package_name_suffix/boot
  328. mkdir -p linux_kernel-$kernel_version-$package_name_suffix/etc/modules
  329. cp .config linux_kernel-$kernel_version-$package_name_suffix/etc/modules/DOTconfig-$kernel_version-$today
  330. cp arch/x86/boot/bzImage linux_kernel-$kernel_version-$package_name_suffix/boot/vmlinuz
  331. BZIMAGE=`find . -type f -name bzImage`
  332. cp System.map linux_kernel-$kernel_version-$package_name_suffix/boot
  333. cp $BZIMAGE linux_kernel-$kernel_version-$package_name_suffix/boot
  334. cp linux_kernel-$kernel_version-$package_name_suffix/lib/modules/${kernel_srcsfs_version}$custom_suffix/{modules.builtin,modules.order} \
  335. linux_kernel-$kernel_version-$package_name_suffix/etc/modules/
  336. [ "$FD" = "1" ] || \
  337. rm linux_kernel-$kernel_version-$package_name_suffix/lib/modules/${kernel_srcsfs_version}$custom_suffix/modules*
  338. mv linux_kernel-$kernel_version-$package_name_suffix ../dist/packages
  339. if [ "$FD" = "1" ];then #make fatdog kernel module package
  340. mv ../dist/packages/linux_kernel-$kernel_version-$package_name_suffix/boot/vmlinuz ../dist/packages/vmlinuz-$kernel_version-$package_name_suffix
  341. #gzip -9 ../dist/packages/vmlinuz-$kernel_version-$package_name_suffix
  342. [ -f ../dist/packages/linux_kernel-$kernel_version-$package_name_suffix/boot/bzImage ] &&
  343. rm -f ../dist/packages/linux_kernel-$kernel_version-$package_name_suffix/boot/bzImage
  344. echo "Huge kernel $kernel_version-$package_name_suffix is ready in dist"
  345. fi
  346. echo "Cleaning the kernel sources"
  347. make clean >> ../build.log 2>&1
  348. make prepare >> ../build.log 2>&1
  349. cd ..
  350. echo "Creating a kernel sources SFS"
  351. mkdir -p kernel_sources-$kernel_version-$package_name_suffix/usr/src
  352. mv linux-$kernel_version kernel_sources-$kernel_version-$package_name_suffix/usr/src/linux
  353. mkdir -p kernel_sources-$kernel_version-$package_name_suffix/lib/modules/${kernel_srcsfs_version}$custom_suffix
  354. ln -s /usr/src/linux kernel_sources-$kernel_version-$package_name_suffix/lib/modules/${kernel_srcsfs_version}$custom_suffix/build
  355. [ ! -f kernel_sources-${kernel_version}-$package_name_suffix/usr/src/linux/include/linux/version.h ] && \
  356. ln -s /usr/src/linux/include/generated/uapi/linux/version.h kernel_sources-${kernel_version}-$package_name_suffix/usr/src/linux/include/linux/version.h
  357. ln -s /usr/src/linux kernel_sources-$kernel_version-$package_name_suffix/lib/modules/${kernel_srcsfs_version}$custom_suffix/source
  358. mksquashfs kernel_sources-$kernel_version-$package_name_suffix dist/sources/kernel_sources-$kernel_version-$package_name_suffix.sfs $COMP
  359. md5sum dist/sources/kernel_sources-$kernel_version-$package_name_suffix.sfs > dist/sources/kernel_sources-$kernel_version-$package_name_suffix.sfs.md5.txt
  360. # build aufs-utils userspace modules
  361. echo "Now to build the aufs-utils for userspace"
  362. if [ ! -f dist/sources/vanilla/aufs-util${today}.tar.bz2 ];then
  363. #git clone git://aufs.git.sourceforge.net/gitroot/aufs/aufs-util.git aufs-util >> build.log 2>&1
  364. git clone git://git.code.sf.net/p/aufs/aufs-util aufs-util
  365. [ $? -ne 0 ] && echo "Failed to get aufs-util from git, do it manually. Kernel is compiled OK :)" && exit
  366. cd aufs-util
  367. git branch -a | grep "aufs$kernel_series" |grep -v 'rcN' | cut -d '.' -f2 > /tmp/aufs-util-version #we go for stable only
  368. while read line
  369. do
  370. if [ "$kernel_branch" = "$line" ];then branch=$line
  371. else
  372. while [ "$kernel_branch" -gt "$line" ]
  373. do branch=$line
  374. echo $branch && break
  375. done
  376. fi
  377. done < /tmp/aufs-util-version
  378. git checkout origin/aufs${kernel_series}.${branch} >> ../build.log 2>&1
  379. [ $? -ne 0 ] && echo "Failed to get aufs-util from git, do it manually. Kernel is compiled OK :)" && exit
  380. # patch Makefile for static build
  381. echo "Patching aufs-util sources"
  382. cp Makefile Makefile.orig
  383. sed -i 's/-static //' Makefile
  384. diff -ru Makefile.orig Makefile > ../dist/sources/patches/aufs-util-dynamic.patch
  385. rm *.orig
  386. else
  387. echo "Extracting the Aufs-util sources"
  388. tar xf dist/sources/vanilla/aufs-util$today.tar.bz2 >> ../build.log 2>&1
  389. if [ $? -ne 0 ]; then
  390. echo "Error: failed to extract the aufs-util sources."
  391. exit 1
  392. fi
  393. cd aufs-util
  394. patch -p1 < ../dist/sources/patches/aufs-util-dynamic.patch >> ../build.log 2>&1
  395. [ "$?" -ne 0 ] && echo "Failed to patch the aufs-util sources, do it manually. Kernel is compiled ok" && exit
  396. fi
  397. arch=`uname -m`
  398. #LinuxSrc=../dist/packages/kernel_headers*
  399. # see if fhsm is enabled in kernel config
  400. CONFIG=`find $CWD/dist/sources -type f -name 'DOTconfig*'`
  401. grep -q 'CONFIG_AUFS_FHSM=y' $CONFIG
  402. [ "$?" -eq 0 ] && export MAKE=make || export MAKE="make BuildFHSM=no"
  403. LinuxSrc=`find $CWD -type d -name 'kernel_headers*'`
  404. export CPPFLAGS="-I $LinuxSrc/usr/include"
  405. $MAKE >> ../build.log 2>&1
  406. [ $? -ne 0 ] && echo "Failed to compile aufs-util, do it manually. Kernel is compiled OK :)" && exit
  407. make DESTDIR=$CWD/dist/packages/aufs-util-$kernel_version-$arch install >> ../build.log 2>&1 #maybe needs absolute path
  408. make clean >> ../build.log 2>&1
  409. if [ "$arch" = "x86_64" ];then
  410. mv $CWD/dist/packages/aufs-util-$kernel_version-$arch/usr/lib \
  411. $CWD/dist/packages/aufs-util-$kernel_version-$arch/usr/lib64
  412. fi
  413. echo "aufs-util-$kernel_version is in dist"
  414. cd ..
  415. if [ "$FD" = "1" ];then #shift aufs-utils to kernel-modules.sfs
  416. echo "Installing aufs-utils into kernel package"
  417. cp -a --remove-destination dist/packages/aufs-util-$kernel_version-$arch/* \
  418. dist/packages/linux_kernel-$kernel_version-$package_name_suffix
  419. if [ $LIBRE -eq 0 ];then
  420. echo "Pausing hereto add extra firmware."
  421. echo "Choose an option:"
  422. # download the fw or offer to copy
  423. tmpfw=/tmp/fw$$
  424. x=1
  425. wget -q $FW_URL -O - |\
  426. sed '/href/!d; /\.tar\./!d; /md5\.txt/d; s/.*href="//; s/".*//' |\
  427. while read f;do
  428. [ "$f" ] && echo "$x $f" >> ${tmpfw}
  429. x=$(($x + 1 ))
  430. done
  431. y=`cat ${tmpfw}|wc -l `
  432. [ "$y" = 0 ] && echo "error, no firmware at that URL" && exit 1
  433. x=$(($x + $y))
  434. echo "$x I'll copy in my own." >> ${tmpfw}
  435. cat ${tmpfw}
  436. echo -n "Enter a number, 1 to $x: "
  437. read fw
  438. if [ "$fw" -gt "$x" ];then "error, wrong number" && exit
  439. elif [ "$fw" = "$x" ];then
  440. echo "once you have manually added firmware to "
  441. echo "dist/packages/linux_kernel-$kernel_version-$package_name_suffix/lib/firmware"
  442. echo "hit ENTER to continue"
  443. read firm
  444. else
  445. fw_pkg=`grep ^$fw ${tmpfw}`
  446. fw_pkg=${fw_pkg##* }
  447. echo "You chose ${fw_pkg}. If that isn't correct change it manually later."
  448. echo "downloading $FW_URL/${fw_pkg}"
  449. wget -t0 -c $FW_URL/${fw_pkg} -P dist/packages
  450. [ $? -ne 0 ] && echo "failed to download ${fw_pkg##* }" && exit 1
  451. tar -xjf dist/packages/${fw_pkg} -C dist/packages/linux_kernel-$kernel_version-$package_name_suffix/lib/
  452. [ $? -ne 0 ] && echo "failed to unpack ${fw_pkg}" && exit 1
  453. echo "Successfully extracted ${fw_pkg}."
  454. fi
  455. if [ ! -d ../kernel-skeleton -a ! -d ../woof-code/kernel-skeleton ]; then
  456. echo "Error: all-firmware folder was not found" >> ../build.log
  457. else
  458. [ -d ../kernel-skeleton ] && AFpath="../kernel-skeleton" ||
  459. AFpath="../woof-code/kernel-skeleton"
  460. cp -aR -f "$AFpath"/* \
  461. dist/packages/linux_kernel-$kernel_version-$package_name_suffix/
  462. cd dist/packages/linux_kernel-$kernel_version-$package_name_suffix/
  463. ./pinstall.sh
  464. rm -f pinstall.sh
  465. mv -f etc/modules/firmware.dep etc/modules/firmware.dep.$kernel_major_version
  466. cd -
  467. fi
  468. rm ${tmpfw}
  469. fi
  470. mksquashfs dist/packages/linux_kernel-$kernel_version-$package_name_suffix dist/packages/kernel-modules.sfs-$kernel_version-$package_name_suffix $COMP
  471. [ "$?" = 0 ] && echo "Huge compatible kernel packages are ready to package./" || exit 1
  472. echo "Packaging huge-$kernel_version-$package_name_suffix kernel"
  473. cd dist/packages/
  474. tar -cjvf huge-$kernel_version-${package_name_suffix}.tar.bz2 \
  475. vmlinuz-$kernel_version-$package_name_suffix kernel-modules.sfs-$kernel_version-$package_name_suffix
  476. [ "$?" = 0 ] && echo "huge-$kernel_version-${package_name_suffix}.tar.bz2 is in dist/packages" || exit 1
  477. md5sum huge-$kernel_version-${package_name_suffix}.tar.bz2 > huge-$kernel_version-${package_name_suffix}.tar.bz2.md5.txt
  478. echo
  479. cd -
  480. fi
  481. tar -c aufs-util | bzip2 -9 > dist/sources/vanilla/aufs-util$today-$arch.tar.bz2
  482. echo "Compressing the log"
  483. bzip2 -9 build.log
  484. cp build.log.bz2 dist/sources
  485. echo "Done!"
  486. [ -f /usr/share/sounds/2barks.au ] && aplay /usr/share/sounds/2barks.au