Tutorial for making an Ubuntu fork.
Published: 2020-11-23 01:28:23

Making an Ubuntu fork is going to be the easiest part of this series, as the tools required are not necessarily difficult to use. We will be using a modified version of a tool developed by the elementryOS team simply known as “os.” We will be using a modified version by Ubuntu Budgie. A GitHub link is provided below.
https://github.com/UbuntuBudgie/iso-builder

## Step 1: Change the Repos & GPG Key. 
For ease of development, we will be using a Launchpad PPA. You simply need to go to launchpad.net and sign up. Once you do that, click your username in the top-right corner. You will then see your account. First thing first is to follow the tutorial by Launchpad to get your PGP key. They offer both graphical versions and ones done in terminal.  https://help.launchpad.net/YourAccount/ImportingYourPGPKey 

Once you have your PGP key there, grab a text-based exported version of your key. You can do this using the following command. Replace [os-name] with the name of your OS.
gpg --output [os-name].key --armor --export username@email 
Anyways. Make sure you have this file. You will be placing this file in the following directory in your fork of the ISO-builder.
[path to iso-builder]/etc/config/archives
This file should replace the ubuntucinnamonremix.key file. Rename the ubuntucinnamonremix.list file to the same name as the key file. In your .list file. 

Going back to your Launchpad, create a PPA named the version of Ubuntu you are forking. The current LTS is probably best to work with. Replace both links with the following:
https://launchpad.net/[your_username]/[ppa-name]/ubuntu @BASECODENAME main
of course replacing [your_username] with your launchpad username, and [ppa-name] with what you named your PPA. 

## Step 2: Terraform Config
Go back to the main directory of the ISO builder. Go into the inner /etc folder. There will be a file called terraform.conf. Make sure the following options are valid:
BASECODENAME, BASEVERSION, CODENAME, VERSION, and NAME. NAME should be the name of your OS, and BASECODENAME and BASEVERSION are the versions of Ubuntu you plan to fork. CODENAME and VERSION can be custom but make sure they make sense for your OS and OS naming scheme.

## Step 3: Custom Packages
Go back to the main directory of the ISO builder. Go into the inner /etc folder. In the package-lists.calamares folder, make sure to add your custom packages, and make sure to remove the Ubuntu Cinnamon Remix packages while your at it. This will be all the packages in desktop.list.chroot_install except for the line that says “@XORG_HWE.” Replace them with your custom packages. In  desktop.list.chroot_live only change/replace calamares-settings-cinnamon-remix, and don’t change anything in pool.list.binary.

## Step 4: Final setup
You lastly need to worry about [iso-builder]/etc/config/bootloaders. Simply go file to file and replace all mentions of Ubuntu Cinnamon with your operating system’s name.

## Step 5: The build
Make sure to install Docker, as this is what is used to build the ISO. Pull the latest Debian Docker with the command sudo docker pull debian. After you have done so, run sudo docker run --privileged -it debian:latest. You should now be in a Debian Docker. Do apt update and install debootstap and git using the APT package manager. Go to the directory /usr/share/debootstrap/scripts and do the following command: cp disco [ubuntu_version], of course replacing [ubuntu_version] with your Ubuntu version. Do mkdir /home/[your_os] and git clone your fork of the repository. Replace your_os with the name of your OS. Run ./build.sh, exit the container, and run sudo docker commit containerID, replacing containerID with the ID of your container. Stop the container with sudo docker stop containerID, and restart it with docker start -i containerID. Change directory to /home/[your_os]/iso-builder and run ./terraform.sh. Let the build script run and you have made an OS! To get it out of the Docker container, simply run sudo docker cp containerID:/home/[your_os]/iso-builder/builds/amd64 . And simply shut down the container one last time.