4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 scriptdir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
20 source $scriptdir/lib.sh
23 tmp=$WORKTMP/install_cd
24 iso_build_dir=$tmp/build
26 input_image=$(readlink -f ${1:-$WORKTMP/goldenimage/$GOLDEN_IMAGE_NAME})
27 output_image_path=${2:-$RESULT_IMAGES_DIR/rec.iso}
28 output_bootcd_path=${3:-$RESULT_IMAGES_DIR/bootcd.iso}
31 mkdir -p $iso_build_dir
33 reposnap_base=$(_read_build_config DEFAULT centos_reposnap_base)
34 release_version=$PRODUCT_RELEASE_LABEL
35 reposnap_base_dir="${reposnap_base}/os/x86_64/"
36 iso_image_label=$(_read_build_config DEFAULT iso_image_label)
37 cd_efi_dir="${reposnap_base_dir}/EFI"
38 cd_images_dir="${reposnap_base_dir}/images"
39 cd_isolinux_dir="${reposnap_base_dir}/isolinux"
41 remove_extra_slashes_from_url() {
42 echo $1 | sed -re 's#([^:])//+#\1/#g'
46 $scriptdir/nexus3_dl.sh \
48 $(basename $nexus_reposnaps) \
49 ${reposnap_base#$nexus_reposnaps/}/os/x86_64 $@
54 echo $url | grep -q /$ || _abort "wget path '$url' must end with slash for recursive wget"
55 # if any extra slashes within path, it messes up the --cut-dirs count
56 url=$(remove_extra_slashes_from_url $url)
57 # count cut length in case url depth changes
58 cut_dirs=$(echo $url | sed -re 's|.*://[^/]+/(.+)|\1|' -e 's|/$||' | grep -o / | wc -l)
59 wget -N -r --no-host-directories --no-verbose --cut-dirs=${cut_dirs} --reject index.html* --no-parent $url
64 # Get files needed for generating CD image.
65 if echo $reposnap_base_dir | grep -E "https?://nexus3"; then
66 nexus_url=$(_read_build_config DEFAULT nexus_url)
67 nexus_reposnaps=$(_read_build_config DEFAULT nexus_reposnaps)
68 get_nexus "EFI/BOOT" "EFI/BOOT/fonts"
69 get_nexus "images:*efiboot.img" "images/pxeboot"
72 wget_dir ${cd_efi_dir}/
73 wget_dir ${cd_images_dir}/
74 rm -rf images/boot.iso
76 wget_dir ${cd_isolinux_dir}/
78 chmod +w -R isolinux/ EFI/ images/
80 if [ -e $scriptdir/isolinux/isolinux.cfg ]; then
81 cp $scriptdir/isolinux/isolinux.cfg isolinux/isolinux.cfg
83 sed -i "s/^timeout.*/timeout 100/" isolinux/isolinux.cfg
84 sed -i "s/^ - Press.*/Beginning the cloud installation process/" isolinux/boot.msg
85 sed -i "s/^#menu hidden/menu hidden/" isolinux/isolinux.cfg
86 sed -i "s/menu default//" isolinux/isolinux.cfg
87 sed -i "/^label linux/amenu default" isolinux/isolinux.cfg
88 sed -i "/append initrd/ s/$/ console=tty0 console=ttyS1,115200/" isolinux/isolinux.cfg
90 cp -f $scriptdir/akraino_splash.png isolinux/splash.png
96 # Copy latest kernel and initrd-provisioning from boot dir
97 virt-copy-out -a $input_image /boot/ ./
99 rm -f $iso_build_dir/isolinux/vmlinuz $iso_build_dir/isolinux/initrd.img
100 KVER=`ls -lrt boot/vmlinuz-* |grep -v rescue |tail -n1 |awk -F 'boot/vmlinuz-' '{print $2}'`
101 cp -fp boot/vmlinuz-${KVER} $iso_build_dir/isolinux/vmlinuz
102 cp -fp boot/initrd-provisioning.img $iso_build_dir/isolinux/initrd.img
105 echo "Generating boot iso"
106 _run_cmd genisoimage -U -r -v -T -J -joliet-long \
107 -V "${release_version}" -A "${release_version}" -P ${iso_image_label} \
108 -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
109 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot \
110 -o boot.iso $iso_build_dir
111 _publish_image $tmp/boot.iso $output_bootcd_path
113 cp -f ${input_image} $iso_build_dir/
115 # Keep the placeholder
116 mkdir -p $iso_build_dir/rpms
118 echo "Generating product iso"
119 _run_cmd genisoimage -U -r -v -T -J -joliet-long \
120 -V "${release_version}" -A "${release_version}" -P ${iso_image_label} \
121 -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
122 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot \
123 -o release.iso $iso_build_dir
124 _run_cmd isohybrid $tmp/release.iso
125 _publish_image $tmp/release.iso $output_image_path
127 echo "Clean up to preserve workspace footprint"
128 rm -f $iso_build_dir/$(basename ${input_image})
129 rm -rf $iso_build_dir/rpms