--pipepart --group-by implemented (except column names).
[parallel.git] / 10seconds_install
blobfebfeb8fa4e0c946342232eedca7752f4b1420a8
1 #!/bin/bash
3 # Copyright (C) 2013-2019 Ole Tange and Free Software Foundation, Inc.
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.
10 # This script downloads the latest version of GNU Parallel, checks
11 # the signature and installs it.
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
17 # You can download and run the script directly by:
18 # $ (wget -O - pi.dk/3 || lynx -source pi.dk/3 || curl pi.dk/3/ || \
19 # fetch -o - http://pi.dk/3) > install.sh
20 # $ sha1sum install.sh
21 # $ md5sum install.sh
22 # $ sha512sum install.sh
23 # $ bash install.sh
25 run() {
26 # tail on openindiana must be /usr/xpg4/bin/tail
27 TAIL=$(echo | tail -n 1 2>/dev/null && echo tail ||
28 (echo | /usr/xpg4/bin/tail -n 1 && echo /usr/xpg4/bin/tail))
29 # grep on openindiana must be /usr/xpg4/bin/grep
30 GREP=$(echo | grep -vE . 2>/dev/null && echo grep ||
31 (echo | /usr/xpg4/bin/grep -vE . && echo /usr/xpg4/bin/grep))
32 # FreeBSD prefers 'fetch', MacOS prefers 'curl', Linux prefers 'wget'
33 GET=$(
34 (lynx -source /dev/null && echo lynx -source) ||
35 (fetch -o /dev/null file:///bin/sh && echo fetch -o -) ||
36 (curl -h >/dev/null && echo curl -L) ||
37 (wget -h >/dev/null && echo wget -qO -) ||
38 echo 'No lynx, wget, curl, fetch: Please inform parallel@gnu.org what you use for downloading URLs' >&2
40 if test "$GET" = ""; then
41 exit 1
44 if ! perl -e 1; then
45 echo No perl installed. GNU Parallel depends on perl. Install perl and retry.
46 exit 1
49 LANG=C
50 LATEST=$($GET http://ftpmirror.gnu.org/parallel |
51 perl -ne '/.*(parallel-\d{8})/ and print $1."\n"' |
52 sort | $TAIL -n1)
53 if test \! -e $LATEST.tar.bz2; then
54 # Source tar does not exist
55 rm -f $LATEST.tar.bz2 $LATEST.tar.bz2.sig
56 $GET http://ftpmirror.gnu.org/parallel/$LATEST.tar.bz2 > $LATEST.tar.bz2
57 $GET http://ftpmirror.gnu.org/parallel/$LATEST.tar.bz2.sig > $LATEST.tar.bz2.sig
60 fetch_keys() {
61 if gpg -h 2>/dev/null >/dev/null ; then
62 # GnuPG installed
63 # Setup .gnupg/gpg.conf if not already done
64 echo | gpg 2>/dev/null >/dev/null
65 keyserver1=keys.gnupg.net
66 keyserver2=pool.sks-keyservers.net
67 if gpg --keyserver $keyserver1 --recv-key 0xFFFFFFF1 ||
68 gpg --keyserver $keyserver2 --recv-key 0xFFFFFFF1 ; then
69 if gpg --keyserver $keyserver1 --recv-key 0x88888888 ||
70 gpg --keyserver $keyserver2 --recv-key 0x88888888; then
71 # OK
72 return 0
73 else
74 echo
75 echo "Cannot fetch keyID 0x88888888, so the signature cannot be checked."
76 return 1
78 else
79 echo
80 echo "Cannot fetch keyID 0xFFFFFFF1, so the signature cannot be checked."
81 return 1
83 else
84 # GnuPG not installed
85 echo
86 echo "GnuPG (gpg) is not installed so the signature cannot be checked."
87 return 1
91 # Check signature - in case ftpmirror.gnu.org is compromised
92 if fetch_keys; then
93 if gpg --with-fingerprint $LATEST.tar.bz2.sig 2>&1 |
94 $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
95 # Source code signed by Ole Tange <ole@tange.dk>
96 # KeyID FFFFFFF1/88888888
97 true
98 else
99 # GnuPG signature failed
100 echo
101 echo "The signature on $LATEST.tar.bz2 is wrong. This may indicate that a criminal has changed the code."
102 echo "THIS IS BAD AND THE CODE WILL NOT BE INSTALLED."
103 echo
104 echo "See http://git.savannah.gnu.org/cgit/parallel.git/tree/README for other installation methods."
105 exit 1
107 else
108 # GnuPG not installed or public keys not downloaded
109 echo "This means that if the code has been changed by criminals, you will not discover that!"
110 echo
111 echo "Continue anyway? (y/n)"
112 read YN </dev/tty
113 if test "$YN" = "n"; then
114 # Stop
115 exit 2
116 else
117 # Continue
118 true
122 bzip2 -dc $LATEST.tar.bz2 | tar xf -
123 cd $LATEST || exit 2
124 if ./configure && make && make install; then
125 echo
126 echo GNU $LATEST installed globally
127 else
128 if ./configure --prefix=$HOME && make && make install; then
129 echo
130 echo GNU $LATEST installed in $HOME/bin
131 else
132 mkdir -p $HOME/bin/;
133 chmod 755 src/*;
134 cp src/parallel src/env_parallel* src/sem src/sql src/niceload src/parcat $HOME/bin;
135 echo
136 echo GNU $LATEST copied to $HOME/bin
139 # Is $HOME/bin already in $PATH?
140 if echo $PATH | grep $HOME/bin >/dev/null; then
141 # $HOME/bin is already in $PATH
142 true
143 else
144 # Add $HOME/bin to $PATH for both bash and csh
145 echo 'PATH=$PATH:$HOME/bin' >> $HOME/.bashrc
146 echo 'setenv PATH ${PATH}:${HOME}/bin' >> $HOME/.cshrc
149 # Is $HOME/share/man already in $MANPATH?
150 if echo $MANPATH | grep $HOME/share/man >/dev/null; then
151 # $HOME/share/man is already in $MANPATH
152 true
153 else
154 # Add $HOME/share/man to $MANPATH for both bash and csh
155 echo 'MANPATH=$MANPATH:$HOME/share/man' >> $HOME/.bashrc
156 echo 'setenv MANPATH ${MANPATH}:${HOME}/share/man' >> $HOME/.cshrc
161 # Make sure the whole script is downloaded before starting