There are tons of Linux distributions available. I have used a few of the more popular distributions. In an effort to better understand what comprises a Linux distribution I have decided to build my own from source code at ground zero.
To accomplish building the distribution a host Linux system is required. In this example I have chosen Mint as a host.
There is a certain layer of software required to build the distribution. Two scripts are employed to ensure the proper environment exists on the host. The first script determines the existence of the required development environment.
[codesyntax lang=”bash”]
cat > version-check.sh << "EOF" #!/bin/bash # Simple script to list version numbers of critical development tools export LC_ALL=C bash --version | head -n1 | cut -d" " -f2-4 MYSH=$(readlink -f /bin/sh) echo "/bin/sh -> $MYSH" echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash" unset MYSH echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3- bison --version | head -n1 if [ -h /usr/bin/yacc ]; then echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`"; elif [ -x /usr/bin/yacc ]; then echo yacc is `/usr/bin/yacc --version | head -n1` else echo "yacc not found" fi bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6- echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2 diff --version | head -n1 find --version | head -n1 gawk --version | head -n1 if [ -h /usr/bin/awk ]; then echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`"; elif [ -x /usr/bin/awk ]; then echo awk is `/usr/bin/awk --version | head -n1` else echo "awk not found" fi gcc --version | head -n1 g++ --version | head -n1 ldd --version | head -n1 | cut -d" " -f2- grep --version | head -n1 gzip --version | head -n1 cat /proc/version m4 --version | head -n1 make --version | head -n1 patch --version | head -n1 echo Perl `perl -V:version` sed --version | head -n1 tar --version | head -n1 makeinfo --version | head -n1 xz --version | head -n1 echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c if [ -x dummy ] then echo "g++ compilation OK"; else echo "g++ compilation failed"; fi rm -f dummy.c dummy EOF bash version-check.sh
[/codesyntax]
The above file should be placed on the host and be made executable. After the file is executed the following script is generated. The resulting script may be found in the file “version-check.sh” (minus double quotes).
[codesyntax lang=”bash”]
#!/bin/bash # Simple script to list version numbers of critical development tools export LC_ALL=C bash --version | head -n1 | cut -d" " -f2-4 MYSH=$(readlink -f /bin/sh) echo "/bin/sh -> $MYSH" echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash" unset MYSH echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3- bison --version | head -n1 if [ -h /usr/bin/yacc ]; then echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`"; elif [ -x /usr/bin/yacc ]; then echo yacc is `/usr/bin/yacc --version | head -n1` else echo "yacc not found" fi bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6- echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2 diff --version | head -n1 find --version | head -n1 gawk --version | head -n1 if [ -h /usr/bin/awk ]; then echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`"; elif [ -x /usr/bin/awk ]; then echo awk is `/usr/bin/awk --version | head -n1` else echo "awk not found" fi gcc --version | head -n1 g++ --version | head -n1 ldd --version | head -n1 | cut -d" " -f2- grep --version | head -n1 gzip --version | head -n1 cat /proc/version m4 --version | head -n1 make --version | head -n1 patch --version | head -n1 echo Perl `perl -V:version` sed --version | head -n1 tar --version | head -n1 makeinfo --version | head -n1 xz --version | head -n1 echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c if [ -x dummy ] then echo "g++ compilation OK"; else echo "g++ compilation failed"; fi rm -f dummy.c dummy
[/codesyntax]
The second script determines the required libraries exist prior to commencing the build.
[codesyntax lang=”bash”]
cat > library-check.sh << "EOF" #!/bin/bash for lib in lib{gmp,mpfr,mpc}.la; do echo $lib: $(if find /usr/lib* -name $lib| grep -q $lib;then :;else echo not;fi) found done unset lib EOF bash library-check.sh
[/codesyntax]
The above file should be placed on the host and be made executable. After the file is executed the following script is generated. The resulting script may be found in the file “library-check.sh” (minus double quotes).
[codesyntax lang=”bash”]
#!/bin/bash for lib in lib{gmp,mpfr,mpc}.la; do echo $lib: $(if find /usr/lib* -name $lib| grep -q $lib;then :;else echo not;fi) found done unset lib
[/codesyntax]
The Acrobat Reader will be useful in this endeavor. The latest version supported by Mint can be accessed by clicking here. Once the package is downloaded use GDebi to install to the proper location.
To create the source code repository for the build a scrip and a take (input) file were created.
The script is listed below.
[codesyntax lang=”bash”]
wget --input-file=wget-list --continue --directory-prefix=$LFS/sources
[/codesyntax]
The take or input file is listed below.
[codesyntax lang=”text”]
http://download.savannah.gnu.org/releases/acl/acl-2.2.52.src.tar.gz http://download.savannah.gnu.org/releases/attr/attr-2.4.47.src.tar.gz http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xz http://ftp.gnu.org/gnu/automake/automake-1.15.tar.xz http://ftp.gnu.org/gnu/bash/bash-4.4.tar.gz http://alpha.gnu.org/gnu/bc/bc-1.06.95.tar.bz2 http://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.bz2 http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.xz http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz https://github.com/libcheck/check/releases/download/0.11.0/check-0.11.0.tar.gz http://ftp.gnu.org/gnu/coreutils/coreutils-8.26.tar.xz http://ftp.gnu.org/gnu/dejagnu/dejagnu-1.6.tar.gz http://ftp.gnu.org/gnu/diffutils/diffutils-3.5.tar.xz http://dev.gentoo.org/~blueness/eudev/eudev-3.2.1.tar.gz http://downloads.sourceforge.net/project/e2fsprogs/e2fsprogs/v1.43.4/e2fsprogs-1.43.4.tar.gz http://prdownloads.sourceforge.net/expat/expat-2.2.0.tar.bz2 http://prdownloads.sourceforge.net/expect/expect5.45.tar.gz ftp://ftp.astron.com/pub/file/file-5.30.tar.gz http://ftp.gnu.org/gnu/findutils/findutils-4.6.0.tar.gz https://github.com/westes/flex/releases/download/v2.6.3/flex-2.6.3.tar.gz http://ftp.gnu.org/gnu/gawk/gawk-4.1.4.tar.xz http://ftp.gnu.org/gnu/gcc/gcc-6.3.0/gcc-6.3.0.tar.bz2 http://ftp.gnu.org/gnu/gdbm/gdbm-1.12.tar.gz http://ftp.gnu.org/gnu/gettext/gettext-0.19.8.1.tar.xz http://ftp.gnu.org/gnu/glibc/glibc-2.25.tar.xz http://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz http://ftp.gnu.org/gnu/gperf/gperf-3.0.4.tar.gz http://ftp.gnu.org/gnu/grep/grep-3.0.tar.xz http://ftp.gnu.org/gnu/groff/groff-1.22.3.tar.gz http://alpha.gnu.org/gnu/grub/grub-2.02~beta3.tar.xz http://ftp.gnu.org/gnu/gzip/gzip-1.8.tar.xz http://anduin.linuxfromscratch.org/LFS/iana-etc-2.30.tar.bz2 http://ftp.gnu.org/gnu/inetutils/inetutils-1.9.4.tar.xz http://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-4.9.0.tar.xz https://www.kernel.org/pub/linux/utils/kbd/kbd-2.0.4.tar.xz https://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-23.tar.xz http://www.greenwoodsoftware.com/less/less-481.tar.gz http://www.linuxfromscratch.org/lfs/downloads/8.0/lfs-bootscripts-20150222.tar.bz2 https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.25.tar.xz http://download.savannah.gnu.org/releases/libpipeline/libpipeline-1.4.1.tar.gz http://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.xz https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.9.9.tar.xz http://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.xz http://ftp.gnu.org/gnu/make/make-4.2.1.tar.bz2 http://download.savannah.gnu.org/releases/man-db/man-db-2.7.6.1.tar.xz https://www.kernel.org/pub/linux/docs/man-pages/man-pages-4.09.tar.xz http://www.multiprecision.org/mpc/download/mpc-1.0.3.tar.gz http://www.mpfr.org/mpfr-3.1.5/mpfr-3.1.5.tar.xz http://ftp.gnu.org/gnu//ncurses/ncurses-6.0.tar.gz http://ftp.gnu.org/gnu/patch/patch-2.7.5.tar.xz http://www.cpan.org/src/5.0/perl-5.24.1.tar.bz2 https://pkg-config.freedesktop.org/releases/pkg-config-0.29.1.tar.gz http://sourceforge.net/projects/procps-ng/files/Production/procps-ng-3.3.12.tar.xz http://downloads.sourceforge.net/project/psmisc/psmisc/psmisc-22.21.tar.gz http://ftp.gnu.org/gnu/readline/readline-7.0.tar.gz http://ftp.gnu.org/gnu/sed/sed-4.4.tar.xz https://github.com/shadow-maint/shadow/releases/download/4.4/shadow-4.4.tar.xz http://www.infodrom.org/projects/sysklogd/download/sysklogd-1.5.1.tar.gz http://download.savannah.gnu.org/releases/sysvinit/sysvinit-2.88dsf.tar.bz2 http://ftp.gnu.org/gnu/tar/tar-1.29.tar.xz http://sourceforge.net/projects/tcl/files/Tcl/8.6.6/tcl-core8.6.6-src.tar.gz http://ftp.gnu.org/gnu/texinfo/texinfo-6.3.tar.xz http://www.iana.org/time-zones/repository/releases/tzdata2016j.tar.gz http://anduin.linuxfromscratch.org/LFS/udev-lfs-20140408.tar.bz2 https://www.kernel.org/pub/linux/utils/util-linux/v2.29/util-linux-2.29.1.tar.xz ftp://ftp.vim.org/pub/vim/unix/vim-8.0.069.tar.bz2 http://cpan.metacpan.org/authors/id/T/TO/TODDR/XML-Parser-2.44.tar.gz http://tukaani.org/xz/xz-5.2.3.tar.xz http://zlib.net/zlib-1.2.11.tar.xz http://www.linuxfromscratch.org/patches/lfs/8.0/bash-4.4-upstream_fixes-1.patch http://www.linuxfromscratch.org/patches/lfs/8.0/bc-1.06.95-memory_leak-1.patch http://www.linuxfromscratch.org/patches/lfs/8.0/bzip2-1.0.6-install_docs-1.patch http://www.linuxfromscratch.org/patches/lfs/8.0/coreutils-8.26-i18n-1.patch http://www.linuxfromscratch.org/patches/lfs/8.0/glibc-2.25-fhs-1.patch http://www.linuxfromscratch.org/patches/lfs/8.0/kbd-2.0.4-backspace-1.patch http://www.linuxfromscratch.org/patches/lfs/8.0/sysvinit-2.88dsf-consolidated-1.patch [/codesyntax]
Mr. Arch Brooks, CEO / Software Engineer, Brooks Computing Systems, LLC. authored this article.