2ffcb0d7684e4975ed583739355bfa6d8bf1e410
[catalyst.git] / targets / netboot2 / netboot2-controller.sh
1 #!/bin/bash
2
3 source ${clst_sharedir}/targets/support/functions.sh
4 source ${clst_sharedir}/targets/support/filesystem-functions.sh
5
6 case ${1} in
7         build_packages)
8                 echo ">>> Building packages ..."
9                 shift
10                 clst_root_path="/" \
11                 clst_packages="$*" \
12                 exec_in_chroot \
13                 ${clst_sharedir}/targets/${clst_target}/${clst_target}-pkg.sh
14         ;;
15
16         pre-kmerge)
17                 # Sets up the build environment before any kernels are compiled
18                 exec_in_chroot ${clst_sharedir}/targets/support/pre-kmerge.sh
19         ;;
20
21         post-kmerge)
22                 # Cleans up the build environment after the kernels are compiled
23                 exec_in_chroot ${clst_sharedir}/targets/support/post-kmerge.sh
24         ;;
25
26         kernel)
27                 shift
28                 export clst_kname="$1"
29
30                 # if we have our own linuxrc, copy it in
31                 if [ -n "${clst_linuxrc}" ]
32                 then
33                         cp -pPR ${clst_linuxrc} ${clst_chroot_path}/tmp/linuxrc
34                 fi
35                 if [ -n "${clst_busybox_config}" ]
36                 then
37                         cp ${clst_busybox_config} ${clst_chroot_path}/tmp/busy-config
38                 fi
39
40                 exec_in_chroot ${clst_sharedir}/targets/support/kmerge.sh
41
42                 delete_from_chroot tmp/linuxrc
43                 delete_from_chroot tmp/busy-config
44
45                 extract_modules ${clst_chroot_path} ${clst_kname}
46                 #16:12 <@solar> kernel_name=foo
47                 #16:13 <@solar> eval clst_boot_kernel_${kernel_name}_config=bar
48                 #16:13 <@solar> eval echo \$clst_boot_kernel_${kernel_name}_config
49         ;;
50
51         image)
52                 # Creates the base initramfs image for the netboot
53                 echo -e ">>> Preparing Image ..."
54                 shift
55
56                 # Copy remaining files over to the initramfs target
57                 clst_files="${@}" \
58                 exec_in_chroot \
59                 ${clst_sharedir}/targets/${clst_target}/${clst_target}-copyfile.sh
60         ;;
61
62         final)
63                 # For each arch, fetch the kernel images and put them in builds/
64                 echo -e ">>> Copying completed kernels to ${clst_target_path} ..."
65                 ${clst_sharedir}/targets/support/netboot2-final.sh
66         ;;
67
68         clean)
69                 exit 0;;
70
71         *)
72                 exit 1;;
73 esac
74
75 exit $?