diff --git a/installer/kvm-qemu.sh b/installer/kvm-qemu.sh index d7b7faddf56..81504d7d719 100644 --- a/installer/kvm-qemu.sh +++ b/installer/kvm-qemu.sh @@ -139,9 +139,16 @@ if [ -f "./kvm-config.sh" ]; then . ./kvm-config.sh fi -# ToDo check if aptitude is installed if no refresh and install -sudo apt-get update 2>/dev/null -sudo apt-get install aptitude -y 2>/dev/null +which aptitude 2>/dev/null +if [ $? -eq 1 ]; then + sudo apt-get update 2>/dev/null + sudo apt-get install aptitude -y 2>/dev/null +fi + +which pip3 2>/dev/null +if [ $? -eq 1 ]; then + sudo python3-pip -y 2>/dev/null +fi NC='\033[0m' RED='\033[0;31m' @@ -150,6 +157,7 @@ echo -e "${RED}\t[!] NEVER install packages from APT that installed by this scri echo -e "${RED}\t[!] NEVER use 'make install' - it poison system and no easy way to upgrade/uninstall/cleanup, use dpkg-deb${NC}" echo -e "${RED}\t[!] NEVER run 'python setup.py install' DO USE 'pip intall .' the same as APT poisoning/upgrading${NC}\n" echo -e "${RED}\t[!] NEVER FORCE system upgrade, it will ignore blacklist and mess with packages installed by APT and this scritp!${NC}\n" +echo -e "${RED}\t[!] NEVER! When upgrading ubuntu release, first uninstall qemu and libvirt, then upgrade and then install again! As is the same as force and bypasses apt mark-hold${NC}\n" function usage() { cat << EndOfHelp @@ -177,7 +185,6 @@ cat << EndOfHelp Issues - will give you error - solution list noip - Install No-ip deamon and enable on boot SysRQ - enable SysRQ - https://sites.google.com/site/syscookbook/rhel/rhel-sysrq-key - jemalloc - install Jemalloc google if you need details ;) Tips: * Latest kernels having some KVM features :) @@ -248,7 +255,7 @@ function _enable_tcp_bbr() { } function install_apparmor() { - aptitude install -f bison linux-generic-hwe-22.04 -y + aptitude install -f bison linux-generic-hwe-24.04 -y aptitude install -f apparmor apparmor-profiles apparmor-profiles-extra apparmor-utils libapparmor-dev libapparmor1 python3-apparmor python3-libapparmor libapparmor-perl -y } @@ -353,7 +360,7 @@ function install_libvmi() { # git checkout add_vmi_request_page_fault # git pull #git clone https://github.com/libvmi/python.git libvmi-python - pip3 install libvmi + PIP_BREAK_SYSTEM_PACKAGES=1 pip3 install libvmi echo "[+] Cloned LibVMI Python repo" fi cd "libvmi-python" || return @@ -362,7 +369,7 @@ function install_libvmi() { aptitude install -f -y python3-pkgconfig python3-cffi python3-future #pip3 install . python3 setup.py build - pip3 install . + PIP_BREAK_SYSTEM_PACKAGES=1 pip3 install . # Rekall cd /tmp || return @@ -481,7 +488,7 @@ EOH echo "[+] Checking/deleting old versions of Libvirt" apt-get purge libvirt0 libvirt-bin libvirt-$libvirt_version 2>/dev/null dpkg -l|grep "libvirt-[0-9]\{1,2\}\.[0-9]\{1,2\}\.[0-9]\{1,2\}"|cut -d " " -f 3|sudo xargs dpkg --purge --force-all 2>/dev/null - apt-get install meson plocate libxml2-utils gnutls-bin gnutls-dev libxml2-dev bash-completion libreadline-dev numactl libnuma-dev python3-docutils flex -y + apt-get install meson plocate libxml2-utils gnutls-bin gnutls-dev libxml2-dev bash-completion libreadline-dev numactl libnuma-dev python3-docutils flex libjson-c-dev pylint pycodestyle -y # Remove old links updatedb temp_libvirt_so_path=$(locate libvirt-qemu.so | head -n1 | awk '{print $1;}') @@ -519,7 +526,7 @@ EOH # To see whole config sudo meson configure # true now is enabled cd /tmp/libvirt-$libvirt_version || return - sudo meson build -D system=true -D driver_remote=enabled -D driver_qemu=enabled -D driver_libvirtd=enabled -D qemu_group=libvirt -D qemu_user=root -D secdriver_apparmor=enabled -D apparmor_profiles=enabled -D bash_completion=auto + sudo meson setup build -D system=true -D driver_remote=enabled -D driver_qemu=enabled -D driver_libvirtd=enabled -D qemu_group=libvirt -D qemu_user=root -D secdriver_apparmor=enabled -D apparmor_profiles=enabled -D bash_completion=auto sudo ninja -C build sudo ninja -C build install @@ -533,11 +540,11 @@ EOH updatedb # ToDo fix bad destiny on some systems, example, first arg should be destiny to link not source # /usr/lib/x86_64-linux-gnu/libvirt-qemu.so.0 -> /usr/lib64/libvirt-qemu.so - temp_libvirt_so_path=$(locate libvirt-qemu.so | head -n1 | awk '{print $1;}') + temp_libvirt_so_path=$(locate libvirt-qemu.so |grep -v "docker"| head -n1 | awk '{print $1;}') temp_export_path=$(locate libvirt.pc | head -n1 | awk '{print $1;}') libvirt_so_path="${temp_libvirt_so_path%/*}/" if [[ $libvirt_so_path == "/usr/lib/x86_64-linux-gnu/" ]]; then - temp_libvirt_so_path=$(locate libvirt-qemu.so | tail -1 | awk '{print $1;}') + temp_libvirt_so_path=$(locate libvirt-qemu.so |grep -v "docker"| tail -1 | awk '{print $1;}') libvirt_so_path="${temp_libvirt_so_path%/*}/" fi export_path="${temp_export_path%/*}/" @@ -545,7 +552,8 @@ EOH if [[ -n "$libvirt_so_path" ]]; then # #ln -s /usr/lib64/libvirt-qemu.so /lib/x86_64-linux-gnu/libvirt-qemu.so.0 - for so_path in $(ls "${libvirt_so_path}"libvirt*.so.0); do ln -sf "$so_path" /lib/$(uname -m)-linux-gnu/$(basename "$so_path"); done + # 24.10.2024 Observed problem with ln -sf, but works just fine with cp + for so_path in $(ls "${libvirt_so_path}"libvirt*.so.0); do echo $so_path; cp "$so_path" /lib/$(uname -m)-linux-gnu/$(basename "$so_path"); done ldconfig else echo "${RED}[!] Problem to create symlink, unknown libvirt_so_path path${NC}" @@ -660,7 +668,7 @@ function install_virt_manager() { gstreamer1.0-x adwaita-icon-theme at-spi2-core augeas-lenses cpu-checker dconf-gsettings-backend dconf-service \ fontconfig fontconfig-config fonts-dejavu-core genisoimage gir1.2-appindicator3-0.1 gir1.2-secret-1 \ gobject-introspection intltool pkg-config libxml2-dev libxslt-dev python3-dev gir1.2-gtk-vnc-2.0 gir1.2-spiceclientgtk-3.0 libgtk-3-dev \ - mlocate gir1.2-gtksource-4 libgtksourceview-4-0 libgtksourceview-4-common pylint pycodestyle -y + plocate gir1.2-gtksource-4 libgtksourceview-4-0 libgtksourceview-4-common pylint pycodestyle -y # should be installed first # moved out as some 20.04 doesn't have this libs %) aptitude install -f -y python3-ntlm-auth libpython3-stdlib libbrlapi-dev libgirepository1.0-dev python3-testresources @@ -682,32 +690,24 @@ function install_virt_manager() { export PKG_CONFIG_PATH=$export_path cd /tmp || return - if [ ! -f libvirt-glib-3.0.0.tar.gz ]; then - wget -q https://libvirt.org/sources/glib/libvirt-glib-3.0.0.tar.gz - wget -q https://libvirt.org/sources/glib/libvirt-glib-3.0.0.tar.gz.asc - gpg --verify "libvirt-glib-3.0.0.tar.gz.asc" - + if [ ! -d "libvirt-glib" ]; then + git clone https://gitlab.com/libvirt/libvirt-glib.git fi - # ToDo add blacklist + cd libvirt-glib tar xf libvirt-glib-3.0.0.tar.gz + meson setup builddir cd libvirt-glib-3.0.0 || return + meson compile -C builddir aclocal && libtoolize --force + sudo ninja -C builddir install automake --add-missing + # for some reason i have to run it twice ./configure + sudo ninja -C builddir install mkdir -p /tmp/libvirt-glib_builded/DEBIAN + mkdir -p /usr/local/lib/girepository-1.0/ echo -e "Package: libvirt-glib-1.0-0\nVersion: 1.0.0\nArchitecture: $ARCH\nMaintainer: $MAINTAINER\nDescription: Custom libvirt-glib-1.0-0" > /tmp/libvirt-glib_builded/DEBIAN/control - make -j"$(nproc)" install DESTDIR=/tmp/libvirt-glib_builded - dpkg-deb --build --root-owner-group /tmp/libvirt-glib_builded - apt-get -y -o Dpkg::Options::="--force-overwrite" install /tmp/libvirt-glib_builded.deb - make -j"$(nproc)" - - # v4 is meson based - # sudo meson build -D system=true - cd /tmp || return - if [ ! -f gir1.2-libvirt-glib-1.0_1.0.0-1_amd64.deb ]; then - wget -q http://launchpadlibrarian.net/297448356/gir1.2-libvirt-glib-1.0_1.0.0-1_amd64.deb - fi - dpkg --force-confold -i gir1.2-libvirt-glib-1.0_1.0.0-1_amd64.deb + cp builddir/libvirt-glib/LibvirtGLib-1.0.typelib /usr/local/lib/girepository-1.0/LibvirtGLib-1.0.typelib /sbin/ldconfig @@ -744,7 +744,7 @@ function install_kvm_linux() { aptitude install -f gtk-update-icon-cache -y 2>/dev/null # WSL support - aptitude install -f gcc make gnutls-bin + aptitude install -f gcc make gnutls-bin -y install_libvirt @@ -820,7 +820,7 @@ function replace_seabios_clues_public() { FILES=( src/hw/blockcmd.c - #src/fw/paravirt.c + src/fw/paravirt.c ) for file in "${FILES[@]}"; do _sed_aux 's/"QEMU"/"'"$BOCHS_BLOCK_REPLACER2"'"/g' "$file" "QEMU was not replaced in $file" @@ -858,14 +858,6 @@ function replace_seabios_clues_public() { done } -function install_jemalloc() { - - # https://zapier.com/engineering/celery-python-jemalloc/ - if ! $(dpkg -l "libjemalloc*" | grep -q "ii libjemalloc"); then - aptitude install -f curl build-essential jq autoconf libjemalloc-dev -y - fi -} - function install_qemu() { cd /tmp || return @@ -1207,7 +1199,7 @@ function cloning() { exit 1 fi - which virt-manager + which virt-manager 2>/dev/null if [ $? -eq 1 ]; then echo "You need to install virt-manager. Run sudo $0 virtmanager" exit 1 @@ -1300,15 +1292,15 @@ esac #check if start with root if [ "$EUID" -ne 0 ]; then - echo 'This script must be run as root' - exit 1 + echo 'This script must be run as root' + exit 1 fi OS="$(uname -s)" MAINTAINER="$(whoami)"_"$(hostname)" ARCH="$(dpkg --print-architecture)" -#add-apt-repository universe -#apt-get update && apt-get upgrade +# add-apt-repository universe +# apt-get update && apt-get upgrade #make case "$COMMAND" in @@ -1316,7 +1308,7 @@ case "$COMMAND" in issues;; 'all') configure_needreboot - aptitude install -f language-pack-UTF-8 -y + aptitude install -f language-pack-UTF-8 python3-pip -y install_qemu install_seabios install_kvm_linux @@ -1387,8 +1379,6 @@ case "$COMMAND" in ;; 'grub') grub_iommu;; -'jemalloc') - install_jemalloc;; 'needreboot') configure_needreboot;; 'mosh')