Log In | Get Help   
Home My Page Projects Code Snippets Project Openings transition state search using dynamics
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files Wiki
[tsscds] Annotation of /trunk/install-gnu-parallel-from-source.sh
[tsscds] / trunk / install-gnu-parallel-from-source.sh Repository:
ViewVC logotype

Annotation of /trunk/install-gnu-parallel-from-source.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 246 - (view) (download) (as text)
Original Path: install-gnu-parallel.sh

1 : baaden 246 #!/bin/bash
2 :    
3 :     # Copyright (C) 2013 Ole Tange and Free Software Foundation, Inc.
4 :     #
5 :     # This program is free software; you can redistribute it and/or modify
6 :     # it under the terms of the GNU General Public License as published by
7 :     # the Free Software Foundation; either version 3 of the License, or
8 :     # (at your option) any later version.
9 :     #
10 :     # This script downloads the latest version of GNU Parallel, checks
11 :     # the signature and installs it.
12 :     #
13 :     # It first tries to install it globally.
14 :     # If that fails, it does a personal installation.
15 :     # If that fails, it copies to $HOME/bin
16 :    
17 :     # Download and run the script directly by:
18 :     # (wget -O - pi.dk/3 || curl pi.dk/3/ || fetch -o - http://pi.dk/3) | bash
19 :    
20 :     # tail on openindiana must be /usr/xpg4/bin/tail
21 :     TAIL=$(echo | tail -n 1 2>/dev/null && echo tail || (echo | /usr/xpg4/bin/tail -n 1 && echo /usr/xpg4/bin/tail))
22 :     # grep on openindiana must be /usr/xpg4/bin/grep
23 :     GREP=$(echo | grep -vE . 2>/dev/null && echo grep || (echo | /usr/xpg4/bin/grep -vE . && echo /usr/xpg4/bin/grep))
24 :     # FreeBSD prefers 'fetch', MacOS prefers 'curl', Linux prefers 'wget'
25 :     GET=$(
26 :     (fetch -o /dev/null file:///bin/sh && echo fetch -o -) ||
27 :     (curl -h >/dev/null && echo curl -L) ||
28 :     (wget -h >/dev/null && echo wget -qO -) ||
29 :     echo 'No wget, curl, fetch: Please inform parallel@gnu.org what you use for downloading URLs' >&2
30 :     )
31 :     if test "$GET" = ""; then
32 :     exit 1
33 :     fi
34 :    
35 :     if ! perl -e 1; then
36 :     echo No perl installed. GNU Parallel depends on perl. Install perl and retry
37 :     exit 1
38 :     fi
39 :    
40 :     LANG=C
41 :     LATEST=$($GET http://ftpmirror.gnu.org/parallel | perl -ne '/.*(parallel-\d{8})/ and print $1."\n"' | sort | $TAIL -n1)
42 :     if test \! -e $LATEST.tar.bz2; then
43 :     # Source tar does not exist
44 :     rm -f $LATEST.tar.bz2 $LATEST.tar.bz2.sig
45 :     $GET http://ftpmirror.gnu.org/parallel/$LATEST.tar.bz2 > $LATEST.tar.bz2
46 :     $GET http://ftpmirror.gnu.org/parallel/$LATEST.tar.bz2.sig > $LATEST.tar.bz2.sig
47 :     fi
48 :    
49 :     # Check signature - in case ftpmirror.gnu.org is compromised
50 :     if gpg -h 2>/dev/null >/dev/null; then
51 :     # GnuPG installed
52 :     # Setup .gnupg/gpg.conf if not already done
53 :     echo | gpg 2>/dev/null >/dev/null
54 :     gpg --keyserver keys.gnupg.net --recv-key FFFFFFF1
55 :     gpg --keyserver keys.gnupg.net --recv-key 88888888
56 :     if gpg --with-fingerprint $LATEST.tar.bz2.sig 2>&1 | $GREP -E '^Primary key fingerprint: BE9C B493 81DE 3166 A3BC 66C1 2C62 29E2 FFFF FFF1|^Primary key fingerprint: CDA0 1A42 08C4 F745 0610 7E7B D1AB 4516 8888 8888' ; then
57 :     # Source code signed by Ole Tange <ole@tange.dk> KeyID FFFFFFF1/88888888
58 :     true
59 :     else
60 :     # GnuPG signature failed
61 :     echo
62 :     echo "The signature on $LATEST.tar.bz2 is wrong. This may indicate that a criminal has changed the code."
63 :     echo "THIS IS BAD AND THE CODE WILL NOT BE INSTALLED."
64 :     echo
65 :     echo "See http://git.savannah.gnu.org/cgit/parallel.git/tree/README for other installation methods."
66 :     exit 1
67 :     fi
68 :     else
69 :     # GnuPG not installed
70 :     echo "GnuPG (gpg) is not installed so the signature cannot be checked."
71 :     echo "This means that if the code has been changed by criminals, you will not discover that!"
72 :     echo
73 :     echo "Continue anyway? (y/n)"
74 :     read YN </dev/tty
75 :     if test "$YN" = "n"; then
76 :     # Stop
77 :     exit 2
78 :     else
79 :     # Continue
80 :     true
81 :     fi
82 :     fi
83 :    
84 :     bzip2 -dc $LATEST.tar.bz2 | tar xf -
85 :     cd $LATEST || exit 2
86 :     if ./configure && make && make install; then
87 :     echo
88 :     echo GNU $LATEST installed globally
89 :     else
90 :     if ./configure --prefix=$HOME && make && make install; then
91 :     echo
92 :     echo GNU $LATEST installed in $HOME/bin
93 :     else
94 :     mkdir -p $HOME/bin/;
95 :     chmod 755 src/*;
96 :     cp src/parallel src/sem src/sql src/niceload $HOME/bin;
97 :     echo
98 :     echo GNU $LATEST copied to $HOME/bin
99 :     fi
100 :    
101 :     # Is $HOME/bin already in $PATH?
102 :     if echo $PATH | grep $HOME/bin >/dev/null; then
103 :     # $HOME/bin is already in $PATH
104 :     true
105 :     else
106 :     # Add $HOME/bin to $PATH for both bash and csh
107 :     echo 'PATH=$PATH:$HOME/bin' >> $HOME/.bashrc
108 :     echo 'setenv PATH ${PATH}:${HOME}/bin' >> $HOME/.cshrc
109 :     fi
110 :    
111 :     # Is $HOME/share/man already in $MANPATH?
112 :     if echo $MANPATH | grep $HOME/share/man >/dev/null; then
113 :     # $HOME/share/man is already in $MANPATH
114 :     true
115 :     else
116 :     # Add $HOME/share/man to $MANPATH for both bash and csh
117 :     echo 'MANPATH=$MANPATH:$HOME/share/man' >> $HOME/.bashrc
118 :     echo 'setenv MANPATH ${MANPATH}:${HOME}/share/man' >> $HOME/.cshrc
119 :     fi
120 :     fi

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge