Released as 20240522 ('Tbilisi')
[parallel.git] / 10seconds_install
blob0beb13c8174eda8e8da1c8d94f30b2f5a5fe5b07
1 #!/bin/bash
3 true <<'EOF'
4 <p>
5 This script downloads the latest version of GNU Parallel, checks
6 the signature and installs it.
8 <p> It first tries to install it globally.
9 <br> If that fails, it does a personal installation.
10 <br> If that fails, it copies to $HOME/bin
12 <p> You can download and run the script directly by:
14 <p> $ (wget -O - pi.dk/3 || lynx -source pi.dk/3 ||
15 curl pi.dk/3/ || fetch -o - http://pi.dk/3) > install.sh
16 <br> $ sha1sum install.sh | grep 12345678
17 <br> $ md5sum install.sh
18 <br> $ sha512sum install.sh
20 <p> Check the sums from https://gnu.org/s/parallel/checksums
21 <br> Then run:
23 <p> $ bash install.sh
26 <br><br><br><br>
27 EOF
29 # SPDX-FileCopyrightText: 2013-2022 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
31 # SPDX-License-Identifier: GPL-3.0-or-later
33 # This program is free software; you can redistribute it and/or
34 # modify it under the terms of the GNU General Public License as
35 # published by the Free Software Foundation; either version 3 of
36 # the License, or (at your option) any later version.
38 run() {
39 # FreeBSD prefers 'fetch', MacOS prefers 'curl', Linux prefers 'wget'
40 get=$(
41 (lynx -source /dev/null && echo lynx -source) ||
42 (fetch -o /dev/null file:///bin/sh && echo fetch -o -) ||
43 (curl -h >/dev/null && echo curl -L) ||
44 (wget -h >/dev/null && echo wget -qO -) ||
45 echo 'No lynx, wget, curl, fetch: Please inform parallel@gnu.org what you use for downloading URLs' >&2
47 if test "$get" = ""; then
48 exit 1
51 if ! perl -e 1; then
52 echo No perl installed. GNU Parallel depends on perl. Install perl and retry.
53 exit 1
56 LANG=C
57 latest=$($get http://ftpmirror.gnu.org/parallel |
58 perl -ne '/.*(parallel-\d{8})/ and print $1."\n"' |
59 perl -e 'print ((reverse sort <>)[0])')
60 if test \! -e "$latest".tar.bz2; then
61 # Source tar does not exist
62 rm -f "$latest".tar.bz2 "$latest".tar.bz2.sig
63 $get http://ftpmirror.gnu.org/parallel/"$latest".tar.bz2 > "$latest".tar.bz2
64 $get http://ftpmirror.gnu.org/parallel/"$latest".tar.bz2.sig > "$latest".tar.bz2.sig
67 fetch_keys() {
68 if gpg -h 2>/dev/null >/dev/null ; then
69 # GnuPG installed
70 # Setup .gnupg/gpg.conf if not already done
71 echo | gpg 2>/dev/null >/dev/null
72 if gpg --list-keys 0x2C6229E2FFFFFFF1 && gpg --list-keys 0xD1AB451688888888 ; then
73 echo Keys fetched
74 # OK
75 return 0
76 else
77 keyservers="keyserver.ubuntu.com
78 pgp.surf.nl
79 keys.openpgp.org
80 pgp.benny-baumann.de"
81 for keyserver in $keyservers ; do
82 if gpg --keyserver "$keyserver" --recv-key 0x2C6229E2FFFFFFF1 &&
83 gpg --keyserver "$keyserver" --recv-key 0xD1AB451688888888 ; then
84 # OK
85 return 0
87 done
88 echo
89 echo "Cannot fetch keyID 0xD1AB451688888888, so the signature cannot be checked."
90 return 1
92 else
93 # GnuPG not installed
94 echo
95 echo "GnuPG (gpg) is not installed so the signature cannot be checked."
96 return 1
100 # Check signature - in case ftpmirror.gnu.org is compromised
101 if fetch_keys; then
102 if gpg --with-fingerprint "$latest".tar.bz2.sig 2>&1 |
103 perl -e 'exit not grep /^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
104 # Source code signed by Ole Tange <ole@tange.dk>
105 # KeyID 0x2C6229E2FFFFFFF1/0xD1AB451688888888
106 true
107 else
108 # GnuPG signature failed
109 echo
110 echo "The signature on $latest.tar.bz2 is wrong. This may indicate that a criminal has changed the code."
111 echo "THIS IS BAD AND THE CODE WILL NOT BE INSTALLED."
112 echo
113 echo "See http://git.savannah.gnu.org/cgit/parallel.git/tree/README for other installation methods."
114 exit 1
116 else
117 # GnuPG not installed or public keys not downloaded
118 echo "This means that if the code has been changed by criminals, you will not discover that!"
119 echo
120 echo "Continue anyway? (y/n)"
121 read YN </dev/tty
122 if test "$YN" = "n"; then
123 # Stop
124 exit 2
125 else
126 # Continue
127 true
131 bzip2 -dc "$latest".tar.bz2 | tar xf -
132 cd "$latest" || exit 2
133 if ./configure && make && make install; then
134 echo
135 echo "GNU $latest installed globally"
136 else
137 if ./configure --prefix="$HOME" && make && make install; then
138 echo
139 echo "GNU $latest installed in $HOME/bin"
140 else
141 mkdir -p "$HOME"/bin/;
142 chmod 755 src/*;
143 cp src/parallel src/env_parallel* src/sem src/sql src/niceload src/parcat "$HOME"/bin;
144 echo
145 echo "GNU $latest copied to $HOME/bin"
148 # Is $HOME/bin already in $PATH?
149 if echo "$PATH" | grep "$HOME"/bin >/dev/null; then
150 # $HOME/bin is already in $PATH
151 true
152 else
153 # Add $HOME/bin to $PATH for both bash and csh
154 echo 'PATH=$PATH:$HOME/bin' >> "$HOME"/.bashrc
155 echo 'setenv PATH ${PATH}:${HOME}/bin' >> "$HOME"/.cshrc
158 # Is $HOME/share/man already in $MANPATH?
159 if echo "$MANPATH" | grep "$HOME"/share/man >/dev/null; then
160 # $HOME/share/man is already in $MANPATH
161 true
162 else
163 # Add $HOME/share/man to $MANPATH for both bash and csh
164 echo 'export MANPATH=$MANPATH:$HOME/share/man' >> "$HOME"/.bashrc
165 echo 'setenv MANPATH ${MANPATH}:${HOME}/share/man' >> "$HOME"/.cshrc
170 # Make sure the whole script is downloaded before starting