diff options
author | JulioJu | 2016-05-29 17:19:12 +0200 |
---|---|---|
committer | JulioJu | 2016-05-29 17:19:12 +0200 |
commit | b3887656821458d429d5a342043b72286b4f958e (patch) | |
tree | d05fafb7eb5acc93b0a9fa637ada6bd630de2f0b | |
parent | a229e7020c203e72f1f839e34b6f4b24f5126900 (diff) | |
download | aur-b3887656821458d429d5a342043b72286b4f958e.tar.gz |
New Downloader
-rw-r--r-- | .SRCINFO | 6 | ||||
-rw-r--r-- | Makefile-legacy.patch | 164 | ||||
-rw-r--r-- | PKGBUILD | 11 | ||||
-rw-r--r-- | marionnet-legacy.install | 207 | ||||
-rw-r--r-- | marionnet.install | 6 | ||||
-rw-r--r-- | marionnet_from_scratch-Downloader | 498 |
6 files changed, 883 insertions, 9 deletions
@@ -3,7 +3,7 @@ pkgbase = marionnet pkgver = 0.90.6 pkgrel = 2 url = https://www.marionnet.org/ - install = marionnet.install + install = marionnet-legacy.install arch = i686 arch = x86_64 license = LGPL @@ -26,12 +26,14 @@ pkgbase = marionnet source = http://wwwfun.kurims.kyoto-u.ac.jp/soft/lsl/dist/lablgtk-2.14.2.tar.gz source = https://www.marionnet.org/download/marionnet_from_scratch/mirror/ocamlbricks-0.90.3.tar.gz source = https://www.marionnet.org/download/marionnet_from_scratch/mirror/marionnet-0.90.6.tar.gz - source = https://raw.githubusercontent.com/JulioJu/Marionnet-old_ArchLinux-installer/master/Makefile.patch + source = https://raw.githubusercontent.com/JulioJu/Marionnet_ArchLinux_Installer/master/Makefile-legacy.patch + source = https://raw.githubusercontent.com/JulioJu/Marionnet_ArchLinux_Installer/master/marionnet_from_scratch-Downloader sha256sums = 83008744c0ba1e3460651b86d0900916edae38813eb9a0300e8eaa861c3e921e sha256sums = 4981abedabdc462303f345104042c88af227ccd50fd30a9bf48fd353ab02d0ba sha256sums = 39cc4cc100124b8363c9760494d7e285803ca22ff8409f79038f3fb4a146a96c sha256sums = 3a571a2cb4724b50eb52e33191d42a6b8396889e728bc974bc396395c9ce03ac sha256sums = 1fd697ff5f7055bcd6da2b6b5233d58bf79a2d4fc59b36eb79fb3c0d63265d3c + sha256sums = 5d8ddf6e5c5b726e892bae2b55eb5eb01f43bd47fa2855ec38797d0598a6ea24 pkgname = marionnet diff --git a/Makefile-legacy.patch b/Makefile-legacy.patch new file mode 100644 index 000000000000..ef921e243193 --- /dev/null +++ b/Makefile-legacy.patch @@ -0,0 +1,164 @@ +--- Makefile 2011-01-28 17:38:56.000000000 +0100 ++++ MakefileArchLinux 2016-05-28 05:04:51.416500935 +0200 +@@ -271,11 +271,11 @@ + # Just a handy alias: + install-doc: install-documentation + +-# Install the data from this package into $prefix/share/$name: ++# Install the data from this package into $prefixInstall/share/$name: + install-data: main install-data-local +- @($(call READ_CONFIG, prefix); \ ++ @($(call READ_CONFIG, prefixInstall); \ + $(call READ_META, name); \ +- directory=$$prefix/share/$$name; \ ++ directory=$$prefixInstall/share/$$name; \ + shopt -s nullglob; \ + if [ -e share ]; then \ + dataifany=`ls -d share/*`; \ +@@ -343,12 +343,12 @@ + echo "We don't have any configuration files to remove."; \ + fi) + +-# Remove the data of this package from $prefix/share/$name: ++# Remove the data of this package from $prefixInstall/share/$name: + uninstall-data: uninstall-data-local +- @( ($(call READ_CONFIG, prefix); \ ++ @( ($(call READ_CONFIG, prefixInstall); \ + $(call READ_META, name); \ +- directory=$$prefix/share/$$name; \ +- echo "Removing $$name data from $$prefix/share/..."; \ ++ directory=$$prefixInstall/share/$$name; \ ++ echo "Removing $$name data from $$prefixInstall/share/..."; \ + shopt -s nullglob; \ + if rm -rf $$directory; then \ + echo "The entire directory $$directory was removed."; \ +@@ -386,40 +386,40 @@ + install-programs: programs install-programs-local + @($(call READ_CONFIG, prefix); \ + $(call READ_META, name); \ +- echo "Creating $$prefix/bin/..."; \ +- (mkdir -p $$prefix/bin &> /dev/null || true); \ +- echo "Creating $$prefix/sbin/..."; \ +- (mkdir -p $$prefix/sbin &> /dev/null || true); \ +- echo "Installing programs from $$name into $$prefix/bin/..."; \ ++ echo "Creating $$prefixInstall/bin/..."; \ ++ (mkdir -p $$prefixInstall/bin &> /dev/null || true); \ ++ echo "Creating $$prefixInstall/sbin/..."; \ ++ (mkdir -p $$prefixInstall/sbin &> /dev/null || true); \ ++ echo "Installing programs from $$name into $$prefixInstall/bin/..."; \ + shopt -s nullglob; \ + for file in $(OTHER_PROGRAMS_TO_INSTALL) _build/*.byte _build/*.native; do \ + basename=`basename $$file`; \ + if echo " $(ROOT_NATIVE_PROGRAMS) $(ROOT_BYTE_PROGRAMS) " | grep -q " $$basename "; then \ +- echo "Installing "`basename $$file`" as a \"root program\" into $$prefix/sbin..."; \ +- cp -a $$file $$prefix/sbin/; \ +- chmod +x $$prefix/sbin/$$basename; \ ++ echo "Installing "`basename $$file`" as a \"root program\" into $$prefixInstall/sbin..."; \ ++ cp -a $$file $$prefixInstall/sbin/; \ ++ chmod +x $$prefixInstall/sbin/$$basename; \ + else \ +- echo "Installing "`basename $$file`" into $$prefix/bin..."; \ +- cp -a $$file $$prefix/bin/; \ +- chmod +x $$prefix/bin/$$basename; \ ++ echo "Installing "`basename $$file`" into $$prefixInstall/bin..."; \ ++ cp -a $$file $$prefixInstall/bin/; \ ++ chmod +x $$prefixInstall/bin/$$basename; \ + fi; \ + done) && \ + echo 'Program installation was successful.' + +-# Remove the programs from this package from $prefix/bin: ++# Remove the programs from this package from $prefixInstall/bin: + uninstall-programs: main uninstall-programs-local +- @($(call READ_CONFIG, prefix); \ ++ @($(call READ_CONFIG, prefixInstall); \ + $(call READ_META, name); \ + echo "Removing $$name programs..."; \ + shopt -s nullglob; \ + for file in $(OTHER_PROGRAMS_TO_INSTALL) _build/*.byte _build/*.native; do \ + basename=`basename $$file`; \ + if echo " $(ROOT_NATIVE_PROGRAMS) $(ROOT_BYTE_PROGRAMS) " | grep -q " $$basename "; then \ +- echo -e "Removing the \"root program\" $$basename from $$prefix/sbin..."; \ +- export pathname=$$prefix/sbin/`basename $$file`; \ ++ echo -e "Removing the \"root program\" $$basename from $$prefixInstall/sbin..."; \ ++ export pathname=$$prefixInstall/sbin/`basename $$file`; \ + else \ +- echo -e "Removing $$basename from $$prefix/bin..."; \ +- export pathname=$$prefix/bin/`basename $$file`; \ ++ echo -e "Removing $$basename from $$prefixInstall/bin..."; \ ++ export pathname=$$prefixInstall/bin/`basename $$file`; \ + fi; \ + rm -f $$pathname; \ + done) && \ +@@ -679,14 +679,14 @@ + # $(2),..,$(9) in a file $(1). + # + # Example: +-# $(call SOURCE_AND_TEST,CONFIGME,prefix); +-# $(call SOURCE_AND_TEST,CONFIGME,prefix,libraryprefix); ++# $(call SOURCE_AND_TEST,CONFIGME,prefixInstall); ++# $(call SOURCE_AND_TEST,CONFIGME,prefixInstall,libraryprefix); + SOURCE_AND_TEST = \ + if ! source $(1) &> /dev/null; then \ + echo 'Evaluating $(1) failed.'; \ + exit 1; \ + fi; \ +- for i in $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9); do \ ++ for i in $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10); do \ + CMD="VAL=$$`echo $$i`"; eval $$CMD; \ + if test -z "$$VAL"; then \ + echo "FATAL: $${i} is undefined in $(1)."; \ +@@ -703,7 +703,7 @@ + # $(call GREP_AND_TEST,META,name); + # $(call GREP_AND_TEST,META,name,version); + GREP_AND_TEST = \ +- for i in $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9); do \ ++ for i in $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10); do \ + if ! CMD=`grep "^$$i=" $(1)`; then \ + echo "FATAL: $$i is undefined in $(1)."; \ + exit 1; \ +@@ -716,10 +716,10 @@ + # if the given names are defined + # + # Example: +-# $(call READ_CONFIG,prefix,libraryprefix); ++# $(call READ_CONFIG,prefixInstall,libraryprefix); + # + READ_CONFIG = \ +- $(call SOURCE_AND_TEST,CONFIGME,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8),$(9)) ++ $(call SOURCE_AND_TEST,CONFIGME,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8),$(9), $(10)) + + # Instance of GREP_AND_TEST: read the file "META" searching for a names + # for all given names +@@ -728,7 +728,7 @@ + # $(call READ_META,name,version); + # + READ_META = \ +- $(call GREP_AND_TEST,META,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8),$(9)) ++ $(call GREP_AND_TEST,META,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8),$(9), $(10)) + + # If the value of the 'version' variable contains the substring 'snapshot' then + # append to its value the current date, in hacker format. 'version' must be already +@@ -758,7 +758,7 @@ + echo $$sourcedirectories + + # Set the shell variable $(1) as the string obtained by prefixing each token +-# in $(2) with the prefix $(3): for example if the shell variable ++# in $(2) with the prefixInstall $(3): for example if the shell variable + # 'sourcedirectories' is set to './A ./B' then + # $(call ADD_PREFIX_TO_EACH_WORD, includes, $$sourcedirectories, -I) + # sets the shell variable 'includes' to '-I ./A -I ./B '. +@@ -906,11 +906,12 @@ + meta.ml: META + @(echo "Building $@..." && \ + $(call READ_META, name, version); \ +- $(call READ_CONFIG, prefix, libraryprefix, configurationprefix, documentationprefix localeprefix); \ ++ $(call READ_CONFIG, prefix, prefixInstall, libraryprefix, configurationprefix, documentationprefix localeprefix); \ + echo -e "(* This file is automatically generated; please don't edit it. *)\n" > $@ && \ + echo -e "let name = \"$$name\";;" >> $@ && \ + echo -e "let version = \"$$version\";;" >> $@ && \ + echo -e "let prefix = \"$$prefix\";;" >> $@ && \ ++ echo -e "let prefixInstall = \"$$prefixInstall\";;" >> $@ && \ + echo -e "let libraryprefix = \"$$libraryprefix\";;" >> $@ && \ + echo -e "let configurationprefix = \"$$configurationprefix\";;" >> $@ && \ + echo -e "let localeprefix = \"$$localeprefix\";;" >> $@ && \ @@ -21,14 +21,16 @@ source=("http://caml.inria.fr/distrib/ocaml-3.11/ocaml-3.11.2.tar.gz" 'http://wwwfun.kurims.kyoto-u.ac.jp/soft/lsl/dist/lablgtk-2.14.2.tar.gz' "https://www.marionnet.org/download/marionnet_from_scratch/mirror/ocamlbricks-0.90.3.tar.gz" "https://www.marionnet.org/download/marionnet_from_scratch/mirror/marionnet-0.90.6.tar.gz" - "https://raw.githubusercontent.com/JulioJu/Marionnet-old_ArchLinux-installer/master/Makefile.patch" + "https://raw.githubusercontent.com/JulioJu/Marionnet_ArchLinux_Installer/master/Makefile-legacy.patch" + "https://raw.githubusercontent.com/JulioJu/Marionnet_ArchLinux_Installer/master/marionnet_from_scratch-Downloader" ) sha256sums=('83008744c0ba1e3460651b86d0900916edae38813eb9a0300e8eaa861c3e921e' '4981abedabdc462303f345104042c88af227ccd50fd30a9bf48fd353ab02d0ba' '39cc4cc100124b8363c9760494d7e285803ca22ff8409f79038f3fb4a146a96c' '3a571a2cb4724b50eb52e33191d42a6b8396889e728bc974bc396395c9ce03ac' - '1fd697ff5f7055bcd6da2b6b5233d58bf79a2d4fc59b36eb79fb3c0d63265d3c') -install=marionnet.install + '1fd697ff5f7055bcd6da2b6b5233d58bf79a2d4fc59b36eb79fb3c0d63265d3c' + '5d8ddf6e5c5b726e892bae2b55eb5eb01f43bd47fa2855ec38797d0598a6ea24') +install=marionnet-legacy.install # ################ # MAKEDEPENDS : CREATED DURING COMPILATION but not keep @@ -246,6 +248,9 @@ EOF optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.hardware-gray.small.png optipng -quiet -fix ${pkgdir}/usr/share/marionnet/images/ico.cable-serial-left-right.large.png + chmod u+x "${srcdir}/marionnet_from_scratch-Downloader" + mv "${srcdir}/marionnet_from_scratch-Downloader" "${pkgdir}/usr/share/marionnet" + echo -e "0\n0.90" > "${pkgdir}/usr/share/marionnet/numberOfStepsPassedForDownloadMarionnetFilesystems.tmp" } diff --git a/marionnet-legacy.install b/marionnet-legacy.install new file mode 100644 index 000000000000..0d6d161b933c --- /dev/null +++ b/marionnet-legacy.install @@ -0,0 +1,207 @@ + +# Adapted from : +# http://bazaar.launchpad.net/~marionnet-drivers/marionnet/trunk/view/head:/useful-scripts/marionnet_from_scratch +# (LGPL) + +post_install () { + +echo -e "* Marionnet installation completed\n\n" + +echo -e "Post installation hook" +echo -e "——————————————————————\n" + +# ============================================================= +# Adjust X -nolisten tcp +# ============================================================= + +# Here $SUDO_OR_NOTHING is null +tmpfile=$(mktemp /tmp/marionnetInstallTmpXXXXXXX) + +function remove_nolisten_assignment_from { +# global SUDO_OR_NOTHING +local i=$1 +$SUDO_OR_NOTHING sed -i -e 's/\(^[a-ZA-Z0-9]*[=].*[-]nolisten tcp.*\)$/#\1\n\1/g' $i +$SUDO_OR_NOTHING sed -i -e 's/\(^[a-ZA-Z0-9]*[=].*\)[-]nolisten tcp\(.*\)$/\1 \2/g' $i +} + +function remove_nolisten_X_or_startx_actuals_from { +# global SUDO_OR_NOTHING +local i=$1 +$SUDO_OR_NOTHING sed -i -e 's/\(^[a-ZA-Z0-9/: ]*X.*\)[-]nolisten tcp\(.*\)$/\1\2/g' $i +$SUDO_OR_NOTHING sed -i -e 's/\(^[a-ZA-Z0-9/: ]*startx.*\)[-]nolisten tcp\(.*\)$/\1\2/g' $i +} + +function remove_DisallowTCP_from { +# global SUDO_OR_NOTHING +local i=$1 +$SUDO_OR_NOTHING sed -i -e 's/\(^DisallowTCP=true.*\)$/#\1\nDisallowTCP=false/g' $i +} + +# Sections in file have the form "[security]" +function ensure_section_and_binding { +[[ $# -ge 3 ]] || return 1 +local SECTION=$1 # ex: security +local VARIABLE=$2 # ex: Enable +local VALUE=$3 # ex: true +local AWK_PROGRAM +shift 3 +AWK_PROGRAM=" +BEGIN {x=0} +/\[$SECTION\]/ {x=1;print;next} +(x==1) && /$VARIABLE=.*/ {print \"$VARIABLE=$VALUE\"; x=2; next} +(x==1) && /\[.*\]/ {print \"$VARIABLE=$VALUE\n\"; print; x=2; next} +/\[.*\]/ {print;next} +{print} + END {if (x==0) print \"[$SECTION]\"; if (x==0 || x==1) print \"$VARIABLE=$VALUE\n\";}" + case $# in + 0) awk "$AWK_PROGRAM" ;; + *) + local i + local TMPFILE=$(tmpfile) + for i in "$@"; do + awk 0<"$i" 1>$TMPFILE "$AWK_PROGRAM" + cat $TMPFILE 1>"$i" + done + rm $TMPFILE + ;; + esac +} + +# This is needed, for instance, for ubuntu 10.10 +function ensure_DisallowTCP_false_to_gdm_custom_dot_conf { +# global SUDO_OR_NOTHING CHANGED_FILES +local custom=${1:-/etc/gdm/custom.conf} +local TMPFILE=$(tmpfile) +cp $custom $TMPFILE +ensure_section_and_binding "security" "DisallowTCP" "false" $TMPFILE +ensure_section_and_binding "xdmcp" "Enable" "true" $TMPFILE +if ! diff -q $custom $TMPFILE >/dev/null; then + CHANGED_FILES+="$custom " + $SUDO_OR_NOTHING bash -c "cat $TMPFILE >$custom" +fi +} + +# This is needed, for instance, for ubuntu 12.04 +function ensure_xserver_allow_tcp_in_lightdm_dot_conf { +# global SUDO_OR_NOTHING CHANGED_FILES +local custom=${1:-/etc/lightdm/lightdm.conf} +local TMPFILE=$(tmpfile) +cp $custom $TMPFILE +ensure_section_and_binding "SeatDefaults" "xserver-allow-tcp" "true" $TMPFILE +if ! diff -q $custom $TMPFILE >/dev/null; then + CHANGED_FILES+="$custom " + $SUDO_OR_NOTHING bash -c "cat $TMPFILE >$custom" +fi +} + + +function apply_all_filters { +# global CHANGED_FILES +local i=$1 +cat $i > $BACKUP +{ remove_nolisten_assignment_from $i; + remove_DisallowTCP_from $i; + remove_nolisten_X_or_startx_actuals_from $i; +} || true +diff -q $BACKUP $i >/dev/null || { +CHANGED_FILES+="$i " + } +} + +function adjust_X_display_manager { +# global SUDO_OR_NOTHING CHANGED_FILES +local BACKUP=$(tmpfile) +DIRS=$($SUDO_OR_NOTHING find /etc/ -type d -name "?dm") +if [[ -d /etc/X11/xinit ]]; then DIRS+=" /etc/X11/xinit/"; fi +FILES=$([[ -n $DIRS ]] && $SUDO_OR_NOTHING find $DIRS -name "*rc" -o -name "*.conf") +FILES=$(for i in $FILES; do grep -l "^[a-zA-Z0-9/_\-= ]*[-]nolisten tcp" $i; done) +for i in $FILES; do apply_all_filters $i; done +rm -f $BACKUP +# A special case: gdm/gdm3 : +if [[ -d /etc/gdm ]]; then + $SUDO_OR_NOTHING touch /etc/gdm/custom.conf + ensure_DisallowTCP_false_to_gdm_custom_dot_conf +elif [[ -d /etc/gdm? ]]; then + $SUDO_OR_NOTHING touch /etc/gdm?/custom.conf /etc/gdm?/daemon.conf + ensure_DisallowTCP_false_to_gdm_custom_dot_conf /etc/gdm?/custom.conf + ensure_DisallowTCP_false_to_gdm_custom_dot_conf /etc/gdm?/daemon.conf +fi +# Another special case: lightdm +if [[ -d /etc/lightdm ]]; then + $SUDO_OR_NOTHING touch /etc/lightdm/lightdm.conf + ensure_xserver_allow_tcp_in_lightdm_dot_conf +fi +[[ -n $CHANGED_FILES ]] +} + +if ps -A -o cmd | grep -q '^[a-zA-Z0-9/]*X.*[-]nolisten tcp'; then + echo -e "\n---" + echo "=============================================================" + echo " Warning readme" + echo " Warning readme" + echo "=============================================================" + echo "* Warning: your X server has been launched with the option '-nolisten tcp'" + echo " => This option should be removed from your X display manager configuration." + echo -n " Shall I try to fix it ([y]/n)? " + read z + if [[ $z != n && $z != N ]]; then + if adjust_X_display_manager; then + echo " Ok. File(s) changed: $CHANGED_FILES" + echo " You must restart your X display manager for the changes to take effect." + else + echo " Sorry, no change performed: you must edit your configuration manually." + fi + fi +else + echo -e "\n* Your X server hasn't been launched with the option \ + '-nolisten tcp' : good." +fi + +# ============================================================= +# Daemon information +# ============================================================= + +echo "\n=============================================================" +echo " Daemon information " +echo "=============================================================\n" + +echo -e "* Before start Marionnet, you must start the daemon :" +echo "sudo systemctl start marionnetdaemon.service" + +# ============================================================= +# Install marionnet_kernels and filesystems +# ============================================================= + +echo "\n=============================================================" +echo " Downlading " +echo "=============================================================" + +echo "\n* Downloading script marionnet_from_scratch : " +wget http://www.marionnet.org/downloads/marionnet_from_scratch/marionnet_from_scratch +echo "* Downlading and installing Marionnet kernels and filesystems (Linux \ +distributions Debian Lenny, Mandriva, Pinocchio, etc.)" +echo -e "* Warning! this process may take several hours!" +chmod u+x ./numberOfStepsPassedForDownloadMarionnetFilesystems.tmp +./numberOfStepsPassedForDownloadMarionnetFilesystems.tmp -m 0.90 --prefix /usr/share/marionnet + + + + +echo "* Post installation completed———\n\n\n" + +} + +post_remove() { +echo -e "* Uninstallation process completed\n\n" + +echo -e "Post remove hook" +echo -e "——————————————————————\n" +echo "* Erasing Marionnet kernels files..." + rm -Rf /usr/share/marionnet +echo "Success." +} + + + + +# vim: ft=sh diff --git a/marionnet.install b/marionnet.install index dd7804a29f20..0d6d161b933c 100644 --- a/marionnet.install +++ b/marionnet.install @@ -181,10 +181,8 @@ wget http://www.marionnet.org/downloads/marionnet_from_scratch/marionnet_from_sc echo "* Downlading and installing Marionnet kernels and filesystems (Linux \ distributions Debian Lenny, Mandriva, Pinocchio, etc.)" echo -e "* Warning! this process may take several hours!" -echo -e "* Command : \`./marionnet_from_scratch --download-only \ ---prefix /opt/marionnet\`" -chmod +x ./marionnet_from_scratch -./marionnet_from_scratch --download-only --prefix /usr +chmod u+x ./numberOfStepsPassedForDownloadMarionnetFilesystems.tmp +./numberOfStepsPassedForDownloadMarionnetFilesystems.tmp -m 0.90 --prefix /usr/share/marionnet diff --git a/marionnet_from_scratch-Downloader b/marionnet_from_scratch-Downloader new file mode 100644 index 000000000000..1d2261963634 --- /dev/null +++ b/marionnet_from_scratch-Downloader @@ -0,0 +1,498 @@ +#!/bin/bash + +# Adapted by JulioJu from : +# http://bazaar.launchpad.net/~marionnet-drivers/marionnet/trunk/view/head:/useful-scripts/marionnet_from_scratch +# by Jean-Vincent Loddo Université Paris 13 +# (may 2016) +# (LGPL) + +# This file is part of marionnet +# Copyright (C) 2010 2011 2012 2013 2014 2015 2016 Jean-Vincent Loddo +# Copyright (C) 2010 2011 2012 2013 2014 2015 2016 Université Paris 13 +# +# 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 2 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/>. + +# Script JulioJu custom version +# 2016.05.28 + +set -e +shopt -s nullglob +shopt -s expand_aliases + +# function exiting_because_error { +# # global KEEP_DEBRIS TWDIR +# echo -e "\n\n\n\nExiting because of an unexpected error in line $BASH_LINENO" +# exit 3 +# } +# # +# trap exiting_because_error ERR + +function trap_custom { +local SIGINT=2 +local SIGQUIT=3 +local SIGABRT=6 +local SIGKILL=9 +local SIGTERM=15 # CTRL-C +local TRAPPED_EVENTS="$SIGINT $SIGQUIT $SIGABRT $SIGKILL $SIGTERM" +trap "exiting_because_signal" $TRAPPED_EVENTS +} + +trap_custom + + +# @todo +# FOR UPDATE THIS SCRIPT, PLEASE MAINTAINS TUNNING SECTION +# FOR UPDATE THIS SCRIPT, PLEASE MAINTAINS TUNNING SECTION +# FOR UPDATE THIS SCRIPT, PLEASE MAINTAINS TUNNING SECTION + +# ============================================================= +# PARSING COMMAND LINE {{{1 +# ============================================================= + +# Getopt's format used to parse the command line: +OPTSTRING="hp:m:b:o:gG:t:kl:d:v:NVDKPFTAOc:" + +function parse_cmdline { +local i j flag +# Transform long format options into the short one: +for i in "$@"; do + if [[ double_dash_found = 1 ]]; then + ARGS+=("$i") + else case "$i" in + --help) + ARGS+=("-h"); + ;; + --marionnet-version|--marionnet) + ARGS+=("-m"); + ;; + --prefix) + ARGS+=("-p"); + ;; + --) + ARGS+=("--"); + double_dash_found=1; + ;; + --[a-zA-Z0-9]*) + echo "*** Illegal long option $i."; + exit 1; + ;; + -[a-zA-Z0-9]*) + j="${i:1}"; + while [[ $j != "" ]]; do ARGS+=("-${j:0:1}"); j="${j:1}"; done; + ;; + *) + ARGS+=("$i") + ;; + esac + fi +done +set - "${ARGS[@]}" +unset ARGS + +# Interpret short format options: +while [[ $# -gt 0 ]]; do + OPTIND=1 + while getopts ":$OPTSTRING" flag; do + if [[ $flag = '?' ]]; then + echo "ERROR: illegal option -$OPTARG."; + exit 1; + fi + eval "option_${flag}=$OPTIND" + eval "option_${flag}_arg='$OPTARG'" + done + for ((j=1; j<OPTIND; j++)) do + if [[ $1 = "--" ]]; then + shift; + for i in "$@"; do ARGS+=("$i"); shift; done + break 2; + else + shift; + fi + done + # Get just the first argument and reloop: + for i in "$@"; do ARGS+=("$i"); shift; break; done +done +} # end of parse_cmdline() + +declare -a ARGS +parse_cmdline "$@" # read OPTSTRING and set ARGS +# Warning: the following two branches could not be grouped +# into the single command (`else' branch): +# set - "${ARGS[@]}"; +# The behaviour is not the same when the array is empty! +if [[ ${#ARGS[@]} -eq 0 ]]; then + set - ""; +else + set - "${ARGS[@]}"; +fi +unset ARGS + +function print_usage_and_exit { + echo -e "\n\nUsage: ${0##*/} [OPTIONS] +Download, and decompress step by step Marionnet's principal dependencies from mirror\ +(http://www.marionnet.org/download/). + + $(print_description_script) +Options: + -p, --prefix PATH Set the installation prefix + -h Print this message and exit + -m, --marionnet VERSION Set marionnet's version (for instance 'trunk') +Defaults: + - the installation prefix is ${PREFIX} + - marionnet's version is ${MARIONNET_VERSION:-latest}" + exit $1 +} + + +# Option -h +if [[ -n ${option_h} ]]; then + print_usage_and_exit 0 +fi + +# Option -p, --prefix +if [[ -n ${option_p} ]]; then + PREFIX=$(realpath "${option_p_arg}") +else + PREFIX=$(realpath /usr/share) +fi + +# test version +MARIONNET_VERSION= +if [[ -n ${option_m} ]]; then + MARIONNET_VERSION="${option_m_arg}" +elif [[ -e "./numberOfStepsPassedForDownloadMarionnetFilesystems.tmp" ]] +then + vr=$(cat "./numberOfStepsPassedForDownloadMarionnetFilesystems.tmp" | tail -n 1) + MARIONNET_VERSION="$vr" + unset vr +fi +if [[ $MARIONNET_VERSION != "trunk" && $MARIONNET_VERSION != "0.90" ]] ; + then + z= + echo "Is it Marionnet trunk version [y/n] ?" + read z + while [[ $z != "y" && $z != "Y" && $z != "n" && $z != "N" ]] ; do + # Infinite loop under Archlinux Build System + echo "Is it Marionnet trunk version [y/n] ?" + read z + done + if [[ $z == "y" || $z == "Y" ]] ; then + MARIONNET_VERSION="trunk" + else + MARIONNET_VERSION="0.90" + fi + unset z +fi + +# ============================================================= +# TUNING {{{1 +# ============================================================= + +if [[ $MARIONNET_VERSION == "trunk" ]] ; then + REQUIRED_MB=7000 + number_of_steps=8 +else + REQUIRED_MB=5000 + number_of_steps=5 +fi + +# kernels weight (Mo) +kernels_weight=3 +pinocchio_weight=49 +big_filesystems_Debian_weight=432 +big_filesystems_Mandriva_weight=347 +big_filesystems_weight=0 +if [[ $MARIONNET_VERSION == "trunk" ]]; then + kernelsv1_weight=3 + tiny_filesystemsv1_weight=16 + big_filesystemsv1_weight=560 +else + kernelsv1_weight=0 + tiny_filesystemsv1_weight=0 + big_filesystemsv1_weight=0 +fi +total_weight=$((\ +$kernels_weight+$pinocchio_weight+\ +$big_filesystems_Debian_weight+$big_filesystems_Mandriva_weight+$big_filesystems_weight+\ +$kernelsv1_weight+$tiny_filesystemsv1_weight+$big_filesystemsv1_weight\ +)) + +# This array is used if download resume, to calculate new total_weight of +# current download +rest=$total_weight +array_weight_total_downloaded=( "$(($rest-$kernels_weight))" +"$(($rest-$pinocchio_weight))" +"$(($rest-$big_filesystems_Debian_weight))" +"$(($rest-$big_filesystems_Mandriva_weight))" +"$(($rest-$big_filesystems_weight))" +"$(($rest-$kernelsv1_weight))" +"$(($rest-$tiny_filesystemsv1_weight))" +"$(($rest-$big_filesystemsv1_weight))") +rest=$total_weight + +# Array used in Main to perfom all download. +if [[ $MARIONNET_VERSION == "trunk" ]]; then + # Work without eval in bash 4.3 + array_perform_action=("download_our_kernels $kernels_weight" + "download_our_pinocchio_filesystems $pinocchio_weight" + "download_our_big_filesystems $big_filesystems_weight" + "download_debian_lenny $big_filesystems_Debian_weight" + "download_mandriva $big_filesystems_Mandriva_weight" + "download_our_v1_kernels $kernelsv1_weight" + "download_our_v1_tiny_filesystems $tiny_filesystemsv1_weight" + "download_our_v1_big_filesystems $big_filesystemsv1_weight") +else + array_perform_action=("download_our_kernels $kernels_weight" + "download_our_pinocchio_filesystems $pinocchio_weight" + "download_our_big_filesystems $big_filesystems_weight") +fi + + +OUR_BASE_URL="https://www.marionnet.org/downloads/marionnet_from_scratch" +OUR_MIRROR="$OUR_BASE_URL/mirror/" +OUR_TRUNK_SPECIFIC_URL="$OUR_BASE_URL/trunk" + + + +# ============================================================= +# Tests function {{{1 +# ============================================================= + +function print_description_script { +echo -e " If the download is interrupted, it can be resumed by execute ${0##*/} who \ +is stored in $(realpath ./). This programm test if the hard disk have \ +enough free space, if there isn't enough, it don't start download. + +Under ArchLinux, if Marionnet have been installed with Aur repository, +files are extract in the good foler (i.e. /usr/share/marionnet). \ +For other distributions, or if you have installed with the script « \ +marionnet_from_scratch » customise the « --prefix » option. " +} + + +function exiting_because_signal { +echo -e "\n\n\n\nExiting because of signal." + +print_description_script + +echo -e "\n\n" + + +if [[ $MARIONNET_VERSION = "trunk" ]]; then + echo -e "If it's trunk version, run « ./marionnet_from_scratch-Download -m trunk" » + echo -e "If $PREFIX/numberOfStepsPassedForDownloadMarionnetFilesystems.tmp exists,\ you can omit « -m trunk »." +fi +echo -e " +--- +--- +Exiting." +exit 2 +} + +# Temporary Working Directory TWDIR (global variable) +# Automatically cleaned when some events occur +function freespace { +local FREE_MB=$(df -B 1M -P $PREFIX | awk '{print $4}' | tail -n 1) +if [[ $FREE_MB -lt $REQUIRED_MB ]]; then + echo "Insufficient free disk space (${FREE_MB} Mb) in the directory $PREFIX." + echo "It's beautifule to have $REQUIRED_MB Mb to install and keep a little bit more space in your disk." + echo "Exiting." + exit 1 +fi 1>&2 +} + +# ============================================================= +# FUNCTIONS FOR DOWNLOADING OUR KERNELS AND FILESYSTEMS {{{1 +# ============================================================= + +function download_our_kernels { +# global $OUR_BASE_URL +# parameters : file-weight $1 +local KERNELS +KERNELS=$(curl -L --silent --show-error "$OUR_BASE_URL" \ + | grep -o 'href="kernels_[^"]*"' \ + | grep -o "kernels_[^\"]*[.]tar[.]gz"\ + ) +echo -e "\n\nStage « $FUNCNAME »" +for i in $KERNELS; do + launch_and_log "$OUR_BASE_URL/$i" $i $1 +done +} + +function download_debian_lenny { +echo -e "\n\nStage « $FUNCNAME »" +i="filesystems_machine-debian-lenny-sid-2008.tar.gz" +launch_and_log "$OUR_BASE_URL/$i" $i $1 +} + +function download_mandriva { +echo -e "\n\nStage « $FUNCNAME »" +i="filesystems_machine-mandriva20100215.tar.gz" +launch_and_log "$OUR_BASE_URL/$i" $i $1 +} + +function download_our_big_filesystems { +# global $OUR_BASE_URL +# parameters : file-weight $1 +local FILESYSTEMS +FILESYSTEMS=$(curl -L --silent --show-error "$OUR_BASE_URL" \ + | grep -o 'href="filesystems_[^"]*"' \ + | grep -o "filesystems_[^\"]*[.]tar[.]gz"\ + | grep -v "filesystems_pinocchio.*[.]tar[.]gz"\ + ) +echo -e "\n\nStage « $FUNCNAME »" +for i in $FILESYSTEMS; do + if [[ $i == "filesystems_machine-debian-lenny-sid-2008.tar.gz" ]] ; then + continue + elif [[ $i == "filesystems_machine-mandriva20100215.tar.gz" ]] ; then + continue + fi + launch_and_log "$OUR_BASE_URL/$i" $i $1 +done +} + +function download_our_pinocchio_filesystems { +# global $OUR_BASE_URL +# parameters : file-weight $1 +local KERNELS +KERNELS=$(curl -L --silent --show-error "$OUR_BASE_URL" \ + | grep -o 'href="kernels_[^"]*"' \ + | grep -o "kernels_[^\"]*[.]tar[.]gz"\ + ) +echo -e "\n\nStage « $FUNCNAME »" +for i in $KERNELS; do + launch_and_log "$OUR_BASE_URL/$i" $i $1 +done +} + +function download_our_v1_kernels { +# global $OUR_TRUNK_SPECIFIC_URL +# parameters : file-weight $1 +local KERNELS +KERNELS=$(curl -L --silent --show-error "$OUR_TRUNK_SPECIFIC_URL" \ + | grep -o 'href="kernels_[^"]*"' \ + | grep -o "kernels_[^\"]*[.]tar[.]gz"\ + ) +echo -e "\n\nStage « $FUNCNAME »" +for i in $KERNELS; do + launch_and_log "$OUR_TRUNK_SPECIFIC_URL/$i" $i $1 +done +} + +function download_our_v1_tiny_filesystems { +# global $OUR_TRUNK_SPECIFIC_URL +# parameters : file-weight $1 +local FILESYSTEMS +FILESYSTEMS=$(curl -L --silent --show-error "$OUR_TRUNK_SPECIFIC_URL" \ + | grep -o 'href="filesystems_guignol[^"]*"' \ + | grep -o "filesystems_[^\"]*[.]tar[.]gz"\ + ) +echo -e "\n\nStage « $FUNCNAME »" +for i in $FILESYSTEMS; do + launch_and_log "$OUR_TRUNK_SPECIFIC_URL/$i" $i $1 +done +} + +function download_our_v1_big_filesystems { +# global $OUR_TRUNK_SPECIFIC_URL +# parameters : file-weight $1 +local FILESYSTEMS +FILESYSTEMS=$(curl -L --silent --show-error "$OUR_TRUNK_SPECIFIC_URL" \ + | grep -o 'href="filesystems_[^"]*"' \ + | grep -o "filesystems_[^\"]*[.]tar[.]gz"\ + | grep -v "filesystems_guignol.*[.]tar[.]gz"\ + ) +echo -e "\n\nStage « $FUNCNAME »" +for i in $FILESYSTEMS; do + launch_and_log "$OUR_TRUNK_SPECIFIC_URL/$i" $i $1 +done +} + +function launch_and_log { +# Parameter : $1 URL, $2 filename, $3 file-weight, +local currentPercentDownloading=$(echo "scale=2;$3/$total_weight*100" | bc) +rest=$(echo "$rest-$3" | bc) +local restPerCent=$(echo "scale=2;$rest/$total_weight*100"|bc) +echo -e "We are going to download $3 Mo ($currentPercentDownloading% of the $total_weight Mo). \ +After this stage this is still $rest Mo to download (or \ +$restPerCent%) " +curl -L -O -C - $1 # -C - => resume download if any ; -L => follow redirections +# @todo sha256sums +echo "Decompressing : " +# tar -xvf ${2} +rm -f ${2} +echo -e "Success…\n\n\n———" +} + + +# ============================================================= +# Main {{{1 +# ============================================================= + +echo -e "\n\n\nMarionnet filesystems downloader" +echo "————————————————————————————————" + +echo "Download, and decompress step by step Marionnet's principal dependencies from mirror\ +(http://www.marionnet.org/download/)." +print_description_script + +mkdir -p $PREFIX +cd $PREFIX +if [[ -e numberOfStepsPassedForDownloadMarionnetFilesystems.tmp ]] +then + stepPerformed=$(cat ./numberOfStepsPassedForDownloadMarionnetFilesystems.tmp | head -n 1) + echo "Restart the download process from Step $stepPerformed" +else + stepPerformed=0 +fi +if [[ ! $stepPerformed =~ ^[0-9]$ ]] ; then + echo "Invalid step readen. Restart downloading" + stepPerformed=0 +fi + +if [[ $stepPerformed -gt 0 && $stepPerformed -le ${#array_weight_total_downloaded[@]} && $stepPerformed \ + -lt $number_of_steps ]]; then + REQUIRED_MB=$(echo "$REQUIRED_MB-($total_weight-${array_weight_total_downloaded[$(($stepPerformed-1))]})" | bc ) + total_weight=${array_weight_total_downloaded[$(($stepPerformed-1))]} +fi + +# freespace > /dev/null # just verify free space + +while [[ $stepPerformed -lt $number_of_steps ]]; do + $(echo ${array_perform_action[$stepPerformed]}) + stepPerformed=$(($stepPerformed+1)) + echo -e "$stepPerformed\n$MARIONNET_VERSION" > \ + "$PREFIX/numberOfStepsPassedForDownloadMarionnetFilesystems.tmp" +done + + +# }}} + +# ============================================================= +# Notes +# ============================================================= + +echo "" +echo '---' +echo "* Notes:" +echo " - Customize your installation by editing /etc/marionnet/marionnet.conf" +echo " - Under Arch Linux if you have installed Marionnet with the community \ +- driven for Arch Users (Aur), you must enable or start Aur \ +marionnetdaemon.service." + +echo '---' +echo "Success." +exit 0 + +# vim: set noet: |