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