forked from TangoCash/saved.buildsystem-ddt
-
Notifications
You must be signed in to change notification settings - Fork 22
/
prepare-for-bs.sh
executable file
·175 lines (159 loc) · 8.41 KB
/
prepare-for-bs.sh
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
#!/bin/bash
# originally created by schischu and konfetti
# fedora parts prepared by lareq
# fedora/suse/ubuntu scripts merged by kire pudsje (kpc)
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (sudo $0)" 1>&2
exit 1
fi
# make sure defines have not already been defined
UBUNTU=
FEDORA=
SUSE=
GENTOO=
# Try to detect the distribution
if `which lsb_release > /dev/null 2>&1`; then
case `lsb_release -s -i` in
Debian*) UBUNTU=1; INSTALL="apt-get -y install";;
Fedora*) FEDORA=1; INSTALL="yum install -y";;
CentOS*) FEDORA=1; INSTALL="yum install -y";;
SUSE*) SUSE=1; INSTALL="zypper install -y";;
Ubuntu*) UBUNTU=1; INSTALL="apt-get -y install";;
LinuxM*) UBUNTU=2; INSTALL="apt-get -y install";;
Gentoo) GENTOO=1; INSTALL="emerge -uN";;
esac
fi
# Not detected by lsb_release, try release files
if [ -z "$FEDORA$GENTOO$SUSE$UBUNTU" ]; then
if [ -f /etc/redhat-release ]; then FEDORA=1; INSTALL="yum install -y";
elif [ -f /etc/fedora-release ]; then FEDORA=1; INSTALL="yum install -y";
elif [ -f /etc/centos-release ]; then FEDORA=1; INSTALL="yum install -y";
elif [ -f /etc/SuSE-release ]; then SUSE=1; INSTALL="zypper install -n";
elif [ -f /etc/debian_version ]; then UBUNTU=1; INSTALL="apt-get -y install";
elif [ -f /etc/gentoo-release ]; then GENTOO=1; INSTALL="emerge -uN"
fi
fi
# still not detected, display error and let the user manually install
if [ -z "$FEDORA$GENTOO$SUSE$UBUNTU" ]; then
echo
echo "Cannot determine which OS distribution you use,"
echo "or your distribution is not (yet) supported."
echo "Please report this fact in the proper forum(s)"
echo
echo "Try installing the following packages: "
# determine probable distribution, based on package system,
# Suse should be last because the others may also have rpm installed.
{ `which apt-get > /dev/null 2>&1` && UBUNTU=1; } || \
{ `which yum > /dev/null 2>&1` && FEDORA=1; } || \
{ `which dnf > /dev/null 2>&1` && FEDORA=1; } || \
{ `which emerge > /dev/null 2>&1` && GENTOO=1; } || \
SUSE=2
INSTALL="echo "
fi
if [ "$FEDORA" == 1 ]; then
FEDORA_VERSION=`cat /etc/fedora-release | cut -d ' ' -f3`
if [[ "$FEDORA_VERSION" -gt "21" ]]; then
INSTALL="dnf install -y --best --allowerasing"
fi
fi
if [ "$SUSE" == 1 ]; then
SUSE_VERSION=`cat /etc/SuSE-release | line | awk '{ print $2 }'`
zypper ar "http://download.opensuse.org/repositories/openSUSE:/$SUSE_VERSION:/Live/standard/" fakeroot
zypper ref
fi
PACKAGES="\
make \
subversion \
ccache \
flex \
bison \
texinfo \
intltool \
libtool \
swig \
dialog \
wget \
cmake \
gperf \
\
${UBUNTU:+rpm} ${FEDORA:+rpm-build} ${GENTOO:+rpm} \
${UBUNTU:+lsb-release} ${SUSE:+lsb-release} ${FEDORA:+redhat-lsb} ${GENTOO:+lsb-release} \
${UBUNTU:+git-core} ${SUSE:+git-core} ${FEDORA:+git} ${GENTOO:+git} \
${UBUNTU:+libncurses5-dev} ${SUSE:+ncurses-devel} ${FEDORA:+ncurses-devel} ${GENTOO:+ncurses} \
${UBUNTU:+libncursesw5-dev} \
${UBUNTU:+gettext} ${SUSE:+gettext-devel} ${FEDORA:+gettext-devel} ${GENTOO:+gettext} \
${UBUNTU:+zlib1g-dev} ${SUSE:+zlib-devel} ${FEDORA:+zlib-devel} ${GENTOO:+zlib} \
${UBUNTU:+g++} ${SUSE:+gcc gcc-c++} ${FEDORA:+gcc-c++} \
${UBUNTU:+libffi-dev} ${SUSE:+libffi-devel} ${FEDORA:+libffi-devel} ${GENTOO:+libffi} \
${UBUNTU:+automake} ${SUSE:+automake make} ${GENTOO:+automake} \
${UBUNTU:+xfslibs-dev} ${SUSE:+xfsprogs-devel} ${GENTOO:+xfsprogs} \
${UBUNTU:+pkg-config} ${SUSE:+pkg-config} ${GENTOO:+pkg-config} \
${UBUNTU:+patch} ${SUSE:+patch} ${GENTOO:+patch} \
${UBUNTU:+autopoint} \
${UBUNTU:+fakeroot} ${GENTOO:+fakeroot} \
${UBUNTU:+gawk} ${GENTOO:+gawk} \
${UBUNTU:+libglib2.0-bin} ${SUSE:+glib2-devel} ${FEDORA:+glib2-devel} ${GENTOO:+glib:2} \
${UBUNTU:+libglib2.0-dev} ${SUSE:+glibc-devel-static} ${FEDORA:+glibc-static} \
${UBUNTU:+doc-base} ${SUSE:+libuuid-devel} ${FEDORA:+libuuid-devel} \
${UBUNTU:+texi2html} \
${UBUNTU:+help2man} \
${UBUNTU:+libcurl4-openssl-dev} ${SUSE:+libcurl-devel} ${FEDORA:+libcurl-devel} \
${UBUNTU:+liblzo2-dev} ${SUSE:+lzo-devel} ${FEDORA:+lzo-devel} ${GENTOO:+lzo:2} \
${UBUNTU:+ruby} ${GENTOO:+ruby} \
${UBUNTU:+libltdl-dev} ${FEDORA:+libtool-ltdl-devel} \
${FEDORA:+byacc} \
${UBUNTU:+libssl-dev} ${SUSE:+libopenssl-devel} ${FEDORA:+openssl-devel} \
${UBUNTU:+libmount-dev} ${FEDORA:+help2man} \
${UBUNTU:+mtools} ${FEDORA:+rpcgen} \
${UBUNTU:+u-boot-tools} \
${UBUNTU:+curl} \
${UBUNTU:+mm-common} ${SUSE:+mm-common} ${FEDORA:+mm-common} ${GENTOO:+mm-common} \
${UBUNTU:+autoconf-archive} \
${UBUNTU:+cpio} \
${UBUNTU:+bc} \
";
if [ "$UBUNTU" == 1 ]; then
if `which lsb_release > /dev/null 2>&1`; then
UBUNTU_VERSION=`lsb_release -r | grep "Release" | cut -f2 | cut -d . -f1`
else
UBUNTU_VERSION=`grep VERSION_ID= /etc/os-release | sed 's/VERSION_ID="\([0-9]*\).*/\1/g'`
fi
elif [ "$UBUNTU" == 2 ]; then
MINT_VERSION=`lsb_release -r | grep "Release" | cut -f2 | cut -d . -f1`
fi
if ([ "$UBUNTU" == 1 ] && [ "$UBUNTU_VERSION" -ge "16" ]) || ([ "$UBUNTU" == 2 ] && [ "$MINT_VERSION" -ge "18" ]); then
PACKAGES="$PACKAGES \
${UBUNTU:+libtool-bin} \
";
fi
if ([ "$UBUNTU" == 1 ] && [ "$UBUNTU_VERSION" -ge "22" ]) || ([ "$UBUNTU" == 2 ] && [ "$MINT_VERSION" -ge "21" ]); then
PACKAGES="$PACKAGES \
${UBUNTU:+gtk-doc-tools} \
";
fi
if [ `which arch > /dev/null 2>&1 && arch || uname -m` == x86_64 ]; then
# ST changed to the -m32 option for their gcc compiler build
# we might need to install more 32bit versions of some packages
PACKAGES="$PACKAGES \
${UBUNTU:+gcc-multilib} ${SUSE:+gcc-32bit} ${FEDORA:+libstdc++-devel.i686} \
${UBUNTU:+binutils-multiarch} ${SUSE:+glibc-devel-32bit} ${FEDORA:+glibc-devel.i686} \
${UBUNTU:+lib32z1-dev} ${SUSE:+zlib-devel-32bit} ${FEDORA:+libgcc.i686} \
${FEDORA:+ncurses-devel.i686} \
${FEDORA:+redhat-lsb.i686} \
${SUSE:+libstdc++-devel-32bit} ${FEDORA:+glibc-static.i686} \
";
fi
echo $INSTALL $PACKAGES
$INSTALL $PACKAGES
# Link sh to bash instead of dash on Ubuntu (and possibly others)
/bin/sh --version 2>/dev/null | grep bash -s -q
if [ ! "$?" -eq "0" ]; then
echo
read -p "/bin/sh should link to /bin/bash, adjust it (Y/n)? "
if [ -z "$REPLY" -o "$REPLY" == "Y" -o "$REPLY" == "y" ]; then
rm -f /bin/sh
ln -s /bin/bash /bin/sh
fi
fi
# for user mknod
#chmod +s /bin/mknod