build.sh (2075B)
1#!/bin/bash 2 3SCRIPT_DIR="$(dirname $0)" 4. ${SCRIPT_DIR}/common.sh 5. ${SCRIPT_DIR}/stable-commits 6[ -e /etc/os-release ] && . /etc/os-release 7 8function usage() 9{ 10 echo "Usage: $0 [OPTIONS] [COMPONENT]" 11 echo " where COMPONENT is an individual component to build:" 12 echo " qemu, ovmf, kernel [host|guest]" 13 echo " (default is to build all components)" 14 echo " where OPTIONS are:" 15 echo " --install PATH Installation path (default $INSTALL_DIR)" 16 echo " --package Create a tarball containing built components" 17 echo " -h|--help Usage information" 18 19 exit 1 20} 21 22INSTALL_DIR="`pwd`/usr/local" 23 24while [ -n "$1" ]; do 25 case "$1" in 26 --install) 27 [ -z "$2" ] && usage 28 INSTALL_DIR="$2" 29 shift; shift 30 ;; 31 -h|--help) 32 usage 33 ;; 34 --package) 35 BUILD_PACKAGE="1" 36 shift 37 ;; 38 -*|--*) 39 echo "Unsupported option: [$1]" 40 usage 41 ;; 42 *) 43 break 44 ;; 45 esac 46done 47 48mkdir -p $INSTALL_DIR 49IDIR=$INSTALL_DIR 50INSTALL_DIR=$(readlink -e $INSTALL_DIR) 51[ -n "$INSTALL_DIR" -a -d "$INSTALL_DIR" ] || { 52 echo "Installation directory [$IDIR] does not exist, exiting" 53 exit 1 54} 55 56if [ -z "$1" ]; then 57 build_install_qemu "$INSTALL_DIR" 58 build_install_ovmf "$INSTALL_DIR/share/qemu" 59 build_kernel $2 60else 61 case "$1" in 62 qemu) 63 build_install_qemu "$INSTALL_DIR" 64 ;; 65 ovmf) 66 build_install_ovmf "$INSTALL_DIR/share/qemu" 67 ;; 68 kernel) 69 # additional argument of "host" or "guest" can be added to limit build to that type 70 build_kernel $2 71 ;; 72 esac 73fi 74 75if [[ "$BUILD_PACKAGE" = "1" ]]; then 76 OUTPUT_DIR="snp-release-`date "+%F"`" 77 rm -rf $OUTPUT_DIR 78 mkdir -p $OUTPUT_DIR/linux/guest 79 mkdir -p $OUTPUT_DIR/linux/host 80 mkdir -p $OUTPUT_DIR/usr 81 cp -dpR $INSTALL_DIR $OUTPUT_DIR/usr/ 82 83 if [ "$ID" = "debian" ] || [ "$ID_LIKE" = "debian" ]; then 84 cp linux/linux-*-guest-*.deb $OUTPUT_DIR/linux/guest -v 85 cp linux/linux-*-host-*.deb $OUTPUT_DIR/linux/host -v 86 else 87 cp kernel-*.rpm $OUTPUT_DIR/linux -v 88 fi 89 90 cp launch-qemu.sh ${OUTPUT_DIR} -v 91 cp install.sh ${OUTPUT_DIR} -v 92 cp kvm.conf ${OUTPUT_DIR} -v 93 tar zcvf ${OUTPUT_DIR}.tar.gz ${OUTPUT_DIR} 94fi