Initial release (version 1.0.0)

parent c556ebab
GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. {http://fsf.org/}
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
......@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -645,14 +645,14 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see {http://www.gnu.org/licenses/}.
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
libreoffice-portable-downloader.bash Copyright (C) 2013 tuxayo
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
......@@ -664,11 +664,12 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
{http://www.gnu.org/licenses/}.
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
{http://www.gnu.org/philosophy/why-not-lgpl.html}.
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
libreoffice-portable-downloader.bash
====================================
This program downloads and extracts the latest version of LibreOffice
in the folder where the program is located.
This program downloads and extracts the latest version of LibreOffice in the folder where the program is located.
Ce programme télécharge et extrait la dernière version de LibreOffice
dans le dossier où le programme est situé.
Fell free to fork or contribute!
#Version 1.0.0
###How does it works?
Using some black magic* it gets the latest version of LibreOffice, downloads the RPM package, extract it and makes a symbolic link to easily launch the office suite.
>*It parses [this page](https://download.documentfoundation.org/libreoffice/stable/) with grep, tail and sed to get the latest version number.
###Typical use case
You study computer science at the university and hopefully they have linux machines but only OpenOffice 3.2 or some other oldish version. With this script you can use the latest version of LibreOffice and benefit from the latest features, performances and interoperability improvements. You can even compress it into an archive to keep it in your USB drive (7z/LZMA is one of the fastest formats for decompressing)
###TODO:
-python version
-check CPIO and RPM dependencies
-limit verbosity of CPIO extraction
-choose to use parameters with functions or global variables -> be consistent
#!/bin/bash
# This program downloads and extracts the latest version of LibreOffice
# in the folder where the program is located.
# Ce programme télécharge et extrait la dernière version de LibreOffice
# dans le dossier où le programme est situé.
#
# Copyright 2013 Victor Grousset <[email protected]>
# Copyright 2013 Alain Drillon <[email protected]>
# Copyright 2013 Julien Papasian
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$scriptDir" #Go to the script directory
function main() {
version=$(getLatestLibreOfficeVersion)
url=$(getLinkLatestLibreOfficeRPM $version)
wget "$url" --no-check-certificate -O "libreOffice"$version".tar.gz"
#nocheck to avoid some https errors(for this, full https security
#is not essential but you can remove the option is you want)
echo "Extracting from .tar.gz"
tar -xzf "libreOffice"$version".tar.gz" #&> /dev/null
extractRPM
echo "Extraction terminée"
cleaning
createShortcut
echo -e "Pour lancer LibreOffice, allez dans le dossier libreOffice"$version" et\nvous y trouverez le launcher"
echo "Version 1.0.0 by Victor Grousset ([email protected]) under GPLv3 Licence"
echo "With the help of Alain Drillon and Julien Papasian"
read #press any key to continue
}
function getLatestLibreOfficeVersion() {
#we download a page on the document foundation server were we can
#always find the latest version number of LibreOffice
wget "https://download.documentfoundation.org/libreoffice/stable/" --no-check-certificate -O ftpLibreOffice.temp &> /dev/null
#nocheck to avoid some https errors
#now we isolate the line containing the version number and extract it with sed and a regexp
lastVersionLibO=$(cat ftpLibreOffice.temp | grep '<tr><td valign="top">&nbsp;</td><td><a href="' | tail -n 1 | sed 's/.*\([0-9]\.[0-9]\.[0-9]\).*/\1/')
rm ftpLibreOffice.temp
echo $lastVersionLibO
}
function getLinkLatestLibreOfficeRPM() {
lastVersionLibO=$1
getProcessorArchitecture
url="https://download.documentfoundation.org/libreoffice/stable/"$lastVersionLibO"/rpm/"$archFolderName"/LibreOffice_"$lastVersionLibO"_Linux_"$archInFileName"_rpm.tar.gz"
echo $url
}
function getProcessorArchitecture() {
arch=$(uname -m)
if [ $arch == "x86_64" ]
then
archFolderName="x86_64"
archInFileName="x86-64"
else
archFolderName="x86"
archInFileName="x86"
fi
}
function extractRPM() {
#first we go to the folder were the RPM files are
cd "LibreOffice_"?"."?"."?"."?"_Linux_"*"_rpm"/RPMS
echo "Extracting from .rpm"
formatOfRpm2cpioOutput=$(getFormatOfRpm2cpioOutput)
case $formatOfRpm2cpioOutput in
"gzip compressed data, from Unix")
extractGzipAndCpio
;;
"ASCII cpio archive (SVR4 with no CRC)")
extractCpio
;;
*)
echo $formatOfRpm2cpioOutput" n'est pas un format reconnu, veuillez m'envoyer le nom du format par email à [email protected] si vous voulez aider à ce que ce script marche bien"
echo "On va faire avec la méthode d'extraction qui a le plus de chances de marcher ^^\""
echo $formatOfRpm2cpioOutput" is not a recognized format, please send me the format name by email to [email protected] if you want this script to works well"
echo "We will try the extraction method which should works most of the time ^^\""
extractCpio
;;
esac
#now move LibreOffice folder to script folder
mv "opt/libreoffice"?"."* "$scriptDir""/libreOffice"$version
cd "$scriptDir"
}
function getFormatOfRpm2cpioOutput() {
#we check the format of one file to choose the good extraction method
firstRpmInFolder=$(ls *.rpm | head -1)
rpm2cpio $firstRpmInFolder> $firstRpmInFolder".cpio"
local formatOfRpm2cpioOutput=$(file -b $firstRpmInFolder".cpio")
rm $firstRpmInFolder".cpio"
echo $formatOfRpm2cpioOutput
}
function extractGzipAndCpio() {
for file in *.rpm
do
rpm2cpio $file | gzip -d | cpio -idm
done
}
function extractCpio() {
for file in *.rpm
do
rpm2cpio $file | cpio -idm
done
}
function cleaning() {
rm -r "LibreOffice_"?"."?"."?"."?"_Linux_"*"_rpm"
rm "libreOffice"?"."?"."?".tar.gz"
}
function createShortcut() {
ln -s ./program/soffice ./libreOffice"$version"/"LibreOffice "$version" Launcher"
}
main
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