File: buildprep

package info (click to toggle)
cvs-fast-export 1.59-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,960 kB
  • sloc: ansic: 5,743; python: 1,391; sh: 532; lex: 352; yacc: 273; makefile: 249; perl: 99
file content (248 lines) | stat: -rwxr-xr-x 5,794 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#!/bin/sh
#
# buildprep - prepare your system for a cvs-fast-export source build.
#
# Use the -n option to dry-run this command, showing what would be done
# without actually doing it
#
# This script swiped from NTPsec.

# Set the defaults
DRYRUN="no"
DOC="no"

OS=$(uname -s)

# Loop through option flags
for optflag in "$@"
do
    case "$optflag" in
    -h|--help)
        cat <<EOF
$0 - prepare your system for a cvs-fast-export source build

  Options:
    -h --help    Show usage information and exit
    -n --dry-run Only show what would be done instead of doing it
       --doc     Install dependencies for building documentation
    -a --all     Install all possible dependencies
EOF
        exit 0
        ;;
    -n|--dry-run)
        DRYRUN="yes"
        ;;
    --doc)
        DOC="yes"
        ;;
    -a|--all)
        DOC="yes"
        ;;
    *)
        echo "# WARNING: Unknown argument: $optflag"
        echo "#"
        ;;
    esac
done

cat <<EOF
# Preparing your system for cvs-fast-export source build...
# This script presently knows about:
#   Ubuntu (and POP_OS), Fedora using yum, Fedora using dnf, Gentoo.
#
# It has some stub code for other systems; please fill that in if you
# can and send us an MR.
#
# If you are running something else, such as macOS or Solaris, please
# read the source for this buildprep script to get an idea of what packages
# are required.
#
EOF

if [ "$DRYRUN" = "yes" ]
then
    do='echo'
    echo "# Run this without -n|--dry-run, as root, for actual installation."
    echo " #You may want to run an update from your package inddex first."
    echo "#"
else
    do=""
    if [ "$(id -u)" != 0 ]
    then
        echo "# ERROR: You must be running as root for your installer to do its thing."
        echo "# ERROR: If you just wish to see what would be done, use the -n option."
        exit 1
    fi
fi

if emerge --version 2>/dev/null
then
    installer=emerge
    install="$do $installer -q y"
elif yum version 2>/dev/null
then
    installer=yum
    install="$do $installer -y install"
elif dnf --version >/dev/null 2>&1
then
    installer=dnf
    install="$do $installer -y install"
elif apt-get --version >/dev/null 2>&1
then
    installer=apt
    install="$do apt-get install -qy"
elif zypper -h >/dev/null 2>&1
then
    # OpenSUSE prefers zypper over yast
    installer=zypper
    install="$do $installer install -y"
elif yast -h >/dev/null 2>&1
then
    installer=yast
    install="$do $installer --install"
elif  apk --version >/dev/null 2>&1
then
    # Alpine Linux, musl rather than glibc
    installer=apk
    install="$do $installer add"
elif command -v pacman
then
    # Arch Linux
    installer=pacman
    install="$do $installer -S --needed --noconfirm"
elif [ "$OS" = "NetBSD" ]
then
    if pkgin -v
    then
        # NetBSD binary package installer
        installer=pkgin
        install="$do $installer install"
    else
        echo "## Looks like a NetBSD system"
        echo "## You need to setup pkgin"
        echo "## The last page of install disk has a check-box to do it"
        echo "## But you don't get that option on a Raspberry Pi."
        echo "## For the Pi, do something like:"
        echo "## pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/earmv7hf/8.0/All/pkgin-0.9.4nb8.tgz"
        echo "## Adjust the version and arch to match your setup."
        exit 1
    fi
elif [ "$OS" = "FreeBSD" ]
then
    if pkg -v
    then
        # FreeBSD binary package installer
        installer=pkg
        install="$do $installer install"
    fi
else
    echo "# ERROR: Package manager unidentified - Unsupported operating system"
    exit 1
fi
echo "# Your package installer is ${installer}."
echo ""

main () {
    # Prerequisites to build the daemon: bison, pps-tools, service libraries
    case $installer in
    apk)
        echo "Not yet supported" >&2
        exit 1
        ;;
    apt)
        # tzdata needs to be installed explicitly so it won't try an interactive
        # configuration when pulled as a dependency.  This package doesn't care
        # whether your Python is 2.x or 3.x.
        $install tzdata
        $install make grep sed gcc bison flex python3 git rcs cvs pylint cppcheck shellcheck
        ;;
    emerge)
        echo "Not yet supported" >&2
        exit 1
        ;;
    pacman)
        $install tzdata
        $install make grep sed gcc bison flex python git rcs cvs \
        python-pylint cppcheck shellcheck
        ;;
    pkgin)
        echo "Not yet supported" >&2
        exit 1
        ;;
    pkg)
        echo "Not yet supported" >&2
        exit 1
        ;;
    yum)
        echo "Not yet supported" >&2
        exit 1
        ;;
    dnf)
        $install tzdata
        $install make grep sed gcc bison flex rcs cvs pylint cppcheck ShellCheck
        ;;
    yast)
        echo "Not yet supported" >&2
        exit 1
        ;;
    zypper)
        echo "Not yet supported" >&2
        exit 1
        ;;
    esac
}

doc () {
    # prerequisites to build documentation
    case $installer in
    apk)
        echo "Not yet supported" >&2
        exit 1
        ;;
    apt)
        $install asciidoc
        ;;
    emerge)
        echo "Not yet supported" >&2
        exit 1
        ;;
    pacman)
        $install asciidoc
        ;;
    pkgin)
        echo "Not yet supported" >&2
        exit 1
        ;;
    pkg)
        echo "Not yet supported" >&2
        exit 1
        ;;
    yum)
        echo "Not yet supported" >&2
        exit 1
        ;;
    dnf)
        $install asciidoc
        ;;
    yast|zypper)
        echo "Not yet supported" >&2
        exit 1
        ;;
    esac
}

# Main sequence
main

if [ "$DOC" = "yes" ]
then
    doc
else
    echo ""
    echo "# Skipping documentation dependencies [--doc]"
fi

echo ""
echo "# Done."

# end