aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuild.sh23
-rwxr-xr-xinstall.sh37
2 files changed, 60 insertions, 0 deletions
diff --git a/build.sh b/build.sh
index cb9f907..9bed1de 100755
--- a/build.sh
+++ b/build.sh
@@ -29,6 +29,10 @@ while [ -n "$1" ]; do
-h|--help)
usage
;;
+ --package)
+ BUILD_PACKAGE="1"
+ shift
+ ;;
-*|--*)
echo "Unsupported option: [$1]"
usage
@@ -64,3 +68,22 @@ else
;;
esac
fi
+
+if [[ "$BUILD_PACKAGE" = "1" ]]; then
+ OUTPUT_DIR="snp-release-`date "+%F"`"
+ rm -rf $OUTPUT_DIR
+ mkdir -p $OUTPUT_DIR/linux
+ mkdir -p $OUTPUT_DIR/usr
+ cp -dpR $INSTALL_DIR $OUTPUT_DIR/usr/
+
+ if [ "$ID_LIKE" = "debian" ]; then
+ cp linux-image-*.deb $OUTPUT_DIR/linux -v
+ else
+ cp kernel-*.rpm $OUTPUT_DIR/linux -v
+ fi
+
+ cp launch-qemu.sh ${OUTPUT_DIR} -v
+ cp install.sh ${OUTPUT_DIR} -v
+ cp kvm.conf ${OUTPUT_DIR} -v
+ tar zcvf ${OUTPUT_DIR}.tar.gz ${OUTPUT_DIR}
+fi
diff --git a/install.sh b/install.sh
new file mode 100755
index 0000000..0d30a65
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# This will install all the dependent packages for qemu and ovmf to run
+if [ "$ID_LIKE" = "debian" ]; then
+ apt-get -y install qemu ovmf
+else
+ dnf install qemu edk2-ovmf
+fi
+
+if [ "$ID_LIKE" = "debian" ]; then
+ dpkg -i linux/linux-image-*.deb
+else
+ rpm -ivh linux/kernel-*.rpm
+fi
+
+# update grub.cfg to disable THP
+if ! grep "transparent_hugepage=never" /etc/default/grub >/dev/null; then
+ orig_cmdline="`grep GRUB_CMDLINE_LINUX /etc/default/grub | cut -f2- -d=`"
+ cmdline="${orig_cmdline::-1}"
+ cmdline="${cmdline:1}"
+ cmdline="${cmdline} transparent_hugepage=never"
+
+ sed -i "/GRUB_CMDLINE_LINUX/c\GRUB_CMDLINE_LINUX=\"${cmdline}\"" /etc/default/grub
+
+ if [ "$ID_LIKE" = "debian" ]; then
+ update-grub2
+ else
+ grub2-mkconfig
+ fi
+fi
+
+#
+cp kvm.conf /etc/modprobe.d/
+
+echo
+echo "Reboot the host and select the SNP kernel"
+echo