Released as 20220622 ('Bongbong')
[parallel.git] / 10seconds_install
blob9f1d2c6954bb9746ea80c1004082d51fbc3e4dcd
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 0xFFFFFFF1 && gpg --list-keys 0x88888888 ; then
73 echo Keys fetched
74 # OK
75 return 0
76 else
77 keyservers="keyserver.ubuntu.com
78 pgp.surf.nl
79 keyserver.bazon.ru
80 agora.cenditel.gob.ve
81 pgp.benny-baumann.de"
82 for keyserver in $keyservers ; do
83 if gpg --keyserver "$keyserver" --recv-key 0xFFFFFFF1 &&
84 gpg --keyserver "$keyserver" --recv-key 0x88888888 ; then
85 # OK
86 return 0
88 done
89 echo
90 echo "Cannot fetch keyID 0x88888888, so the signature cannot be checked."
91 return 1
93 else
94 # GnuPG not installed
95 echo
96 echo "GnuPG (gpg) is not installed so the signature cannot be checked."
97 return 1
101 # Check signature - in case ftpmirror.gnu.org is compromised
102 if fetch_keys; then
103 if gpg --with-fingerprint "$latest".tar.bz2.sig 2>&1 |
104 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
105 # Source code signed by Ole Tange <ole@tange.dk>
106 # KeyID FFFFFFF1/88888888
107 true
108 else
109 # GnuPG signature failed
110 echo
111 echo "The signature on $latest.tar.bz2 is wrong. This may indicate that a criminal has changed the code."
112 echo "THIS IS BAD AND THE CODE WILL NOT BE INSTALLED."
113 echo
114 echo "See http://git.savannah.gnu.org/cgit/parallel.git/tree/README for other installation methods."
115 exit 1
117 else
118 # GnuPG not installed or public keys not downloaded
119 echo "This means that if the code has been changed by criminals, you will not discover that!"
120 echo
121 echo "Continue anyway? (y/n)"
122 read YN </dev/tty
123 if test "$YN" = "n"; then
124 # Stop
125 exit 2
126 else
127 # Continue
128 true
132 bzip2 -dc "$latest".tar.bz2 | tar xf -
133 cd "$latest" || exit 2
134 if ./configure && make && make install; then
135 echo
136 echo "GNU $latest installed globally"
137 else
138 if ./configure --prefix="$HOME" && make && make install; then
139 echo
140 echo "GNU $latest installed in $HOME/bin"
141 else
142 mkdir -p "$HOME"/bin/;
143 chmod 755 src/*;
144 cp src/parallel src/env_parallel* src/sem src/sql src/niceload src/parcat "$HOME"/bin;
145 echo
146 echo "GNU $latest copied to $HOME/bin"
149 # Is $HOME/bin already in $PATH?
150 if echo "$PATH" | grep "$HOME"/bin >/dev/null; then
151 # $HOME/bin is already in $PATH
152 true
153 else
154 # Add $HOME/bin to $PATH for both bash and csh
155 echo 'PATH=$PATH:$HOME/bin' >> "$HOME"/.bashrc
156 echo 'setenv PATH ${PATH}:${HOME}/bin' >> "$HOME"/.cshrc
159 # Is $HOME/share/man already in $MANPATH?
160 if echo "$MANPATH" | grep "$HOME"/share/man >/dev/null; then
161 # $HOME/share/man is already in $MANPATH
162 true
163 else
164 # Add $HOME/share/man to $MANPATH for both bash and csh
165 echo 'export MANPATH=$MANPATH:$HOME/share/man' >> "$HOME"/.bashrc
166 echo 'setenv MANPATH ${MANPATH}:${HOME}/share/man' >> "$HOME"/.cshrc
171 # Make sure the whole script is downloaded before starting