diff mbox series

VSCode : Enable SWUpdate Development inside Docker Container

Message ID 20241129135056.373492-1-ayoub.zaki@embetrix.com
State New
Delegated to: Stefano Babic
Headers show
Series VSCode : Enable SWUpdate Development inside Docker Container | expand

Commit Message

Ayoub Zaki Nov. 29, 2024, 1:50 p.m. UTC
This will enable seamless Development of **swupdate** Project with VSCode inside Docker container.

The VSCode Container provides:

* Automatic Mapping of the host user UID/GID inside the container
* GCC Cross-Compilers (armhf/aarch64)
* GDB Multiarch for Debugging
* Remote SSH on the Target with seamless ssh mapping of the Host inside the container (Linux/Windows WSL)
* Git and Git Extensions to work and send Patches
* Python modules to work with swupdateclient

Note: This require Docker installation for Linux/or Windows :
      [1] https://docs.docker.com/engine/install

      VSCode Extensions (extensions.json) will be recommended for the installation

For more Information :
[2] https://code.visualstudio.com/docs/devcontainers/containers
[3] https://www.youtube.com/watch?v=C_5tDWsWSj0
[4] https://www.youtube.com/watch?v=b1RavPr_878

Signed-off-by: Ayoub Zaki <ayoub.zaki@embetrix.com>
---
 .devcontainer/Dockerfile        | 116 ++++++++++++++++++++++++++++++++
 .devcontainer/devcontainer.json |  29 ++++++++
 .gitignore                      |   4 ++
 .vscode/extensions.json         |  10 +++
 .vscode/tasks.json              |  74 ++++++++++++++++++++
 5 files changed, 233 insertions(+)
 create mode 100644 .devcontainer/Dockerfile
 create mode 100644 .devcontainer/devcontainer.json
 create mode 100644 .vscode/extensions.json
 create mode 100644 .vscode/tasks.json

Comments

Ayoub Zaki Dec. 10, 2024, 10:09 a.m. UTC | #1
Hi Stefano,

any update on this Patch ?

Best regards

On Friday, November 29, 2024 at 2:51:03 PM UTC+1 Ayoub Zaki wrote:

> This will enable seamless Development of **swupdate** Project with VSCode 
> inside Docker container.
>
> The VSCode Container provides:
>
> * Automatic Mapping of the host user UID/GID inside the container
> * GCC Cross-Compilers (armhf/aarch64)
> * GDB Multiarch for Debugging
> * Remote SSH on the Target with seamless ssh mapping of the Host inside 
> the container (Linux/Windows WSL)
> * Git and Git Extensions to work and send Patches
> * Python modules to work with swupdateclient
>
> Note: This require Docker installation for Linux/or Windows :
> [1] https://docs.docker.com/engine/install
>
> VSCode Extensions (extensions.json) will be recommended for the 
> installation
>
> For more Information :
> [2] https://code.visualstudio.com/docs/devcontainers/containers
> [3] https://www.youtube.com/watch?v=C_5tDWsWSj0
> [4] https://www.youtube.com/watch?v=b1RavPr_878
>
> Signed-off-by: Ayoub Zaki <ayoub...@embetrix.com>
> ---
> .devcontainer/Dockerfile | 116 ++++++++++++++++++++++++++++++++
> .devcontainer/devcontainer.json | 29 ++++++++
> .gitignore | 4 ++
> .vscode/extensions.json | 10 +++
> .vscode/tasks.json | 74 ++++++++++++++++++++
> 5 files changed, 233 insertions(+)
> create mode 100644 .devcontainer/Dockerfile
> create mode 100644 .devcontainer/devcontainer.json
> create mode 100644 .vscode/extensions.json
> create mode 100644 .vscode/tasks.json
>
> diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
> new file mode 100644
> index 00000000..0045b850
> --- /dev/null
> +++ b/.devcontainer/Dockerfile
> @@ -0,0 +1,116 @@
> +FROM debian:12
> +
> +RUN dpkg --add-architecture armhf && apt-get update
> +RUN dpkg --add-architecture arm64 && apt-get update
> +RUN apt-get install -y \
> + build-essential \
> + crossbuild-essential-armhf \
> + crossbuild-essential-arm64 \
> + gdb-multiarch \
> + cmake \
> + ccache \
> + qemu-user
> +
> +# Install swupdate native dependencies
> +RUN apt-get install -y \
> + libebgenv-dev \
> + libmtd-dev \
> + libubi-dev \
> + libzck-dev \
> + libcurl4-openssl-dev \
> + libssl-dev \
> + libwolfssl-dev \
> + libsystemd-dev \
> + libjson-c-dev \
> + libncurses5-dev \
> + libncursesw5-dev \
> + libarchive-dev \
> + libconfig-dev \
> + libz-dev \
> + libyaml-dev \
> + lua5.2-dev
> +
> +# Install swupdate dependencies for armhf
> +RUN apt-get install -y \
> + libebgenv-dev:armhf \
> + libmtd-dev:armhf \
> + libubi-dev:armhf \
> + libzck-dev:armhf \
> + libcurl4-openssl-dev:armhf \
> + libssl-dev:armhf \
> + libwolfssl-dev:armhf \
> + libsystemd-dev:armhf \
> + libjson-c-dev:armhf \
> + libncurses5-dev:armhf \
> + libncursesw5-dev:armhf \
> + libarchive-dev:armhf \
> + libconfig-dev:armhf \
> + libz-dev:armhf \
> + libyaml-dev:armhf \
> + lua5.2-dev:armhf
> +
> +# Install swupdate dependencies for arm64
> +RUN apt-get install -y \
> + libebgenv-dev:arm64 \
> + libmtd-dev:arm64 \
> + libubi-dev:arm64 \
> + libzck-dev:arm64 \
> + libcurl4-openssl-dev:arm64 \
> + libssl-dev:arm64 \
> + libwolfssl-dev:arm64 \
> + libsystemd-dev:arm64 \
> + libjson-c-dev:arm64 \
> + libncurses5-dev:arm64 \
> + libncursesw5-dev:arm64 \
> + libarchive-dev:arm64 \
> + libconfig-dev:arm64 \
> + libz-dev:arm64 \
> + libyaml-dev:arm64 \
> + lua5.2-dev:arm64
> +
> +# Aditional development tools
> +RUN apt-get install -y \
> + git-core \
> + git-man \
> + git-email \
> + sudo \
> + nano \
> + vim \
> + curl \
> + openssh-client \
> + bash-completion
> +
> +# Install libubootenv library (new version not available in debian)
> +# for native, armhf and arm64
> +RUN git clone https://github.com/sbabic/libubootenv.git && \
> + cd libubootenv && \
> + cmake -DCMAKE_INSTALL_LIBDIR=/usr/lib/x86_64-linux-gnu \
> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
> + make -j && \
> + sudo make install && git clean -fdx && \
> + cmake -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
> + -DCMAKE_INSTALL_LIBDIR=/usr/lib/arm-linux-gnueabihf \
> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
> + make -j && \
> + sudo make install && git clean -fdx && \
> + cmake -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
> + -DCMAKE_INSTALL_LIBDIR=/usr/lib/aarch64-linux-gnu \
> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
> + make -j && \
> + sudo make install
> +
> +# Install python3 and dependencie required for python swupdateclient
> +RUN apt-get install -y \
> + python3 \
> + python3-pip \
> + python3-requests \
> + python3-websockets \
> + python3-termcolor
> +
> +# Add swupdate user
> +RUN useradd -ms /bin/bash swupdate
> +RUN echo "swupdate ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers
> +USER swupdate
> +WORKDIR /home/swupdate
> +
> +CMD ["/bin/bash"]
> diff --git a/.devcontainer/devcontainer.json 
> b/.devcontainer/devcontainer.json
> new file mode 100644
> index 00000000..cb4c5120
> --- /dev/null
> +++ b/.devcontainer/devcontainer.json
> @@ -0,0 +1,29 @@
> +{
> + "name": "swupdate-docker",
> + "build": {
> + "dockerfile": "Dockerfile"
> + },
> +
> + "customizations": {
> + "vscode": {
> + "settings": {
> + "terminal.integrated.profiles.linux": {
> + "bash": {
> + "path": "/bin/bash",
> + "args": ["-l"]
> + }
> + },
> + "terminal.integrated.defaultProfile.linux": "bash"
> + },
> + "extensions": [
> + "ms-vscode.cpptools",
> + "eamodio.gitlens"
> + ]
> + }
> + },
> +
> + // Map the host .ssh folder into the container for a seamless ssh 
> experience
> + "mounts": [
> + 
> "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/swupdate/.ssh,type=bind,consistency=cached"
> + ]
> +}
> diff --git a/.gitignore b/.gitignore
> index 4755ff07..68cd2ee3 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -127,6 +127,10 @@ web-app/swupdate-www.tar.gz
> !.gitlab-ci.yml
> !.github
>
> +# vscode
> +!.devcontainer
> +!.vscode
> +
> # swupdateclient
> Pipfile
> Pipfile.lock
> diff --git a/.vscode/extensions.json b/.vscode/extensions.json
> new file mode 100644
> index 00000000..4bdb6854
> --- /dev/null
> +++ b/.vscode/extensions.json
> @@ -0,0 +1,10 @@
> +{
> + "recommendations": [
> + "ms-vscode-remote.remote-containers",
> + "ms-vscode-remote.remote-wsl",
> + "ms-vscode-remote.vscode-remote-extensionpack",
> + "ms-vscode.cpptools-extension-pack",
> + "ms-vscode.cpptools",
> + "eamodio.gitlens",
> + ]
> +}
> diff --git a/.vscode/tasks.json b/.vscode/tasks.json
> new file mode 100644
> index 00000000..3eec68f5
> --- /dev/null
> +++ b/.vscode/tasks.json
> @@ -0,0 +1,74 @@
> +{
> + "version": "2.0.0",
> + "tasks": [
> + {
> + "type": "shell",
> + "label": "configure",
> + "command": "make",
> + "group": "build",
> + "problemMatcher": [],
> + "detail": "Configure Swupdate using menuconfig",
> + "args": [
> + "menuconfig"
> + ],
> + },
> + {
> + "type": "shell",
> + "label": "clean",
> + "command": "make",
> + "group": "build",
> + "problemMatcher": [],
> + "detail": "Clean Swupdate build",
> + "args": [
> + "clean"
> + ],
> + },
> + {
> + "type": "shell",
> + "label": "compile",
> + "command": "make",
> + "group": "build",
> + "problemMatcher": [],
> + "detail": "Compile Swupdate (native)",
> + "args": [
> + "-j"
> + ],
> + },
> + {
> + "type": "shell",
> + "label": "cross compile armhf",
> + "command": "make",
> + "group": "build",
> + "problemMatcher": [],
> + "detail": "Cross-Compile Swupdate for armhf",
> + "args": [
> + "-j"
> + ],
> + "options": {
> + "env": {
> + "CC": "arm-linux-gnueabihf-gcc",
> + "LD": "arm-linux-gnueabihf-gcc",
> + "CROSS_COMPILE": "arm-linux-gnueabihf-"
> + }
> + }
> + },
> + {
> + "type": "shell",
> + "label": "cross compile aarch64",
> + "command": "make",
> + "group": "build",
> + "problemMatcher": [],
> + "detail": "Cross-Compile Swupdate for armhf",
> + "args": [
> + "-j"
> + ],
> + "options": {
> + "env": {
> + "CC": "aarch64-linux-gnu-gcc",
> + "LD": "aarch64-linux-gnu-gcc",
> + "CROSS_COMPILE": "aarch64-linux-gnu-"
> + }
> + }
> + }
> + ]
> +}
> -- 
> 2.43.0
>
>
Mark Jonas Dec. 13, 2024, 8:06 a.m. UTC | #2
Hi Ayoub,

To me a good step towards consideration of the patch would be to break
it down into a small, first step now and to improve it in later steps.

On the one hand there is a lot of functionality in your setup, even
things I do not understand why they are needed in the decontainer. On
the other hand, there are some essential things missing, e.g. to be
able to run all tests. What about starting with a simple, basic
devcontainer which can compile swupdate on x86-x64 including running
the tests. And then later building it up step by step?

I think a good starting point would be to start with a minimal
.devcontainer/Dockerfile and .devcontainer/devcontainer.json. To avoid
duplication and ease maintenance I recommend to use the existing
ci/setup.sh for installing the dependencies into the devcontainer.

Please also consider adding user documentation. And do not forget to
make your contribution REUSE compliant.

What do you think?

Cheers,
Mark

On Tue, Dec 10, 2024 at 11:09 AM 'ayoub...@googlemail.com' via
swupdate <swupdate@googlegroups.com> wrote:
>
> Hi Stefano,
>
> any update on this Patch ?
>
> Best regards
>
> On Friday, November 29, 2024 at 2:51:03 PM UTC+1 Ayoub Zaki wrote:
>>
>> This will enable seamless Development of **swupdate** Project with VSCode inside Docker container.
>>
>> The VSCode Container provides:
>>
>> * Automatic Mapping of the host user UID/GID inside the container
>> * GCC Cross-Compilers (armhf/aarch64)
>> * GDB Multiarch for Debugging
>> * Remote SSH on the Target with seamless ssh mapping of the Host inside the container (Linux/Windows WSL)
>> * Git and Git Extensions to work and send Patches
>> * Python modules to work with swupdateclient
>>
>> Note: This require Docker installation for Linux/or Windows :
>> [1] https://docs.docker.com/engine/install
>>
>> VSCode Extensions (extensions.json) will be recommended for the installation
>>
>> For more Information :
>> [2] https://code.visualstudio.com/docs/devcontainers/containers
>> [3] https://www.youtube.com/watch?v=C_5tDWsWSj0
>> [4] https://www.youtube.com/watch?v=b1RavPr_878
>>
>> Signed-off-by: Ayoub Zaki <ayoub...@embetrix.com>
>> ---
>> .devcontainer/Dockerfile | 116 ++++++++++++++++++++++++++++++++
>> .devcontainer/devcontainer.json | 29 ++++++++
>> .gitignore | 4 ++
>> .vscode/extensions.json | 10 +++
>> .vscode/tasks.json | 74 ++++++++++++++++++++
>> 5 files changed, 233 insertions(+)
>> create mode 100644 .devcontainer/Dockerfile
>> create mode 100644 .devcontainer/devcontainer.json
>> create mode 100644 .vscode/extensions.json
>> create mode 100644 .vscode/tasks.json
>>
>> diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
>> new file mode 100644
>> index 00000000..0045b850
>> --- /dev/null
>> +++ b/.devcontainer/Dockerfile
>> @@ -0,0 +1,116 @@
>> +FROM debian:12
>> +
>> +RUN dpkg --add-architecture armhf && apt-get update
>> +RUN dpkg --add-architecture arm64 && apt-get update
>> +RUN apt-get install -y \
>> + build-essential \
>> + crossbuild-essential-armhf \
>> + crossbuild-essential-arm64 \
>> + gdb-multiarch \
>> + cmake \
>> + ccache \
>> + qemu-user
>> +
>> +# Install swupdate native dependencies
>> +RUN apt-get install -y \
>> + libebgenv-dev \
>> + libmtd-dev \
>> + libubi-dev \
>> + libzck-dev \
>> + libcurl4-openssl-dev \
>> + libssl-dev \
>> + libwolfssl-dev \
>> + libsystemd-dev \
>> + libjson-c-dev \
>> + libncurses5-dev \
>> + libncursesw5-dev \
>> + libarchive-dev \
>> + libconfig-dev \
>> + libz-dev \
>> + libyaml-dev \
>> + lua5.2-dev
>> +
>> +# Install swupdate dependencies for armhf
>> +RUN apt-get install -y \
>> + libebgenv-dev:armhf \
>> + libmtd-dev:armhf \
>> + libubi-dev:armhf \
>> + libzck-dev:armhf \
>> + libcurl4-openssl-dev:armhf \
>> + libssl-dev:armhf \
>> + libwolfssl-dev:armhf \
>> + libsystemd-dev:armhf \
>> + libjson-c-dev:armhf \
>> + libncurses5-dev:armhf \
>> + libncursesw5-dev:armhf \
>> + libarchive-dev:armhf \
>> + libconfig-dev:armhf \
>> + libz-dev:armhf \
>> + libyaml-dev:armhf \
>> + lua5.2-dev:armhf
>> +
>> +# Install swupdate dependencies for arm64
>> +RUN apt-get install -y \
>> + libebgenv-dev:arm64 \
>> + libmtd-dev:arm64 \
>> + libubi-dev:arm64 \
>> + libzck-dev:arm64 \
>> + libcurl4-openssl-dev:arm64 \
>> + libssl-dev:arm64 \
>> + libwolfssl-dev:arm64 \
>> + libsystemd-dev:arm64 \
>> + libjson-c-dev:arm64 \
>> + libncurses5-dev:arm64 \
>> + libncursesw5-dev:arm64 \
>> + libarchive-dev:arm64 \
>> + libconfig-dev:arm64 \
>> + libz-dev:arm64 \
>> + libyaml-dev:arm64 \
>> + lua5.2-dev:arm64
>> +
>> +# Aditional development tools
>> +RUN apt-get install -y \
>> + git-core \
>> + git-man \
>> + git-email \
>> + sudo \
>> + nano \
>> + vim \
>> + curl \
>> + openssh-client \
>> + bash-completion
>> +
>> +# Install libubootenv library (new version not available in debian)
>> +# for native, armhf and arm64
>> +RUN git clone https://github.com/sbabic/libubootenv.git && \
>> + cd libubootenv && \
>> + cmake -DCMAKE_INSTALL_LIBDIR=/usr/lib/x86_64-linux-gnu \
>> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
>> + make -j && \
>> + sudo make install && git clean -fdx && \
>> + cmake -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
>> + -DCMAKE_INSTALL_LIBDIR=/usr/lib/arm-linux-gnueabihf \
>> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
>> + make -j && \
>> + sudo make install && git clean -fdx && \
>> + cmake -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
>> + -DCMAKE_INSTALL_LIBDIR=/usr/lib/aarch64-linux-gnu \
>> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
>> + make -j && \
>> + sudo make install
>> +
>> +# Install python3 and dependencie required for python swupdateclient
>> +RUN apt-get install -y \
>> + python3 \
>> + python3-pip \
>> + python3-requests \
>> + python3-websockets \
>> + python3-termcolor
>> +
>> +# Add swupdate user
>> +RUN useradd -ms /bin/bash swupdate
>> +RUN echo "swupdate ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers
>> +USER swupdate
>> +WORKDIR /home/swupdate
>> +
>> +CMD ["/bin/bash"]
>> diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
>> new file mode 100644
>> index 00000000..cb4c5120
>> --- /dev/null
>> +++ b/.devcontainer/devcontainer.json
>> @@ -0,0 +1,29 @@
>> +{
>> + "name": "swupdate-docker",
>> + "build": {
>> + "dockerfile": "Dockerfile"
>> + },
>> +
>> + "customizations": {
>> + "vscode": {
>> + "settings": {
>> + "terminal.integrated.profiles.linux": {
>> + "bash": {
>> + "path": "/bin/bash",
>> + "args": ["-l"]
>> + }
>> + },
>> + "terminal.integrated.defaultProfile.linux": "bash"
>> + },
>> + "extensions": [
>> + "ms-vscode.cpptools",
>> + "eamodio.gitlens"
>> + ]
>> + }
>> + },
>> +
>> + // Map the host .ssh folder into the container for a seamless ssh experience
>> + "mounts": [
>> + "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/swupdate/.ssh,type=bind,consistency=cached"
>> + ]
>> +}
>> diff --git a/.gitignore b/.gitignore
>> index 4755ff07..68cd2ee3 100644
>> --- a/.gitignore
>> +++ b/.gitignore
>> @@ -127,6 +127,10 @@ web-app/swupdate-www.tar.gz
>> !.gitlab-ci.yml
>> !.github
>>
>> +# vscode
>> +!.devcontainer
>> +!.vscode
>> +
>> # swupdateclient
>> Pipfile
>> Pipfile.lock
>> diff --git a/.vscode/extensions.json b/.vscode/extensions.json
>> new file mode 100644
>> index 00000000..4bdb6854
>> --- /dev/null
>> +++ b/.vscode/extensions.json
>> @@ -0,0 +1,10 @@
>> +{
>> + "recommendations": [
>> + "ms-vscode-remote.remote-containers",
>> + "ms-vscode-remote.remote-wsl",
>> + "ms-vscode-remote.vscode-remote-extensionpack",
>> + "ms-vscode.cpptools-extension-pack",
>> + "ms-vscode.cpptools",
>> + "eamodio.gitlens",
>> + ]
>> +}
>> diff --git a/.vscode/tasks.json b/.vscode/tasks.json
>> new file mode 100644
>> index 00000000..3eec68f5
>> --- /dev/null
>> +++ b/.vscode/tasks.json
>> @@ -0,0 +1,74 @@
>> +{
>> + "version": "2.0.0",
>> + "tasks": [
>> + {
>> + "type": "shell",
>> + "label": "configure",
>> + "command": "make",
>> + "group": "build",
>> + "problemMatcher": [],
>> + "detail": "Configure Swupdate using menuconfig",
>> + "args": [
>> + "menuconfig"
>> + ],
>> + },
>> + {
>> + "type": "shell",
>> + "label": "clean",
>> + "command": "make",
>> + "group": "build",
>> + "problemMatcher": [],
>> + "detail": "Clean Swupdate build",
>> + "args": [
>> + "clean"
>> + ],
>> + },
>> + {
>> + "type": "shell",
>> + "label": "compile",
>> + "command": "make",
>> + "group": "build",
>> + "problemMatcher": [],
>> + "detail": "Compile Swupdate (native)",
>> + "args": [
>> + "-j"
>> + ],
>> + },
>> + {
>> + "type": "shell",
>> + "label": "cross compile armhf",
>> + "command": "make",
>> + "group": "build",
>> + "problemMatcher": [],
>> + "detail": "Cross-Compile Swupdate for armhf",
>> + "args": [
>> + "-j"
>> + ],
>> + "options": {
>> + "env": {
>> + "CC": "arm-linux-gnueabihf-gcc",
>> + "LD": "arm-linux-gnueabihf-gcc",
>> + "CROSS_COMPILE": "arm-linux-gnueabihf-"
>> + }
>> + }
>> + },
>> + {
>> + "type": "shell",
>> + "label": "cross compile aarch64",
>> + "command": "make",
>> + "group": "build",
>> + "problemMatcher": [],
>> + "detail": "Cross-Compile Swupdate for armhf",
>> + "args": [
>> + "-j"
>> + ],
>> + "options": {
>> + "env": {
>> + "CC": "aarch64-linux-gnu-gcc",
>> + "LD": "aarch64-linux-gnu-gcc",
>> + "CROSS_COMPILE": "aarch64-linux-gnu-"
>> + }
>> + }
>> + }
>> + ]
>> +}
>> --
>> 2.43.0
>>
> --
> You received this message because you are subscribed to the Google Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to swupdate+unsubscribe@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/swupdate/92af3ff2-e1cc-4568-bd80-ff29a9a58df4n%40googlegroups.com.
Ayoub Zaki Dec. 13, 2024, 10:27 a.m. UTC | #3
Hello Mark,

Thank you for taking the time to review the patch.

Could you clarify which functionalities are not fully understood? I’d be 
happy to provide further explanations.

The current .devcontainer/Dockerfile and .devcontainer/devcontainer.json 
configurations are kept basic. 

They include all necessary dependencies to compile "native" x86-x64 as well 
as armhf/aarch64 and to run tests.

As for the ci/setup.sh script, it cannot be directly used in this context 
since it relies on Ubuntu, which complicates adding support for additional 
architectures like armhf and aarch64, this is why I used it to Debian 
instead.

For the CI, I agree it could be beneficial to introduce a dedicated 
Dockerfile. In the future, we could aim to converge the VS Code 
devcontainer and the CI Docker configurations to simplify maintenance and 
ensure consistency.

Looking forward to hearing your thoughts.

Best regards,
Ayoub
On Friday, December 13, 2024 at 9:06:36 AM UTC+1 Mark Jonas wrote:

> Hi Ayoub,
>
> To me a good step towards consideration of the patch would be to break
> it down into a small, first step now and to improve it in later steps.
>
> On the one hand there is a lot of functionality in your setup, even
> things I do not understand why they are needed in the decontainer. On
> the other hand, there are some essential things missing, e.g. to be
> able to run all tests. What about starting with a simple, basic
> devcontainer which can compile swupdate on x86-x64 including running
> the tests. And then later building it up step by step?
>
> I think a good starting point would be to start with a minimal
> .devcontainer/Dockerfile and .devcontainer/devcontainer.json. To avoid
> duplication and ease maintenance I recommend to use the existing
> ci/setup.sh for installing the dependencies into the devcontainer.
>
> Please also consider adding user documentation. And do not forget to
> make your contribution REUSE compliant.
>
> What do you think?
>
> Cheers,
> Mark
>
> On Tue, Dec 10, 2024 at 11:09 AM 'ayoub...@googlemail.com' via
> swupdate <swup...@googlegroups.com> wrote:
> >
> > Hi Stefano,
> >
> > any update on this Patch ?
> >
> > Best regards
> >
> > On Friday, November 29, 2024 at 2:51:03 PM UTC+1 Ayoub Zaki wrote:
> >>
> >> This will enable seamless Development of **swupdate** Project with 
> VSCode inside Docker container.
> >>
> >> The VSCode Container provides:
> >>
> >> * Automatic Mapping of the host user UID/GID inside the container
> >> * GCC Cross-Compilers (armhf/aarch64)
> >> * GDB Multiarch for Debugging
> >> * Remote SSH on the Target with seamless ssh mapping of the Host inside 
> the container (Linux/Windows WSL)
> >> * Git and Git Extensions to work and send Patches
> >> * Python modules to work with swupdateclient
> >>
> >> Note: This require Docker installation for Linux/or Windows :
> >> [1] https://docs.docker.com/engine/install
> >>
> >> VSCode Extensions (extensions.json) will be recommended for the 
> installation
> >>
> >> For more Information :
> >> [2] https://code.visualstudio.com/docs/devcontainers/containers
> >> [3] https://www.youtube.com/watch?v=C_5tDWsWSj0
> >> [4] https://www.youtube.com/watch?v=b1RavPr_878
> >>
> >> Signed-off-by: Ayoub Zaki <ayoub...@embetrix.com>
> >> ---
> >> .devcontainer/Dockerfile | 116 ++++++++++++++++++++++++++++++++
> >> .devcontainer/devcontainer.json | 29 ++++++++
> >> .gitignore | 4 ++
> >> .vscode/extensions.json | 10 +++
> >> .vscode/tasks.json | 74 ++++++++++++++++++++
> >> 5 files changed, 233 insertions(+)
> >> create mode 100644 .devcontainer/Dockerfile
> >> create mode 100644 .devcontainer/devcontainer.json
> >> create mode 100644 .vscode/extensions.json
> >> create mode 100644 .vscode/tasks.json
> >>
> >> diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
> >> new file mode 100644
> >> index 00000000..0045b850
> >> --- /dev/null
> >> +++ b/.devcontainer/Dockerfile
> >> @@ -0,0 +1,116 @@
> >> +FROM debian:12
> >> +
> >> +RUN dpkg --add-architecture armhf && apt-get update
> >> +RUN dpkg --add-architecture arm64 && apt-get update
> >> +RUN apt-get install -y \
> >> + build-essential \
> >> + crossbuild-essential-armhf \
> >> + crossbuild-essential-arm64 \
> >> + gdb-multiarch \
> >> + cmake \
> >> + ccache \
> >> + qemu-user
> >> +
> >> +# Install swupdate native dependencies
> >> +RUN apt-get install -y \
> >> + libebgenv-dev \
> >> + libmtd-dev \
> >> + libubi-dev \
> >> + libzck-dev \
> >> + libcurl4-openssl-dev \
> >> + libssl-dev \
> >> + libwolfssl-dev \
> >> + libsystemd-dev \
> >> + libjson-c-dev \
> >> + libncurses5-dev \
> >> + libncursesw5-dev \
> >> + libarchive-dev \
> >> + libconfig-dev \
> >> + libz-dev \
> >> + libyaml-dev \
> >> + lua5.2-dev
> >> +
> >> +# Install swupdate dependencies for armhf
> >> +RUN apt-get install -y \
> >> + libebgenv-dev:armhf \
> >> + libmtd-dev:armhf \
> >> + libubi-dev:armhf \
> >> + libzck-dev:armhf \
> >> + libcurl4-openssl-dev:armhf \
> >> + libssl-dev:armhf \
> >> + libwolfssl-dev:armhf \
> >> + libsystemd-dev:armhf \
> >> + libjson-c-dev:armhf \
> >> + libncurses5-dev:armhf \
> >> + libncursesw5-dev:armhf \
> >> + libarchive-dev:armhf \
> >> + libconfig-dev:armhf \
> >> + libz-dev:armhf \
> >> + libyaml-dev:armhf \
> >> + lua5.2-dev:armhf
> >> +
> >> +# Install swupdate dependencies for arm64
> >> +RUN apt-get install -y \
> >> + libebgenv-dev:arm64 \
> >> + libmtd-dev:arm64 \
> >> + libubi-dev:arm64 \
> >> + libzck-dev:arm64 \
> >> + libcurl4-openssl-dev:arm64 \
> >> + libssl-dev:arm64 \
> >> + libwolfssl-dev:arm64 \
> >> + libsystemd-dev:arm64 \
> >> + libjson-c-dev:arm64 \
> >> + libncurses5-dev:arm64 \
> >> + libncursesw5-dev:arm64 \
> >> + libarchive-dev:arm64 \
> >> + libconfig-dev:arm64 \
> >> + libz-dev:arm64 \
> >> + libyaml-dev:arm64 \
> >> + lua5.2-dev:arm64
> >> +
> >> +# Aditional development tools
> >> +RUN apt-get install -y \
> >> + git-core \
> >> + git-man \
> >> + git-email \
> >> + sudo \
> >> + nano \
> >> + vim \
> >> + curl \
> >> + openssh-client \
> >> + bash-completion
> >> +
> >> +# Install libubootenv library (new version not available in debian)
> >> +# for native, armhf and arm64
> >> +RUN git clone https://github.com/sbabic/libubootenv.git && \
> >> + cd libubootenv && \
> >> + cmake -DCMAKE_INSTALL_LIBDIR=/usr/lib/x86_64-linux-gnu \
> >> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
> >> + make -j && \
> >> + sudo make install && git clean -fdx && \
> >> + cmake -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
> >> + -DCMAKE_INSTALL_LIBDIR=/usr/lib/arm-linux-gnueabihf \
> >> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
> >> + make -j && \
> >> + sudo make install && git clean -fdx && \
> >> + cmake -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
> >> + -DCMAKE_INSTALL_LIBDIR=/usr/lib/aarch64-linux-gnu \
> >> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
> >> + make -j && \
> >> + sudo make install
> >> +
> >> +# Install python3 and dependencie required for python swupdateclient
> >> +RUN apt-get install -y \
> >> + python3 \
> >> + python3-pip \
> >> + python3-requests \
> >> + python3-websockets \
> >> + python3-termcolor
> >> +
> >> +# Add swupdate user
> >> +RUN useradd -ms /bin/bash swupdate
> >> +RUN echo "swupdate ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers
> >> +USER swupdate
> >> +WORKDIR /home/swupdate
> >> +
> >> +CMD ["/bin/bash"]
> >> diff --git a/.devcontainer/devcontainer.json 
> b/.devcontainer/devcontainer.json
> >> new file mode 100644
> >> index 00000000..cb4c5120
> >> --- /dev/null
> >> +++ b/.devcontainer/devcontainer.json
> >> @@ -0,0 +1,29 @@
> >> +{
> >> + "name": "swupdate-docker",
> >> + "build": {
> >> + "dockerfile": "Dockerfile"
> >> + },
> >> +
> >> + "customizations": {
> >> + "vscode": {
> >> + "settings": {
> >> + "terminal.integrated.profiles.linux": {
> >> + "bash": {
> >> + "path": "/bin/bash",
> >> + "args": ["-l"]
> >> + }
> >> + },
> >> + "terminal.integrated.defaultProfile.linux": "bash"
> >> + },
> >> + "extensions": [
> >> + "ms-vscode.cpptools",
> >> + "eamodio.gitlens"
> >> + ]
> >> + }
> >> + },
> >> +
> >> + // Map the host .ssh folder into the container for a seamless ssh 
> experience
> >> + "mounts": [
> >> + 
> "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/swupdate/.ssh,type=bind,consistency=cached"
> >> + ]
> >> +}
> >> diff --git a/.gitignore b/.gitignore
> >> index 4755ff07..68cd2ee3 100644
> >> --- a/.gitignore
> >> +++ b/.gitignore
> >> @@ -127,6 +127,10 @@ web-app/swupdate-www.tar.gz
> >> !.gitlab-ci.yml
> >> !.github
> >>
> >> +# vscode
> >> +!.devcontainer
> >> +!.vscode
> >> +
> >> # swupdateclient
> >> Pipfile
> >> Pipfile.lock
> >> diff --git a/.vscode/extensions.json b/.vscode/extensions.json
> >> new file mode 100644
> >> index 00000000..4bdb6854
> >> --- /dev/null
> >> +++ b/.vscode/extensions.json
> >> @@ -0,0 +1,10 @@
> >> +{
> >> + "recommendations": [
> >> + "ms-vscode-remote.remote-containers",
> >> + "ms-vscode-remote.remote-wsl",
> >> + "ms-vscode-remote.vscode-remote-extensionpack",
> >> + "ms-vscode.cpptools-extension-pack",
> >> + "ms-vscode.cpptools",
> >> + "eamodio.gitlens",
> >> + ]
> >> +}
> >> diff --git a/.vscode/tasks.json b/.vscode/tasks.json
> >> new file mode 100644
> >> index 00000000..3eec68f5
> >> --- /dev/null
> >> +++ b/.vscode/tasks.json
> >> @@ -0,0 +1,74 @@
> >> +{
> >> + "version": "2.0.0",
> >> + "tasks": [
> >> + {
> >> + "type": "shell",
> >> + "label": "configure",
> >> + "command": "make",
> >> + "group": "build",
> >> + "problemMatcher": [],
> >> + "detail": "Configure Swupdate using menuconfig",
> >> + "args": [
> >> + "menuconfig"
> >> + ],
> >> + },
> >> + {
> >> + "type": "shell",
> >> + "label": "clean",
> >> + "command": "make",
> >> + "group": "build",
> >> + "problemMatcher": [],
> >> + "detail": "Clean Swupdate build",
> >> + "args": [
> >> + "clean"
> >> + ],
> >> + },
> >> + {
> >> + "type": "shell",
> >> + "label": "compile",
> >> + "command": "make",
> >> + "group": "build",
> >> + "problemMatcher": [],
> >> + "detail": "Compile Swupdate (native)",
> >> + "args": [
> >> + "-j"
> >> + ],
> >> + },
> >> + {
> >> + "type": "shell",
> >> + "label": "cross compile armhf",
> >> + "command": "make",
> >> + "group": "build",
> >> + "problemMatcher": [],
> >> + "detail": "Cross-Compile Swupdate for armhf",
> >> + "args": [
> >> + "-j"
> >> + ],
> >> + "options": {
> >> + "env": {
> >> + "CC": "arm-linux-gnueabihf-gcc",
> >> + "LD": "arm-linux-gnueabihf-gcc",
> >> + "CROSS_COMPILE": "arm-linux-gnueabihf-"
> >> + }
> >> + }
> >> + },
> >> + {
> >> + "type": "shell",
> >> + "label": "cross compile aarch64",
> >> + "command": "make",
> >> + "group": "build",
> >> + "problemMatcher": [],
> >> + "detail": "Cross-Compile Swupdate for armhf",
> >> + "args": [
> >> + "-j"
> >> + ],
> >> + "options": {
> >> + "env": {
> >> + "CC": "aarch64-linux-gnu-gcc",
> >> + "LD": "aarch64-linux-gnu-gcc",
> >> + "CROSS_COMPILE": "aarch64-linux-gnu-"
> >> + }
> >> + }
> >> + }
> >> + ]
> >> +}
> >> --
> >> 2.43.0
> >>
> > --
> > You received this message because you are subscribed to the Google 
> Groups "swupdate" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to swupdate+u...@googlegroups.com.
> > To view this discussion visit 
> https://groups.google.com/d/msgid/swupdate/92af3ff2-e1cc-4568-bd80-ff29a9a58df4n%40googlegroups.com
> .
>
Stefano Babic Dec. 14, 2024, 5:37 p.m. UTC | #4
Hi Ayoub,

On 13.12.24 11:27, 'ayoub...@googlemail.com' via swupdate wrote:
> Hello Mark,
>
> Thank you for taking the time to review the patch.
>
> Could you clarify which functionalities are not fully understood? I’d be
> happy to provide further explanations.
>
> The current .devcontainer/Dockerfile and .devcontainer/devcontainer.json
> configurations are kept basic.
>
> They include all necessary dependencies to compile "native" x86-x64 as
> well as armhf/aarch64 and to run tests.
>
> As for the ci/setup.sh script, it cannot be directly used in this
> context since it relies on Ubuntu, which complicates adding support for
> additional architectures like armhf and aarch64, this is why I used it
> to Debian instead.

The choice for Ubuntu was just done because this was the platform I used
to build and test natively. It is not mandatory and we can agree to
switch from Ubuntu to Debian.

>
> For the CI, I agree it could be beneficial to introduce a dedicated
> Dockerfile.

The way I use Ci is via a gitlab-runner that already runs a docker
executor, using the Ubuntu image. Is it possible to start the runner
with a Dockerfile instead of a prebuilt image ? As far as I know, the
image is just picked up from somewhere.

> In the future, we could aim to converge the VS Code
> devcontainer and the CI Docker configurations to simplify maintenance
> and ensure consistency.
>
> Looking forward to hearing your thoughts.

IMHO if we want to provide a dev container, we should be sure that the
project can be built with all configuration. I have tested to build into
VSCode in container, and I get these errors:

==========
/usr/bin/ld: cannot find -lmbedcrypto: No such file or directory
/usr/bin/ld: cannot find -lmbedtls: No such file or directory
/usr/bin/ld: cannot find -lmbedx509: No such file or directory
/usr/bin/ld: cannot find -lfdisk: No such file or directory
/usr/bin/ld: cannot find -lblkid: No such file or directory
/usr/bin/ld: cannot find -lext2fs: No such file or directory
/usr/bin/ld: cannot find -luuid: No such file or directory
/usr/bin/ld: cannot find -lblkid: No such file or directory
/usr/bin/ld: cannot find -lbtrfsutil: No such file or directory
/usr/bin/ld: cannot find -ludev: No such file or directory
/usr/bin/ld: cannot find -lblkid: No such file or directory
/usr/bin/ld: cannot find -lrsync: No such file or directory
/usr/bin/ld: cannot find -lzmq: No such file or directory
/usr/bin/ld: cannot find -lgpiod: No such file or directory
/usr/bin/ld: cannot find -lwebsockets: No such file or directory
/usr/bin/ld: cannot find -luriparser: No such file or directory

because libraries are not in container, so the container isn't complete.

I agree that a short documentation about how to use it helps (use
"reopen in dev container" in VSCode, etc.).

I will also suggest to split the patch: Dockerfile can be used
independently from VSCode, for example. For the extension, VSCode
rejected to do anything without installing LLDB in container. If this
doesn't happen only to me, it should be added to the extensions.json.

Best regards,
Stefano

>
> Best regards,
> Ayoub
>
> On Friday, December 13, 2024 at 9:06:36 AM UTC+1 Mark Jonas wrote:
>
>     Hi Ayoub,
>
>     To me a good step towards consideration of the patch would be to break
>     it down into a small, first step now and to improve it in later steps.
>
>     On the one hand there is a lot of functionality in your setup, even
>     things I do not understand why they are needed in the decontainer. On
>     the other hand, there are some essential things missing, e.g. to be
>     able to run all tests. What about starting with a simple, basic
>     devcontainer which can compile swupdate on x86-x64 including running
>     the tests. And then later building it up step by step?
>
>     I think a good starting point would be to start with a minimal
>     .devcontainer/Dockerfile and .devcontainer/devcontainer.json. To avoid
>     duplication and ease maintenance I recommend to use the existing
>     ci/setup.sh for installing the dependencies into the devcontainer.
>
>     Please also consider adding user documentation. And do not forget to
>     make your contribution REUSE compliant.
>
>     What do you think?
>
>     Cheers,
>     Mark
>
>     On Tue, Dec 10, 2024 at 11:09 AM 'ayoub...@googlemail.com' via
>     swupdate <swup...@googlegroups.com> wrote:
>      >
>      > Hi Stefano,
>      >
>      > any update on this Patch ?
>      >
>      > Best regards
>      >
>      > On Friday, November 29, 2024 at 2:51:03 PM UTC+1 Ayoub Zaki wrote:
>      >>
>      >> This will enable seamless Development of **swupdate** Project
>     with VSCode inside Docker container.
>      >>
>      >> The VSCode Container provides:
>      >>
>      >> * Automatic Mapping of the host user UID/GID inside the container
>      >> * GCC Cross-Compilers (armhf/aarch64)
>      >> * GDB Multiarch for Debugging
>      >> * Remote SSH on the Target with seamless ssh mapping of the Host
>     inside the container (Linux/Windows WSL)
>      >> * Git and Git Extensions to work and send Patches
>      >> * Python modules to work with swupdateclient
>      >>
>      >> Note: This require Docker installation for Linux/or Windows :
>      >> [1] https://docs.docker.com/engine/install <https://
>     docs.docker.com/engine/install>
>      >>
>      >> VSCode Extensions (extensions.json) will be recommended for the
>     installation
>      >>
>      >> For more Information :
>      >> [2] https://code.visualstudio.com/docs/devcontainers/containers
>     <https://code.visualstudio.com/docs/devcontainers/containers>
>      >> [3] https://www.youtube.com/watch?v=C_5tDWsWSj0 <https://
>     www.youtube.com/watch?v=C_5tDWsWSj0>
>      >> [4] https://www.youtube.com/watch?v=b1RavPr_878 <https://
>     www.youtube.com/watch?v=b1RavPr_878>
>      >>
>      >> Signed-off-by: Ayoub Zaki <ayoub...@embetrix.com>
>      >> ---
>      >> .devcontainer/Dockerfile | 116 ++++++++++++++++++++++++++++++++
>      >> .devcontainer/devcontainer.json | 29 ++++++++
>      >> .gitignore | 4 ++
>      >> .vscode/extensions.json | 10 +++
>      >> .vscode/tasks.json | 74 ++++++++++++++++++++
>      >> 5 files changed, 233 insertions(+)
>      >> create mode 100644 .devcontainer/Dockerfile
>      >> create mode 100644 .devcontainer/devcontainer.json
>      >> create mode 100644 .vscode/extensions.json
>      >> create mode 100644 .vscode/tasks.json
>      >>
>      >> diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
>      >> new file mode 100644
>      >> index 00000000..0045b850
>      >> --- /dev/null
>      >> +++ b/.devcontainer/Dockerfile
>      >> @@ -0,0 +1,116 @@
>      >> +FROM debian:12
>      >> +
>      >> +RUN dpkg --add-architecture armhf && apt-get update
>      >> +RUN dpkg --add-architecture arm64 && apt-get update
>      >> +RUN apt-get install -y \
>      >> + build-essential \
>      >> + crossbuild-essential-armhf \
>      >> + crossbuild-essential-arm64 \
>      >> + gdb-multiarch \
>      >> + cmake \
>      >> + ccache \
>      >> + qemu-user
>      >> +
>      >> +# Install swupdate native dependencies
>      >> +RUN apt-get install -y \
>      >> + libebgenv-dev \
>      >> + libmtd-dev \
>      >> + libubi-dev \
>      >> + libzck-dev \
>      >> + libcurl4-openssl-dev \
>      >> + libssl-dev \
>      >> + libwolfssl-dev \
>      >> + libsystemd-dev \
>      >> + libjson-c-dev \
>      >> + libncurses5-dev \
>      >> + libncursesw5-dev \
>      >> + libarchive-dev \
>      >> + libconfig-dev \
>      >> + libz-dev \
>      >> + libyaml-dev \
>      >> + lua5.2-dev
>      >> +
>      >> +# Install swupdate dependencies for armhf
>      >> +RUN apt-get install -y \
>      >> + libebgenv-dev:armhf \
>      >> + libmtd-dev:armhf \
>      >> + libubi-dev:armhf \
>      >> + libzck-dev:armhf \
>      >> + libcurl4-openssl-dev:armhf \
>      >> + libssl-dev:armhf \
>      >> + libwolfssl-dev:armhf \
>      >> + libsystemd-dev:armhf \
>      >> + libjson-c-dev:armhf \
>      >> + libncurses5-dev:armhf \
>      >> + libncursesw5-dev:armhf \
>      >> + libarchive-dev:armhf \
>      >> + libconfig-dev:armhf \
>      >> + libz-dev:armhf \
>      >> + libyaml-dev:armhf \
>      >> + lua5.2-dev:armhf
>      >> +
>      >> +# Install swupdate dependencies for arm64
>      >> +RUN apt-get install -y \
>      >> + libebgenv-dev:arm64 \
>      >> + libmtd-dev:arm64 \
>      >> + libubi-dev:arm64 \
>      >> + libzck-dev:arm64 \
>      >> + libcurl4-openssl-dev:arm64 \
>      >> + libssl-dev:arm64 \
>      >> + libwolfssl-dev:arm64 \
>      >> + libsystemd-dev:arm64 \
>      >> + libjson-c-dev:arm64 \
>      >> + libncurses5-dev:arm64 \
>      >> + libncursesw5-dev:arm64 \
>      >> + libarchive-dev:arm64 \
>      >> + libconfig-dev:arm64 \
>      >> + libz-dev:arm64 \
>      >> + libyaml-dev:arm64 \
>      >> + lua5.2-dev:arm64
>      >> +
>      >> +# Aditional development tools
>      >> +RUN apt-get install -y \
>      >> + git-core \
>      >> + git-man \
>      >> + git-email \
>      >> + sudo \
>      >> + nano \
>      >> + vim \
>      >> + curl \
>      >> + openssh-client \
>      >> + bash-completion
>      >> +
>      >> +# Install libubootenv library (new version not available in
>     debian)
>      >> +# for native, armhf and arm64
>      >> +RUN git clone https://github.com/sbabic/libubootenv.git
>     <https://github.com/sbabic/libubootenv.git> && \
>      >> + cd libubootenv && \
>      >> + cmake -DCMAKE_INSTALL_LIBDIR=/usr/lib/x86_64-linux-gnu \
>      >> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
>      >> + make -j && \
>      >> + sudo make install && git clean -fdx && \
>      >> + cmake -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
>      >> + -DCMAKE_INSTALL_LIBDIR=/usr/lib/arm-linux-gnueabihf \
>      >> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
>      >> + make -j && \
>      >> + sudo make install && git clean -fdx && \
>      >> + cmake -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
>      >> + -DCMAKE_INSTALL_LIBDIR=/usr/lib/aarch64-linux-gnu \
>      >> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
>      >> + make -j && \
>      >> + sudo make install
>      >> +
>      >> +# Install python3 and dependencie required for python
>     swupdateclient
>      >> +RUN apt-get install -y \
>      >> + python3 \
>      >> + python3-pip \
>      >> + python3-requests \
>      >> + python3-websockets \
>      >> + python3-termcolor
>      >> +
>      >> +# Add swupdate user
>      >> +RUN useradd -ms /bin/bash swupdate
>      >> +RUN echo "swupdate ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers
>      >> +USER swupdate
>      >> +WORKDIR /home/swupdate
>      >> +
>      >> +CMD ["/bin/bash"]
>      >> diff --git a/.devcontainer/devcontainer.json b/.devcontainer/
>     devcontainer.json
>      >> new file mode 100644
>      >> index 00000000..cb4c5120
>      >> --- /dev/null
>      >> +++ b/.devcontainer/devcontainer.json
>      >> @@ -0,0 +1,29 @@
>      >> +{
>      >> + "name": "swupdate-docker",
>      >> + "build": {
>      >> + "dockerfile": "Dockerfile"
>      >> + },
>      >> +
>      >> + "customizations": {
>      >> + "vscode": {
>      >> + "settings": {
>      >> + "terminal.integrated.profiles.linux": {
>      >> + "bash": {
>      >> + "path": "/bin/bash",
>      >> + "args": ["-l"]
>      >> + }
>      >> + },
>      >> + "terminal.integrated.defaultProfile.linux": "bash"
>      >> + },
>      >> + "extensions": [
>      >> + "ms-vscode.cpptools",
>      >> + "eamodio.gitlens"
>      >> + ]
>      >> + }
>      >> + },
>      >> +
>      >> + // Map the host .ssh folder into the container for a seamless
>     ssh experience
>      >> + "mounts": [
>      >> + "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/
>     home/swupdate/.ssh,type=bind,consistency=cached"
>      >> + ]
>      >> +}
>      >> diff --git a/.gitignore b/.gitignore
>      >> index 4755ff07..68cd2ee3 100644
>      >> --- a/.gitignore
>      >> +++ b/.gitignore
>      >> @@ -127,6 +127,10 @@ web-app/swupdate-www.tar.gz
>      >> !.gitlab-ci.yml
>      >> !.github
>      >>
>      >> +# vscode
>      >> +!.devcontainer
>      >> +!.vscode
>      >> +
>      >> # swupdateclient
>      >> Pipfile
>      >> Pipfile.lock
>      >> diff --git a/.vscode/extensions.json b/.vscode/extensions.json
>      >> new file mode 100644
>      >> index 00000000..4bdb6854
>      >> --- /dev/null
>      >> +++ b/.vscode/extensions.json
>      >> @@ -0,0 +1,10 @@
>      >> +{
>      >> + "recommendations": [
>      >> + "ms-vscode-remote.remote-containers",
>      >> + "ms-vscode-remote.remote-wsl",
>      >> + "ms-vscode-remote.vscode-remote-extensionpack",
>      >> + "ms-vscode.cpptools-extension-pack",
>      >> + "ms-vscode.cpptools",
>      >> + "eamodio.gitlens",
>      >> + ]
>      >> +}
>      >> diff --git a/.vscode/tasks.json b/.vscode/tasks.json
>      >> new file mode 100644
>      >> index 00000000..3eec68f5
>      >> --- /dev/null
>      >> +++ b/.vscode/tasks.json
>      >> @@ -0,0 +1,74 @@
>      >> +{
>      >> + "version": "2.0.0",
>      >> + "tasks": [
>      >> + {
>      >> + "type": "shell",
>      >> + "label": "configure",
>      >> + "command": "make",
>      >> + "group": "build",
>      >> + "problemMatcher": [],
>      >> + "detail": "Configure Swupdate using menuconfig",
>      >> + "args": [
>      >> + "menuconfig"
>      >> + ],
>      >> + },
>      >> + {
>      >> + "type": "shell",
>      >> + "label": "clean",
>      >> + "command": "make",
>      >> + "group": "build",
>      >> + "problemMatcher": [],
>      >> + "detail": "Clean Swupdate build",
>      >> + "args": [
>      >> + "clean"
>      >> + ],
>      >> + },
>      >> + {
>      >> + "type": "shell",
>      >> + "label": "compile",
>      >> + "command": "make",
>      >> + "group": "build",
>      >> + "problemMatcher": [],
>      >> + "detail": "Compile Swupdate (native)",
>      >> + "args": [
>      >> + "-j"
>      >> + ],
>      >> + },
>      >> + {
>      >> + "type": "shell",
>      >> + "label": "cross compile armhf",
>      >> + "command": "make",
>      >> + "group": "build",
>      >> + "problemMatcher": [],
>      >> + "detail": "Cross-Compile Swupdate for armhf",
>      >> + "args": [
>      >> + "-j"
>      >> + ],
>      >> + "options": {
>      >> + "env": {
>      >> + "CC": "arm-linux-gnueabihf-gcc",
>      >> + "LD": "arm-linux-gnueabihf-gcc",
>      >> + "CROSS_COMPILE": "arm-linux-gnueabihf-"
>      >> + }
>      >> + }
>      >> + },
>      >> + {
>      >> + "type": "shell",
>      >> + "label": "cross compile aarch64",
>      >> + "command": "make",
>      >> + "group": "build",
>      >> + "problemMatcher": [],
>      >> + "detail": "Cross-Compile Swupdate for armhf",
>      >> + "args": [
>      >> + "-j"
>      >> + ],
>      >> + "options": {
>      >> + "env": {
>      >> + "CC": "aarch64-linux-gnu-gcc",
>      >> + "LD": "aarch64-linux-gnu-gcc",
>      >> + "CROSS_COMPILE": "aarch64-linux-gnu-"
>      >> + }
>      >> + }
>      >> + }
>      >> + ]
>      >> +}
>      >> --
>      >> 2.43.0
>      >>
>      > --
>      > You received this message because you are subscribed to the
>     Google Groups "swupdate" group.
>      > To unsubscribe from this group and stop receiving emails from it,
>     send an email to swupdate+u...@googlegroups.com.
>      > To view this discussion visit https://groups.google.com/d/msgid/
>     swupdate/92af3ff2-e1cc-4568-bd80-ff29a9a58df4n%40googlegroups.com
>     <https://groups.google.com/d/msgid/swupdate/92af3ff2-e1cc-4568-bd80-
>     ff29a9a58df4n%40googlegroups.com>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swupdate+unsubscribe@googlegroups.com
> <mailto:swupdate+unsubscribe@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/
> swupdate/f70373dc-3f65-4c26-b6ee-3a68de58a3a0n%40googlegroups.com
> <https://groups.google.com/d/msgid/swupdate/f70373dc-3f65-4c26-
> b6ee-3a68de58a3a0n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Ayoub Zaki Dec. 16, 2024, 1:18 p.m. UTC | #5
Hello Stefano,

On Saturday, December 14, 2024 at 6:37:19 PM UTC+1 Stefano Babic wrote:

Hi Ayoub, 

On 13.12.24 11:27, 'ayoub...@googlemail.com' via swupdate wrote: 
> Hello Mark, 
> 
> Thank you for taking the time to review the patch. 
> 
> Could you clarify which functionalities are not fully understood? I’d be 
> happy to provide further explanations. 
> 
> The current .devcontainer/Dockerfile and .devcontainer/devcontainer.json 
> configurations are kept basic. 
> 
> They include all necessary dependencies to compile "native" x86-x64 as 
> well as armhf/aarch64 and to run tests. 
> 
> As for the ci/setup.sh script, it cannot be directly used in this 
> context since it relies on Ubuntu, which complicates adding support for 
> additional architectures like armhf and aarch64, this is why I used it 
> to Debian instead. 

The choice for Ubuntu was just done because this was the platform I used 
to build and test natively. It is not mandatory and we can agree to 
switch from Ubuntu to Debian. 

> 
> For the CI, I agree it could be beneficial to introduce a dedicated 
> Dockerfile. 

The way I use Ci is via a gitlab-runner that already runs a docker 
executor, using the Ubuntu image. Is it possible to start the runner 
with a Dockerfile instead of a prebuilt image ? As far as I know, the 
image is just picked up from somewhere.


I think gitlab CI does not support that directly (only Jenkins do), we need 
to add a step to build the image from Dockerfile:

[1] https://gitlab.com/gitlab-org/gitlab/-/issues/22801
[2] https://stackoverflow.com/questions/46266152/how-to-use-dockerfile-in-gitlab-ci



> In the future, we could aim to converge the VS Code 
> devcontainer and the CI Docker configurations to simplify maintenance 
> and ensure consistency. 
> 
> Looking forward to hearing your thoughts. 

IMHO if we want to provide a dev container, we should be sure that the 
project can be built with all configuration. I have tested to build into 
VSCode in container, and I get these errors: 

========== 
/usr/bin/ld: cannot find -lmbedcrypto: No such file or directory 
/usr/bin/ld: cannot find -lmbedtls: No such file or directory 
/usr/bin/ld: cannot find -lmbedx509: No such file or directory 
/usr/bin/ld: cannot find -lfdisk: No such file or directory 
/usr/bin/ld: cannot find -lblkid: No such file or directory 
/usr/bin/ld: cannot find -lext2fs: No such file or directory 
/usr/bin/ld: cannot find -luuid: No such file or directory 
/usr/bin/ld: cannot find -lblkid: No such file or directory 
/usr/bin/ld: cannot find -lbtrfsutil: No such file or directory 
/usr/bin/ld: cannot find -ludev: No such file or directory 
/usr/bin/ld: cannot find -lblkid: No such file or directory 
/usr/bin/ld: cannot find -lrsync: No such file or directory 
/usr/bin/ld: cannot find -lzmq: No such file or directory 
/usr/bin/ld: cannot find -lgpiod: No such file or directory 
/usr/bin/ld: cannot find -lwebsockets: No such file or directory 
/usr/bin/ld: cannot find -luriparser: No such file or directory


Okay good to know, I will check if all the dependencies can be added for 
all the architectures, but I suspect some of the (same) package (from 
different arch) will step on each others toes.




because libraries are not in container, so the container isn't complete. 

I agree that a short documentation about how to use it helps (use 
"reopen in dev container" in VSCode, etc.). 

I will also suggest to split the patch: Dockerfile can be used 
independently from VSCode, for example. For the extension, VSCode 
rejected to do anything without installing LLDB in container. If this 
doesn't happen only to me, it should be added to the extensions.json. 

Best regards, 
Stefano


I will get back to it during the X-mass holidays.

best regards 



> 
> Best regards, 
> Ayoub 
> 
> On Friday, December 13, 2024 at 9:06:36 AM UTC+1 Mark Jonas wrote: 
> 
> Hi Ayoub, 
> 
> To me a good step towards consideration of the patch would be to break 
> it down into a small, first step now and to improve it in later steps. 
> 
> On the one hand there is a lot of functionality in your setup, even 
> things I do not understand why they are needed in the decontainer. On 
> the other hand, there are some essential things missing, e.g. to be 
> able to run all tests. What about starting with a simple, basic 
> devcontainer which can compile swupdate on x86-x64 including running 
> the tests. And then later building it up step by step? 
> 
> I think a good starting point would be to start with a minimal 
> .devcontainer/Dockerfile and .devcontainer/devcontainer.json. To avoid 
> duplication and ease maintenance I recommend to use the existing 
> ci/setup.sh for installing the dependencies into the devcontainer. 
> 
> Please also consider adding user documentation. And do not forget to 
> make your contribution REUSE compliant. 
> 
> What do you think? 
> 
> Cheers, 
> Mark 
> 
> On Tue, Dec 10, 2024 at 11:09 AM 'ayoub...@googlemail.com' via 
> swupdate <swup...@googlegroups.com> wrote: 
> > 
> > Hi Stefano, 
> > 
> > any update on this Patch ? 
> > 
> > Best regards 
> > 
> > On Friday, November 29, 2024 at 2:51:03 PM UTC+1 Ayoub Zaki wrote: 
> >> 
> >> This will enable seamless Development of **swupdate** Project 
> with VSCode inside Docker container. 
> >> 
> >> The VSCode Container provides: 
> >> 
> >> * Automatic Mapping of the host user UID/GID inside the container 
> >> * GCC Cross-Compilers (armhf/aarch64) 
> >> * GDB Multiarch for Debugging 
> >> * Remote SSH on the Target with seamless ssh mapping of the Host 
> inside the container (Linux/Windows WSL) 
> >> * Git and Git Extensions to work and send Patches 
> >> * Python modules to work with swupdateclient 
> >> 
> >> Note: This require Docker installation for Linux/or Windows : 
> >> [1] https://docs.docker.com/engine/install <https:// 
> docs.docker.com/engine/install> 
> >> 
> >> VSCode Extensions (extensions.json) will be recommended for the 
> installation 
> >> 
> >> For more Information : 
> >> [2] https://code.visualstudio.com/docs/devcontainers/containers 
> <https://code.visualstudio.com/docs/devcontainers/containers> 
> >> [3] https://www.youtube.com/watch?v=C_5tDWsWSj0 <https:// 
> www.youtube.com/watch?v=C_5tDWsWSj0> 
> >> [4] https://www.youtube.com/watch?v=b1RavPr_878 <https:// 
> www.youtube.com/watch?v=b1RavPr_878> 
> >> 
> >> Signed-off-by: Ayoub Zaki <ayoub...@embetrix.com> 
> >> --- 
> >> .devcontainer/Dockerfile | 116 ++++++++++++++++++++++++++++++++ 
> >> .devcontainer/devcontainer.json | 29 ++++++++ 
> >> .gitignore | 4 ++ 
> >> .vscode/extensions.json | 10 +++ 
> >> .vscode/tasks.json | 74 ++++++++++++++++++++ 
> >> 5 files changed, 233 insertions(+) 
> >> create mode 100644 .devcontainer/Dockerfile 
> >> create mode 100644 .devcontainer/devcontainer.json 
> >> create mode 100644 .vscode/extensions.json 
> >> create mode 100644 .vscode/tasks.json 
> >> 
> >> diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile 
> >> new file mode 100644 
> >> index 00000000..0045b850 
> >> --- /dev/null 
> >> +++ b/.devcontainer/Dockerfile 
> >> @@ -0,0 +1,116 @@ 
> >> +FROM debian:12 
> >> + 
> >> +RUN dpkg --add-architecture armhf && apt-get update 
> >> +RUN dpkg --add-architecture arm64 && apt-get update 
> >> +RUN apt-get install -y \ 
> >> + build-essential \ 
> >> + crossbuild-essential-armhf \ 
> >> + crossbuild-essential-arm64 \ 
> >> + gdb-multiarch \ 
> >> + cmake \ 
> >> + ccache \ 
> >> + qemu-user 
> >> + 
> >> +# Install swupdate native dependencies 
> >> +RUN apt-get install -y \ 
> >> + libebgenv-dev \ 
> >> + libmtd-dev \ 
> >> + libubi-dev \ 
> >> + libzck-dev \ 
> >> + libcurl4-openssl-dev \ 
> >> + libssl-dev \ 
> >> + libwolfssl-dev \ 
> >> + libsystemd-dev \ 
> >> + libjson-c-dev \ 
> >> + libncurses5-dev \ 
> >> + libncursesw5-dev \ 
> >> + libarchive-dev \ 
> >> + libconfig-dev \ 
> >> + libz-dev \ 
> >> + libyaml-dev \ 
> >> + lua5.2-dev 
> >> + 
> >> +# Install swupdate dependencies for armhf 
> >> +RUN apt-get install -y \ 
> >> + libebgenv-dev:armhf \ 
> >> + libmtd-dev:armhf \ 
> >> + libubi-dev:armhf \ 
> >> + libzck-dev:armhf \ 
> >> + libcurl4-openssl-dev:armhf \ 
> >> + libssl-dev:armhf \ 
> >> + libwolfssl-dev:armhf \ 
> >> + libsystemd-dev:armhf \ 
> >> + libjson-c-dev:armhf \ 
> >> + libncurses5-dev:armhf \ 
> >> + libncursesw5-dev:armhf \ 
> >> + libarchive-dev:armhf \ 
> >> + libconfig-dev:armhf \ 
> >> + libz-dev:armhf \ 
> >> + libyaml-dev:armhf \ 
> >> + lua5.2-dev:armhf 
> >> + 
> >> +# Install swupdate dependencies for arm64 
> >> +RUN apt-get install -y \ 
> >> + libebgenv-dev:arm64 \ 
> >> + libmtd-dev:arm64 \ 
> >> + libubi-dev:arm64 \ 
> >> + libzck-dev:arm64 \ 
> >> + libcurl4-openssl-dev:arm64 \ 
> >> + libssl-dev:arm64 \ 
> >> + libwolfssl-dev:arm64 \ 
> >> + libsystemd-dev:arm64 \ 
> >> + libjson-c-dev:arm64 \ 
> >> + libncurses5-dev:arm64 \ 
> >> + libncursesw5-dev:arm64 \ 
> >> + libarchive-dev:arm64 \ 
> >> + libconfig-dev:arm64 \ 
> >> + libz-dev:arm64 \ 
> >> + libyaml-dev:arm64 \ 
> >> + lua5.2-dev:arm64 
> >> + 
> >> +# Aditional development tools 
> >> +RUN apt-get install -y \ 
> >> + git-core \ 
> >> + git-man \ 
> >> + git-email \ 
> >> + sudo \ 
> >> + nano \ 
> >> + vim \ 
> >> + curl \ 
> >> + openssh-client \ 
> >> + bash-completion 
> >> + 
> >> +# Install libubootenv library (new version not available in 
> debian) 
> >> +# for native, armhf and arm64 
> >> +RUN git clone https://github.com/sbabic/libubootenv.git 
> <https://github.com/sbabic/libubootenv.git> && \ 
> >> + cd libubootenv && \ 
> >> + cmake -DCMAKE_INSTALL_LIBDIR=/usr/lib/x86_64-linux-gnu \ 
> >> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \ 
> >> + make -j && \ 
> >> + sudo make install && git clean -fdx && \ 
> >> + cmake -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \ 
> >> + -DCMAKE_INSTALL_LIBDIR=/usr/lib/arm-linux-gnueabihf \ 
> >> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \ 
> >> + make -j && \ 
> >> + sudo make install && git clean -fdx && \ 
> >> + cmake -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \ 
> >> + -DCMAKE_INSTALL_LIBDIR=/usr/lib/aarch64-linux-gnu \ 
> >> + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \ 
> >> + make -j && \ 
> >> + sudo make install 
> >> + 
> >> +# Install python3 and dependencie required for python 
> swupdateclient 
> >> +RUN apt-get install -y \ 
> >> + python3 \ 
> >> + python3-pip \ 
> >> + python3-requests \ 
> >> + python3-websockets \ 
> >> + python3-termcolor 
> >> + 
> >> +# Add swupdate user 
> >> +RUN useradd -ms /bin/bash swupdate 
> >> +RUN echo "swupdate ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers 
> >> +USER swupdate 
> >> +WORKDIR /home/swupdate 
> >> + 
> >> +CMD ["/bin/bash"] 
> >> diff --git a/.devcontainer/devcontainer.json b/.devcontainer/ 
> devcontainer.json 
> >> new file mode 100644 
> >> index 00000000..cb4c5120 
> >> --- /dev/null 
> >> +++ b/.devcontainer/devcontainer.json 
> >> @@ -0,0 +1,29 @@ 
> >> +{ 
> >> + "name": "swupdate-docker", 
> >> + "build": { 
> >> + "dockerfile": "Dockerfile" 
> >> + }, 
> >> + 
> >> + "customizations": { 
> >> + "vscode": { 
> >> + "settings": { 
> >> + "terminal.integrated.profiles.linux": { 
> >> + "bash": { 
> >> + "path": "/bin/bash", 
> >> + "args": ["-l"] 
> >> + } 
> >> + }, 
> >> + "terminal.integrated.defaultProfile.linux": "bash" 
> >> + }, 
> >> + "extensions": [ 
> >> + "ms-vscode.cpptools", 
> >> + "eamodio.gitlens" 
> >> + ] 
> >> + } 
> >> + }, 
> >> + 
> >> + // Map the host .ssh folder into the container for a seamless 
> ssh experience 
> >> + "mounts": [ 
> >> + "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/ 
> home/swupdate/.ssh,type=bind,consistency=cached" 
> >> + ] 
> >> +} 
> >> diff --git a/.gitignore b/.gitignore 
> >> index 4755ff07..68cd2ee3 100644 
> >> --- a/.gitignore 
> >> +++ b/.gitignore 
> >> @@ -127,6 +127,10 @@ web-app/swupdate-www.tar.gz 
> >> !.gitlab-ci.yml 
> >> !.github 
> >> 
> >> +# vscode 
> >> +!.devcontainer 
> >> +!.vscode 
> >> + 
> >> # swupdateclient 
> >> Pipfile 
> >> Pipfile.lock 
> >> diff --git a/.vscode/extensions.json b/.vscode/extensions.json 
> >> new file mode 100644 
> >> index 00000000..4bdb6854 
> >> --- /dev/null 
> >> +++ b/.vscode/extensions.json 
> >> @@ -0,0 +1,10 @@ 
> >> +{ 
> >> + "recommendations": [ 
> >> + "ms-vscode-remote.remote-containers", 
> >> + "ms-vscode-remote.remote-wsl", 
> >> + "ms-vscode-remote.vscode-remote-extensionpack", 
> >> + "ms-vscode.cpptools-extension-pack", 
> >> + "ms-vscode.cpptools", 
> >> + "eamodio.gitlens", 
> >> + ] 
> >> +} 
> >> diff --git a/.vscode/tasks.json b/.vscode/tasks.json 
> >> new file mode 100644 
> >> index 00000000..3eec68f5 
> >> --- /dev/null 
> >> +++ b/.vscode/tasks.json 
> >> @@ -0,0 +1,74 @@ 
> >> +{ 
> >> + "version": "2.0.0", 
> >> + "tasks": [ 
> >> + { 
> >> + "type": "shell", 
> >> + "label": "configure", 
> >> + "command": "make", 
> >> + "group": "build", 
> >> + "problemMatcher": [], 
> >> + "detail": "Configure Swupdate using menuconfig", 
> >> + "args": [ 
> >> + "menuconfig" 
> >> + ], 
> >> + }, 
> >> + { 
> >> + "type": "shell", 
> >> + "label": "clean", 
> >> + "command": "make", 
> >> + "group": "build", 
> >> + "problemMatcher": [], 
> >> + "detail": "Clean Swupdate build", 
> >> + "args": [ 
> >> + "clean" 
> >> + ], 
> >> + }, 
> >> + { 
> >> + "type": "shell", 
> >> + "label": "compile", 
> >> + "command": "make", 
> >> + "group": "build", 
> >> + "problemMatcher": [], 
> >> + "detail": "Compile Swupdate (native)", 
> >> + "args": [ 
> >> + "-j" 
> >> + ], 
> >> + }, 
> >> + { 
> >> + "type": "shell", 
> >> + "label": "cross compile armhf", 
> >> + "command": "make", 
> >> + "group": "build", 
> >> + "problemMatcher": [], 
> >> + "detail": "Cross-Compile Swupdate for armhf", 
> >> + "args": [ 
> >> + "-j" 
> >> + ], 
> >> + "options": { 
> >> + "env": { 
> >> + "CC": "arm-linux-gnueabihf-gcc", 
> >> + "LD": "arm-linux-gnueabihf-gcc", 
> >> + "CROSS_COMPILE": "arm-linux-gnueabihf-" 
> >> + } 
> >> + } 
> >> + }, 
> >> + { 
> >> + "type": "shell", 
> >> + "label": "cross compile aarch64", 
> >> + "command": "make", 
> >> + "group": "build", 
> >> + "problemMatcher": [], 
> >> + "detail": "Cross-Compile Swupdate for armhf", 
> >> + "args": [ 
> >> + "-j" 
> >> + ], 
> >> + "options": { 
> >> + "env": { 
> >> + "CC": "aarch64-linux-gnu-gcc", 
> >> + "LD": "aarch64-linux-gnu-gcc", 
> >> + "CROSS_COMPILE": "aarch64-linux-gnu-" 
> >> + } 
> >> + } 
> >> + } 
> >> + ] 
> >> +} 
> >> -- 
> >> 2.43.0 
> >> 
> > -- 
> > You received this message because you are subscribed to the 
> Google Groups "swupdate" group. 
> > To unsubscribe from this group and stop receiving emails from it, 
> send an email to swupdate+u...@googlegroups.com. 
> > To view this discussion visit https://groups.google.com/d/msgid/ 
> swupdate/92af3ff2-e1cc-4568-bd80-ff29a9a58df4n%40googlegroups.com 
> <https://groups.google.com/d/msgid/swupdate/92af3ff2-e1cc-4568-bd80- 
> ff29a9a58df4n%40googlegroups.com>. 
> 
> -- 
> You received this message because you are subscribed to the Google 
> Groups "swupdate" group. 
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to swupdate+u...@googlegroups.com 
> <mailto:swupdate+u...@googlegroups.com>. 
> To view this discussion visit https://groups.google.com/d/msgid/ 
> swupdate/f70373dc-3f65-4c26-b6ee-3a68de58a3a0n%40googlegroups.com 
> <https://groups.google.com/d/msgid/swupdate/f70373dc-3f65-4c26- 
> b6ee-3a68de58a3a0n%40googlegroups.com?utm_medium=email&utm_source=footer>.
diff mbox series

Patch

diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 00000000..0045b850
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,116 @@ 
+FROM debian:12
+
+RUN dpkg --add-architecture armhf && apt-get update
+RUN dpkg --add-architecture arm64 && apt-get update
+RUN apt-get install -y \
+        build-essential \
+        crossbuild-essential-armhf \
+        crossbuild-essential-arm64 \
+        gdb-multiarch \
+        cmake \
+        ccache \
+        qemu-user
+
+# Install swupdate native dependencies
+RUN apt-get install -y \
+        libebgenv-dev \
+        libmtd-dev \
+        libubi-dev \
+        libzck-dev \
+        libcurl4-openssl-dev \
+        libssl-dev \
+        libwolfssl-dev  \
+        libsystemd-dev \
+        libjson-c-dev \
+        libncurses5-dev \
+        libncursesw5-dev \
+        libarchive-dev \
+        libconfig-dev \
+        libz-dev \
+        libyaml-dev \
+        lua5.2-dev
+
+# Install swupdate dependencies for armhf
+RUN apt-get install -y \
+        libebgenv-dev:armhf  \
+        libmtd-dev:armhf  \
+        libubi-dev:armhf  \
+        libzck-dev:armhf  \
+        libcurl4-openssl-dev:armhf  \
+        libssl-dev:armhf  \
+        libwolfssl-dev:armhf  \
+        libsystemd-dev:armhf  \
+        libjson-c-dev:armhf  \
+        libncurses5-dev:armhf  \
+        libncursesw5-dev:armhf  \
+        libarchive-dev:armhf  \
+        libconfig-dev:armhf \
+        libz-dev:armhf \
+        libyaml-dev:armhf \
+        lua5.2-dev:armhf
+
+# Install swupdate dependencies for arm64
+RUN apt-get install -y \
+        libebgenv-dev:arm64  \
+        libmtd-dev:arm64  \
+        libubi-dev:arm64  \
+        libzck-dev:arm64  \
+        libcurl4-openssl-dev:arm64  \
+        libssl-dev:arm64  \
+        libwolfssl-dev:arm64  \
+        libsystemd-dev:arm64  \
+        libjson-c-dev:arm64  \
+        libncurses5-dev:arm64  \
+        libncursesw5-dev:arm64  \
+        libarchive-dev:arm64  \
+        libconfig-dev:arm64  \
+        libz-dev:arm64 \
+        libyaml-dev:arm64 \
+        lua5.2-dev:arm64
+
+# Aditional development tools
+RUN apt-get install -y \
+        git-core \
+        git-man \
+        git-email \
+        sudo \
+        nano \
+        vim \
+        curl \
+        openssh-client \
+        bash-completion
+
+# Install libubootenv library (new version not available in debian)
+# for native, armhf and arm64
+RUN  git clone https://github.com/sbabic/libubootenv.git && \
+        cd libubootenv && \
+        cmake  -DCMAKE_INSTALL_LIBDIR=/usr/lib/x86_64-linux-gnu \
+                -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
+        make -j && \
+        sudo make install && git clean -fdx && \
+        cmake -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
+                -DCMAKE_INSTALL_LIBDIR=/usr/lib/arm-linux-gnueabihf \
+                -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
+        make -j && \
+        sudo make install && git clean -fdx && \
+        cmake -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
+                -DCMAKE_INSTALL_LIBDIR=/usr/lib/aarch64-linux-gnu \
+                -DCMAKE_INSTALL_INCLUDEDIR=/usr/include . && \
+        make -j && \
+        sudo make install
+
+# Install python3 and dependencie required for python swupdateclient
+RUN apt-get install -y \
+        python3 \
+        python3-pip \
+        python3-requests \
+        python3-websockets \
+        python3-termcolor
+
+# Add swupdate user
+RUN useradd -ms /bin/bash swupdate
+RUN echo "swupdate ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers
+USER swupdate
+WORKDIR /home/swupdate
+
+CMD ["/bin/bash"]
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 00000000..cb4c5120
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,29 @@ 
+{
+	"name": "swupdate-docker",
+	"build": {
+		"dockerfile": "Dockerfile"
+	},
+
+	"customizations": {
+		"vscode": {
+			"settings": {
+				"terminal.integrated.profiles.linux": {
+					"bash": {
+					  "path": "/bin/bash",
+					  "args": ["-l"]
+					}
+				},
+				"terminal.integrated.defaultProfile.linux": "bash"
+			},
+			"extensions": [
+				"ms-vscode.cpptools",
+				"eamodio.gitlens"
+			]
+		}
+	},
+
+	// Map the host .ssh folder into the container for a seamless ssh experience
+	"mounts": [
+		"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/swupdate/.ssh,type=bind,consistency=cached"
+	]
+}
diff --git a/.gitignore b/.gitignore
index 4755ff07..68cd2ee3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -127,6 +127,10 @@  web-app/swupdate-www.tar.gz
 !.gitlab-ci.yml
 !.github
 
+# vscode
+!.devcontainer
+!.vscode
+
 # swupdateclient
 Pipfile
 Pipfile.lock
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 00000000..4bdb6854
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,10 @@ 
+{
+	"recommendations": [
+                "ms-vscode-remote.remote-containers",
+                "ms-vscode-remote.remote-wsl",
+                "ms-vscode-remote.vscode-remote-extensionpack",
+                "ms-vscode.cpptools-extension-pack",
+                "ms-vscode.cpptools",
+                "eamodio.gitlens",
+	]
+}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 00000000..3eec68f5
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,74 @@ 
+{
+	"version": "2.0.0",
+	"tasks": [
+		{
+			"type": "shell",
+			"label": "configure",
+			"command": "make",
+			"group": "build",
+			"problemMatcher": [],
+			"detail": "Configure Swupdate using menuconfig",
+			"args": [
+				"menuconfig"
+			],
+		},
+		{
+			"type": "shell",
+			"label": "clean",
+			"command": "make",
+			"group": "build",
+			"problemMatcher": [],
+			"detail": "Clean Swupdate build",
+			"args": [
+				"clean"
+			],
+		},
+		{
+			"type": "shell",
+			"label": "compile",
+			"command": "make",
+			"group": "build",
+			"problemMatcher": [],
+			"detail": "Compile Swupdate (native)",
+			"args": [
+				"-j"
+			],
+		},
+		{
+			"type": "shell",
+			"label": "cross compile armhf",
+			"command": "make",
+			"group": "build",
+			"problemMatcher": [],
+			"detail": "Cross-Compile Swupdate for armhf",
+			"args": [
+				"-j"
+			],
+			"options": {
+				"env": {
+					"CC": "arm-linux-gnueabihf-gcc",
+					"LD": "arm-linux-gnueabihf-gcc",
+					"CROSS_COMPILE": "arm-linux-gnueabihf-"
+				}
+			}
+		},
+		{
+			"type": "shell",
+			"label": "cross compile aarch64",
+			"command": "make",
+			"group": "build",
+			"problemMatcher": [],
+			"detail": "Cross-Compile Swupdate for armhf",
+			"args": [
+				"-j"
+			],
+			"options": {
+				"env": {
+					"CC": "aarch64-linux-gnu-gcc",
+					"LD": "aarch64-linux-gnu-gcc",
+					"CROSS_COMPILE": "aarch64-linux-gnu-"
+				}
+			}
+		}
+	]
+}