From 833605c37722c8284091b35ad29f610a43a6c64d Mon Sep 17 00:00:00 2001 From: Michal Czyz Date: Wed, 27 Mar 2024 13:13:24 +0100 Subject: [PATCH] Split scripts Signed-off-by: Michal Czyz --- .devcontainer/prebuilt/devcontainer.json | 3 +- Dockerfile-lxqt | 7 +++ scripts/common.sh | 16 +++++ scripts/install-desktop-deps.sh | 64 +++++++++++++++++++ scripts/install-desktop.sh | 80 +----------------------- scripts/install.sh | 2 +- 6 files changed, 91 insertions(+), 81 deletions(-) create mode 100644 scripts/common.sh create mode 100644 scripts/install-desktop-deps.sh diff --git a/.devcontainer/prebuilt/devcontainer.json b/.devcontainer/prebuilt/devcontainer.json index b53202b..5945dc8 100644 --- a/.devcontainer/prebuilt/devcontainer.json +++ b/.devcontainer/prebuilt/devcontainer.json @@ -5,6 +5,5 @@ "6080": { "label": "desktop" } - }//, - // "onCreateCommand": "bash /workspaces/openroad-codespace/update-config.sh" + }, } diff --git a/Dockerfile-lxqt b/Dockerfile-lxqt index d3eb0f0..9a02235 100644 --- a/Dockerfile-lxqt +++ b/Dockerfile-lxqt @@ -1,5 +1,12 @@ FROM ghcr.io/antmicro/openroad-codespace:orfs +COPY ./scripts/common.sh /usr/local/bin/common.sh +COPY ./scripts/install-desktop-deps.sh /usr/local/bin/install-desktop-deps.sh +RUN bash /usr/local/bin/install-desktop-deps.sh + COPY ./scripts/install-desktop.sh /usr/local/bin/install-desktop.sh RUN bash /usr/local/bin/install-desktop.sh RUN chsh -s /bin/bash + +ENV DISPLAY=:1 +ENTRYPOINT [ "/usr/local/share/desktop-init.sh" ] diff --git a/scripts/common.sh b/scripts/common.sh new file mode 100644 index 0000000..b3cc983 --- /dev/null +++ b/scripts/common.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +apt_get_update() +{ + apt-get update -y +} + +# Checks if packages are installed and installs them if not +check_packages() { + if ! dpkg -s "$@" > /dev/null 2>&1; then + apt_get_update + apt-get -y install --no-install-recommends "$@" + fi +} diff --git a/scripts/install-desktop-deps.sh b/scripts/install-desktop-deps.sh new file mode 100644 index 0000000..12fbc9b --- /dev/null +++ b/scripts/install-desktop-deps.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +. common.sh + +package_list=" + tigervnc-standalone-server \ + tigervnc-common \ + dbus-x11 \ + x11-utils \ + x11-xserver-utils \ + xdg-utils \ + fbautostart \ + at-spi2-core \ + xterm \ + eterm \ + nautilus\ + mousepad \ + seahorse \ + gnome-icon-theme \ + gnome-keyring \ + libx11-dev \ + libxkbfile-dev \ + libsecret-1-dev \ + libgbm-dev \ + libnotify4 \ + libnss3 \ + libxss1 \ + libasound2 \ + xfonts-base \ + xfonts-terminus \ + fonts-noto \ + fonts-wqy-microhei \ + fonts-droid-fallback \ + htop \ + ncdu \ + curl \ + ca-certificates\ + unzip \ + nano \ + locales \ + xfwm4 \ + lxqt \ + breeze-icon-theme \ + vim \ + " + +# Packages to attempt to install if essential tools are missing (ie: vncpasswd). +# This is useful, at least, for Ubuntu 22.04 (jammy) +package_list_additional=" + tigervnc-tools" + +set -e + +# Ensure apt is in non-interactive to avoid prompts +export DEBIAN_FRONTEND=noninteractive + +apt_get_update +check_packages ${package_list} + +# On newer versions of Ubuntu (22.04), +# we need an additional package that isn't provided in earlier versions +if ! type vncpasswd > /dev/null 2>&1; then + check_packages ${package_list_additional} +fi diff --git a/scripts/install-desktop.sh b/scripts/install-desktop.sh index 3eedeb6..d613166 100644 --- a/scripts/install-desktop.sh +++ b/scripts/install-desktop.sh @@ -9,6 +9,8 @@ # TODO: Add Antmicro license header +. common.sh + NOVNC_VERSION="${NOVNCVERSION:-"1.2.0"}" # TODO: Add in a 'latest' auto-detect and swap name to 'version' VNC_PASSWORD=${PASSWORD:-"vscode"} NOVNC_PORT="${WEBPORT:-6080}" @@ -19,57 +21,6 @@ USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}" WEBSOCKETIFY_VERSION=0.10.0 -package_list=" - tigervnc-standalone-server \ - tigervnc-common \ - dbus-x11 \ - x11-utils \ - x11-xserver-utils \ - xdg-utils \ - fbautostart \ - at-spi2-core \ - xterm \ - eterm \ - nautilus\ - mousepad \ - seahorse \ - gnome-icon-theme \ - gnome-keyring \ - libx11-dev \ - libxkbfile-dev \ - libsecret-1-dev \ - libgbm-dev \ - libnotify4 \ - libnss3 \ - libxss1 \ - libasound2 \ - xfonts-base \ - xfonts-terminus \ - fonts-noto \ - fonts-wqy-microhei \ - fonts-droid-fallback \ - htop \ - ncdu \ - curl \ - ca-certificates\ - unzip \ - nano \ - locales \ - xfwm4 \ - lxqt \ - breeze-icon-theme \ - " - -# Packages to attempt to install if essential tools are missing (ie: vncpasswd). -# This is useful, at least, for Ubuntu 22.04 (jammy) -package_list_additional=" - tigervnc-tools" - -set -e - -# Clean up -rm -rf /var/lib/apt/lists/* - if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -92,21 +43,7 @@ elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then USERNAME=root fi -apt_get_update() -{ - if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then - echo "Running apt-get update..." - apt-get update -y - fi -} -# Checks if packages are installed and installs them if not -check_packages() { - if ! dpkg -s "$@" > /dev/null 2>&1; then - apt_get_update - apt-get -y install --no-install-recommends "$@" - fi -} ########################## # Install starts here # @@ -117,15 +54,6 @@ export DEBIAN_FRONTEND=noninteractive apt_get_update -# Install X11, fluxbox and VS Code dependencies -check_packages ${package_list} - -# On newer versions of Ubuntu (22.04), -# we need an additional package that isn't provided in earlier versions -if ! type vncpasswd > /dev/null 2>&1; then - check_packages ${package_list_additional} -fi - # Check at least one locale exists if ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen @@ -301,9 +229,6 @@ EOF echo "${VNC_PASSWORD}" | vncpasswd -f > /usr/local/etc/vscode-dev-containers/vnc-passwd chmod +x /usr/local/share/desktop-init.sh /usr/local/bin/set-resolution -# Clean up -rm -rf /var/lib/apt/lists/* - cat << EOF You now have a working desktop! Connect to in one of the following ways: @@ -317,7 +242,6 @@ In both cases, use the password "${VNC_PASSWORD}" when connecting EOF - # TODO: Install more themes # git clone https://github.com/lxqt/lxqt-themes.git # cp -r lxqt-themes /usr/share/lxqt/themes/ diff --git a/scripts/install.sh b/scripts/install.sh index 9974d96..0ea40dc 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -4,7 +4,7 @@ export KLAYOUT_VER=${KLAYOUT_VER:-0.28.17-1} export DEBIAN_FRONTEND=noninteractive apt-get -qqy update -apt-get install -qqy --no-install-recommends git wget ca-certificates make libqt5charts +apt-get install -qqy --no-install-recommends git wget ca-certificates make update-ca-certificates wget https://www.klayout.org/downloads/Ubuntu-22/klayout_${KLAYOUT_VER}_amd64.deb