From 2733e442770f7c4cd4dd3bab2ae22c6a166cc1b4 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Sat, 17 Feb 2024 01:25:20 -0500 Subject: [PATCH] add Dockerfile for cross-platform packaging using Wine. --- ReadMe.md | 88 ++++++++++++++++++++++++++++++++++++ ubuntu-20-04-wine.dockerfile | 86 +++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 ubuntu-20-04-wine.dockerfile diff --git a/ReadMe.md b/ReadMe.md index 27ba5df..193f816 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -3,6 +3,9 @@ ## Usage: +
+from source (.py) + ```sh usage: sigmadouble.py [-h] [-v] [-f filename] [-i mapped_ipv4] [-p mapped_port_base] @@ -25,6 +28,32 @@ optional arguments: -l mapping_loaded_filename, --load mapping_loaded_filename mapping loaded filename, to UCC log; YAML formatted ``` +
+ +
+from binary (.exe) + +```sh +usage: sigmadouble.exe [-h] [-v] [-f filename] [-i mapped_ipv4] [-p mapped_port_base] + [-s mapping_stored_filename | -l mapping_loaded_filename] + +CLI argument parsing + +optional arguments: + -h, --help show this help message and exit + -v, --verbose verbosity + -f filename, --filename filename + filename of UCC log + -i mapped_ipv4, --ip mapped_ipv4 + mapped IPv4 address; only for mapping stored filename + -p mapped_port_base, --port mapped_port_base + mapped TCP listening port base; only for mapping stored filename + -s mapping_stored_filename, --store mapping_stored_filename + mapping stored filename, from UCC log; YAML formatted + -l mapping_loaded_filename, --load mapping_loaded_filename + mapping loaded filename, to UCC log; YAML formatted +``` +
## Description: A test double to **emulate** Sigma handshaking based on existing log. @@ -44,3 +73,62 @@ The UCC core must alter: > > Notice here, when DUT is one of testbeds, the handle (IP-port pair) of the testbed is recommended to be commented/removed. Thus, when UCC core sends request to test double, then, test double will send corresponding response back; **just like replaying the tapes of music**. + +## Build: + +
+Cross-platform packaging using Wine + +Building _Windows 11_ binary executable steps under _Ubuntu 20.04_ are following. + +* To build the docker image using existing Dockerfile; **Wine** installation is included in the Dockerfile +```sh +docker build -f ubuntu-20-04-wine.dockerfile -t wine-20-04 . --build-arg UID=$UID --build-arg USER=$USER --build-arg PASSWORD="demonslayer" +``` +* To disable the access control of X-server +```sh +xhost + +``` + +* To launch the docker container; current working directory is mounted to _/mnt_ +```sh +docker run -it --name wine-20-04-inst --device /dev/snd --device=/dev/dri -e DISPLAY=$DISPLAY -e XMODIFIERS=@im=fcitx -e QT_IM_MODULE=fcitx -e GTK_IM_MODULE=fcitx -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v $(pwd):/mnt --net=host wine-20-04 bash +``` + +* To download a suitable python installer such as v3.8 under the container +```sh +wget https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe -O /mnt/python-3.8.10-amd64.exe +``` + +* To install the python installer under the container +```sh +WINEPREFIX=~/.wine64 wine /mnt/python-3.8.10-amd64.exe +``` + +* To install dependency for this _test double_ under the container +```sh +WINEPREFIX=~/.wine64 wine ~/.wine64/drive_c/users/`id -u -n`/AppData/Local/Programs/Python/Python38/python.exe -m pip install pyyaml +``` + +* To install dependency for packaging under the container +```sh +WINEPREFIX=~/.wine64 wine ~/.wine64/drive_c/users/`id -u -n`/AppData/Local/Programs/Python/Python38/python.exe -m pip install pyinstaller +``` + +* To package the binary executable under the container; the binary executable is stored in the distributable directory (i.e. _/mnt_) +```sh +WINEPREFIX=~/.wine64 wine ~/.wine64/drive_c/users/`id -u -n`/AppData/Local/Programs/Python/Python38/Scripts/pyinstaller.exe --clean --console --onefile /mnt/sigmadouble.py --distpath /mnt +``` + +* To exit the container +```sh +exit +``` + +* To enable the access control of X-server +```sh +xhost - +``` + +
+ diff --git a/ubuntu-20-04-wine.dockerfile b/ubuntu-20-04-wine.dockerfile new file mode 100644 index 0000000..72c4543 --- /dev/null +++ b/ubuntu-20-04-wine.dockerfile @@ -0,0 +1,86 @@ +FROM --platform=amd64 ubuntu:20.04 + +ARG UID=9527 +ARG USER=WFA +ARG PASSWORD="docker" +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update -y && \ + apt-get install -y --no-install-recommends \ + software-properties-common \ + ca-certificates \ + language-pack-en \ + language-pack-zh-hant* \ + locales \ + locales-all \ + wget + +# Install Wine +RUN dpkg --add-architecture i386 && \ + mkdir -pm755 /etc/apt/keyrings && \ + wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key && \ + wget -nc -P /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/$(lsb_release -sc)/winehq-$(lsb_release -sc).sources && \ + apt-get update -y && \ + # Wine 7.0 stable has some issues with some games I tested + # Use Wine 7.11 staging instead + apt-get install -y --install-recommends winehq-staging + +# GStreamer plugins +RUN apt-get update -y && \ + apt-get install -y --install-recommends \ + gstreamer1.0-libav:i386 +RUN apt-get update -y && \ + apt-get install -y --install-recommends \ + gstreamer1.0-plugins-bad:i386 +RUN apt-get update -y && \ + apt-get install -y --install-recommends \ + gstreamer1.0-plugins-base:i386 +RUN apt-get update -y && \ + apt-get install -y --install-recommends \ + gstreamer1.0-plugins-good:i386 +RUN apt-get update -y && \ + apt-get install -y --install-recommends \ + gstreamer1.0-plugins-ugly:i386 +RUN apt-get update -y && \ + apt-get install -y --install-recommends \ + gstreamer1.0-pulseaudio:i386 + +# Install dependencies for display scaling +RUN apt-get update -y && \ + apt-get install -y --install-recommends \ + build-essential \ + bc \ + git \ + xpra \ + xvfb \ + python3 \ + python3-pip + +# Install OpenGL acceleration for display scaling +RUN pip3 install PyOpenGL==3.1.5 PyOpenGL_accelerate==3.1.5 + +# Install display scaling script +RUN cd /tmp && \ + git clone https://github.com/kaueraal/run_scaled.git && \ + cp /tmp/run_scaled/run_scaled /usr/local/bin/ + +# Install missing fonts for Chinese +RUN apt-get update -y && \ + apt-get install -y --install-recommends \ + fonts-wqy-microhei + +# Install driver for Intel HD graphics +RUN apt-get -y install libgl1-mesa-glx libgl1-mesa-dri + +ENV LC_ALL zh_TW.UTF-8 +ENV LANG zh_TW.UTF-8 +# Make sure the terminal is still English +ENV LANGUAGE en_US.UTF-8 + +RUN apt-get install -qqy sudo +RUN useradd -r -m -d /home/$USER -s /bin/bash -g root -g sudo -u $UID $USER +RUN echo "$USER:$PASSWORD" | chpasswd +RUN echo "root:$PASSWORD" | chpasswd +USER $USER +WORKDIR /home/$USER +