-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLFSPkgSetUp
executable file
·253 lines (209 loc) · 6.64 KB
/
LFSPkgSetUp
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
249
250
251
252
#!/bin/bash -e
#
# ©K. D. Hedger. Mon 12 Jun 15:48:46 BST 2017 kdhedger68713@gmail.com
#
# This file (LFSSetUp) is part of BootCD.
#
# BootCD is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# at your option) any later version.
# BootCD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BootCD. If not, see <http://www.gnu.org/licenses/>.
#
LOCALLFSVERSION=10.1
PIBUILD=0
PIVERS=4
USESYSTEMD=0
USERDATA=
#$1=varname $2=message
readWithDefault ()
{
local varname="$1"
local varcontents="${!varname}"
local message="$2"
read -e -p "$message [ ${varcontents} ] "
if [ "X$REPLY" != "X" ];then
eval "${varname}='$REPLY'"
fi
}
case $(uname -m) in
arm*)
PIBUILD=1
LIBDIRSUFFIX=""
;;
x86_64)
LIBDIRSUFFIX=64
;;
*)
LIBDIRSUFFIX=""
;;
esac
#set variables if possible
if [ -e /etc/lfspkg.rc ];then
. /etc/lfspkg.rc
USERDATA=$(sed -n '/####USER DATA####/,$p' /etc/lfspkg.rc)
else
LFSVERSION=12.0
PIBUILD=0
PIVERS=4
USESYSTEMD=0
LIBDIRSUFFIX=64
BUILDSCRIPTS="/LFSPkgBuildScripts/"
OUTPUT="/LFSBuiltPackages/$LFSVERSION"
SOURCEARCHIVES="/LFSSourceArchives/$LFSVERSION"
PKGARCHIVES="/LFSBuiltPackages/$LFSVERSION"
COMPILEAT="/LFSSourceArchives/$LFSVERSION"
SCRIPTLOG=1
CHECKETC=1
CONFIGOPTIONS="--prefix=/usr --sysconfdir=/etc --libexecdir=/usr/libexec --libdir=/usr/lib --disable-nls --disable-static"
MESONCONFIGOPTIONS="--prefix=/usr --sysconfdir=/etc --libexecdir=/usr/libexec --libdir=/usr/lib --buildtype=release --default-library=shared"
CMAKEOPTIONS="-DCMAKE_INSTALL_PREFIX=/usr -DLIB_SUFFIX="" -DCMAKE_PREFIX_PATH=/usr/lib/qt5/cmake -DUSE_QT5=TRUE -Wno-dev"
XORG_CONFIG="--prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man --localstatedir=/var --disable-static"
MAKEFLAGS="-j$(($(nproc)-1))"
export QT5PREFIX=/usr
export QT5DIR=$QT5DIR
export XORG_PREFIX="/usr"
exportJAVA_HOME=/opt/jdk
export PATH="${QT5DIR}:${PATH}"
fi
#LFS Version
LFSVERSION=${LFSVERSION:-"12.0"}
readWithDefault "LFSVERSION" "Enter Version"
#use systemd :(
readWithDefault "USESYSTEMD" "Build with systemd support"
#for rpi
if [ $PIBUILD -eq 1 ];then
PIVERS=${PIVERS:-"4"}
readWithDefault "PIVERS" "Enter Pi Version"
fi
#libdir suffix
readWithDefault "LIBDIRSUFFIX" "Enter Suffix For Lib Folders"
#buildscripts location
BUILDSCRIPTS="/LFSPkgBuildScripts/"
readWithDefault "BUILDSCRIPTS" "Enter Folder For Build Scripts"
#Folder for built pkgs
OUTPUT=${OUTPUT:-"/LFSBuiltPackages/$LFSVERSION"}
readWithDefault "OUTPUT" "Enter Folder For Temporary Files"
#Place to store downloaded source archives, defaults to /LFSSourceArchives/${LFSVERSION}
SOURCEARCHIVES=${SOURCEARCHIVES:-"/LFSSourceArchives/${LFSVERSION}"}
readWithDefault "SOURCEARCHIVES" "Enter Folder For Source Archives"
#Place to store package archives, defaults to $OUTPUT
PKGARCHIVES=${PKGARCHIVES:-"$OUTPUT"}
readWithDefault "PKGARCHIVES" "Enter Folder For Built Package Archives"
#compile at folder for large builds
COMPILEAT=${COMPILEAT:-""}
readWithDefault "COMPILEAT" "Compile In This Folder Instead Of In Pkg Folder"
#log op from scripts
SCRIPTLOG=${SCRIPTLOG:-1}
readWithDefault "SCRIPTLOG" "Log Output From Scripts, 0 = Don't Log"
#check /etc/ for config file clashes
CHECKETC=${CHECKETC:-1}
readWithDefault "CHECKETC" "Check /etc For Possible Config File Clashes, 0 = No Check"
#qt5 and cmake stuff
QT5PREFIX=${QT5PREFIX:-"/usr"}
readWithDefault "QT5PREFIX" "Qt5 Install Location"
QT5DIR=$QT5PREFIX/lib${LIBDIRSUFFIX}/qt5
#xorg prefix
XORG_PREFIX=${XORG_PREFIX:-"/usr"}
readWithDefault "XORG_PREFIX" "Build Locattion For Xorg"
#java home
JAVA_HOME=${JAVA_HOME:-"/opt/jdk"}
readWithDefault "JAVA_HOME" "Java Install Location"
#general config options
if [ -e /etc/lfspkg.rc ];then
unset CONFIGOPTIONS
CONFIGOPTIONS=$(sed -n 's/^CONFIGOPTIONS=\(.*\)$/\1/p' /etc/lfspkg.rc|sed 's/"//g')
fi
readWithDefault "CONFIGOPTIONS" "Enter Basic Options For \"configure\" Scripts"
#config options for meson
if [ -e /etc/lfspkg.rc ];then
unset MESONCONFIGOPTIONS
MESONCONFIGOPTIONS=$(sed -n 's/^MESONCONFIGOPTIONS=\(.*\)$/\1/p' /etc/lfspkg.rc|sed 's/"//g')
fi
readWithDefault "MESONCONFIGOPTIONS" "Enter Basic Options For \"meson\" Scripts"
#cmake config
if [ -e /etc/lfspkg.rc ];then
unset CMAKEOPTIONS
CMAKEOPTIONS=$(sed -n 's/^CMAKEOPTIONS=\(.*\)$/\1/p' /etc/lfspkg.rc|sed 's/"//g')
fi
readWithDefault "CMAKEOPTIONS" "Enter Basic Options For \"cmake\" Scripts"
#xorg configure options
if [ -e /etc/lfspkg.rc ];then
unset XORG_CONFIG
XORG_CONFIG=$(sed -n 's/^XORG_CONFIG=\(.*\)$/\1/p' /etc/lfspkg.rc|sed 's/"//g')
fi
readWithDefault "XORG_CONFIG" "Xorg Configure Options"
#general purpose make flags
MAKEFLAGS=${MAKEFLAGS:-" -j$(nproc) "}
readWithDefault "MAKEFLAGS" "General Purpose Switches To Make"
echo "----SUMMARY----"
echo
echo "LFSVERSION=$LFSVERSION"
echo "PIBUILD=$PIBUILD"
echo "PIVERS=$PIVERS"
echo "USESYSTEMD=$USESYSTEMD"
echo "LIBDIRSUFFIX=$LIBDIRSUFFIX"
echo "BUILDSCRIPTS=$BUILDSCRIPTS"
echo
echo "OUTPUT=\"\${OUTPUT:-$OUTPUT}\""
echo "SOURCEARCHIVES=\"\${SOURCEARCHIVES:-${SOURCEARCHIVES}}\""
echo "PKGARCHIVES==\"\${PKGARCHIVES:-${PKGARCHIVES}}\""
echo "COMPILEAT=\"\${COMPILEAT:-${COMPILEAT}}\""
echo
echo "SCRIPTLOG=$SCRIPTLOG"
echo "CHECKETC=$CHECKETC"
echo
echo "XORG_PREFIX=$XORG_PREFIX"
echo "QT5PREFIX=$QT5PREFIX"
echo "QT5DIR=$QT5DIR"
echo "JAVA_HOME=$JAVA_HOME"
echo
echo "CONFIGOPTIONS=$CONFIGOPTIONS"
echo "MESONCONFIGOPTIONS=$MESONCONFIGOPTIONS"
echo "CMAKEOPTIONS=$CMAKEOPTIONS"
echo "XORG_CONFIG=$XORG_CONFIG"
echo
echo "MAKEFLAGS=\"\${MAKEFLAGS:-$MAKEFLAGS}"\"
echo
echo "--------"
SUMMARY="N/y"
readWithDefault "SUMMARY" "Write Config Files?"
if [ ! ${SUMMARY,,} = "y" ];then
exit 1
fi
rcpath=""
if [ $UID -eq 0 ];then
rcpath=/etc/lfspkg.rc
else
rcpath=$(tty)
fi
cat > $rcpath << EOF
LFSVERSION=$LFSVERSION
PIBUILD=$PIBUILD
PIVERS=$PIVERS
USESYSTEMD=$USESYSTEMD
LIBDIRSUFFIX=$LIBDIRSUFFIX
BUILDSCRIPTS="$BUILDSCRIPTS"
OUTPUT="\${OUTPUT:-$OUTPUT}"
SOURCEARCHIVES="\${SOURCEARCHIVES:-${SOURCEARCHIVES}}"
PKGARCHIVES="\${PKGARCHIVES:-${PKGARCHIVES}}"
COMPILEAT="\${COMPILEAT:-${COMPILEAT}}"
SCRIPTLOG=$SCRIPTLOG
CHECKETC=$CHECKETC
CONFIGOPTIONS="$CONFIGOPTIONS"
MESONCONFIGOPTIONS="$MESONCONFIGOPTIONS"
CMAKEOPTIONS="$CMAKEOPTIONS"
XORG_CONFIG="$XORG_CONFIG"
MAKEFLAGS="\${MAKEFLAGS:-$MAKEFLAGS}"
export QT5PREFIX=$QT5PREFIX
export QT5DIR=$QT5DIR
export XORG_PREFIX="$XORG_PREFIX"
export JAVA_HOME=$JAVA_HOME
$USERDATA
EOF