On Mon, Feb 8, 2021 at 5:12 AM Waldemar Kozaczuk <[email protected]> wrote:
> Add new script download_and_build_qemu.sh that allows building QEMU from > sources. It installs all necessary packages to build QEMU from sources, > downloads QEMU sources and builds both x86_64 and aarch64 versions of > it. > > Signed-off-by: Waldemar Kozaczuk <[email protected]> > --- > scripts/download_and_build_qemu.sh | 61 ++++++++++++++++++++++++++++++ > 1 file changed, 61 insertions(+) > create mode 100755 scripts/download_and_build_qemu.sh > > diff --git a/scripts/download_and_build_qemu.sh > b/scripts/download_and_build_qemu.sh > new file mode 100755 > index 00000000..711882ec > --- /dev/null > +++ b/scripts/download_and_build_qemu.sh > @@ -0,0 +1,61 @@ > +#!/bin/bash > +# > +# Copyright (C) 2020 Waldemar Kozaczuk > +# > +# This work is open source software, licensed under the terms of the > +# BSD license as described in the LICENSE file in the top-level directory. > +# > + > +# This scripts installs all necessary packages to build QEMU from sources, > +# downloads QEMU sources and builds both x86_64 and aarch64 versions of it > +# > +# Usage: > +# ./scripts/download_and_build_qemu.sh <QEMU_VERSION> > +# > + > +#Install tools > +USER_ID=$(id -u) > +LINUX_DIST_ID=$(python3 -c "import distro; print(distro.id())") > I guess that's ok, but personally I prefer something simpler, like using "test -f /etc/redhat-release" or "test -f /etc/fedora-release" to check if this is a redhat-like system (including Fedora) and specifically fedora. + > +case ${LINUX_DIST_ID} in > + fedora|centos) > + PACKAGES="ninja-build cmake3 glib2-devel libfdt-devel pixman-devel > zlib-devel libaio-devel libcap-devel libiscsi-devel" > + if [[ "${LINUX_DIST_ID}" == "fedora" ]]; then > + PACKAGE_MANAGER=dnf > + else > + PACKAGE_MANAGER=yum > + fi ;; > + ubuntu) > + PACKAGES="ninja-build cmake libglib2.0-dev libfdt-dev libpixman-1-dev > zlib1g-dev libaio-dev libcap-dev libnfs-dev libiscsi-dev" > + PACKAGE_MANAGER="apt-get" ;; > + *) > + echo "Unsupported distribution!" && exit 1 > +esac > + > +if [[ "${USER_ID}" == "0" ]]; then > + echo "Installing all necessary packages!" && ${PACKAGE_MANAGER} -y > install ${PACKAGES} > I personally prefer not to add the "-y". I think it's a good idea to allow the user, who has no idea that this script is even planning to install anything, say ok if anything needs to be installed. +else > + echo "Needs super user access to install all necessary packages!" && > sudo ${PACKAGE_MANAGER} -y install ${PACKAGES} > +fi > + > +#Download and build qemu > +QEMU_VERSION=$1 > +QEMU_VERSION=${QEMU_VERSION:-v5.2.0} > + > +OSV_ROOT=$(dirname $(readlink -e $0))/.. > +BUILD_DIR=${OSV_ROOT}/build/downloaded_packages > + > +mkdir -p ${BUILD_DIR} > Please use double quotes on $BUILD_DIR here an in most lines below. If the current directory's name has a space in it, all this code will break. +pushd ${BUILD_DIR} > + > +if [[ ! -d qemu ]]; then > + git clone --depth 1 --branch ${QEMU_VERSION} git:// > git.qemu.org/qemu.git > +fi > +cd qemu > +mkdir -p build && cd build > + > +../configure --target-list=x86_64-softmmu,aarch64-softmmu > +make -j$(nproc) > +popd > + > +echo "Built QEMU at ${BUILD_DIR}/qemu/build/qemu-system-x86_64 and > ${BUILD_DIR}/qemu/build/qemu-system-aarch64" > -- > 2.29.2 > > -- > You received this message because you are subscribed to the Google Groups > "OSv Development" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/osv-dev/20210208031209.1266843-1-jwkozaczuk%40gmail.com > . > -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/CANEVyjsZqQ7rJXnpR1ibup6R_BSJ1yXKV5KNFV_p9c6PQwryzw%40mail.gmail.com.
