From 331e410892fd674ae3aa3d283c1489df7c459633 Mon Sep 17 00:00:00 2001 From: Kai Salmen Date: Tue, 28 Sep 2021 22:41:27 +0200 Subject: [PATCH] Updated several software package versions and fixed issues detected in #1 --- .gitattributes | 3 +++ CHANGELOG.md | 12 ++++++++++++ README.md | 27 +++++++++++++++++---------- installUbuntuLTS.ps1 | 8 ++++---- scripts/config/system/wsl.conf | 5 ++++- scripts/install/installDocker.sh | 9 ++++++--- scripts/install/installGradle.sh | 2 +- scripts/install/installMaven.sh | 6 +++--- scripts/install/installNodejs.sh | 5 ++++- scripts/report/listVersions.sh | 2 +- 10 files changed, 55 insertions(+), 24 deletions(-) create mode 100644 .gitattributes create mode 100644 CHANGELOG.md diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c0772fd --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto +*.sh text eol=lf diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..eebae13 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog + +## 2021-09-28 +- Fixed Issue #1: Staging area is now created if it does not exist +- Fixed Issue #2: Updated [README.md](./README.md) and updated default wsl.conf +- Updated docker-compose from `1.28.4` to `2.0.0`. Command is now `docker compose` instead of `docker-compose` +- Updated Gradle from `6.8.3`to `7.2` +- Updated Apache Maven to from `3.6.3` to `3.8.2` +- n install the latest nodejs version instead of lts version +- All other software packages are installed with the latest version +- Added [.gitattributes](.gitattributes) config to ensure sh files stay with lf line ending +- Introduced this changelog diff --git a/README.md b/README.md index 40a9181..e49d4bd 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,44 @@ Automated creation of WSL 2 Development Machine === -Welcome to the WSL Tooling repository. The aim of this project is to supply with the ability to autpmatically install a fully working WSL 2 development environment just by invoking a powershell script even without the `wsl --install` flag. +Welcome to the WSL Tooling repository. The aim of this project is to supply you with the ability to automatically install a fully working WSL 2 development environment just by invoking a powershell script even without the `wsl --install` flag. -I have fully reworked and updated the whole installation. Once your Windows is capabale of running WSL 2 instances, the Ubuntu LTS WSL 2 installation is fully automatic. +I have fully reworked and updated the whole installation. Once your Windows is capable of running WSL 2 instances, the Ubuntu LTS WSL 2 installation is fully automatic. ## Preparation -This repository must be clone on your local disk. +This repository must be cloned on your local disk. -### Enable Windows Subsystem for Linux V2 support +### Enable Windows Subsystem for Linux ***This step is only required if WSL support was never activated before on your Windows machine*** -Open a powershell with administrative privileges and execute: -Run the script to enable WSL and VM paltform on your machine +Open a powershell with **administrative** privileges and execute this script to enable WSL and VM platform on your machine. +It might be necessary to adjust the security policy (see first commnd below) because the Powershell scripts are not digitally signed (https:/go.microsoft.com/fwlink/?LinkID=135170): ```powershell +# Optional: Set Security to Bypass +Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass +# Enable WSL .\enableWSL.ps1 ``` This will take a couple of minutes. If it was not enabled before, you need to reboot Windows. A restart is required if any of the two above features have not been installed before. +### Set WSL default version to 2 + Set the default WSL version to 2. Open a powershell with administrative privileges: ```powershell .\installWSL2.ps1 ``` -## Installation +## Distribution Installation ### Download and Install Ubuntu LTS (20.04) If not already done, open a new powershell with administrative privileges and install Ubuntu LTS. You **need** to provide four arguments. If you don't specify them on command line, then the script will ask: - ``: Provide a name for the WSL that is goind to be created (e.g. `devbox`) - ``: The directory where the vhdx disk of the new WSL is stored - ``: the name of the user that is used when WSL distro is launched without `-u` -- ``: Tell if all software packages (see [Available Software](#Available-Software)) shall be installed or if `false` only a fully updated system with configured user is supplied +- ``: Use `true`|`false`. Tell if all software packages (see [Available Software](#Available-Software)) shall be installed or if `false` only a fully updated system with configured user is supplied For example, the command can look as follows: ```powershell installUbuntuLTS.ps1 devbox D:\WSL2\devbox kai true @@ -42,7 +47,7 @@ installUbuntuLTS.ps1 devbox D:\WSL2\devbox kai true ### Available Software Package If don't want to install all packages during initial WSL creation, you can install them one buy one. They are available here [./scripts](./scripts). These are currently available - Ubunut Base Package (git, virt-manager, firefox, dbus-x11, x11-apps, make, unzip) ([scripts/install/installBasePackage.sh](./scripts/install/installBasePackage.sh)) -- docker &docker-compose ([scripts/install/installDocker.sh](./scripts/install/installDocker.sh)) +- docker & compose V2 ([scripts/install/installDocker.sh](./scripts/install/installDocker.sh)) - OpenJDK 11 ([scripts/install/installOpenjdk.sh](scripts/install/installOpenjdk.sh)) - Apache Maven ([scripts/install/installMaven.sh](./scripts/install/installMaven.sh)) - Gradle ([scripts/install/installGradle.sh](./scripts/install/installGradle.sh)) @@ -55,12 +60,14 @@ If don't want to install all packages during initial WSL creation, you can insta Firefox and other tools can be installed directly with Ubuntu's package manager `apt`. Some of the above scripts also use `apt` and apply additional configuration. #### Removal -Not available yet, but with fast a internet connection and fast SSD you have the WSL recreated in approx. five minutes. :sunglasses: +Not available yet, but with a fast internet connection and fast SSD you have the WSL recreated in approx. five minutes. :sunglasses: ## Usage ### X-Server +***Once Windows 11 including WSLg is generally available this will become superfluous.*** + I recommend to use [VcXsrv](https://sourceforge.net/projects/vcxsrv/) (also available via chocolatey) to connect to user interfaces launched from WSL on display 0. The WSL linux setup configures everything properly. Use the following Powershell script to launch (it assume vcxsrv is installed at default location `C:\Program Files\VcXsrv\vcxsrv.exe`): ```powershell .\scripts\xserver\xerver.ps1 diff --git a/installUbuntuLTS.ps1 b/installUbuntuLTS.ps1 index 50b793e..2add071 100644 --- a/installUbuntuLTS.ps1 +++ b/installUbuntuLTS.ps1 @@ -22,15 +22,15 @@ Remove-Item .\staging\$wslName.zip Remove-Item -r .\staging\$wslName\ # Update the system -wsl -d $wslName -u root -- apt update`; apt upgrade -y +wsl -d $wslName -u root bash -ic "apt update; apt upgrade -y" # create your user and add it to sudoers -wsl -d $wslName -u root -e scripts/config/system/createUser.sh $username +wsl -d $wslName -u root bash -ic "./scripts/config/system/createUser.sh $username" # ensure WSL Distro is restarted when first used with user account wsl -t $wslName if ($installAllSoftware -ieq $true) { - wsl -d $wslName -u root -- ./scripts/install/installBasePackages.sh - wsl -d $wslName -u $username -- ./scripts/install/installAllSoftware.sh + wsl -d $wslName -u root bash -ic ./scripts/install/installBasePackages.sh + wsl -d $wslName -u $username bash -ic ./scripts/install/installAllSoftware.sh } diff --git a/scripts/config/system/wsl.conf b/scripts/config/system/wsl.conf index 521081e..7717735 100644 --- a/scripts/config/system/wsl.conf +++ b/scripts/config/system/wsl.conf @@ -1,6 +1,9 @@ # Enable extra metadata options by default [automount] enabled = true -mountFsTab = true +root = /mnt +options="metadata,umask=22,fmask=11" +mountFsTab = false + [Interop] appendWindowsPath = False diff --git a/scripts/install/installDocker.sh b/scripts/install/installDocker.sh index 812e5d6..3665e38 100644 --- a/scripts/install/installDocker.sh +++ b/scripts/install/installDocker.sh @@ -12,6 +12,9 @@ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubun sudo apt update sudo apt install -y --no-install-recommends docker-ce -VERSION_DOCKER_COMPOSE="1.28.4" -sudo curl -fSL "https://github.com/docker/compose/releases/download/${VERSION_DOCKER_COMPOSE}/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose -sudo chmod +x /usr/local/bin/docker-compose +VERSION_DOCKER_COMPOSE="2.0.0" +if [[ ! -d ~/.docker/cli-plugins ]]; then + mkdir -p ~/.docker/cli-plugins +fi +curl -fSL https://github.com/docker/compose/releases/download/v2.0.0/docker-compose-linux-amd64 -o ~/.docker/cli-plugins/docker-compose +chmod +x ~/.docker/cli-plugins/docker-compose diff --git a/scripts/install/installGradle.sh b/scripts/install/installGradle.sh index 4f2fbac..5eb7308 100644 --- a/scripts/install/installGradle.sh +++ b/scripts/install/installGradle.sh @@ -2,7 +2,7 @@ set -euo pipefail DIR_ME=$(realpath $(dirname $0)) -VERSION_GRADLE="6.8.3" +VERSION_GRADLE="7.2" # This script is called by any user. It shall succeed without a username parameter . ${DIR_ME}/.installUtils.sh diff --git a/scripts/install/installMaven.sh b/scripts/install/installMaven.sh index 7f56b60..c4ba003 100644 --- a/scripts/install/installMaven.sh +++ b/scripts/install/installMaven.sh @@ -2,7 +2,7 @@ set -euo pipefail DIR_ME=$(realpath $(dirname $0)) -VERSION_MAVEN="3.6.3" +VERSION_MAVEN="3.8.2" # This script is called by any user. It shall succeed without a username parameter . ${DIR_ME}/.installUtils.sh @@ -14,7 +14,7 @@ if [[ -d /usr/share/maven ]]; then fi if [[ $(which mvn | wc -l) == 0 ]]; then - + sudo mkdir -p /usr/lib/maven # download & unpack @@ -31,7 +31,7 @@ if [[ $(which mvn | wc -l) == 0 ]]; then # only use windows m2 if told to do so if [[ ${USE_WIN_M2} == "--useWinM2" ]]; then - if [[ ! -z ${WINDOWS_USER_HOME} ]]; then + if [[ -n ${WINDOWS_USER_HOME} ]]; then if [[ -f ${WINDOWS_USER_HOME}/.m2/settings.xml ]]; then cp -f ${WINDOWS_USER_HOME}/.m2/settings.xml ${HOMEDIR}/.m2 diff --git a/scripts/install/installNodejs.sh b/scripts/install/installNodejs.sh index 0cbddb7..25998fc 100644 --- a/scripts/install/installNodejs.sh +++ b/scripts/install/installNodejs.sh @@ -9,7 +9,7 @@ setUserName ${1-"$(whoami)"} if [[ $(which n | wc -l) == 0 ]]; then sudo apt install -y make - cp ${HOMEDIR}/.bashrc ${HOMEDIR}/.bashrc.bak + cp ${HOMEDIR}/.bashrc ${HOMEDIR}/.bashrc.bak curl -L https://git.io/n-install | bash -s -- -y mv ${HOMEDIR}/.bashrc.bak ${HOMEDIR}/.bashrc else @@ -22,6 +22,9 @@ modifyBashrc "configureN.sh" ". ${HOMEDIR}/.local/bin/env/configureN.sh" # source the script, so the following installation can proceed . ${HOMEDIR}/.local/bin/env/configureN.sh +# Ensure latest node version is installed +n latest + if [[ $(which tsc | wc -l) == 0 ]]; then npm install -g typescript tsc -version diff --git a/scripts/report/listVersions.sh b/scripts/report/listVersions.sh index e737109..326fb07 100644 --- a/scripts/report/listVersions.sh +++ b/scripts/report/listVersions.sh @@ -11,7 +11,7 @@ echo -e "\n\nListing software versions:" echo -e "\ndocker:" docker --version -docker-compose --version +docker --help | grep compose echo -e "\njava:" java --version