This repo contains software to build linux from scratch and package it into rpm files.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1339 lines
41 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #!/bin/bash
  2. #-----------------------------------------------------------------------------
  3. # Title: tools.sh
  4. # Date: 2020-05-31
  5. # Version: 2.0
  6. # Author: chris@cromer.cl
  7. # Options:
  8. #-----------------------------------------------------------------------------
  9. # Copyright 2020 Chris Cromer
  10. # Copyright 2019 Baho Utot
  11. #-----------------------------------------------------------------------------
  12. # This program is free software: you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation, either version 3 of the License, or
  15. # (at your option) any later version.
  16. # This program is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU General Public License for more details.
  20. # You should have received a copy of the GNU General Public License
  21. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  22. #-----------------------------------------------------------------------------
  23. set -o errexit # exit if error...insurance ;)
  24. set -o nounset # exit if variable not initalized
  25. set +h # disable hashall
  26. #-----------------------------------------------------------------------------
  27. # Common variables
  28. PRGNAME=${0##*/} # script name minus the path
  29. TOPDIR=${PWD} # this directory
  30. PARENT=/usr/src/LFS-RPM # build system master directory
  31. MKFLAGS="-j 1" # Number of cpu to use in building pkgs default = 1
  32. #-----------------------------------------------------------------------------
  33. # Common support functions
  34. function die {
  35. local _red="\\033[1;31m"
  36. local _normal="\\033[0;39m"
  37. [ -n "$*" ] && printf "${_red}$*${_normal}\n"
  38. false
  39. exit 1
  40. }
  41. function msg {
  42. printf "%s\n" "${1}"
  43. return
  44. }
  45. function msg_line {
  46. printf "%s" "${1}"
  47. return
  48. }
  49. function msg_failure {
  50. local _red="\\033[1;31m"
  51. local _normal="\\033[0;39m"
  52. printf "${_red}%s${_normal}\n" "FAILURE"
  53. exit 2
  54. }
  55. function msg_success {
  56. local _green="\\033[1;32m"
  57. local _normal="\\033[0;39m"
  58. printf "${_green}%s${_normal}\n" "SUCCESS"
  59. return
  60. }
  61. function msg_log {
  62. printf "\n%s\n\n" "${1}" >> ${_logfile} 2>&1
  63. return
  64. }
  65. function end_run {
  66. local _green="\\033[1;32m"
  67. local _normal="\\033[0;39m"
  68. printf "${_green}%s${_normal}\n" "Run Complete - ${PRGNAME}"
  69. return
  70. }
  71. #-----------------------------------------------------------------------------
  72. # Local functions
  73. function _sanity {
  74. [ $(whoami) = "lfs" ] || die "Not running as user lfs, you should be!"
  75. [ -v LFS ] || die "LFS environment variable missing/not set"
  76. [ "/tools/bin:/bin:/usr/bin" = "${PATH}" ] || die "PATH environment variable missing/not corrrect"
  77. [ -v LFS_TGT ] || die "LFS_TGT environment variable missing/not set"
  78. [ "${HOSTTYPE}-lfs-${OSTYPE}" = "${LFS_TGT}" ] || die "LFS_TGT environment variable incorrect"
  79. [ -d ${LFS} ] || die "${LFS} directory missing"
  80. [ -d ${LFS}/tools ] || die "${LFS}/tools directory missing"
  81. [ -h /tools ] || die "tools root symlink missing"
  82. [ $(stat -c %U ${LFS}/tools) = "lfs" ] || die "The tools directory not owned by user lfs"
  83. [ ${TOPDIR} = ${LFS}${PARENT} ] || die "Not in the correct build directory"
  84. [ -d "${TOPDIR}/LOGS" ] || install -dm 755 "${TOPDIR}/LOGS"
  85. [ -d "${TOPDIR}/BUILD" ] || install -dm 755 "${TOPDIR}/BUILD"
  86. return
  87. }
  88. function do_strip {
  89. msg_line "Stripping file: "
  90. strip --strip-debug /tools/lib/* > /dev/null 2&>1 || true
  91. /usr/bin/strip --strip-unneeded /tools/{,s}bin/* > /dev/null 2&>1 || true
  92. rm -rf /tools/{,share}/{info,man,doc}
  93. find /tools/{lib,libexec} -name \*.la -delete
  94. msg_success
  95. return
  96. }
  97. function set-mkflags {
  98. msg_line "Setting MKFLAGS: "
  99. MKFLAGS="-j 1" # default
  100. MKFLAGS="-j $(getconf _NPROCESSORS_ONLN || true)" # how many processors on this host
  101. [ '-j' == "${MKFLAGS}" ] && MKFLAGS="-j 2" # set two cpu's default
  102. printf "%s" "${FUNCNAME}: MKFLAGS: ${MKFLAGS}: "
  103. msg_success
  104. return
  105. }
  106. function unpack {
  107. # $1 = source package name
  108. local tarball=${TOPDIR}/SOURCES/${1}
  109. msg_line " Unpacking: ${1}: "
  110. [ -e ${tarball} ] || die " File not found: FAILURE"
  111. tar xf ${tarball} && msg_success || msg_failure
  112. return 0
  113. }
  114. function clean-build-directory {
  115. msg_line "Cleaning BUILD directory: "
  116. rm -rf ${TOPDIR}/BUILD/*
  117. rm -rf ${TOPDIR}/BUILDROOT/*
  118. msg_success
  119. return
  120. }
  121. #-----------------------------------------------------------------------------
  122. # Package functions
  123. function Binutils-Pass-1 {
  124. # Binutils-2.34 - Pass 1
  125. local pkg=binutils-2.34.tar.xz
  126. local pkg_dir=${pkg%%.tar*}
  127. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  128. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  129. > ${logfile}
  130. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  131. unpack "${pkg}"
  132. pushd ${pkg_dir} >> /dev/null 2>&1
  133. mkdir build
  134. pushd build >> /dev/null 2>&1
  135. msg_line " Configure: "
  136. ../configure --prefix=/tools \
  137. --with-sysroot=${LFS} \
  138. --with-lib-path=/tools/lib \
  139. --target=${LFS_TGT} \
  140. --disable-nls \
  141. --disable-werror >> ${logfile} 2>&1
  142. msg_success
  143. msg_line " Make: "
  144. make ${MKFLAGS} >> ${logfile} 2>&1
  145. msg_success
  146. msg_line " Install: "
  147. install -vdm 755 /tools/lib >> ${logfile} 2>&1
  148. [ "x86_64" = ${HOSTTYPE} ] && ln -sv lib /tools/lib64 >> ${logfile} 2>&1
  149. make install >> ${logfile} 2>&1
  150. msg_success
  151. popd > /dev/null 2>&1
  152. popd > /dev/null 2>&1
  153. popd > /dev/null 2>&1
  154. clean-build-directory
  155. mv ${logfile} ${logfile}.complete
  156. return
  157. }
  158. function GCC-Pass-1 {
  159. # GCC-9.2.0 - Pass 1
  160. local pkg=gcc-9.2.0.tar.xz
  161. local pkg_dir=${pkg%%.tar*}
  162. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  163. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  164. > ${logfile}
  165. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  166. unpack "${pkg}"
  167. pushd ${pkg_dir} >> /dev/null 2>&1
  168. for file in gcc/config/{linux,i386/linux{,64}}.h; do
  169. cp -u $file{,.orig}
  170. sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' -e 's@/usr@/tools@g' $file.orig > $file
  171. cat >> ${file} <<- EOF
  172. #undef STANDARD_STARTFILE_PREFIX_1
  173. #undef STANDARD_STARTFILE_PREFIX_2
  174. #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
  175. #define STANDARD_STARTFILE_PREFIX_2 ""
  176. EOF
  177. touch $file.orig
  178. done
  179. case ${HOSTTYPE} in
  180. x86_64) sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
  181. ;;
  182. esac
  183. unpack mpfr-4.0.2.tar.xz
  184. unpack gmp-6.2.0.tar.xz
  185. unpack mpc-1.1.0.tar.gz
  186. mv -v mpfr-4.0.2 mpfr >> ${logfile} 2>&1
  187. mv -v gmp-6.2.0 gmp >> ${logfile} 2>&1
  188. mv -v mpc-1.1.0 mpc >> ${logfile} 2>&1
  189. mkdir build
  190. pushd build >> /dev/null 2>&1
  191. msg_line " Configure: "
  192. ../configure \
  193. --target=${LFS_TGT} \
  194. --prefix=/tools \
  195. --with-glibc-version=2.11 \
  196. --with-sysroot=${LFS} \
  197. --with-newlib \
  198. --without-headers \
  199. --with-local-prefix=/tools \
  200. --with-native-system-header-dir=/tools/include \
  201. --disable-nls \
  202. --disable-shared \
  203. --disable-multilib \
  204. --disable-decimal-float \
  205. --disable-threads \
  206. --disable-libatomic \
  207. --disable-libgomp \
  208. --disable-libquadmath \
  209. --disable-libssp \
  210. --disable-libvtv \
  211. --disable-libstdcxx \
  212. --enable-languages=c,c++ >> ${logfile} 2>&1
  213. msg_success
  214. msg_line " Make: "
  215. make ${MKFLAGS} >> ${logfile} 2>&1
  216. msg_success
  217. msg_line " Install: "
  218. make install >> ${logfile} 2>&1
  219. msg_success
  220. popd > /dev/null 2>&1
  221. popd > /dev/null 2>&1
  222. popd > /dev/null 2>&1
  223. clean-build-directory
  224. mv ${logfile} ${logfile}.complete
  225. return
  226. }
  227. function Linux-API-Headers {
  228. # Linux-5.5.3 API Headers
  229. local pkg=linux-5.5.3.tar.xz
  230. local pkg_dir=${pkg%%.tar*}
  231. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  232. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  233. > ${logfile}
  234. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  235. unpack "${pkg}"
  236. pushd ${pkg_dir} >> /dev/null 2>&1
  237. msg_line " Make: "
  238. make mrproper >> ${logfile} 2>&1
  239. msg_success
  240. msg_line " Install: "
  241. make headers >> ${logfile} 2>&1
  242. cp -rv usr/include/* /tools/include >> ${logfile} 2>&1
  243. msg_success
  244. popd > /dev/null 2>&1
  245. popd > /dev/null 2>&1
  246. clean-build-directory
  247. mv ${logfile} ${logfile}.complete
  248. return
  249. }
  250. function Glibc {
  251. # Glibc-2.31
  252. local pkg=glibc-2.31.tar.xz
  253. local pkg_dir=${pkg%%.tar*}
  254. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  255. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  256. > ${logfile}
  257. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  258. unpack "${pkg}"
  259. pushd ${pkg_dir} >> /dev/null 2>&1
  260. mkdir build
  261. pushd build >> /dev/null 2>&1
  262. msg_line " Configure: "
  263. ../configure \
  264. --prefix=/tools \
  265. --host=${LFS_TGT} \
  266. --build=$(../scripts/config.guess) \
  267. --enable-kernel=3.2 \
  268. --with-headers=/tools/include >> ${logfile} 2>&1
  269. msg_success
  270. msg_line " Make: "
  271. make ${MKFLAGS} >> ${logfile} 2>&1
  272. msg_success
  273. msg_line " Install: "
  274. make install >> ${logfile} 2>&1
  275. msg_success
  276. popd > /dev/null 2>&1
  277. popd > /dev/null 2>&1
  278. popd > /dev/null 2>&1
  279. clean-build-directory
  280. mv ${logfile} ${logfile}.complete
  281. msg_line " Testing glibc: "
  282. echo 'int main(){}' > dummy.c
  283. ${LFS_TGT}-gcc dummy.c >> ${logfile}.test 2>&1
  284. echo "Test: [Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]" >> ${logfile}.test 2>&1
  285. readelf -l a.out | grep ': /tools' >> ${logfile}.test 2>&1
  286. rm dummy.c a.out
  287. msg_success
  288. return
  289. }
  290. function Libstdc {
  291. # Libstdc++ from GCC-9.2.0
  292. local pkg=gcc-9.2.0.tar.xz
  293. local pkg_dir=${pkg%%.tar*}
  294. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  295. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  296. > ${logfile}
  297. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  298. unpack "${pkg}"
  299. pushd ${pkg_dir} >> /dev/null 2>&1
  300. mkdir build
  301. pushd build >> /dev/null 2>&1
  302. msg_line " Configure: "
  303. ../libstdc++-v3/configure \
  304. --host=${LFS_TGT} \
  305. --prefix=/tools \
  306. --disable-multilib \
  307. --disable-nls \
  308. --disable-libstdcxx-threads \
  309. --disable-libstdcxx-pch \
  310. --with-gxx-include-dir=/tools/${LFS_TGT}/include/c++/9.2.0 >> ${logfile} 2>&1
  311. msg_success
  312. msg_line " Make: "
  313. make ${MKFLAGS} >> ${logfile} 2>&1
  314. msg_success
  315. msg_line " Install: "
  316. make install >> ${logfile} 2>&1
  317. msg_success
  318. popd > /dev/null 2>&1
  319. popd > /dev/null 2>&1
  320. popd > /dev/null 2>&1
  321. clean-build-directory
  322. mv ${logfile} ${logfile}.complete
  323. return
  324. }
  325. function Binutils-Pass-2 {
  326. # Binutils-2.34 - Pass 2
  327. local pkg=binutils-2.34.tar.xz
  328. local pkg_dir=${pkg%%.tar*}
  329. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  330. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  331. > ${logfile}
  332. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  333. unpack "${pkg}"
  334. pushd ${pkg_dir} >> /dev/null 2>&1
  335. mkdir build
  336. pushd build >> /dev/null 2>&1
  337. msg_line " Configure: "
  338. CC=${LFS_TGT}-gcc \
  339. AR=${LFS_TGT}-ar \
  340. RANLIB=${LFS_TGT}-ranlib \
  341. ../configure \
  342. --prefix=/tools \
  343. --disable-nls \
  344. --disable-werror \
  345. --with-lib-path=/tools/lib \
  346. --with-sysroot >> ${logfile} 2>&1
  347. msg_success
  348. msg_line " Make: "
  349. make ${MKFLAGS} >> ${logfile} 2>&1
  350. msg_success
  351. msg_line " Install: "
  352. make install >> ${logfile} 2>&1
  353. msg_success
  354. msg_line " Prepare the linker for Re-adjusting: "
  355. make -C ld clean >> ${logfile} 2>&1
  356. make -C ld LIB_PATH=/usr/lib:/lib >> ${logfile} 2>&1
  357. cp -v ld/ld-new /tools/bin >> ${logfile} 2>&1
  358. msg_success
  359. popd > /dev/null 2>&1
  360. popd > /dev/null 2>&1
  361. popd > /dev/null 2>&1
  362. clean-build-directory
  363. mv ${logfile} ${logfile}.complete
  364. return
  365. }
  366. function GCC-Pass-2 {
  367. # GCC-9.2.0 - Pass 2
  368. local pkg=gcc-9.2.0.tar.xz
  369. local pkg_dir=${pkg%%.tar*}
  370. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  371. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  372. > ${logfile}
  373. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  374. unpack "${pkg}"
  375. pushd ${pkg_dir} >> /dev/null 2>&1
  376. cat gcc/limitx.h gcc/glimits.h gcc/limity.h > `dirname $(${LFS_TGT}-gcc -print-libgcc-file-name)`/include-fixed/limits.h
  377. for file in gcc/config/{linux,i386/linux{,64}}.h; do
  378. cp -u $file{,.orig} >> ${logfile} 2>&1
  379. sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' -e 's@/usr@/tools@g' $file.orig > $file
  380. cat >> ${file} <<- EOF
  381. #undef STANDARD_STARTFILE_PREFIX_1
  382. #undef STANDARD_STARTFILE_PREFIX_2
  383. #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
  384. #define STANDARD_STARTFILE_PREFIX_2 ""
  385. EOF
  386. touch $file.orig
  387. done
  388. case ${HOSTTYPE} in
  389. x86_64) sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
  390. ;;
  391. esac
  392. unpack mpfr-4.0.2.tar.xz
  393. unpack gmp-6.2.0.tar.xz
  394. unpack mpc-1.1.0.tar.gz
  395. mv -v mpfr-4.0.2 mpfr >> ${logfile} 2>&1
  396. mv -v gmp-6.2.0 gmp >> ${logfile} 2>&1
  397. mv -v mpc-1.1.0 mpc >> ${logfile} 2>&1
  398. sed -e '1161 s|^|//|' -i libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
  399. mkdir build
  400. pushd build >> /dev/null 2>&1
  401. msg_line " Configure: "
  402. CC=${LFS_TGT}-gcc \
  403. CXX=${LFS_TGT}-g++ \
  404. AR=${LFS_TGT}-ar \
  405. RANLIB=${LFS_TGT}-ranlib \
  406. ../configure \
  407. --prefix=/tools \
  408. --with-local-prefix=/tools \
  409. --with-native-system-header-dir=/tools/include \
  410. --enable-languages=c,c++ \
  411. --disable-libstdcxx-pch \
  412. --disable-multilib \
  413. --disable-bootstrap \
  414. --disable-libgomp >> ${logfile} 2>&1
  415. msg_success
  416. msg_line " Make: "
  417. make ${MKFLAGS} >> ${logfile} 2>&1
  418. msg_success
  419. msg_line " Install: "
  420. make install >> ${logfile} 2>&1
  421. ln -sv gcc /tools/bin/cc >> ${logfile} 2>&1
  422. msg_success
  423. popd > /dev/null 2>&1
  424. popd > /dev/null 2>&1
  425. popd > /dev/null 2>&1
  426. clean-build-directory
  427. mv ${logfile} ${logfile}.complete
  428. msg_line "Testing gcc pass-2: "
  429. echo 'int main(){}' > dummy.c
  430. cc dummy.c >> ${logfile}.test 2>&1
  431. echo "Test: [Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]" >> ${logfile}.test 2>&1
  432. readelf -l a.out | grep ': /tools' >> ${logfile}.test 2>&1
  433. rm dummy.c a.out
  434. msg_success
  435. return
  436. }
  437. function Tcl {
  438. # Tcl-8.6.10
  439. local pkg=tcl8.6.10-src.tar.gz
  440. local pkg_dir=${pkg%%-src*}
  441. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  442. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  443. > ${logfile}
  444. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  445. unpack "${pkg}"
  446. pushd ${pkg_dir} >> /dev/null 2>&1
  447. cd unix
  448. msg_line " Configure: "
  449. ./configure --prefix=/tools >> ${logfile} 2>&1
  450. msg_success
  451. msg_line " Make: "
  452. make ${MKFLAGS} >> ${logfile} 2>&1
  453. msg_success
  454. msg_line " Install: "
  455. make install >> ${logfile} 2>&1
  456. chmod -v u+w /tools/lib/libtcl8.6.so >> ${logfile} 2>&1
  457. make install-private-headers >> ${logfile} 2>&1
  458. ln -sv tclsh8.6 /tools/bin/tclsh >> ${logfile} 2>&1
  459. msg_success
  460. cd -
  461. popd > /dev/null 2>&1
  462. popd > /dev/null 2>&1
  463. clean-build-directory
  464. mv ${logfile} ${logfile}.complete
  465. return
  466. }
  467. function Expect {
  468. # Expect-5.45.4
  469. local pkg=expect5.45.4.tar.gz
  470. local pkg_dir=${pkg%%.tar*}
  471. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  472. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  473. > ${logfile}
  474. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  475. unpack "${pkg}"
  476. pushd ${pkg_dir} >> /dev/null 2>&1
  477. msg_line " Configure: "
  478. cp -v configure{,.orig} >> ${logfile} 2>&1
  479. sed 's:/usr/local/bin:/bin:' configure.orig > configure
  480. ./configure \
  481. --prefix=/tools \
  482. --with-tcl=/tools/lib \
  483. --with-tclinclude=/tools/include>> ${logfile} 2>&1
  484. msg_success
  485. msg_line " Make: "
  486. make ${MKFLAGS} >> ${logfile} 2>&1
  487. msg_success
  488. msg_line " Install: "
  489. make SCRIPTS="" install >> ${logfile} 2>&1
  490. msg_success
  491. popd > /dev/null 2>&1
  492. popd > /dev/null 2>&1
  493. clean-build-directory
  494. mv ${logfile} ${logfile}.complete
  495. return
  496. }
  497. function DejaGNU {
  498. # DejaGNU-1.6.2
  499. local pkg=dejagnu-1.6.2.tar.gz
  500. local pkg_dir=${pkg%%.tar*}
  501. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  502. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  503. > ${logfile}
  504. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  505. unpack "${pkg}"
  506. pushd ${pkg_dir} >> /dev/null 2>&1
  507. msg_line " Configure: "
  508. ./configure --prefix=/tools >> ${logfile} 2>&1
  509. msg_success
  510. msg_line " Install: "
  511. make install >> ${logfile} 2>&1
  512. msg_success
  513. popd > /dev/null 2>&1
  514. popd > /dev/null 2>&1
  515. clean-build-directory
  516. mv ${logfile} ${logfile}.complete
  517. return
  518. }
  519. # M4-1.4.18
  520. function M4 {
  521. # M4-1.4.18
  522. local pkg=m4-1.4.18.tar.xz
  523. local pkg_dir=${pkg%%.tar*}
  524. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  525. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  526. > ${logfile}
  527. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  528. unpack "${pkg}"
  529. pushd ${pkg_dir} >> /dev/null 2>&1
  530. msg_line " Configure: "
  531. sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c >> ${logfile} 2>&1
  532. echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h
  533. ./configure --prefix=/tools >> ${logfile} 2>&1
  534. msg_success
  535. msg_line " Make: "
  536. make ${MKFLAGS} >> ${logfile} 2>&1
  537. msg_success
  538. msg_line " Install: "
  539. make install >> ${logfile} 2>&1
  540. msg_success
  541. popd > /dev/null 2>&1
  542. popd > /dev/null 2>&1
  543. clean-build-directory
  544. mv ${logfile} ${logfile}.complete
  545. return
  546. }
  547. function Ncurses {
  548. # Ncurses-6.2
  549. local pkg=ncurses-6.2.tar.gz
  550. local pkg_dir=${pkg%%.tar*}
  551. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  552. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  553. > ${logfile}
  554. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  555. unpack "${pkg}"
  556. pushd ${pkg_dir} >> /dev/null 2>&1
  557. msg_line " Configure: "
  558. sed -i s/mawk// configure >> ${logfile} 2>&1
  559. ./configure \
  560. --prefix=/tools \
  561. --with-shared \
  562. --without-debug \
  563. --without-ada \
  564. --enable-widec \
  565. --enable-overwrite >> ${logfile} 2>&1
  566. msg_success
  567. msg_line " Make: "
  568. make ${MKFLAGS} >> ${logfile} 2>&1
  569. msg_success
  570. msg_line " Install: "
  571. make install >> ${logfile} 2>&1
  572. ln -s libncursesw.so /tools/lib/libncurses.so >> ${logfile} 2>&1
  573. msg_success
  574. popd > /dev/null 2>&1
  575. popd > /dev/null 2>&1
  576. clean-build-directory
  577. mv ${logfile} ${logfile}.complete
  578. return
  579. }
  580. function Bash {
  581. # Bash-5.0
  582. local pkg=bash-5.0.tar.gz
  583. local pkg_dir=${pkg%%.tar*}
  584. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  585. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  586. > ${logfile}
  587. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  588. unpack "${pkg}"
  589. pushd ${pkg_dir} >> /dev/null 2>&1
  590. msg_line " Configure: "
  591. ./configure --prefix=/tools --without-bash-malloc >> ${logfile} 2>&1
  592. msg_success
  593. msg_line " Make: "
  594. make ${MKFLAGS} >> ${logfile} 2>&1
  595. msg_success
  596. msg_line " Install: "
  597. make install >> ${logfile} 2>&1
  598. ln -sv bash /tools/bin/sh >> ${logfile} 2>&1
  599. msg_success
  600. popd > /dev/null 2>&1
  601. popd > /dev/null 2>&1
  602. clean-build-directory
  603. mv ${logfile} ${logfile}.complete
  604. return
  605. }
  606. function Bison {
  607. # Bison-3.5.2
  608. local pkg=bison-3.5.2.tar.xz
  609. local pkg_dir=${pkg%%.tar*}
  610. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  611. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  612. > ${logfile}
  613. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  614. unpack "${pkg}"
  615. pushd ${pkg_dir} >> /dev/null 2>&1
  616. msg_line " Configure: "
  617. ./configure --prefix=/tools >> ${logfile} 2>&1
  618. msg_success
  619. msg_line " Make: "
  620. make ${MKFLAGS} >> ${logfile} 2>&1
  621. msg_success
  622. msg_line " Install: "
  623. make install >> ${logfile} 2>&1
  624. msg_success
  625. popd > /dev/null 2>&1
  626. popd > /dev/null 2>&1
  627. clean-build-directory
  628. mv ${logfile} ${logfile}.complete
  629. return
  630. }
  631. function Bzip {
  632. # Bzip2-1.0.8
  633. local pkg=bzip2-1.0.8.tar.gz
  634. local pkg_dir=${pkg%%.tar*}
  635. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  636. local OPTFLAGS=" -march=x86-64 -mtune=generic -O2 -pipe -fPIC "
  637. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  638. > ${logfile}
  639. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  640. unpack "${pkg}"
  641. pushd ${pkg_dir} >> /dev/null 2>&1
  642. msg_line " Configure: "
  643. make ${MKFLAGS} -f Makefile-libbz2_so >> ${logfile} 2>&1
  644. make ${MKFLAGS} clean >> ${logfile} 2>&1
  645. msg_success
  646. msg_line " Make: "
  647. make ${MKFLAGS} >> ${logfile} 2>&1
  648. msg_success
  649. msg_line " Install: "
  650. make PREFIX=/tools install >> ${logfile} 2>&1
  651. cp -v bzip2-shared /tools/bin/bzip2 >> ${logfile} 2>&1
  652. cp -av libbz2.so* /tools/lib >> ${logfile} 2>&1
  653. ln -sv libbz2.so.1.0 /tools/lib/libbz2.so >> ${logfile} 2>&1
  654. msg_success
  655. popd > /dev/null 2>&1
  656. popd > /dev/null 2>&1
  657. clean-build-directory
  658. mv ${logfile} ${logfile}.complete
  659. return
  660. }
  661. function Coreutils {
  662. # Coreutils-8.31
  663. local pkg=coreutils-8.31.tar.xz
  664. local pkg_dir=${pkg%%.tar*}
  665. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  666. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  667. > ${logfile}
  668. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  669. unpack "${pkg}"
  670. pushd ${pkg_dir} >> /dev/null 2>&1
  671. msg_line " Configure: "
  672. ./configure --prefix=/tools --enable-install-program=hostname >> ${logfile} 2>&1
  673. msg_success
  674. msg_line " Make: "
  675. make ${MKFLAGS} >> ${logfile} 2>&1
  676. msg_success
  677. msg_line " Install: "
  678. make install >> ${logfile} 2>&1
  679. msg_success
  680. popd > /dev/null 2>&1
  681. popd > /dev/null 2>&1
  682. clean-build-directory
  683. mv ${logfile} ${logfile}.complete
  684. return
  685. }
  686. function Diffutils {
  687. # Diffutils-3.7
  688. local pkg=diffutils-3.7.tar.xz
  689. local pkg_dir=${pkg%%.tar*}
  690. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  691. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  692. > ${logfile}
  693. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  694. unpack "${pkg}"
  695. pushd ${pkg_dir} >> /dev/null 2>&1
  696. msg_line " Configure: "
  697. ./configure --prefix=/tools >> ${logfile} 2>&1
  698. msg_success
  699. msg_line " Make: "
  700. make ${MKFLAGS} >> ${logfile} 2>&1
  701. msg_success
  702. msg_line " Install: "
  703. make install >> ${logfile} 2>&1
  704. msg_success
  705. popd > /dev/null 2>&1
  706. popd > /dev/null 2>&1
  707. clean-build-directory
  708. mv ${logfile} ${logfile}.complete
  709. return
  710. }
  711. function File {
  712. # File-5.38
  713. local pkg=file-5.38.tar.gz
  714. local pkg_dir=${pkg%%.tar*}
  715. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  716. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  717. > ${logfile}
  718. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  719. unpack "${pkg}"
  720. pushd ${pkg_dir} >> /dev/null 2>&1
  721. msg_line " Configure: "
  722. ./configure --prefix=/tools >> ${logfile} 2>&1
  723. msg_success
  724. msg_line " Make: "
  725. make ${MKFLAGS} >> ${logfile} 2>&1
  726. msg_success
  727. msg_line " Install: "
  728. make install >> ${logfile} 2>&1
  729. msg_success
  730. popd > /dev/null 2>&1
  731. popd > /dev/null 2>&1
  732. clean-build-directory
  733. mv ${logfile} ${logfile}.complete
  734. return
  735. }
  736. function Findutils {
  737. # Findutils-4.7.0
  738. local pkg=findutils-4.7.0.tar.xz
  739. local pkg_dir=${pkg%%.tar*}
  740. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  741. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  742. > ${logfile}
  743. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  744. unpack "${pkg}"
  745. pushd ${pkg_dir} >> /dev/null 2>&1
  746. msg_line " Configure: "
  747. ./configure --prefix=/tools >> ${logfile} 2>&1
  748. msg_success
  749. msg_line " Make: "
  750. make ${MKFLAGS} >> ${logfile} 2>&1
  751. msg_success
  752. msg_line " Install: "
  753. make install >> ${logfile} 2>&1
  754. msg_success
  755. popd > /dev/null 2>&1
  756. popd > /dev/null 2>&1
  757. clean-build-directory
  758. mv ${logfile} ${logfile}.complete
  759. return
  760. }
  761. function Gawk {
  762. # Gawk-5.0.1
  763. local pkg=gawk-5.0.1.tar.xz
  764. local pkg_dir=${pkg%%.tar*}
  765. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  766. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  767. > ${logfile}
  768. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  769. unpack "${pkg}"
  770. pushd ${pkg_dir} >> /dev/null 2>&1
  771. msg_line " Configure: "
  772. ./configure --prefix=/tools >> ${logfile} 2>&1
  773. msg_success
  774. msg_line " Make: "
  775. make ${MKFLAGS} >> ${logfile} 2>&1
  776. msg_success
  777. msg_line " Install: "
  778. make install >> ${logfile} 2>&1
  779. msg_success
  780. popd > /dev/null 2>&1
  781. popd > /dev/null 2>&1
  782. clean-build-directory
  783. mv ${logfile} ${logfile}.complete
  784. return
  785. }
  786. function Gettext {
  787. # Gettext-0.20.1
  788. local pkg=gettext-0.20.1.tar.xz
  789. local pkg_dir=${pkg%%.tar*}
  790. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  791. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  792. > ${logfile}
  793. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  794. unpack "${pkg}"
  795. pushd ${pkg_dir} >> /dev/null 2>&1
  796. msg_line " Configure: "
  797. ./configure --disable-shared >> ${logfile} 2>&1
  798. msg_success
  799. msg_line " Make: "
  800. make ${MKFLAGS} >> ${logfile} 2>&1
  801. msg_success
  802. msg_line " Install: "
  803. cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /tools/bin >> ${logfile} 2>&1
  804. msg_success
  805. cd - > /dev/null 2>&1
  806. popd > /dev/null 2>&1
  807. popd > /dev/null 2>&1
  808. clean-build-directory
  809. mv ${logfile} ${logfile}.complete
  810. return
  811. }
  812. function Grep {
  813. # Grep-3.4
  814. local pkg=grep-3.4.tar.xz
  815. local pkg_dir=${pkg%%.tar*}
  816. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  817. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  818. > ${logfile}
  819. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  820. unpack "${pkg}"
  821. pushd ${pkg_dir} >> /dev/null 2>&1
  822. msg_line " Configure: "
  823. ./configure --prefix=/tools >> ${logfile} 2>&1
  824. msg_success
  825. msg_line " Make: "
  826. make ${MKFLAGS} >> ${logfile} 2>&1
  827. msg_success
  828. msg_line " Install: "
  829. make install >> ${logfile} 2>&1
  830. msg_success
  831. popd > /dev/null 2>&1
  832. popd > /dev/null 2>&1
  833. clean-build-directory
  834. mv ${logfile} ${logfile}.complete
  835. return
  836. }
  837. function Gzip {
  838. # Gzip-1.10
  839. local pkg=gzip-1.10.tar.xz
  840. local pkg_dir=${pkg%%.tar*}
  841. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  842. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  843. > ${logfile}
  844. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  845. unpack "${pkg}"
  846. pushd ${pkg_dir} >> /dev/null 2>&1
  847. msg_line " Configure: "
  848. ./configure --prefix=/tools >> ${logfile} 2>&1
  849. msg_success
  850. msg_line " Make: "
  851. make ${MKFLAGS} >> ${logfile} 2>&1
  852. msg_success
  853. msg_line " Install: "
  854. make install >> ${logfile} 2>&1
  855. msg_success
  856. popd > /dev/null 2>&1
  857. popd > /dev/null 2>&1
  858. clean-build-directory
  859. mv ${logfile} ${logfile}.complete
  860. return
  861. }
  862. function Make {
  863. # Make-4.3
  864. local pkg=make-4.3.tar.gz
  865. local pkg_dir=${pkg%%.tar*}
  866. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  867. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  868. > ${logfile}
  869. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  870. unpack "${pkg}"
  871. pushd ${pkg_dir} >> /dev/null 2>&1
  872. msg_line " Configure: "
  873. ./configure --prefix=/tools --without-guile >> ${logfile} 2>&1
  874. msg_success
  875. msg_line " Make: "
  876. make ${MKFLAGS} >> ${logfile} 2>&1
  877. msg_success
  878. msg_line " Install: "
  879. make install >> ${logfile} 2>&1
  880. msg_success
  881. popd > /dev/null 2>&1
  882. popd > /dev/null 2>&1
  883. clean-build-directory
  884. mv ${logfile} ${logfile}.complete
  885. return
  886. }
  887. function Patch {
  888. # Patch-2.7.6
  889. local pkg=patch-2.7.6.tar.xz
  890. local pkg_dir=${pkg%%.tar*}
  891. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  892. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  893. > ${logfile}
  894. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  895. unpack "${pkg}"
  896. pushd ${pkg_dir} >> /dev/null 2>&1
  897. msg_line " Configure: "
  898. ./configure --prefix=/tools >> ${logfile} 2>&1
  899. msg_success
  900. msg_line " Make: "
  901. make ${MKFLAGS} >> ${logfile} 2>&1
  902. msg_success
  903. msg_line " Install: "
  904. make install >> ${logfile} 2>&1
  905. msg_success
  906. popd > /dev/null 2>&1
  907. popd > /dev/null 2>&1
  908. clean-build-directory
  909. mv ${logfile} ${logfile}.complete
  910. return
  911. }
  912. function Perl {
  913. # Perl-5.30.1
  914. local pkg=perl-5.30.1.tar.xz
  915. local pkg_dir=${pkg%%.tar*}
  916. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  917. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  918. > ${logfile}
  919. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  920. unpack "${pkg}"
  921. pushd ${pkg_dir} >> /dev/null 2>&1
  922. msg_line " Configure: "
  923. sh Configure -des -Dprefix=/tools -Dlibs=-lm -Uloclibpth -Ulocincpth >> ${logfile} 2>&1
  924. msg_success
  925. msg_line " Make: "
  926. make ${MKFLAGS} >> ${logfile} 2>&1
  927. msg_success
  928. msg_line " Install: "
  929. cp -v perl cpan/podlators/scripts/pod2man /tools/bin >> ${logfile} 2>&1
  930. mkdir -pv /tools/lib/perl5/5.30.1 >> ${logfile} 2>&1
  931. cp -Rv lib/* /tools/lib/perl5/5.30.1 >> ${logfile} 2>&1
  932. msg_success
  933. popd > /dev/null 2>&1
  934. popd > /dev/null 2>&1
  935. clean-build-directory
  936. mv ${logfile} ${logfile}.complete
  937. return
  938. }
  939. function Python {
  940. # Python-3.8.1
  941. local pkg=Python-3.8.1.tar.xz
  942. local pkg_dir=${pkg%%.tar*}
  943. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  944. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  945. > ${logfile}
  946. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  947. unpack "${pkg}"
  948. pushd ${pkg_dir} >> /dev/null 2>&1
  949. msg_line " Configure: "
  950. sed -i '/def add_multiarch_paths/a \ return' setup.py
  951. ./configure --prefix=/tools --without-ensurepip >> ${logfile} 2>&1
  952. msg_success
  953. msg_line " Make: "
  954. make ${MKFLAGS} >> ${logfile} 2>&1
  955. msg_success
  956. msg_line " Install: "
  957. make install >> ${logfile} 2>&1
  958. msg_success
  959. popd > /dev/null 2>&1
  960. popd > /dev/null 2>&1
  961. clean-build-directory
  962. mv ${logfile} ${logfile}.complete
  963. return
  964. }
  965. function Sed {
  966. # Sed-4.8
  967. local pkg=sed-4.8.tar.xz
  968. local pkg_dir=${pkg%%.tar*}
  969. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  970. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  971. > ${logfile}
  972. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  973. unpack "${pkg}"
  974. pushd ${pkg_dir} >> /dev/null 2>&1
  975. msg_line " Configure: "
  976. ./configure --prefix=/tools >> ${logfile} 2>&1
  977. msg_success
  978. msg_line " Make: "
  979. make ${MKFLAGS} >> ${logfile} 2>&1
  980. msg_success
  981. msg_line " Install: "
  982. make install >> ${logfile} 2>&1
  983. msg_success
  984. popd > /dev/null 2>&1
  985. popd > /dev/null 2>&1
  986. clean-build-directory
  987. mv ${logfile} ${logfile}.complete
  988. return
  989. }
  990. function Tar {
  991. # Tar-1.32
  992. local pkg=tar-1.32.tar.xz
  993. local pkg_dir=${pkg%%.tar*}
  994. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  995. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  996. > ${logfile}
  997. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  998. unpack "${pkg}"
  999. pushd ${pkg_dir} >> /dev/null 2>&1
  1000. msg_line " Configure: "
  1001. ./configure --prefix=/tools >> ${logfile} 2>&1
  1002. msg_success
  1003. msg_line " Make: "
  1004. make ${MKFLAGS} >> ${logfile} 2>&1
  1005. msg_success
  1006. msg_line " Install: "
  1007. make install >> ${logfile} 2>&1
  1008. msg_success
  1009. popd > /dev/null 2>&1
  1010. popd > /dev/null 2>&1
  1011. clean-build-directory
  1012. mv ${logfile} ${logfile}.complete
  1013. return
  1014. }
  1015. function Texinfo {
  1016. # Texinfo-6.7
  1017. local pkg=texinfo-6.7.tar.xz
  1018. local pkg_dir=${pkg%%.tar*}
  1019. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  1020. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  1021. > ${logfile}
  1022. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  1023. unpack "${pkg}"
  1024. pushd ${pkg_dir} >> /dev/null 2>&1
  1025. msg_line " Configure: "
  1026. ./configure --prefix=/tools >> ${logfile} 2>&1
  1027. msg_success
  1028. msg_line " Make: "
  1029. make ${MKFLAGS} >> ${logfile} 2>&1
  1030. msg_success
  1031. msg_line " Install: "
  1032. make install >> ${logfile} 2>&1
  1033. msg_success
  1034. popd > /dev/null 2>&1
  1035. popd > /dev/null 2>&1
  1036. clean-build-directory
  1037. mv ${logfile} ${logfile}.complete
  1038. return
  1039. }
  1040. function Xz {
  1041. # Xz-5.2.4
  1042. local pkg=xz-5.2.4.tar.xz
  1043. local pkg_dir=${pkg%%.tar*}
  1044. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  1045. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  1046. > ${logfile}
  1047. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  1048. unpack "${pkg}"
  1049. pushd ${pkg_dir} >> /dev/null 2>&1
  1050. msg_line " Configure: "
  1051. ./configure --prefix=/tools >> ${logfile} 2>&1
  1052. msg_success
  1053. msg_line " Make: "
  1054. make ${MKFLAGS} >> ${logfile} 2>&1
  1055. msg_success
  1056. msg_line " Install: "
  1057. make install >> ${logfile} 2>&1
  1058. msg_success
  1059. popd > /dev/null 2>&1
  1060. popd > /dev/null 2>&1
  1061. clean-build-directory
  1062. mv ${logfile} ${logfile}.complete
  1063. return
  1064. }
  1065. # RPM STUFF
  1066. function Zlib {
  1067. local pkg=zlib-1.2.11.tar.xz
  1068. local pkg_dir=${pkg%%.tar*}
  1069. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  1070. local OPTFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fPIC"
  1071. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  1072. > ${logfile}
  1073. install -dm 755 ${TOPDIR}/BUILDROOT
  1074. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  1075. unpack "${pkg}"
  1076. pushd ${pkg_dir} >> /dev/null 2>&1
  1077. msg_line " Configure: "
  1078. CFLAGS=${OPTFLAGS} \
  1079. CXXFLAGS=${OPTFLAGS} \
  1080. ./configure \
  1081. --prefix=/tools \
  1082. --static >> ${logfile} 2>&1
  1083. msg_success
  1084. msg_line " Make: "
  1085. make ${MKFLAGS} >> ${logfile} 2>&1
  1086. msg_success
  1087. msg_line " Install: "
  1088. make DESTDIR=${TOPDIR}/BUILDROOT install >> ${logfile} 2>&1
  1089. rm -rf ${TOPDIR}/BUILDROOT/tools/share
  1090. cp -ar ${TOPDIR}/BUILDROOT/tools/* /tools
  1091. msg_success
  1092. popd > /dev/null 2>&1
  1093. popd > /dev/null 2>&1
  1094. clean-build-directory
  1095. mv ${logfile} ${logfile}.complete
  1096. return
  1097. }
  1098. function Popt {
  1099. local pkg=popt-1.16.tar.gz
  1100. local pkg_dir=${pkg%%.tar*}
  1101. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  1102. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  1103. > ${logfile}
  1104. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  1105. unpack "${pkg}"
  1106. pushd ${pkg_dir} >> /dev/null 2>&1
  1107. msg_line " Configure: "
  1108. ./configure \
  1109. --prefix=/tools \
  1110. --disable-shared \
  1111. --enable-static >> ${logfile} 2>&1
  1112. msg_success
  1113. msg_line " Make: "
  1114. make ${MKFLAGS} >> ${logfile} 2>&1
  1115. msg_success
  1116. msg_line " Install: "
  1117. make DESTDIR=${TOPDIR}/BUILDROOT install >> ${logfile} 2>&1
  1118. rm -rf ${TOPDIR}/BUILDROOT/tools/lib/libpopt.la
  1119. rm -rf ${TOPDIR}/BUILDROOT/tools/share
  1120. cp -ar ${TOPDIR}/BUILDROOT/tools/* /tools
  1121. msg_success
  1122. popd > /dev/null 2>&1
  1123. popd > /dev/null 2>&1
  1124. clean-build-directory
  1125. mv ${logfile} ${logfile}.complete
  1126. return
  1127. }
  1128. function Openssl {
  1129. local pkg=openssl-1.1.1d.tar.gz
  1130. local pkg_dir=${pkg%%.tar*}
  1131. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  1132. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  1133. > ${logfile}
  1134. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  1135. unpack "${pkg}"
  1136. pushd ${pkg_dir} >> /dev/null 2>&1
  1137. msg_line " Configure: "
  1138. ./config \
  1139. --prefix=/tools \
  1140. --openssldir=/tools/etc/ssl \
  1141. no-shared \
  1142. no-zlib \
  1143. enable-md2 >> ${logfile} 2>&1
  1144. msg_success
  1145. msg_line " Make: "
  1146. make ${MKFLAGS} >> ${logfile} 2>&1
  1147. msg_success
  1148. msg_line " Install: "
  1149. make DESTDIR=${TOPDIR}/BUILDROOT install >> ${logfile} 2>&1
  1150. rm -rf ${TOPDIR}/BUILDROOT/tools/share
  1151. cp -a ${TOPDIR}/BUILDROOT/tools/bin/* /tools/bin/
  1152. cp -ar ${TOPDIR}/BUILDROOT/tools/etc/* /tools/etc/
  1153. cp -ar ${TOPDIR}/BUILDROOT/tools/include/* /tools/include/
  1154. cp -ar ${TOPDIR}/BUILDROOT/tools/lib64/* /tools/lib/
  1155. msg_success
  1156. popd > /dev/null 2>&1
  1157. popd > /dev/null 2>&1
  1158. clean-build-directory
  1159. mv ${logfile} ${logfile}.complete
  1160. return
  1161. }
  1162. function Libelf {
  1163. local pkg=elfutils-0.178.tar.bz2
  1164. local pkg_dir=${pkg%%.tar*}
  1165. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  1166. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  1167. > ${logfile}
  1168. install -dm 755 ${TOPDIR}/BUILDROOT
  1169. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  1170. unpack "${pkg}"
  1171. pushd ${pkg_dir} >> /dev/null 2>&1
  1172. msg_line " Configure: "
  1173. ./configure \
  1174. --prefix=/tools \
  1175. --disable-debuginfod \
  1176. --program-prefix="eu-" \
  1177. --disable-shared \
  1178. --enable-static >> ${logfile} 2>&1
  1179. msg_success
  1180. msg_line " Make: "
  1181. make ${MKFLAGS} >> ${logfile} 2>&1
  1182. msg_success
  1183. msg_line " Install: "
  1184. make DESTDIR=${TOPDIR}/BUILDROOT -C libelf install >> ${logfile} 2>&1
  1185. install -Dm644 config/libelf.pc ${TOPDIR}/BUILDROOT/tools/lib/pkgconfig/libelf.pc
  1186. cp -ar ${TOPDIR}/BUILDROOT/tools/* /tools
  1187. msg_success
  1188. popd > /dev/null 2>&1
  1189. popd > /dev/null 2>&1
  1190. clean-build-directory
  1191. mv ${logfile} ${logfile}.complete
  1192. return
  1193. }
  1194. function Rpm {
  1195. local pkg=rpm-4.15.1.tar.bz2
  1196. local pkg_dir=${pkg%%.tar*}
  1197. local logfile="${TOPDIR}/LOGS/tools-${FUNCNAME}.log"
  1198. [ -e ${logfile}.complete ] && { msg "Skipping: ${FUNCNAME}";return 0; } || msg "Building: ${FUNCNAME}"
  1199. > ${logfile}
  1200. pushd ${TOPDIR}/BUILD >> /dev/null 2>&1
  1201. unpack "${pkg}"
  1202. pushd ${pkg_dir} >> /dev/null 2>&1
  1203. unpack db-5.3.28.tar.gz
  1204. msg_line " Configure: "
  1205. sed -i 's/--srcdir=$db_dist/--srcdir=$db_dist --with-pic/' db3/configure
  1206. ln -vs db-5.3.28 db >> ${logfile} 2>&1
  1207. ./configure \
  1208. --prefix=/tools \
  1209. --program-prefix= \
  1210. --sysconfdir=/tools/etc \
  1211. --with-crypto=openssl \
  1212. --without-external-db \
  1213. --without-archive \
  1214. --without-lua \
  1215. --disable-dependency-tracking \
  1216. --disable-silent-rules \
  1217. --disable-rpath \
  1218. --disable-plugins \
  1219. --disable-inhibit-plugin \
  1220. --disable-shared \
  1221. --enable-static \
  1222. --enable-zstd=no \
  1223. --disable-openmp \
  1224. --enable-lmdb=no >> ${logfile} 2>&1
  1225. msg_success
  1226. msg_line " Make: "
  1227. make ${MKFLAGS} >> ${logfile} 2>&1
  1228. msg_success
  1229. msg_line " Install: "
  1230. make DESTDIR=${TOPDIR}/BUILDROOT install >> ${logfile} 2>&1
  1231. rm -rf ${TOPDIR}/BUILDROOT/tools/share
  1232. rm -rf ${TOPDIR}/BUILDROOT/tools/lib/*.la
  1233. rm -rf ${TOPDIR}/BUILDROOT/tools/lib/rpm-plugins/*.la
  1234. cp -ar ${TOPDIR}/BUILDROOT/tools/* /tools
  1235. msg_success
  1236. popd > /dev/null 2>&1
  1237. popd > /dev/null 2>&1
  1238. # This is for rpm and rpmbuild
  1239. [ -d ${LFS}/tmp ] || install -vdm 755 ${LFS}/tmp
  1240. [ -d ${LFS}/bin ] || install -vdm 755 ${LFS}/bin
  1241. [ -d ${LFS}/usr/bin ] || install -vdm 755 ${LFS}/usr/bin
  1242. [ -h ${LFS}/bin/sh ] || ln -sf /tools/bin/bash ${LFS}/bin/sh
  1243. [ -h ${LFS}/bin/bash ] || ln -sf /tools/bin/bash ${LFS}/bin
  1244. [ -h ${LFS}//usr/bin/getconf ] || ln -sf /tools/bin/getconf ${LFS}/usr/bin
  1245. [ -d ${LFS}/tools/etc/rpm ] || install -vdm 755 ${LFS}/tools/etc/rpm
  1246. cp SOURCES/macros ${LFS}/tools/etc/rpm/macros
  1247. clean-build-directory
  1248. mv ${logfile} ${logfile}.complete
  1249. return
  1250. }
  1251. function Remove_files {
  1252. msg_line "Removing unnecessary files: "
  1253. # /tools/bin
  1254. rm -f /mnt/lfs/tools/bin/c_rehash
  1255. rm -f /mnt/lfs/tools/bin/gendiff
  1256. rm -f /mnt/lfs/tools/bin/openssl
  1257. # /tools/lib/pkgconfig
  1258. rm -f /mnt/lfs/tools/lib/pkgconfig/libcrypto.pc
  1259. rm -f /mnt/lfs/tools/lib/pkgconfig/libelf.pc
  1260. rm -f /mnt/lfs/tools/lib/pkgconfig/libssl.pc
  1261. rm -f /mnt/lfs/tools/lib/pkgconfig/openssl.pc
  1262. rm -f /mnt/lfs/tools/lib/pkgconfig/popt.pc
  1263. rm -f /mnt/lfs/tools/lib/pkgconfig/rpm.pc
  1264. rm -f /mnt/lfs/tools/lib/pkgconfig/zlib.pc
  1265. # /tools/etc/ssl
  1266. rm -fr /mnt/lfs/tools/etc/ssl
  1267. # /tools/include
  1268. rm -fr /mnt/lfs/tools/include/elfutils
  1269. rm -f /mnt/lfs/tools/include/gelf.h
  1270. rm -f /mnt/lfs/tools/include/libelf.h
  1271. rm -f /mnt/lfs/tools/include/nlist.h
  1272. rm -fr /mnt/lfs/tools/include/openssl
  1273. rm -f /mnt/lfs/tools/include/popt.h
  1274. rm -fr /mnt/lfs/tools/include/rpm
  1275. rm -f /mnt/lfs/tools/include/zconf.h
  1276. rm -f /mnt/lfs/tools/include/zlib.h
  1277. # /tools/lib
  1278. rm -fr /mnt/lfs/tools/lib/engines-1.1
  1279. rm -f /mnt/lfs/tools/lib/libcrypto.a
  1280. rm -f /mnt/lfs/tools/lib/libssl.a
  1281. rm -rf /mnt/lfs/tools/lib/libz.a
  1282. rm -f /mnt/lfs/tools/lib/libelf.a
  1283. rm -f /mnt/lfs/tools/lib/libpopt.a
  1284. rm -f /mnt/lfs/tools/lib/librpm.a
  1285. rm -f /mnt/lfs/tools/lib/librpmbuild.a
  1286. rm -f /mnt/lfs/tools/lib/librpmio.a
  1287. rm -f /mnt/lfs/tools/lib/librpmsign.a
  1288. find /tools/{lib,libexec} -name \*.la -delete
  1289. msg_success
  1290. return
  1291. }
  1292. #-----------------------------------------------------------------------------
  1293. # Mainline
  1294. LIST=""
  1295. LIST+="_sanity set-mkflags clean-build-directory "
  1296. LIST+="Binutils-Pass-1 "
  1297. LIST+="GCC-Pass-1 "
  1298. LIST+="Linux-API-Headers "
  1299. LIST+="Glibc "
  1300. LIST+="Libstdc "
  1301. LIST+="Binutils-Pass-2 "
  1302. LIST+="GCC-Pass-2 "
  1303. LIST+="Tcl "
  1304. LIST+="Expect "
  1305. LIST+="DejaGNU "
  1306. LIST+="M4 "
  1307. LIST+="Ncurses "
  1308. LIST+="Bash "
  1309. LIST+="Bison "
  1310. LIST+="Bzip "
  1311. LIST+="Coreutils "
  1312. LIST+="Diffutils "
  1313. LIST+="File "
  1314. LIST+="Findutils "
  1315. LIST+="Gawk "
  1316. LIST+="Gettext "
  1317. LIST+="Grep "
  1318. LIST+="Gzip "
  1319. LIST+="Make "
  1320. LIST+="Patch "
  1321. LIST+="Perl "
  1322. LIST+="Python "
  1323. LIST+="Sed "
  1324. LIST+="Tar "
  1325. LIST+="Texinfo "
  1326. LIST+="Xz "
  1327. # rpm stuff
  1328. LIST+="Zlib "
  1329. LIST+="Popt "
  1330. LIST+="Openssl "
  1331. LIST+="Libelf "
  1332. LIST+="Rpm "
  1333. LIST+="Remove_files "
  1334. for i in ${LIST};do ${i};done
  1335. end_run