Commit b7efa70b authored by Pierre-Yves Fourmond's avatar Pierre-Yves Fourmond

Issue #33 - Handle .liar_software file installation and automatic upgrade

parent 44d97b67
#!/bin/bash
#
# Copyright (C) 2017 Pierre-Yves Fourmond.
# This file is part of liar, the Linux Installer for ARchives.
# liar is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# liar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with liar. If not, see <http://www.gnu.org/licenses/>.
#
#
# This file is used by liar-completion, which defines Bash tab auto-completion rules for the liar command.
#
LIAR=.liar_software
VERSION=0.2-dev
if [ "$1" = "version" ]; then
echo "$LIAR version $VERSION"
fi
software="\
ant atom \
firefox \
go goland gradle groovy \
hugo \
icecat idea_community idea_ultimate \
jdk10 jdk11 jdk12 jdk_ri7 jdk_ri8 jdk_ri9 jdk_ri10 jdk_ri11 \
marp maven \
netbeans \
pycharm_community pycharm_professional \
robo3t rubymine \
sbt scala sublimetext \
torbrowser \
visualvm \
webstorm \
"
ant=http://mirrors.standaloneinstaller.com/apache/ant/binaries/apache-ant-1.10.5-bin.zip
atom=https://github.com/atom/atom/releases/download/v1.33.0/atom-amd64.tar.gz
firefox=https://download-installer.cdn.mozilla.net/pub/firefox/releases/63.0.3/linux-x86_64/fr/firefox-63.0.3.tar.bz2
go=https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz
goland=https://download.jetbrains.com/go/goland-2018.3.2.tar.gz
gradle=https://downloads.gradle.org/distributions/gradle-5.0-bin.zip
groovy=https://dl.bintray.com/groovy/maven/apache-groovy-binary-2.5.5.zip
hugo=https://github.com/gohugoio/hugo/releases/download/v0.52/hugo_0.52_Linux-64bit.tar.gz
icecat=https://ftp.gnu.org/gnu/gnuzilla/60.3.0/icecat-60.3.0.en-US.gnulinux-x86_64.tar.bz2
idea_community=https://download.jetbrains.com/idea/ideaIC-2018.3.2.tar.gz
idea_ultimate=https://download.jetbrains.com/idea/ideaIU-2018.3.2.tar.gz
jdk10=https://download.java.net/java/GA/jdk10/10.0.2/19aef61b38124481863b1413dce1855f/13/openjdk-10.0.2_linux-x64_bin.tar.gz
jdk11=https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz
jdk12=https://download.java.net/java/early_access/jdk12/20/GPL/openjdk-12-ea+20_linux-x64_bin.tar.gz
jdk_ri7=https://download.java.net/openjdk/jdk7u75/ri/openjdk-7u75-b13-linux-x64-18_dec_2014.tar.gz
jdk_ri8=https://download.java.net/openjdk/jdk8u40/ri/openjdk-8u40-b25-linux-x64-10_feb_2015.tar.gz
jdk_ri9=https://download.java.net/openjdk/jdk9/ri/openjdk-9+181_linux-x64_ri.zip
jdk_ri10=https://download.java.net/openjdk/jdk10/ri/openjdk-10+44_linux-x64_bin_ri.tar.gz
jdk_ri11=https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz
marp=https://github.com/yhatt/marp/releases/download/v0.0.14/0.0.14-Marp-linux-x64.tar.gz
maven=http://apache.mediamirrors.org/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz
netbeans=http://mirrors.ircam.fr/pub/apache/incubator/netbeans/incubating-netbeans-java/incubating-9.0/incubating-netbeans-java-9.0-bin.zip
pycharm_community=https://download.jetbrains.com/python/pycharm-community-2018.3.2.tar.gz
pycharm_professional=https://download.jetbrains.com/python/pycharm-professional-2018.3.2.tar.gz
robo3t=https://download.robomongo.org/1.2.1/linux/robo3t-1.2.1-linux-x86_64-3e50a65.tar.gz
rubymine=https://download.jetbrains.com/ruby/RubyMine-2018.3.1.tar.gz
sbt=https://sbt-downloads.cdnedge.bluemix.net/releases/v1.2.7/sbt-1.2.7.zip
scala=https://downloads.lightbend.com/scala/2.12.8/scala-2.12.8.tgz
sublimetext=https://download.sublimetext.com/sublime_text_3_build_3176_x64.tar.bz2
torbrowser=https://dist.torproject.org/torbrowser/8.0.4/tor-browser-linux64-8.0.4_fr.tar.xz
visualvm=https://github.com/visualvm/visualvm.src/releases/download/1.4.2/visualvm_142.zip
webstorm=https://download.jetbrains.com/webstorm/WebStorm-2018.3.2.tar.gz
......@@ -49,7 +49,7 @@ For a complete list of tarball delivered software installable with `liar`, see [
### New features
Starting from [0.2-dev version](https://framagit.org/grumpyf0x48/liar/tree/master), the following features and changes have been added:
Since `liar` version 0.1, the following features and changes have been added:
- Software archive checksum verification (md5, sha1, sha256 or sha512)
- Improvements for binaries filtering in symbolic links creation
......@@ -58,7 +58,7 @@ Starting from [0.2-dev version](https://framagit.org/grumpyf0x48/liar/tree/maste
- Remove command is now able to remove several softwares at a time
- Complete rewrite of command line completion
- list command output can be sorted by any column
- Ability to upgrade liar in development version
- Ability to upgrade liar and [.liar_software](#liar_software) file from the [Git repository](https://framagit.org/grumpyf0x48/liar) (development version only)
## Installation
......@@ -524,7 +524,6 @@ To sort the output using another column, `-S` option may be used. For example, t
hugo hugo hugo_0.31.1_Linux-64bit.tar.gz 2017/12/09
idea-communi idea-IC-181.4668 ideaIC-2018.1.2.tar.gz 2018/05/06
maven apache-maven-3.3 apache-maven-3.3.9-bin.tar.gz 2017/03/26
netbeans netbeans netbeans-8.2-201609300101-javaee.zip 2017/10/16
pycharm pycharm-communit pycharm-community-2017.1.tar.gz 2017/03/27
quantum_node firefox firefox-57.0.2.tar.bz2 2017/12/17
rubymine RubyMine-2017.2. RubyMine-2017.2.4.tar.gz 2017/10/15
......@@ -694,24 +693,17 @@ text/x-python
text/x-sh
```
It is customisable by the user.
#### .liar_software
This file describes which software `liar` can install and where to download them. It is used by [command line completion](#bash-completion-installation).
This file describes which software `liar` can install, in which version and where to download their archives. It is used by [command line completion](#bash-completion-installation).
The beginning of `.liar_software` is:
It is automatically upgraded at `bash` startup when it is outdated and can be upgraded manually witn the [upgrade](#upgrade) command.
```
software="asciinema ant atom firefox gradle groovy hugo icecat idea_community idea_ultimate jdk7 jdk8 jdk9 jdk10 maven netbeans netbeans_dev pycharm_community pycharm_professional robo3t rubymine sublimetext torbrowser webstorm"
asciinema=https://github.com/asciinema/asciinema/releases/download/v1.2.0/asciinema-1.2.0-linux-amd64.tar.gz
ant=http://apache.crihan.fr/dist//ant/binaries/apache-ant-1.10.4-bin.zip
atom=https://github.com/atom/atom/releases/download/v1.28.1/atom-amd64.tar.gz
firefox=https://download-installer.cdn.mozilla.net/pub/firefox/releases/61.0/linux-x86_64/fr/firefox-61.0.tar.bz2
gradle=https://downloads.gradle.org/distributions/gradle-4.8.1-bin.zip
...
```
`.liar_software` can also be customised by the user. In this case, upgrade of the file should be disabled as follows:
Of course, the user can add software to this file to suit his needs.
$ export LIAR_SOFTWARE_FILE=custom
## Dependencies
......@@ -755,7 +747,6 @@ Finally, **bash-completion** is required when using Bash command line completion
- JetBrains IDE (GoLand, IntelliJ IDEA, PyCharm, RubyMine, WebStorm, ...)
- Marp
- Mozilla Firefox
- NetBeans
- Robo 3T (Formerly RoboMongo)
- Scala and sbt
- Sublime Text
......@@ -764,6 +755,8 @@ Finally, **bash-completion** is required when using Bash command line completion
Asciinema is no longer tested as it is not delivered anymore as an [archive](https://discourse.asciinema.org/t/changes-in-asciinema-packaging/90).
NetBeans is no longer tested as the URL to download a specific version changes too often for nothing.
## Docker image
`liar` docker image is based on Debian Stretch and has the latest development version of liar installed.
......
......@@ -775,6 +775,10 @@ liar_upgrade() {
if [ -d "$liar_folder" ] && ! upgrade liar-completion "$liar_folder"; then
return 1
fi
if [ "$LIAR_SOFTWARE_FILE" != "custom" ] && ! upgrade .liar_software "$HOME"; then
return 1
fi
}
liar_main() {
......
......@@ -25,66 +25,38 @@
#
LIAR=liar-completion
URL=https://git.framasoft.org/grumpyf0x48/liar/raw/master
VERSION=0.2-dev
ALL_COMMANDS="help install list remove version upgrade"
ALL_OPTIONS="-d -l -s -p -a -c -t -S -v -r -b -f"
SOFTWARE_FILE="$HOME/.liar_software"
_liar_load_software_file() {
software_file="$HOME/.liar_software"
if [ ! -f "$software_file" ] || [ "$BASH_SOURCE" -nt "$software_file" ]; then
cat << EOF > "$software_file"
software="ant atom \
firefox \
go goland gradle groovy \
hugo \
icecat idea_community idea_ultimate \
jdk10 jdk11 jdk12 jdk_ri7 jdk_ri8 jdk_ri9 jdk_ri10 jdk_ri11 \
marp maven \
netbeans \
pycharm_community pycharm_professional \
robo3t rubymine \
sbt scala sublimetext \
torbrowser \
visualvm \
webstorm"
ant=http://mirrors.standaloneinstaller.com/apache/ant/binaries/apache-ant-1.10.5-bin.zip
atom=https://github.com/atom/atom/releases/download/v1.33.0/atom-amd64.tar.gz
firefox=https://download-installer.cdn.mozilla.net/pub/firefox/releases/63.0.3/linux-x86_64/fr/firefox-63.0.3.tar.bz2
go=https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz
goland=https://download.jetbrains.com/go/goland-2018.3.2.tar.gz
gradle=https://downloads.gradle.org/distributions/gradle-5.0-bin.zip
groovy=https://dl.bintray.com/groovy/maven/apache-groovy-binary-2.5.5.zip
hugo=https://github.com/gohugoio/hugo/releases/download/v0.52/hugo_0.52_Linux-64bit.tar.gz
icecat=https://ftp.gnu.org/gnu/gnuzilla/60.3.0/icecat-60.3.0.en-US.gnulinux-x86_64.tar.bz2
idea_community=https://download.jetbrains.com/idea/ideaIC-2018.3.2.tar.gz
idea_ultimate=https://download.jetbrains.com/idea/ideaIU-2018.3.2.tar.gz
jdk10=https://download.java.net/java/GA/jdk10/10.0.2/19aef61b38124481863b1413dce1855f/13/openjdk-10.0.2_linux-x64_bin.tar.gz
jdk11=https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz
jdk12=https://download.java.net/java/early_access/jdk12/20/GPL/openjdk-12-ea+20_linux-x64_bin.tar.gz
jdk_ri7=https://download.java.net/openjdk/jdk7u75/ri/openjdk-7u75-b13-linux-x64-18_dec_2014.tar.gz
jdk_ri8=https://download.java.net/openjdk/jdk8u40/ri/openjdk-8u40-b25-linux-x64-10_feb_2015.tar.gz
jdk_ri9=https://download.java.net/openjdk/jdk9/ri/openjdk-9+181_linux-x64_ri.zip
jdk_ri10=https://download.java.net/openjdk/jdk10/ri/openjdk-10+44_linux-x64_bin_ri.tar.gz
jdk_ri11=https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz
marp=https://github.com/yhatt/marp/releases/download/v0.0.14/0.0.14-Marp-linux-x64.tar.gz
maven=http://apache.mediamirrors.org/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz
netbeans=http://mirrors.ircam.fr/pub/apache/incubator/netbeans/incubating-netbeans-java/incubating-9.0/incubating-netbeans-java-9.0-bin.zip
pycharm_community=https://download.jetbrains.com/python/pycharm-community-2018.3.2.tar.gz
pycharm_professional=https://download.jetbrains.com/python/pycharm-professional-2018.3.2.tar.gz
robo3t=https://download.robomongo.org/1.2.1/linux/robo3t-1.2.1-linux-x86_64-3e50a65.tar.gz
rubymine=https://download.jetbrains.com/ruby/RubyMine-2018.3.1.tar.gz
sbt=https://sbt-downloads.cdnedge.bluemix.net/releases/v1.2.7/sbt-1.2.7.zip
scala=https://downloads.lightbend.com/scala/2.12.8/scala-2.12.8.tgz
sublimetext=https://download.sublimetext.com/sublime_text_3_build_3176_x64.tar.bz2
torbrowser=https://dist.torproject.org/torbrowser/8.0.4/tor-browser-linux64-8.0.4_fr.tar.xz
visualvm=https://github.com/visualvm/visualvm.src/releases/download/1.4.2/visualvm_142.zip
webstorm=https://download.jetbrains.com/webstorm/WebStorm-2018.3.2.tar.gz
EOF
_liar_update_software_file() {
if ! ping -c1 -W1 git.framasoft.org >/dev/null 2>&1; then
return;
fi
. "$software_file"
if [ "$LIAR_SOFTWARE_FILE" != "custom" ] && _liar_is_obsolete "$SOFTWARE_FILE"; then
software_file_url="$URL/$(basename "$SOFTWARE_FILE")"
if which curl >/dev/null 2>&1; then
curl -s -L "$software_file_url" -o "$SOFTWARE_FILE"
elif which wget >/dev/null 2>&1; then
wget -q "$software_file_url" -O "$SOFTWARE_FILE"
fi
fi
}
_liar_is_obsolete() {
file=$1
if [ ! -f "$file" ]; then
return 0
fi
find_result="$(find "$(dirname "$file")" -name "$(basename "$file")" -mtime +1)"
if [ -n "$find_result" ]; then
return 0
fi
return 1
}
_liar_is_present_in_list() {
......@@ -121,7 +93,9 @@ _liar_get_installed_software() {
_liar_completion() {
local cur prev all_commands all_options curr_command dest_folder installed_software
_liar_load_software_file
if [ -f "$SOFTWARE_FILE" ]; then
. "$SOFTWARE_FILE"
fi
# Remove already set options to not complete with them
# Compute current command
......@@ -235,3 +209,5 @@ complete -o default -F _liar_completion liar
if [ "$1" = "version" ]; then
echo "$LIAR version $VERSION"
fi
(_liar_update_software_file >/dev/null 2>&1 &)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment