From 1b535ea2c19881a4795e93569e3452c861742df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hohwiller?= Date: Fri, 17 Dec 2021 19:23:17 +0100 Subject: [PATCH] #641: improve mirrors (#647) --- documentation/advanced-tooling-mac.asciidoc | 70 +++- .../advanced-tooling-windows.asciidoc | 2 +- .../main/resources/scripts/command/cicdgen | 16 +- .../main/resources/scripts/command/cobigen | 19 +- .../src/main/resources/scripts/command/docker | 27 +- .../main/resources/scripts/command/eclipse | 45 +- .../src/main/resources/scripts/command/gradle | 12 +- .../main/resources/scripts/command/intellij | 32 +- .../src/main/resources/scripts/command/ionic | 12 +- .../src/main/resources/scripts/command/jasypt | 11 +- .../src/main/resources/scripts/command/java | 45 +- .../main/resources/scripts/command/jenkins | 12 +- .../main/resources/scripts/command/kubectl | 11 +- .../src/main/resources/scripts/command/mvn | 18 +- scripts/src/main/resources/scripts/command/ng | 26 +- .../src/main/resources/scripts/command/node | 37 +- .../src/main/resources/scripts/command/npm | 9 +- .../main/resources/scripts/command/project | 2 +- .../src/main/resources/scripts/command/sonar | 15 +- .../src/main/resources/scripts/command/vscode | 26 +- .../src/main/resources/scripts/command/yarn | 17 +- .../main/resources/scripts/devon.properties | 2 +- scripts/src/main/resources/scripts/functions | 395 ++++++++++++------ 23 files changed, 470 insertions(+), 391 deletions(-) mode change 100644 => 100755 scripts/src/main/resources/scripts/command/cicdgen mode change 100644 => 100755 scripts/src/main/resources/scripts/command/ionic diff --git a/documentation/advanced-tooling-mac.asciidoc b/documentation/advanced-tooling-mac.asciidoc index 26fc5f082..6e2a21924 100644 --- a/documentation/advanced-tooling-mac.asciidoc +++ b/documentation/advanced-tooling-mac.asciidoc @@ -25,41 +25,62 @@ To get this feature for macOS `Terminal.app` open Finder and run the workflow `s == Keyboard Keyboard support is not an integration however, some users coming from other platforms may struggle with the way macOS deals with (external non-apple) keyboards. -So to make it short: if you are happy with your keyboard and shortcuts, you can skip all the following. Otherwise, if you think that pressing keys like `Home`, `End`, etc. should just work as expected or pressing `Alt Gr` should allow you to type the special characters as printed on your German keyboard then here you will find a solution to your problems! -To get all automated you can just run the script `system/mac/keyboard/install-mac-keyboard-support.sh` (in `${DEVON_IDE_HOME}`). If you would like to understand what is going on, you want to customize the keyboard settings to your needs, or you want a keyboard layout other than German ISO, please read on. +So to make it short: if you are happy with your keyboard and shortcuts, you can skip all the following. +Otherwise, if you think that pressing keys like `Home`, `End`, etc. should just work as expected or pressing `Alt Gr` should allow you to type the special characters as printed on your German keyboard then here you will find a solution to your problems! +To get all automated you can just run the script `system/mac/keyboard/install-mac-keyboard-support.sh` (in `${DEVON_IDE_HOME}`). +If you would like to understand what is going on, you want to customize the keyboard settings to your needs, or you want a keyboard layout other than German ISO, please read on. === Keyboard Layouts -Keyboard layouts allow a find-grained mapping of each key on your keyboard to its resulting input character or behaviour. They are macOS native features and do not need to have software running as a background service to make the keyboard mapping work (see Karabiner section below as an alternative). -They are provided as so called `bundle` (white lego brick icon). Like a macOS app this is a folder containing a `Contents` folder with a specific sub-folder structure. In the `Resources` subfolder `*.keylayout` files are placed and define the exact mapping for the keyboard. As an example we provide a `Keyboard Layouts` folder containing a `bundle` for a German keyboard mapping. +Keyboard layouts allow a find-grained mapping of each key on your keyboard to its resulting input character or behaviour. +They are macOS native features and do not need to have software running as a background service to make the keyboard mapping work (see Karabiner section below as an alternative). +They are provided as so called `bundle` (white lego brick icon). Like a macOS app this is a folder containing a `Contents` folder with a specific sub-folder structure. +In the `Resources` subfolder `*.keylayout` files are placed and define the exact mapping for the keyboard. +As an example we provide a `Keyboard Layouts` folder containing a `bundle` for a German keyboard mapping. -To install keyboard layouts simply doubleclick the `bundle` or copy it to `~/Library/Keyboard Layouts`. To actually use them go to `System Preferences` and select `Keyboard`. Then, select the tab `Input Sources`. With the `+` button you can add a keyboard layout for your daily usage with your mac. Please note that the keyboard layout shipped with `devonfw-ide` is called `German-ISO` and can be found in the `Others` section at the end of the list. It can be used as an example or template, if you want to create your own layout. +To install keyboard layouts simply double-click the `bundle` or copy it to `~/Library/Keyboard Layouts`. +To actually use them go to `System Preferences` and select `Keyboard`. +Then, select the tab `Input Sources`. +With the `+` button you can add a keyboard layout for your daily usage with your Mac. +Please note that the keyboard layout shipped with `devonfw-ide` is called `German-ISO` and can be found in the `Others` section at the end of the list. +It can be used as an example or template, if you want to create your own layout. image::images/keyboard-layouts.png["Keyboard Preferences / Input Sources"] When you have multiple mappings in place, on the top menu bar you will find a little icon next to the current time that allows you to switch between the keyboard layouts, which is very handy when you switch from your native MacBook keyboard to an external USB keyboard or vice versa. Even for a pure MacOS geek this can be helpful in case a friend coming from Windows/Linux is supposed to type something on the Mac in a pair-programming session. -In our German keyboard mapping example you can use the keys like `Alt Gr`, etc. to type special characters as you would expect and as printed on your keyboard. To make `Pos1`, `End`, etc. work properly across all apps please read on to the next section(s). +In our German keyboard mapping example you can use the keys like `Alt Gr`, etc. to type special characters as you would expect and as printed on your keyboard. +To make `Pos1`, `End`, etc. work properly across all apps please read on to the next section(s). -In case you would like to create your own keyboard layout you can of course edit the `*.keylayout` files in a text editor. However, to make this much more comfortable, you can use the graphical editor tool https://scripts.sil.org/ukelele[Ukelele]. -Besides, the app itself, the Ukelele `dmg` file, also contains a `Documentation` and a `Resources` folder. The latter contains many keyboard layouts that you can use as a starting point. +In case you would like to create your own keyboard layout you can of course edit the `*.keylayout` files in a text editor. +However, to make this much more comfortable, you can use the graphical editor tool https://scripts.sil.org/ukelele[Ukelele]. +Besides, the app itself, the Ukelele `dmg` file, also contains a `Documentation` and a `Resources` folder. +The latter contains many keyboard layouts that you can use as a starting point. === Key Bindings -Still, various keyboard shortcuts might not work as expected for you. Therefore, we provide you with an advanced configuration in the folder `system/mac/keyboard/KeyBindings` that you can copy to your `~/Library` folder: +Still, various keyboard shortcuts might not work as expected for you. +Therefore, we provide you with an advanced configuration in the folder `system/mac/keyboard/KeyBindings` that you can copy to your `~/Library` folder: ``` cd system/mac/keyboard/ cp -r KeyBindings ~/Library ``` -To make the changes work you need to log out and log in again or you can reboot. After that, your `Home` (`Pos1`) and `End` buttons should work as expected including with selection via `Shift` and/or `Command`. Also, you can use `Command` together with the left or right arrow key to move between words and combined it with `Shift` for selection. As an example, for further customization you can press `Command` + `<` to type the unicode character `«`. +To make the changes work you need to log out and log in again or you can reboot. +After that, your `Home` (`Pos1`) and `End` buttons should work as expected including with selection via `Shift` and/or `Command`. +Also, you can use `Command` together with the left or right arrow key to move between words and combined it with `Shift` for selection. +As an example, for further customization you can press `Command` + `<` to type the unicode character `«`. -However, still some apps listen to keyboard events on a lower level and come with their own keyboard mappings. In these apps you might still experience unexpected behaviour. Solutions can be found in the following sub-sections. +However, still some apps listen to keyboard events on a lower level and come with their own keyboard mappings. +In these apps you might still experience unexpected behaviour. +Solutions can be found in the following sub-sections. === Switch Control and Command If you are used to windows or linux and get easily confused by the apple keyboard behaviour you might want to switch the `Control` and the `Option` key. -Open `System Preferences` and select `Keyboard`. Then, in the first tab, click on the button `Modifier Keys...`. For every keyboard you can customize the behaviour of your modifier keys and therefore switch `Control` and `Option` as illustrated in the screenshot: +Open `System Preferences` and select `Keyboard`. +Then, in the first tab, click on the button `Modifier Keys...`. +For every keyboard you can customize the behaviour of your modifier keys and therefore switch `Control` and `Option` as illustrated in the screenshot: image::images/keyboard-modifier-keys.png["Keyboard Preferences / Modifier Keys"] @@ -69,14 +90,31 @@ image::images/keyboard-shortcuts.png["Keyboard Preferences / Shortcuts"] ==== Eclipse -In Eclipse, move and select by word as described above does not work. Even worse, the most important shortcut does not work: `Control` + `Space` for code completion (content assist). You can manually redefine the key bindings in `Preferences` under `General > Keys`. However, with multiple IDE installations and workspaces this will quickly get tedious. Therefore, you can `Export` and `Import` specific `Preferences` such as `Keys Preferences` to/from a `*.epf` (Eclipse PreFerences) file. -We have done all this for you so you can just import the file located in `system/mac/keyboard/Eclipse/eclipse-mac-keybindings.epf` into your Eclipse. Happy coding. +In Eclipse, move and select by word as described above does not work. +Even worse, the most important shortcut does not work: `Control` + `Space` for code completion (content assist). +You can manually redefine the key bindings in `Preferences` under `General > Keys`. +However, with multiple IDE installations and workspaces this will quickly get tedious. +Therefore, you can `Export` and `Import` specific `Preferences` such as `Keys Preferences` to/from a `*.epf` (Eclipse PreFerences) file. +We have done all this for you so you can just import the file located in `system/mac/keyboard/Eclipse/eclipse-mac-keybindings.epf` into your Eclipse. +Happy coding. === Karabiner -If you want more dynamics and do not worry about an app that has to run in the background to make your keyboard work as you like (no relevant performance overhead), you can try https://pqrs.org/osx/karabiner/[Karabiner Elements]. This is a powerful tool to remap your keyboard shortcuts. In the UI you can only directly create and edit `Simple Modifications` that are too limited for most use-cases. However, using `Complex Modifications` you can do a lot of magic to customize the keyboard behaviour to your personal needs. A key with any combination of modifiers can be mapped to any key with arbitrary modifiers. This can also be bound to conditions based on the frontmost application or the keyboard model. These complex modifications are configured as `*.json` files. We have included a set with useful rules for external keyboards, programmer shortcuts, etc. If you have Karabiner installed, you only need to copy the contents of the `karabiner` folder located in this directory to your `~/.config` folder: +If you want more dynamics and do not worry about an app that has to run in the background to make your keyboard work as you like (no relevant performance overhead), you can try https://pqrs.org/osx/karabiner/[Karabiner Elements]. +This is a powerful tool to remap your keyboard shortcuts. +In the UI you can only directly create and edit `Simple Modifications` that are too limited for most use-cases. +However, using `Complex Modifications` you can do a lot of magic to customize the keyboard behaviour to your personal needs. +A key with any combination of modifiers can be mapped to any key with arbitrary modifiers. +This can also be bound to conditions based on the frontmost application or the keyboard model. +These complex modifications are configured as `*.json` files. +We have included a set with useful rules for external keyboards, programmer shortcuts, etc. +If you have Karabiner installed, you only need to copy the contents of the `karabiner` folder located in this directory to your `~/.config` folder: ``` cd system/mac/keyboard/ cp karabiner/assets/complex_modifications/*.json ~/.config/karabiner/assets/complex_modifications/ ``` -Now, if you open the `Complex Modifications` in the Karabiner app, you can click on the `+ Add rule` button and will see these mappings in the pop up. Select the rules you want to add (e.g. add all) and you are done. Unlike other solutions, you can quickly tweak your keyboard without the need to log out and restart apps, which gives faster trial and error turnarounds. Further, if you want to tweak your own configs, Karabiner comes with a secondary app called Karabiner-EventViewer that shows you the names of the keys, modifiers, and apps for the events you are triggering. This is very helpful to get the config right. +Now, if you open the `Complex Modifications` in the Karabiner app, you can click on the `+ Add rule` button and will see these mappings in the pop up. +Select the rules you want to add (e.g. add all) and you are done. +Unlike other solutions, you can quickly tweak your keyboard without the need to log out and restart apps, which gives faster trial and error turnarounds. +Further, if you want to tweak your own configs, Karabiner comes with a secondary app called Karabiner-EventViewer that shows you the names of the keys, modifiers, and apps for the events you are triggering. +This is very helpful to get the config right. diff --git a/documentation/advanced-tooling-windows.asciidoc b/documentation/advanced-tooling-windows.asciidoc index 59d6da454..c923145e5 100644 --- a/documentation/advanced-tooling-windows.asciidoc +++ b/documentation/advanced-tooling-windows.asciidoc @@ -84,7 +84,7 @@ Are you are used to symbolic and hard links in Linux? Do you have to work with W If you even want to have it integrated in windows explorer you might want to install http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html[linkshellextension]. However, you might want to disable SmartMove in the http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html#configuration[configuration] if you face strange performance issues when moving folders. === Linux -Install https://www.cygwin.com/[Cygwin] and get your bash in windows with ssh-agent, awk, sed, tar, and all the tools you love (or hate). Windows 10 has already a Linux as an installable feature included: WSL and from Version 2004 on WSL2, which is a native Linux Kernel running on Windows (an a light weight VM). +Install https://www.cygwin.com/[Cygwin] and get your bash in windows with ssh-agent, awk, sed, tar, and all the tools you love (or hate). Windows 10 has already a Linux as an installable feature included: WSL and from Version 2004 on WSL2, which is a native Linux Kernel running on Windows (in a light weight VM). === X11 Do you want to connect via SSH and need to open an X11 app from the server? Do you want to see the GUI on your windows desktop? diff --git a/scripts/src/main/resources/scripts/command/cicdgen b/scripts/src/main/resources/scripts/command/cicdgen old mode 100644 new mode 100755 index d0ea79e19..6e185f744 --- a/scripts/src/main/resources/scripts/command/cicdgen +++ b/scripts/src/main/resources/scripts/command/cicdgen @@ -18,24 +18,18 @@ source "$(dirname "${0}")"/../functions function doSetup() { if command -v cicdgen &> /dev/null && [ "${1}" != "update" ] then - if [ "${1}" = "setup" ] + if [ "${1}" != "silent" ] then - echo "cicdgen is already installed at $(command -v cicdgen)" - exit + doEcho "cicdgen is already installed at $(command -v cicdgen)" + return fi else - doDevonCommand npm -q setup - local npm_command="${DEVON_IDE_HOME}/software/node/npm" - if [ ! -x "${npm_command}" ] - then - npm_command="${DEVON_IDE_HOME}/software/node/bin/npm" - fi - doRunCommand "'${npm_command}' install -g @devonfw/cicdgen@latest" "install cicdgen" + doDevonCommand npm install -g @devonfw/cicdgen@latest fi } doRunCicdgen() { - doSetup + doSetup silent cicdgen generate "${@}" } diff --git a/scripts/src/main/resources/scripts/command/cobigen b/scripts/src/main/resources/scripts/command/cobigen index c1113e115..ce22ba2c2 100755 --- a/scripts/src/main/resources/scripts/command/cobigen +++ b/scripts/src/main/resources/scripts/command/cobigen @@ -16,13 +16,18 @@ source "$(dirname "${0}")"/../functions function doSetup() { # We need Java to run and Maven for installing plug-ins - doDevonCommand mvn -q setup - if [ -n "${1}" ] || [ ! -d "${COBIGEN_CLI_HOME}" ] + doDevonCommand mvn setup silent + if [ "${1}" == "silent" ] && [ -d "${COBIGEN_CLI_HOME}" ] + then + return + fi + if [ ! -d "${COBIGEN_CLI_HOME}" ] then doUpgradeMavenArtifact "${COBIGEN_CLI_HOME}" "https://repo.maven.apache.org/maven2/com/devonfw/cobigen" "cli" "${COBIGEN_VERSION:-LATEST}" ".tar.gz" doExtendPath "${COBIGEN_CLI_HOME}" doEcho "To be fully functional please rerun 'devon' command to update your PATH properly." - else + elif [ "${1}" != "silent" ] + then doEcho "Software already installed at ${COBIGEN_CLI_HOME}" doEcho "To force install please run devon cobigen setup." fi @@ -48,12 +53,10 @@ then echo " «args» call CobiGen CLI with the specified arguments" echo echo "Options:" -elif [ -z "${1}" ] -then - doSetup -elif [ "${1}" = "setup" ] +elif [ -z "${1}" ] || [ "${1}" = "setup" ] then - doSetup setup + doSetup "${2}" else + doSetup silent doRunCLI "${@}" fi diff --git a/scripts/src/main/resources/scripts/command/docker b/scripts/src/main/resources/scripts/command/docker index d8e3c5014..0a71305aa 100755 --- a/scripts/src/main/resources/scripts/command/docker +++ b/scripts/src/main/resources/scripts/command/docker @@ -18,30 +18,22 @@ source "$(dirname "${0}")"/../functions function doSetup() { if doIsDockerInstalled then - doEcho "docker is already installed at $(command -v docker)" - docker version + if [ "${1}" != "silent" ] && ! isQuiet + then + doEcho "docker is already installed at $(command -v docker)" + docker version + fi else doRequireNotBatch #Start setup local version="${DOCKER_VERSION:-stable}" - local os - local arch - local ext local code - local filename - arch="$(uname -m)" - if [ "${arch}" = "x86_64" ] - then - arch="amd64" - fi if doIsWindows then code="Docker%20Desktop%20Installer" - ext="exe" elif doIsMacOs then code="Docker" - ext="dmg" else doFail "Sorry, docker-installation support is not yet implemented for your OS. Please install manually or help devonfw-ide to support it for your OS by contributing a pull-request." fi @@ -50,8 +42,7 @@ function doSetup() { then ts="$(date +%Y-%m)" fi - filename="${code//\%20/_}-${ts}.${ext}" - doDownload "-" "" "docker" "${version}" "${os}" "${arch}" "${ext}" "${code}" "${filename}" + doDownload "-" "" "docker" "${version}" "" "${code}" if doIsWindows then doEcho "Installating Docker Desktop for Windows..." @@ -71,7 +62,7 @@ function doSetup() { # Call Docker with specified arguments. function doRun() { - doSetup + doSetup silent doEcho "Running: docker ${*}" docker "${@}" } @@ -80,7 +71,7 @@ function doRun() { function doIsDockerInstalled() { if command -v docker &> /dev/null then - doEcho "docker is already installed at $(command -v docker)" + return else return 255 fi @@ -97,7 +88,7 @@ case ${1} in echo ;; "setup" | "s" | "") - doSetup setup + doSetup setup "${2}" ;; *) doRun "${@}" diff --git a/scripts/src/main/resources/scripts/command/eclipse b/scripts/src/main/resources/scripts/command/eclipse index bd6700d3e..8e0c28cd9 100755 --- a/scripts/src/main/resources/scripts/command/eclipse +++ b/scripts/src/main/resources/scripts/command/eclipse @@ -42,28 +42,10 @@ function doInstallEclipsePlugin() { } function doSetup() { - doDevonCommand java -q setup - if [ -n "${1}" ] || [ ! -d "${ECLIPSE_HOME}" ] + doDevonCommand java setup silent + if [ "${1}" != "silent" ] || [ ! -d "${ECLIPSE_HOME}" ] then - local version="${ECLIPSE_VERSION:-2021-03}" - local eclipse_edition_type=${ECLIPSE_EDITION_TYPE:-java} - local os - local ext - local arch - arch="$(uname -m)" - if doIsMacOs - then - os="macosx-cocoa" - ext="dmg" - elif doIsWindows - then - os="win32" - ext="zip" - else - os="linux-gtk" - ext="tar.gz" - fi - doInstall "-" "${ECLIPSE_HOME}" "eclipse" "${version}" "${os}" "${arch}" "${ext}" "${eclipse_edition_type}" + doInstall "-" "${ECLIPSE_HOME}" "eclipse" "${ECLIPSE_VERSION:-2021-03}" "${ECLIPSE_EDITION_TYPE:-java}" if doIsMacOs then if [ ! -x "${ECLIPSE_HOME}/eclipse" ] @@ -75,12 +57,12 @@ function doSetup() { fi doAddPlugins fi - if [ -n "${1}" ] + if [ ! -x "${ECLIPSE_HOME}/eclipse" ] + then + doFail "Eclipse binary is not available in ${ECLIPSE_HOME}" + fi + if [ "${1}" != "silent" ] && ! isQuiet then - if [ ! -x "${ECLIPSE_HOME}/eclipse" ] - then - doFail "Eclipse binary is not available in ${ECLIPSE_HOME}" - fi local eclipseproduct="${ECLIPSE_HOME}/Eclipse.app/Contents/Eclipse/.eclipseproduct" if [ ! -e "${eclipseproduct}" ] then @@ -273,8 +255,12 @@ fi ECLIPSE_HOME="${DEVON_IDE_HOME}/software/eclipse" if [ -z "${1}" ] then - doSetup + doSetup silent doStartEclipse +elif [ "${1}" = "setup" ] +then + doSetup "${2}" + exit fi if [ "${1}" = "--all" ] then @@ -285,7 +271,7 @@ while [ -n "${1}" ] do if [ "${1}" = "run" ] || [ "${1}" = "start" ] then - doSetup + doSetup silent doStartEclipse elif [ "${1}" = "ws-up" ] || [ "${1}" = "ws-update" ] then @@ -296,9 +282,6 @@ do elif [ "${1}" = "ws-reverse-add" ] then doConfigureEclipse -x - elif [ "${1}" = "setup" ] - then - doSetup setup elif [ "${1}" = "create-script" ] then doCreateIdeScript eclipse diff --git a/scripts/src/main/resources/scripts/command/gradle b/scripts/src/main/resources/scripts/command/gradle index 9f3303ad9..1ab363a34 100755 --- a/scripts/src/main/resources/scripts/command/gradle +++ b/scripts/src/main/resources/scripts/command/gradle @@ -16,13 +16,13 @@ source "$(dirname "${0}")"/../functions # $1: optional setup function doSetup() { - doDevonCommand java -q setup - if [ -n "${1}" ] || [ ! -d "${GRADLE_HOME}" ] + doDevonCommand java setup silent + if [ "${1}" != "silent" ] || [ ! -d "${GRADLE_HOME}" ] then local version="${GRADLE_VERSION:-5.5.1}" - doInstall "-" "${GRADLE_HOME}" "gradle" "${version}" "-" + doInstall "-" "${GRADLE_HOME}" "gradle" "${version}" "" "" "-" fi - if [ -n "${1}" ] + if [ "${1}" != "silent" ] && ! doIsQuiet then doRunCommand "'${GRADLE}' -v" "verify installation of gradle" fi @@ -62,7 +62,7 @@ function doRunBuild() { then gradle_cmd="./gradlew" else - doSetup + doSetup silent fi doEcho "Running: ${gradle_cmd} ${*}" if doIsQuiet @@ -98,7 +98,7 @@ then doRunBuild ${GRADLE_BUILD_OPTS:-clean dist} elif [ "${1}" = "setup" ] then - doSetup setup + doSetup "${2}" else if [ "${1}" = "get-version" ] then diff --git a/scripts/src/main/resources/scripts/command/intellij b/scripts/src/main/resources/scripts/command/intellij index cdccb57b8..be4e5700a 100755 --- a/scripts/src/main/resources/scripts/command/intellij +++ b/scripts/src/main/resources/scripts/command/intellij @@ -16,26 +16,16 @@ source "$(dirname "${0}")"/../functions cd "${DEVON_IDE_HOME}" || exit 255 function doSetup() { - doDevonCommand java -q setup - if [ -n "${1}" ] || [ ! -d "${IDEA_HOME}" ] + doDevonCommand java setup silent + if [ "${1}" != "silent" ] || [ ! -d "${IDEA_HOME}" ] then local version="${INTELLIJ_VERSION:-2020.2.1}" - local software_edition_type="${INTELLIJ_EDITION_TYPE:-C}" - local ext - if doIsMacOs - then - ext="dmg" - elif doIsWindows - then - ext="win.zip" - else - ext="tar.gz" - fi - doInstall "-" "${IDEA_HOME}" "intellij" "${version}" "-" "${arch}" "${ext}" "${software_edition_type}" + local edition="${INTELLIJ_EDITION_TYPE:-C}" + doInstall "-" "${IDEA_HOME}" "intellij" "${version}" "${edition}" if [ "${?}" = 0 ] && doIsMacOs then echo "Doing workarounds for MacOS quirks..." - if [ "${software_edition_type}" = "U" ] + if [ "${edition}" = "U" ] then mv "${DEVON_IDE_HOME}/software/intellij/IntelliJ IDEA.app" "${DEVON_IDE_HOME}/software/intellij/IntelliJ.app" else @@ -52,7 +42,7 @@ function doSetup() { export PATH="${IDEA_HOME}/bin:${PATH}" doAddPlugins fi - if [ -n "${1}" ] + if [ "${1}" != "silent" ] && ! doIsQuiet then doRunCommand "command -v idea" "verify installation of IntelliJ" if [ -e "${IDEA_HOME}/product-info.json" ] @@ -181,8 +171,12 @@ fi IDEA_HOME="${DEVON_IDE_HOME}/software/intellij" if [ -z "${1}" ] then - doSetup + doSetup silent doStartIntellij +elif [ "${1}" = "setup" ] +then + doSetup "${2}" + exit fi if [ "${1}" = "--all" ] then @@ -193,6 +187,7 @@ while [ -n "${1}" ] do if [ "${1}" = "run" ] || [ "${1}" = "start" ] then + doSetup silent shift doStartIntellij "${@}" elif [ "${1}" = "ws-up" ] || [ "${1}" = "ws-update" ] @@ -204,9 +199,6 @@ do elif [ "${1}" = "ws-reverse-add" ] then doConfigureIntellij "-x" - elif [ "${1}" = "setup" ] - then - doSetup setup elif [ "${1}" = "create-script" ] then doCreateIdeScript intellij diff --git a/scripts/src/main/resources/scripts/command/ionic b/scripts/src/main/resources/scripts/command/ionic old mode 100644 new mode 100755 index 406b712bf..980320a77 --- a/scripts/src/main/resources/scripts/command/ionic +++ b/scripts/src/main/resources/scripts/command/ionic @@ -18,12 +18,12 @@ source "$(dirname "${0}")"/../functions function doSetup() { if command -v ionic &> /dev/null then - if [ -n "${1}" ] + if [ "${1}" != "silent" ] then - echo "ionic-cli (ionic) is already installed at $(command -v ionic)" + doEcho "ionic-cli (ionic) is already installed at $(command -v ionic)" fi else - doDevonCommand npm -q setup + doDevonCommand npm setup silent local npm_command="${DEVON_IDE_HOME}/software/node/npm" if [ ! -x "${npm_command}" ] then @@ -50,17 +50,17 @@ fi if [ -z "${1}" ] || [ "${1}" = "setup" ] then - doSetup setup + doSetup "${2}" elif [ "${1}" = "create" ] then shift - doSetup + doSetup silent ionic start "${@}" elif [ "${1}" = "cicd" ] then shift doDevonCommand cicdgen ng "${*}" else - doSetup + doSetup silent ionic "${@}" fi diff --git a/scripts/src/main/resources/scripts/command/jasypt b/scripts/src/main/resources/scripts/command/jasypt index ab7e5dc52..f576e201c 100755 --- a/scripts/src/main/resources/scripts/command/jasypt +++ b/scripts/src/main/resources/scripts/command/jasypt @@ -16,20 +16,19 @@ source "$(dirname "${0}")"/../functions # $1: optional setup function doSetup() { - doDevonCommand java -q setup + doDevonCommand java setup silent if [ ! -e "${JASYPT_ARTIFACT}" ] then doEcho "Downloading jasypt version ${JASYPT_VERSION} to local maven repository..." doDevonCommand mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.2:get "-Dartifact=org.jasypt:jasypt:${JASYPT_VERSION}" - elif [ -n "${1}" ] + elif [ "${1}" != "silent" ] then doEcho "Jasypt version ${JASYPT_VERSION} is already installed." fi } function doJasypt() { - - doSetup + doSetup silent if [ -z "${2}" ] then local masterpassword @@ -43,7 +42,7 @@ function doJasypt() { } function doDecrypt() { - doSetup + doSetup silent java -cp "${JASYPT_ARTIFACT}" org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI "${@}" } @@ -65,7 +64,7 @@ then echo "Options:" elif [ "${1}" = "setup" ] then - doSetup setup + doSetup "${2}" elif [ "${1}" = "encrypt" ] then shift diff --git a/scripts/src/main/resources/scripts/command/java b/scripts/src/main/resources/scripts/command/java index 68ea649a0..f8a44284b 100755 --- a/scripts/src/main/resources/scripts/command/java +++ b/scripts/src/main/resources/scripts/command/java @@ -23,12 +23,8 @@ source "$(dirname "${0}")"/../functions # $1: optional setup function doSetup() { - if [ -z "${JAVA_HOME}" ] - then - export JAVA_HOME="${DEVON_IDE_HOME}/software/java" - echo "JAVA_HOME is not set, assuming ${JAVA_HOME}" - fi - if [ -n "${1}" ] || [ ! -d "${JAVA_HOME}" ] + export JAVA_HOME="${DEVON_IDE_HOME}/software/java" + if [ "${1}" != "silent" ] || [ ! -d "${JAVA_HOME}" ] then local version="${JAVA_VERSION:-11.0.9.1_1}" local code @@ -38,34 +34,17 @@ function doSetup() { else code="jdk-${version/_/%2B}" fi - local software_dir="${JAVA_HOME}" - if doIsMacOs - then - software_dir="${DEVON_IDE_HOME}/software/jdk" - fi - local ext="tar.gz" - if doIsWindows - then - ext="zip" - fi - local arch - arch="$(uname -m)" - if [ "${arch}" = "x86_64" ] - then - arch="x64" - elif [ "${arch}" = "arm64" ] - then - arch="aarch64" - fi - doInstall "-" "${software_dir}" "java" "${version}" "" "${arch}" "${ext}" "${code}" - if [ ! -d "${JAVA_HOME}" ] && [ -d "${DEVON_IDE_HOME}/software/jdk" ] && [ "${software_dir}" = "${DEVON_IDE_HOME}/software/jdk" ] + doInstall "-" "${JAVA_HOME}" "java" "${version}" "" "${code}" + if [ ! -d "${DEVON_IDE_HOME}/software/java/bin" ] && [ ! -d "${DEVON_IDE_HOME}/software/jdk" ] && doIsMacOs && [ -d "${DEVON_IDE_HOME}/software/java/Contents" ] then - echo "Creating symlink as workaround for Java on MacOS" - doRunCommand "ln -sf 'jdk/Contents/Home' '${JAVA_HOME}'" - doExtendPath "${JAVA_HOME}" + doEcho "Creating symlink as workaround for Java on MacOS" + doRunCommand "mv '${DEVON_IDE_HOME}/software/java' '${DEVON_IDE_HOME}/software/jdk'" + doRunCommand "ln -sf 'jdk/Contents/Home' '${DEVON_IDE_HOME}/software/java'" + doRunCommand "cp '${DEVON_IDE_HOME}/software/jdk/.devon.software.version' '${DEVON_IDE_HOME}/software/java'" fi + doExtendPath "${JAVA_HOME}" fi - if [ -n "${1}" ] && ! doIsQuiet + if [ "${1}" != "silent" ] && ! doIsQuiet then doRunCommand "'${JAVA_HOME}/bin/java' -version" "verify installation of Java" fi @@ -114,10 +93,10 @@ then echo "Options:" elif [ -z "${1}" ] || [ "${1}" = "setup" ] then - doSetup setup + doSetup "${2}" elif [ "${1}" = "create" ] then - doSetup + doSetup silent shift doCreate "${@}" elif [ "${1}" = "migrate" ] diff --git a/scripts/src/main/resources/scripts/command/jenkins b/scripts/src/main/resources/scripts/command/jenkins index fcc3a8d84..8bebd86a9 100755 --- a/scripts/src/main/resources/scripts/command/jenkins +++ b/scripts/src/main/resources/scripts/command/jenkins @@ -16,16 +16,16 @@ source "$(dirname "${0}")"/../functions # $1: optional setup function doSetup() { - doDevonCommand java -q setup + doDevonCommand java setup silent if [ -d "${JENKINS_HOME}" ] then - if [ -n "${1}" ] + if [ "${1}" != "silent" ] then echo "Jenkins is already installed at ${JENKINS_HOME}" fi else local version=${JENKINS_VERSION:-latest} - doDownload "-" "" "jenkins" "${version}" "-" + doDownload "-" "" "jenkins" "${version}" "-" "" "" "" "" "jenkins.war" mkdir -p "${JENKINS_HOME}" doRunCommand "mv '${DEVON_DOWNLOAD_DIR}/jenkins.war' '${JENKINS_HOME}/jenkins.war'" # http://localhost:9999/jnlpJars/jenkins-cli.jar @@ -34,14 +34,14 @@ function doSetup() { doRunCommand "jar xf jenkins.war WEB-INF/jenkins-cli.jar" cd "${cwd}" || exit 255 fi - if [ -n "${1}" ] + if [ "${1}" != "silent" ] && ! doIsQuiet then doRunCommand "java -jar '${JENKINS_HOME}/jenkins.war' --version" "verify installation of Jenkins" fi } function doStart() { - doSetup + doSetup silent doRunCommand "java -jar '${JENKINS_HOME}/jenkins.war' --httpPort=${JENKINS_PORT:-9999} ${JENKINS_OPTS} || echo -e 'Jenkins could not be started.\nIf you see \"Address already in use\" error above this only means it was already running.' &" sleep 15 echo @@ -91,7 +91,7 @@ then echo "Options:" elif [ "${1}" = "setup" ] then - doSetup setup + doSetup "${2}" elif [ "${1}" = "start" ] then doStart diff --git a/scripts/src/main/resources/scripts/command/kubectl b/scripts/src/main/resources/scripts/command/kubectl index ffe3254d9..cbb5ba622 100755 --- a/scripts/src/main/resources/scripts/command/kubectl +++ b/scripts/src/main/resources/scripts/command/kubectl @@ -18,19 +18,16 @@ source "$(dirname "${0}")"/../functions function doSetup() { if doIsKubernetesInstalled then - if [ "${1}" = "setup" ] + if [ "${1}" != "silent" ] && ! doIsQuiet then doEcho "Kubernetes is already installed at $(command -v kubectl)" kubectl version fi return fi - if doIsWindows + if doIsWindows || doIsMacOs then - doDevonCommand docker -q setup - elif doIsMacOs - then - doDevonCommand docker -q setup + doDevonCommand docker setup silent else doFail "Sorry, kubernetes-installation support is not yet implemented for your OS. Please install manually or help devonfw-ide to support it for your OS by contributing a pull-request." fi @@ -65,7 +62,7 @@ case ${1} in echo ;; "setup" | "s" | "") - doSetup setup + doSetup "${2}" ;; *) doRun "${@}" diff --git a/scripts/src/main/resources/scripts/command/mvn b/scripts/src/main/resources/scripts/command/mvn index 3ecd6b8a5..2e162acfa 100755 --- a/scripts/src/main/resources/scripts/command/mvn +++ b/scripts/src/main/resources/scripts/command/mvn @@ -16,13 +16,13 @@ source "$(dirname "${0}")"/../functions # $1: optional setup function doSetup() { - doDevonCommand java -q setup - if [ -n "${1}" ] || [ ! -d "${MAVEN_HOME}" ] + doDevonCommand java setup silent + if [ "${1}" != "silent" ] || [ ! -d "${MAVEN_HOME}" ] then local version=${MAVEN_VERSION:-3.8.1} - doInstall "-" "${MAVEN_HOME}" "maven" "${version}" "-" + doInstall "-" "${MAVEN_HOME}" "maven" "${version}" "" "" "-" fi - if [ -n "${1}" ] + if [ "${1}" != "silent" ] then if [ -d "${SETTINGS_PATH}" ] then @@ -68,7 +68,7 @@ function doSetup() { echo "Please run the following command to fix:" echo "devon setup" fi - if ! doIsQuiet + if [ "${1}" != "silent" ] && ! doIsQuiet then doRunCommand "'${MVN}' -v" "verify installation of maven" fi @@ -77,7 +77,7 @@ function doSetup() { # $@: optional maven arguments function doGetProjectVersion() { - doSetup + doSetup silent local maven_project_version if [ -e ".mvn/maven.config" ] then @@ -212,7 +212,7 @@ function doSetPomVersion() { rm pom.xml.bak fi fi - doSetup + doSetup silent local maven_project_version # shellcheck disable=SC2016 maven_project_version="$("${MVN}" -q org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -DforceStdout)" @@ -307,7 +307,7 @@ function doRunBuild() { then maven_cmd="./mvnw" else - doSetup + doSetup silent fi doEcho "Running: ${maven_cmd} ${*}" if doIsQuiet @@ -344,7 +344,7 @@ then doRunBuild ${MVN_BUILD_OPTS:-clean install} elif [ "${1}" = "setup" ] then - doSetup setup + doSetup "${2}" elif [ "${1}" = "get-version" ] then doGetProjectVersion diff --git a/scripts/src/main/resources/scripts/command/ng b/scripts/src/main/resources/scripts/command/ng index e4e8cccc9..6ee929834 100755 --- a/scripts/src/main/resources/scripts/command/ng +++ b/scripts/src/main/resources/scripts/command/ng @@ -16,18 +16,20 @@ source "$(dirname "${0}")"/../functions # $1: optional setup function doSetup() { - doDevonCommand npm -q setup - - local software_version=${NG_VERSION:-latest} + doDevonCommand npm setup silent + local version=${NG_VERSION:-latest} local installed_version installed_version=$(npm list -g --depth 0 | sed -n -e '/angular\/cli/ s/.*@//p') - - if [ "$installed_version" == "$software_version" ] + if [ "${installed_version}" == "${version}" ] + then + if [ "${1}" != "silent" ] + then + doEcho "Version ${installed_version} of angular-cli (ng) is already installed at ${NG_CMD}." + fi + elif [ "${1}" != "silent" ] || [ "${version}" != "latest" ] then - doEcho "Version ${installed_version} of angular-cli (ng) is already installed at ${NG_CMD}." - else - doEcho "Installing angular-cli ${software_version}..." - doDevonCommand npm install -g "@angular/cli@${software_version}" + doEcho "Installing angular-cli ${version}..." + doDevonCommand npm install -g "@angular/cli@${version}" fi } @@ -53,17 +55,17 @@ fi if [ -z "${1}" ] || [ "${1}" = "setup" ] then - doSetup setup + doSetup "${2}" elif [ "${1}" = "create" ] then shift - doSetup + doSetup silent ng new "${@}" elif [ "${1}" = "cicd" ] then shift doDevonCommand cicdgen ng "${*}" else - doSetup + doSetup silent "${NG_CMD}" "${@}" fi diff --git a/scripts/src/main/resources/scripts/command/node b/scripts/src/main/resources/scripts/command/node index e77c83504..3de90a71c 100755 --- a/scripts/src/main/resources/scripts/command/node +++ b/scripts/src/main/resources/scripts/command/node @@ -16,37 +16,12 @@ source "$(dirname "${0}")"/../functions # $1: optional setup function doSetup() { - if [ -n "${1}" ] || [ ! -d "${NODE_HOME}" ] + if [ "${1}" != "silent" ] || [ ! -d "${NODE_HOME}" ] then local version="${NODE_VERSION:-v14.17.6}" - local os - local arch - arch="$(uname -m)" - if [ "$arch" == "x86_64" ] - then - arch="x64" - elif [ "$arch" == "i386" ] || [ "$arch" == "i686" ] - then - arch="x86" - elif [ "$arch" == "aarch64" ] - then - arch="arm64" - fi - local ext="tar.gz" - if doIsMacOs - then - os="darwin" - elif doIsWindows - then - os="win" - ext="zip" - else - os="linux" - ext="tar.xz" - fi - doInstall "-" "${NODE_HOME}" "nodejs" "${version}" "${os}" "${arch}" "${ext}" + doInstall "-" "${NODE_HOME}" "nodejs" "${version}" fi - if [ -n "${1}" ] && ! doIsQuiet + if [ "${1}" != "silent" ] && ! doIsQuiet then local node_binary="${NODE_HOME}/node.exe" if [ ! -x "${node_binary}" ] @@ -60,13 +35,13 @@ function doSetup() { function doSetupDevon4node() { if ! command -v devon4node &> /dev/null then - doDevonCommand yarn -q setup + doDevonCommand yarn setup silent doDevonCommand npm install -g @devon4node/cli@latest fi } function doRun() { - doSetup + doSetup silent doEcho "Running: node ${*}" if doIsQuiet then @@ -95,7 +70,7 @@ case ${1} in exit ;; "setup" | "s") - doSetup setup + doSetup "${2}" ;; "create" | "c") shift diff --git a/scripts/src/main/resources/scripts/command/npm b/scripts/src/main/resources/scripts/command/npm index 36fca37ef..5191934b9 100755 --- a/scripts/src/main/resources/scripts/command/npm +++ b/scripts/src/main/resources/scripts/command/npm @@ -18,8 +18,9 @@ source "$(dirname "${0}")"/../functions function doSetup() { if [ ! -x "${NPM_CMD}" ] then - doDevonCommand node -q setup - else + doDevonCommand node setup silent + elif [ "${1}" != "silent" ] + then doEcho "npm is already installed at ${NPM_CMD}" fi } @@ -56,7 +57,7 @@ function doCheckTopLevelProject() { } function doRunBuild() { - doSetup + doSetup silent doEcho "Running: npm ${*}" if doIsQuiet then @@ -113,7 +114,7 @@ then fi elif [ "${1}" = "setup" ] then - doSetup setup + doSetup "${2}" elif [ "${1}" = "get-version" ] then doGetProjectVersion diff --git a/scripts/src/main/resources/scripts/command/project b/scripts/src/main/resources/scripts/command/project index e9d08efb9..1a0553afc 100755 --- a/scripts/src/main/resources/scripts/command/project +++ b/scripts/src/main/resources/scripts/command/project @@ -34,7 +34,7 @@ function doSetup() { project_force="" if doIsForce then - project_force="force" + project_force="force" fi last_cwd="${PWD}" for file in "${SETTINGS_PATH}"/projects/*.properties diff --git a/scripts/src/main/resources/scripts/command/sonar b/scripts/src/main/resources/scripts/command/sonar index 69c841552..60003631c 100755 --- a/scripts/src/main/resources/scripts/command/sonar +++ b/scripts/src/main/resources/scripts/command/sonar @@ -16,16 +16,13 @@ source "$(dirname "${0}")"/../functions # $1: optional setup function doSetup() { - if [ -n "${1}" ] - then - doDevonCommand java -q setup - fi - if [ -n "${1}" ] || [ ! -d "${SONARQUBE_HOME}" ] + doDevonCommand java setup silent + if [ "${1}" != "silent" ] || [ ! -d "${SONARQUBE_HOME}" ] then local version="${SONARQUBE_VERSION:-7.9.1}" - doInstall "-" "${SONARQUBE_HOME}" "sonarqube" "${version}" "-" + doInstall "-" "${SONARQUBE_HOME}" "sonarqube" "${version}" "" "" "-" fi - if [ -n "${1}" ] + if [ "${1}" != "silent" ] && ! doIsQuiet then echo doRunCommand "'${SONAR}' -v" "verify installation of sonarqube" fi @@ -40,7 +37,7 @@ function doStop() { } function doSonar() { - doSetup + doSetup silent if doIsWindows then if [ "${1}" = "start" ] @@ -85,7 +82,7 @@ then echo "Options:" elif [ "${1}" = "setup" ] then - doSetup setup + doSetup "${2}" elif [ "${1}" = "start" ] then doStart diff --git a/scripts/src/main/resources/scripts/command/vscode b/scripts/src/main/resources/scripts/command/vscode index c248159d5..9e8c5927f 100755 --- a/scripts/src/main/resources/scripts/command/vscode +++ b/scripts/src/main/resources/scripts/command/vscode @@ -16,22 +16,10 @@ source "$(dirname "${0}")"/../functions cd "${DEVON_IDE_HOME}" || exit 255 function doSetup() { - if [ -n "${1}" ] || [ ! -d "${VSCODE_HOME}" ] + if [ "${1}" != "silent" ] || [ ! -d "${VSCODE_HOME}" ] then local version="${VSCODE_VERSION:-1.54.1}" - local ext="zip" - local os - if doIsMacOs - then - os="darwin" - elif doIsWindows - then - os="win32-x64-archive" - else - os="linux-x64" - ext="tgz" - fi - doInstall "-" "${VSCODE_HOME}" "vscode" "${version}" "${os}" "" "${ext}" + doInstall "-" "${VSCODE_HOME}" "vscode" "${version}" if [ "${?}" = 0 ] then if doIsMacOs @@ -41,7 +29,6 @@ function doSetup() { chmod a+x "${VSCODE_HOME}/bin/code" fi fi - cleanupPlugins doAddPlugins fi @@ -154,6 +141,10 @@ if [ -z "${1}" ] then doSetup doStartVsCode +elif [ "${1}" = "setup" ] +then + doSetup "${2}" + exit fi if [ "${1}" = "--all" ] then @@ -164,7 +155,7 @@ while [ -n "${1}" ] do if [ "${1}" = "run" ] || [ "${1}" = "start" ] then - doSetup + doSetup silent doStartVsCode elif [ "${1}" = "ws-up" ] || [ "${1}" = "ws-update" ] then @@ -175,9 +166,6 @@ do elif [ "${1}" = "ws-reverse-add" ] then doConfigureVsCode -x - elif [ "${1}" = "setup" ] - then - doSetup setup elif [ "${1}" = "create-script" ] then doCreateIdeScript vscode diff --git a/scripts/src/main/resources/scripts/command/yarn b/scripts/src/main/resources/scripts/command/yarn index 2def4ddf5..5ab0c9ff9 100755 --- a/scripts/src/main/resources/scripts/command/yarn +++ b/scripts/src/main/resources/scripts/command/yarn @@ -16,21 +16,22 @@ source "$(dirname "${0}")"/../functions # $1: optional setup function doSetup() { - local version=${YARN_VERSION:-latest} + local version="${YARN_VERSION:-latest}" local installed_version if command -v yarn &> /dev/null then - installed_version=$(yarn -version) + installed_version="$(yarn -version)" fi - if [ "$installed_version" == "$version" ] + if [ "${installed_version}" == "${version}" ] then - if [ -n "${1}" ] + if [ "${1}" != "silent" ] then doEcho "Version ${installed_version} of yarn is already installed at $(command -v yarn)" fi - else - doDevonCommand npm -q setup + elif [ "${1}" != "silent" ] || [ "${version}" != "latest" ] + then + doDevonCommand npm setup silent if command -v npm &> /dev/null then doRunCommand "npm install -g yarn@${version}" @@ -72,7 +73,7 @@ function doCheckTopLevelProject() { } function doRunBuild() { - doSetup + doSetup silent doEcho "Running: yarn ${*}" if doIsQuiet then @@ -123,7 +124,7 @@ then fi elif [ "${1}" = "setup" ] then - doSetup setup + doSetup "${2}" elif [ "${1}" = "get-version" ] then doGetProjectVersion diff --git a/scripts/src/main/resources/scripts/devon.properties b/scripts/src/main/resources/scripts/devon.properties index 0bd9cd9cf..792a4d13a 100755 --- a/scripts/src/main/resources/scripts/devon.properties +++ b/scripts/src/main/resources/scripts/devon.properties @@ -4,7 +4,7 @@ # For details see https://github.com/devonfw/ide/blob/master/documentation/configuration.asciidoc #************************************************************************************************ -DEVON_IDE_TOOLS=(java mvn node npm) +DEVON_IDE_TOOLS=(mvn npm) DEVON_CREATE_START_SCRIPTS=(eclipse vscode) SETTINGS_PATH=${DEVON_IDE_HOME}/settings export NPM_CONFIG_USERCONFIG=${DEVON_IDE_HOME}/conf/npm/.npmrc diff --git a/scripts/src/main/resources/scripts/functions b/scripts/src/main/resources/scripts/functions index d1584290b..9f990512c 100755 --- a/scripts/src/main/resources/scripts/functions +++ b/scripts/src/main/resources/scripts/functions @@ -24,6 +24,10 @@ function doFail() { if [ -n "${2}" ] then echo "Exit code was ${2}" + if [ "${2}" = "0" ] + then + exit 1 + fi exit "${2}" else exit 255 @@ -349,62 +353,129 @@ function doDevonCommandAndReturn() { # $2: the optional, target directory to save to # $3: the software to download (e.g. 'java', 'mvn', 'node') # $4: the version of the software to download -# $5: operating system name -# $6: the optional architecture (e.g. x64 or x86_64) -# $7: the optional extension (e.g. 'tar.gz' or 'zip') -# $8: the optional code (magic value to avoid tool specific quirks in general functions) -# $9: optional filename to save to +# $5: the optional edition (e.g. "enterprise" or "community") +# $6: the optional code (magic value to avoid tool specific quirks in general functions) +# $7: operating system name +# $8: the optional architecture (e.g. x64 or x86_64) +# $9: the optional extension (e.g. 'tar.gz' or 'zip') +# $10: the optional filename to download to function doDownload() { doLicenseAgreement local url="${1}" local target_dir="${2}" local software="${3}" local version="${4}" - local os="${5}" - local arch="${6}" - local ext="${7}" - local code="${8}" - local filename"${9}" + local edition="${5}" + local code="${6}" + local os="${7}" + local arch="${8}" + local ext="${9}" + local filename="${10}" if [ -z "${target_dir}" ] then target_dir="${DEVON_DOWNLOAD_DIR}" fi mkdir -p "${target_dir}" local tmp_file - tmp_file=$(mktemp -ut "${filename}.XXXXXX") + tmp_file=$(mktemp -ut "${software}-${version}.XXXXXX") if [ "${url}" = "" ] || [ "${url}" = "-" ] then if [ -z "${arch}" ] then arch="$(uname -m)" fi - local filename_fallback="${software}-${version}" - if [ -n "${os}" ] - then - filename_fallback="${filename_fallback}-${os}" - fi - if [ "${arch}" != "-" ] + if [ -z "${os}" ] then - filename_fallback="${filename_fallback}-${arch}" + if doIsMacOs + then + os="mac" + elif doIsWindows + then + os="windows" + else + os="${OSTYPE}" + fi fi - filename_fallback="${filename_fallback}.${ext}" local mirrors_dir="${DEVON_IDE_HOME}/mirrors" doDebug "Cloning or updating download mirrors" doGitPullOrClone "${mirrors_dir}" "${DEVON_MIRRORS:-https://github.com/devonfw/ide-mirrors.git}" - if [ ! -d "${mirrors_dir}/${software}" ] + local mirrors_software_dir="${mirrors_dir}/${software}" + if [ ! -d "${mirrors_software_dir}" ] + then + doFail "No mirror is configured at ${mirrors_software_dir}" + fi + local mirrors_override_dir="${mirrors_software_dir}" + local folder + if [ -e "${mirrors_software_dir}/versions" ] + then + while IFS='<' read -r folder version_limit + do + doVersionCompare "${version}" "${version_limit}" + result=${?} + # ${version} < ${version_limit} ? + if [ "${result}" = 2 ] + then + mirrors_override_dir="${mirrors_software_dir}/${folder}" + if [ ! -d "${mirrors_override_dir}" ] + then + doWarning "Configured version folder does not exist: ${mirrors_override_dir}" + fi + fi + done < "${mirrors_software_dir}/versions" + fi + if [ "${mirrors_override_dir}" != "${mirrors_software_dir}" ] then - doFail "No mirror is configured at ${mirrors_dir}/${software}" + doDebug "For software ${software} in version ${version} the mirror config is overridden by ${mirrors_override_dir}" fi - local mirrors_file="${mirrors_dir}/${software}/${version}" - if [ ! -e "${mirrors_file}" ] + # remap architecture + local mirrors_arch + mirrors_arch="$(doGetFirstExistingPath "${mirrors_override_dir}/arch-mappings" "${mirrors_software_dir}/arch-mappings" "${mirrors_dir}/arch-mappings")" + if [ -e "${mirrors_arch}" ] then - doDebug "Mirror file not found for version at ${mirrors_file}" - mirrors_file="${mirrors_dir}/${software}/default" + while IFS="=" read -r key value + do + if [ "${key}" = "${arch}" ] || [ "${key}" = '*' ] + then + doDebug "Remapped architecture from ${arch} to ${value} for software ${software} in version ${version}" + arch="${value}" + break + fi + done < "${mirrors_arch}" fi - if [ ! -e "${mirrors_file}" ] + # map OS to ext(ension) + local mirrors_ext + mirrors_ext="$(doGetFirstExistingPath "${mirrors_override_dir}/ext-mappings" "${mirrors_software_dir}/ext-mappings")" + if [ -e "${mirrors_ext}" ] then - doFail "No mirror is configured at ${mirrors_file}" + while IFS="=" read -r key value + do + if [ "${key}" = "${os}" ] || [ "${key}" = '*' ] + then + doDebug "Mapped extension to ${value} for OS ${os} and software ${software} in version ${version}" + ext="${value}" + break + fi + done < "${mirrors_ext}" fi + # remap operating system + local mirrors_os + mirrors_os="$(doGetFirstExistingPathOrFail "${mirrors_override_dir}/os-mappings" "${mirrors_software_dir}/os-mappings" "${mirrors_dir}/os-mappings")" + local key + local value + while IFS="=" read -r key value + do + if [ "${key}" = "${os}" ] || [ "${key}" = '*' ] + then + doDebug "Remapped OS from ${os} to ${value} for software ${software} in version ${version}" + os="${value}" + break + fi + done < "${mirrors_os}" + # get mirror URLs + local mirrors_urls + mirrors_urls="$(doGetFirstExistingPathOrFail "${mirrors_override_dir}/urls" "${mirrors_software_dir}/urls")" + doDebug "Reading mirror URLs from ${mirrors_urls}" + local major="${version//[^0-9]*}" local mirror local mirrors @@ -413,8 +484,20 @@ function doDownload() { do mirrors[i]="${mirror}" ((++i)) - done < "${mirrors_file}" - # here we could actually pick the mirrors from the array in random order + done < "${mirrors_urls}" + # suffle mirrors to choose mirrors in random order and distribute load + local size="${#mirrors[*]}" + local rand + local tmp + local i + for ((i=size-1; i>0; i--)) + do + rand=$((RANDOM%(size+1))) + tmp="${mirrors[i]}" + mirrors[i]="${mirrors[rand]}" + mirrors[rand]="${tmp}" + done + # download from mirrors, try next mirror on error for mirror in "${mirrors[@]}" do local mirror_url="${mirror}" @@ -422,9 +505,29 @@ function doDownload() { mirror_url="${mirror_url//\$\{os\}/${os}}" mirror_url="${mirror_url//\$\{arch\}/${arch}}" mirror_url="${mirror_url//\$\{ext\}/${ext}}" - mirror_url="${mirror_url//\$\{code\}/${code}}" + mirror_url="${mirror_url//\$\{edition\}/${edition}}" mirror_url="${mirror_url//\$\{major\}/${major}}" - doDownloadInternal "${mirror_url}" "${tmp_file}" "${target_dir}" "${filename}" "${filename_fallback}" + mirror_url="${mirror_url//\$\{code\}/${code}}" + if [ -z "${filename}" ] + then + filename="${software}-${version}" + if [ -n "${edition}" ] + then + filename="${filename}-${edition}" + fi + if [ "${os}" != "-" ] && [ -n "${os}" ] + then + filename="${filename}-${os}" + fi + if [ -n "${ext}" ] + then + filename="${filename}.${ext}" + else + doWarning "No filename extension configured for ${software} in version ${version}" + filename="${filename}.$(doGetExtension "${mirror_url}")" + fi + fi + doDownloadInternal "${mirror_url}" "${tmp_file}" "${target_dir}" "${filename}" local result=${?} if [ "${result}" = 0 ] || [ "${result}" = 255 ] then @@ -447,20 +550,18 @@ function doDownload() { # $2: path to tmp-file to download to # $3: path to download folder # $4: optional download filename -# $5: fallback download filename (default from URL maybe "stable" lacking extension) function doDownloadInternal() { - # DOWNLOAD_FILENAME is a return variable + local url="${1}" + local tmp_file="${2}" + local target_folder="${3}" DOWNLOAD_FILENAME="${4}" if [ -z "${DOWNLOAD_FILENAME}" ] then - DOWNLOAD_FILENAME="${1/*\//}" - if [ "${DOWNLOAD_FILENAME/*\./.}" = "${DOWNLOAD_FILENAME}" ] - then - DOWNLOAD_FILENAME="${5}" - fi + DOWNLOAD_FILENAME="${url/*\//}" fi - doDebug "Downloading ${DOWNLOAD_FILENAME} from ${1}" - local target="${3}/${DOWNLOAD_FILENAME}" + doEcho "Trying to download ${DOWNLOAD_FILENAME} from ${url}" + local target="${target_folder}/${DOWNLOAD_FILENAME}" + if [ -f "${target}" ] && [ -z "${force}" ] then doEcho "Artifact already exists at ${target}\nTo force update please delete the file and run again." @@ -471,16 +572,61 @@ function doDownloadInternal() { then curl_opt="--silent" fi - curl ${curl_opt} -fL "${1}" -o "${2}" + curl ${curl_opt} -fL "${url}" -o "${tmp_file}" local result=${?} if [ "${result}" != 0 ] then - doEcho "Failed to download ${1} with exit code ${result}" + doEcho "Failed to download ${url} with exit code ${result}" return ${result} else - mv "${2}" "${target}" - doDebug "Download of ${DOWNLOAD_FILENAME} from ${1} succeeded." + mv "${tmp_file}" "${target}" + doDebug "Download of ${DOWNLOAD_FILENAME} from ${url} succeeded." + fi +} + +# $1: filename (potentiall including absolute or relative path) +# echos the file extension +function doGetExtension() { + local filename=${1/*\//} + local ext="${filename/*\./}" + local filename_base="${filename:0:(${#filename}-${#ext}-1)}" + if [ "${filename_base/*\./.}" = ".tar" ] + then + ext="tar.${ext}" fi + echo "${ext}" +} + +#.$@ any number of file paths +# echos the first of the given paths that does exist +function doGetFirstExistingPathOrFail() { + local message="None of the followin path(s) exists:" + while [ -n "${1}" ] + do + message="${message}\n${1}" + if [ -e "${1}" ] + then + echo "${1}" + return + fi + shift + done + doFail "${message}" +} + +#.$@ any number of file paths +# echos the first of the given paths that does exist +function doGetFirstExistingPath() { + while [ -n "${1}" ] + do + if [ -e "${1}" ] + then + echo "${1}" + return + fi + shift + done + return 1 } # $1: the file to extract @@ -514,7 +660,7 @@ function doExtract() { rm "${target_dir}/Applications" fi else - doFail "Unknown archive format: ${ext}. Can not extract ${1}" ${result} + doFail "Unknown archive format: ${ext}. Can not extract ${1}" fi doEcho "Successfully extracted archive ${filename} to updates/extracted" } @@ -580,7 +726,7 @@ function doReplaceExtractedSkipSingleFolder() { local backup_dir="${3}" shift 3 - if [ "${#*}" == 1 ] && [ -d "${1}" ] && [[ ! "${1}" =~ .*\.app ]] + if [ "${#*}" = 1 ] && [ -d "${1}" ] && [[ ! "${1}" =~ .*\.app ]] then source_dir="${1}" fi @@ -598,7 +744,7 @@ function doReplaceExtracted() { do if [ -e "${extracted_file}" ] then - if [ "${extracted_file/*\//}" == "workspaces" ] + if [ "${extracted_file/*\//}" = "workspaces" ] then doEcho "as the target already exists, omitting ${extracted_file}" else @@ -758,29 +904,30 @@ function doMavenArchetype() { # $5: suffix (e.g. '-sources.jar') # $6: currentVersion function doUpgradeMavenArtifact() { - doLicenseAgreement - if [ -d "${1}/.git" ] - then - doEcho "Found git repository ${1} - updating via git" - doGitPullOrClone "${1}" - return ${?} - fi - local download_url="${2}" + local target_path="${1}" + local url="${2}" local artifact_id="${3}" - download_url="${download_url}/${artifact_id}" local target_version="${4}" local suffix="${5}" local current_version="${6}" + doLicenseAgreement + if [ -d "${target_path}/.git" ] + then + doEcho "Found git repository ${target_path} - updating via git" + doGitPullOrClone "${target_path}" + return ${?} + fi + url="${url}/${artifact_id}" local current_repo="${DEVON_SOFTWARE_REPOSITORY}" if [ "${current_version}" = "0" ] then return 1 fi doEcho "*** Software Update of ${artifact_id} ***" - doEcho "Updating ${1} from ${download_url}" + doEcho "Updating ${target_path} from ${url}" if [ "${target_version}" = "LATEST" ] then - doMavenGetLatestVersion "${download_url}" + doMavenGetLatestVersion "${url}" target_version="${LATEST_VERSION}" DEVON_SOFTWARE_REPOSITORY= fi @@ -808,8 +955,8 @@ function doUpgradeMavenArtifact() { then doAskToContinue "Latest version seems unstable: ${target_version}\nAre you sure you want to install this version?" fi - download_url="${download_url}/${target_version}/${artifact_id}-${target_version}${suffix}" - doInstall "${1}" "${download_url}" "${artifact_id}" "${target_version}" "${suffix}" "-" + url="${url}/${target_version}/${artifact_id}-${target_version}${suffix}" + doInstall "${url}" "${1}" "${artifact_id}" "${target_version}" "${suffix}" "-" DEVON_SOFTWARE_REPOSITORY="${current_repo}" } @@ -824,33 +971,41 @@ function doMoveGlobSafe() { } # $1: absolute target path -# $2: URL -# $3: Branch to checkout (optional) +# $2: URL (may be URL#branch) function doGitPullOrClone() { - if [ -d "${1}/.git" ] + local dir="${1}" + local url="${2}" + local git_opts="" + if ! doIsDebug + then + git_opts="-q" + fi + if [ -d "${dir}/.git" ] then local remotes - remotes=$(cd "${1}" && git remote) + remotes=$(cd "${dir}" && git remote) if [ -n "${remotes}" ] then - doRunCommand "git pull" "" "${1}" + doRunCommand "git pull ${git_opts}" "" "${dir}" else - doEcho "Can not update local git repository: ${1}" + doEcho "Can not update local git repository: ${dir}" return 1 fi else - if [ -z "${2}" ] + if [ -z "${url}" ] then - doFail "Not a git repository: ${1}" + doFail "Not a git repository: ${dir}" else - mkdir -p "${1}" - pushd "${1}" || exit 255 - doRunCommand "git clone --recursive '${2}' --config core.autocrlf=false ." - if [ -n "${3}" ] - then - doRunCommand "git checkout ${3}" + mkdir -p "${dir}" + pushd "${dir}" > /dev/null || exit 255 + local branch="${url/*#/}" + url="${url%#*}" + doRunCommand "git clone ${git_opts} --recursive '${url}' --config core.autocrlf=false ." + if [ "${branch}" != "${url}" ] + then + doRunCommand "git checkout ${git_opts} ${branch}" fi - popd || exit 255 + popd > /dev/null || exit 255 fi fi } @@ -859,54 +1014,30 @@ function doGitPullOrClone() { # $2: absolute target path where to install # $3: name of software # $4: version of software -# $5: optional OS indicator ('-' if OS independent) -# $6: optional architecture (e.g. x86_64) -# $7: optional extension (e.g. 'tar.gz' or 'zip') -# $8: optional code (for tool specific quirks) -# $9: optional software repository (overrides DEVON_SOFTWARE_REPOSITORY) +# $5: the optional edition (e.g. "enterprise" or "community") +# $6: optional code (for tool specific quirks) +# $7: optional OS indicator ('-' if OS independent) +# $8: optional architecture (e.g. x86_64) +# $9: optional extension (e.g. 'tar.gz' or 'zip') function doInstall() { local url="${1}" local target_path="${2}" local software="${3}" local version="${4}" - local os="${5}" - local arch="${6}" - local ext="${7}" - local code="${8}" - local software_repository="${9}" - local filename - if [ -z "${software_repository}" ] - then - software_repository="${DEVON_SOFTWARE_REPOSITORY}" - fi - if [ -z "${os}" ] - then - if doIsMacOs - then - os="mac" - elif doIsWindows - then - os="windows" - else - os="linux" - fi - fi + local edition="${5}" + local code="${6}" + local os="${7}" + local arch="${8}" + local ext="${9}" local download_dir="${DEVON_DOWNLOAD_DIR}" if [ -z "${target_path}" ] || [ -z "${url}" ] || [ -z "${software}" ] then doFail "missing arguments for doInstall: ${*}" fi local result=0 - local git_url="${url%#*}" - if [ "${git_url/*\./.}" = ".git" ] + if [ "${url/.git/}" != "${url}" ] then - local branch=${url/*.git#/} - if [ "${branch}" = "${git_url}" ] - then - doGitPullOrClone "${target_path}" "${url}" - else - doGitPullOrClone "${target_path}" "${git_url}" "${branch}" - fi + doGitPullOrClone "${target_path}" "${url}" return fi local version_file="${target_path}/.devon.software.version" @@ -928,25 +1059,33 @@ function doInstall() { mkdir -p "${DEVON_IDE_HOME}/software" fi local repo="default" - if [ -n "${version}" ] + if [ -n "${DEVON_SOFTWARE_REPOSITORY}" ] && [ -n "${version}" ] then - if [ -n "${software_repository}" ] + local filename="${software}-${version}" + if [ "${os}" != "-" ] then - filename="${software}-${version}" - if [ "${os}" != "-" ] + if [ -z "${os}" ] then - filename="${filename}-${os}" + if doIsMacOs + then + filename="${filename}-mac" + elif doIsWindows + then + filename="${filename}-windows" + else + filename="${filename}-linux" + fi fi - ext="tgz" - url="${software_repository}/${software}/${version}/${filename}.tgz" - result=1 - repo="${DEVON_SOFTWARE_REPOSITORY/*:\/\//}" - local host="${repo/\/*/}" - repo="${repo:${#host}}" - host="${host/:/_}" - repo="${host}/${repo//[^A-Za-z0-9._-]/_}" - download_dir="${download_dir}/${repo}" fi + ext="tgz" + url="${DEVON_SOFTWARE_REPOSITORY}/${software}/${version}/${filename}.tgz" + result=1 + repo="${DEVON_SOFTWARE_REPOSITORY/*:\/\//}" + local host="${repo/\/*/}" + repo="${repo:${#host}}" + host="${host/:/_}" + repo="${host}/${repo//[^A-Za-z0-9._-]/_}" + download_dir="${download_dir}/${repo}" fi doEcho "Starting installation of ${software} in version ${version} to ${target_path}" if [ -L "${target_path}" ] @@ -962,9 +1101,9 @@ function doInstall() { fi if [ ! -d "${install_path}" ] || [ "${install_path}" == "${target_path}" ] then - doDownload "${url}" "${download_dir}" "${software}" "${version}" "${os}" "${arch}" "${ext}" "${code}" "${filename}" - filename="${DOWNLOAD_FILENAME}" - doExtract "${download_dir}/${filename}" "${dir}" + doDownload "${url}" "${download_dir}" "${software}" "${version}" "${edition}" "${code}" "${os}" "${arch}" "${ext}" + doDebug "Received download file ${DOWNLOAD_FILENAME}" + doExtract "${download_dir}/${DOWNLOAD_FILENAME}" "${dir}" doReplaceExtracted "${DEVON_IDE_HOME}/updates/extracted/${dir}" "${install_path}" if [ "${install_path}" != "${DEVON_IDE_HOME}" ] then