User Tools

Site Tools


cucumber_linux_from_scratch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cucumber_linux_from_scratch [2018/11/04 13:37]
z5t1
cucumber_linux_from_scratch [2018/11/14 00:12] (current)
z5t1 [The End]
Line 51: Line 51:
 ===== Downloading the Cucumber Linux Source Tree ===== ===== Downloading the Cucumber Linux Source Tree =====
  
-Clone the Git repository for the official Cucumber Linux source tree:+Add the privilege separation user ''​portuser''​. This user will be the only user with write access the ports tree, as well as the user account used to download all of the sources. It is important that this is an unprivileged account, as it will be connecting to several untrusted servers. 
 + 
 +  useradd -m portuser 
 + 
 +Clone the Git repository for the official Cucumber Linux source tree using portstrap:
  
   install -m 755 -d chroot/usr   install -m 755 -d chroot/usr
-  ​cd chroot/​usr +  ​wget https://raw.githubusercontent.com/​cucumberlinux/​ports/​master/​utilities/​tools/​portstrap 
-  git clone https://github.com/​cucumberlinux/​ports.git+  chmod +x portstrap 
 +  ROOT=/​opt/​culfs/​chroot ​./portstrap
  
-If you are building a version of Cucumber Linux other than the current development versionswitch ​to the appropriate Git branch for it:+When asked to choose the location to clone the ports tree frompress enter to accept ​the default.
  
-  cd ports +When asked which branch of the ports tree to clone, do one of the following: 
-  ​git checkout 2.0 +  ​* If you are building the current development version of Cucumber Linux, enter ''​master''​
-  ​cd ..+  ​* If you are building any other version of Cucumber Linux, enter the version number (i.e. ''​2.0''​). 
 + 
 +When asked to choose the user that will be able to write to the ports tree, enter ''​portuser''​.
  
 Temporarily change the portmake configuration so it expects to find the ports tree in /opt: Temporarily change the portmake configuration so it expects to find the ports tree in /opt:
Line 69: Line 76:
   fi   fi
   echo PORTS_TREE=/​opt/​culfs/​chroot/​usr/​ports > /​etc/​portmake.conf   echo PORTS_TREE=/​opt/​culfs/​chroot/​usr/​ports > /​etc/​portmake.conf
-  ​+
 Download the source tarballs for the phase 2 and 3 packages. This must be done now, as the chroot environment will not have internet access until after phase 3 is built. This step will also verify the integrity of all the downloaded tarballs via checksums and PGP signatures. Download the source tarballs for the phase 2 and 3 packages. This must be done now, as the chroot environment will not have internet access until after phase 3 is built. This step will also verify the integrity of all the downloaded tarballs via checksums and PGP signatures.
  
-  ports/​utilities/​tools/​portmake download-recursive phase2 +  ​chroot/usr/ports/​utilities/​tools/​portmake download-recursive phase2 
-  ports/​utilities/​tools/​portmake download-recursive phase3+  ​chroot/usr/ports/​utilities/​tools/​portmake download-recursive phase3
   ​   ​
 Restore the original portmake.conf. Restore the original portmake.conf.
Line 88: Line 95:
 There are two additional packages that must be downloaded now so they are available immediately inside the chroot environment:​ pkgtools and tar 1.13. Create a directory to store them in: There are two additional packages that must be downloaded now so they are available immediately inside the chroot environment:​ pkgtools and tar 1.13. Create a directory to store them in:
  
-  cd ..+  cd chroot
   mkdir sources   mkdir sources
   cd sources   cd sources
Line 108: Line 115:
 In this chapter, we will perform a few additional tasks to prepare for building the temporary system. In this chapter, we will perform a few additional tasks to prepare for building the temporary system.
  
-===== Adding the lfs user =====+===== Creating Necessary Directories ​=====
   ​   ​
 Create a directory to download the phase 1 source tarballs to:   Create a directory to download the phase 1 source tarballs to:  
  
-  mkdir /opt/culfs/lfscript/sources +  mkdir /​opt/​culfs/​lfscript/​sources
- +
-Ensure that the lfs user has full access to /​opt/​culfs/​lfscript:​ +
- +
-  chown -Rv lfs /​opt/​culfs/​lfscript +
-  ​+
 ====== Chapter 5 - Building Phase 1 ====== ====== Chapter 5 - Building Phase 1 ======
  
Line 136: Line 138:
   ./lfscript -B   ./lfscript -B
   ​   ​
-Note that lfscript will exit with a reported failure. This is because lfscript will attempt to continue on after chapter 5 and begin building chapter 6. It will fail at building chapter 6 (because we don't use it for that part on Cucumber Linux), but will still build the tools tarball successfully. Therefore, this error can be safely ignored. When you reach the error message, press ''​^C''​.+
  
 ===== Installing /tools to the Chroot ===== ===== Installing /tools to the Chroot =====
Line 143: Line 145:
  
   cd ../chroot   cd ../chroot
-  tar -xvJf ../​lfscript/​packages-*/lfs-*/​toolchain.bak.txz+  tar -xvJf ../​lfscript/​packages-*/​toolchain.bak.txz
   ​   ​
 ===== Preparing the Chroot ===== ===== Preparing the Chroot =====
Line 187: Line 189:
  
 At the end of this phase, the system will be capable of running itself (without the /tools directory), but will not be capable of compiling itself yet. At the end of this phase, the system will be capable of running itself (without the /tools directory), but will not be capable of compiling itself yet.
 +
 +
  
 ===== Enter the Chroot ===== ===== Enter the Chroot =====
Line 290: Line 294:
   chmod 600  /​var/​log/​btmp   chmod 600  /​var/​log/​btmp
  
 +==== Customize Portmake ====
  
 +If desired, you can customize the Portmake configuration. This will let you change the build tag from ''​localport''​. This step is optional.
 +
 +  cp -v /​usr/​ports/​utilities/​templates/​portmake.conf /etc/
 +
 +If desired, edit the file /​etc/​portmake.conf to your liking.
  
 ===== Build a few Packages Manually ===== ===== Build a few Packages Manually =====
Line 343: Line 353:
   chmod 755 /​tools/​bin/​gpg   chmod 755 /​tools/​bin/​gpg
  
 +
 +Also create a dummy sudo to satisfy a dependency in Portmake:
 +
 +  cat > /​tools/​bin/​sudo << EOF
 +  #!/bin/bash
 +  ​
 +  while [ \$# -ne 0 ]; do
 +    case \$1 in
 +      '​-u'​)
 +        shift 2
 +        ;;
 +      *)
 +        exec \$@
 +        ;;
 +    esac
 +  done
 +  EOF
 +  chmod 755 /​tools/​bin/​sudo
  
 Build and install them: Build and install them:
Line 375: Line 403:
   ​   ​
   gcc -dumpspecs | sed -e '​s@/​tools@@g' ​                  \   gcc -dumpspecs | sed -e '​s@/​tools@@g' ​                  \
-    -e '/​\*startfile_prefix_spec:/​{n;​s@.*@/​usr/​lib${LIBDIRSUFFIX}/​ @}' \+    -e '/​\*startfile_prefix_spec:/​{n;​s@.*@/​usr/​lib'${LIBDIRSUFFIX}'/ @}' \
     -e '/​\*cpp:/​{n;​s@$@ -isystem /​usr/​include@}'​ >      \     -e '/​\*cpp:/​{n;​s@$@ -isystem /​usr/​include@}'​ >      \
     `dirname $(gcc --print-libgcc-file-name)`/​specs     `dirname $(gcc --print-libgcc-file-name)`/​specs
Line 462: Line 490:
 At the end of this phase the system will be complete. At the end of this phase the system will be complete.
  
-Similarly, this entire process can be automated with portmake ​as well. Note that this will take a //very long// time (even longer than phases 1. 2 & 3).+===== Modifying the Chroot Environment ===== 
 + 
 +Before we can build the remainder of the system, we must make a few modifications to the chroot environment to enable the ports tree and portmake to function properly. 
 + 
 +==== Set up DNS ==== 
 + 
 +Create a resolv.conf so the chroot can resolve DNS queries. Feel free to substitute in your favorite DNS servers here. 
 + 
 +  cat > /​etc/​resolv.conf << EOF 
 +  nameserver 208.67.222.222 
 +  nameserver 208.67.220.220 
 +  EOF 
 + 
 +==== Remove the Tools Directory ==== 
 + 
 +The ''/​tools''​ directory is no longer needed, so remove it to ensure that the tools located there do not impact phase 4 and update the PATH variable accordingly. 
 + 
 +  rm -rf /tools 
 +  export PATH=/​bin:/​usr/​bin:/​sbin:/​usr/​sbin 
 + 
 +===== Building the Packages ===== 
 + 
 +Proceed to build the phase 4 packages. ​Similarly ​to phase 3, this entire process can be automated with portmake. Note that this will take a //very long// time (even longer than phases 1. 2 & 3).
  
   /​usr/​ports/​utilities/​tools/​portmake install phase4   /​usr/​ports/​utilities/​tools/​portmake install phase4
  
-====== Chapter 9 - Creating the installer ======+====== Chapter 9 - Creating ​the Installer Image ====== 
 + 
 +We are done building the packages now, so exit the chroot environment. 
 + 
 +  exit 
 + 
 +===== Getting the Installer Buildscripts ===== 
 + 
 +Navigate to /opt/culfs and download ​the installer ​buildscripts from GitHub: 
 + 
 +  cd /​opt/​culfs 
 +  git clone https://​github.com/​cucumberlinux/​installer.git 
 + 
 +===== Building the Installer ​===== 
 + 
 +Enter the installer directory. 
 + 
 +  cd installer 
 + 
 +Run the build-iso.sh script, setting some special variables. 
 + 
 +  PORTSDIR=/​opt/​culfs/​chroot/​usr/​ports PKGDIR=/​opt/​culfs/​chroot/​opt/​packages ./​build-iso.sh 
 + 
 +This will the installer ISO file and place it in /tmp.
  
 +====== The End ======
  
 +Congrats, you made it!
cucumber_linux_from_scratch.txt · Last modified: 2018/11/14 00:12 by z5t1