Skip to content

Commit

Permalink
Split scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Czyz <[email protected]>
  • Loading branch information
mczyz-antmicro committed Mar 27, 2024
1 parent 150529f commit 833605c
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 81 deletions.
3 changes: 1 addition & 2 deletions .devcontainer/prebuilt/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"6080": {
"label": "desktop"
}
}//,
// "onCreateCommand": "bash /workspaces/openroad-codespace/update-config.sh"
},
}
7 changes: 7 additions & 0 deletions Dockerfile-lxqt
Original file line number Diff line number Diff line change
@@ -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" ]
16 changes: 16 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
@@ -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
}
64 changes: 64 additions & 0 deletions scripts/install-desktop-deps.sh
Original file line number Diff line number Diff line change
@@ -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
80 changes: 2 additions & 78 deletions scripts/install-desktop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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
Expand All @@ -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 #
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 833605c

Please sign in to comment.