Chakra-Live
Cherimoya uses Chakra-Live to create liveCDs. Chakra-Live was built for the Chakra project by Phil Miller, based on Gerardo Exequiel Pozzi's ArchISO. It includes usage of squashFS and Aufs2 multiple overlays, which was removed in the current ArchISO.
Contents
Introduction
Chakra-Live works similarly to ArchISO; it installs packages from a list to make a "pure" installation, and uses a simple "overlay" filesystem to configure every single aspect of the resulting system. This makes for an extremely easy-to-use liveCD creator, one that stays simple no matter what level you develop at. It also increases transparency, as instead of relying on complicated and abstract bash scripts to edit files, you just dump the files in where they should be, and that's that.
Unlike other liveCD creators, Chakra-Live makes sure all configuration and installation is as automated as possible, making it possible to redistribute all the settings and package lists in a single folder called a "profile". This makes for a system that needs almost no human input while building, like a Makefile. When you give this profile to someone else, it's only a matter of a single command to reproduce the results.
Getting started
Before beginning, you will need:
- Choose one:
- Any Linux distro, just add Pacman
- A Chakra-based operating system, such as Cherimoya (recommended)
- git
- Basic development tools needed to compile C source code (GCC, Make, whatnot)
- wget
To use Chakra-Live, a Linux distro must be used, with pacman installed to it. See instructions below to install pacman.
Once you've got that, you'll need to get Chakra-Live. Use the following command:
git clone git://gitorious.org/chakra/chakra-live.git
Now you have all the files to begin.
Installing Pacman
Because we create a chroot to build a liveCD, any Linux distro from Gentoo to Debian can work on Cherimoya. All you need to do is to install the pacman package manager to your host system.
Gentoo
Gentoo has a pacman package ready to go. Just unmask and emerge it:
# echo sys-apps/pacman >> /etc/portage/package.keywords # emerge -va sys-apps/pacman
Because Gentoo does not have libfetch, you will need to uncomment one of the two XferCommand lines in /etc/pacman.conf. I recommend using the wget line:
XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
Other distros
For other distros, such as Debian or Fedora, they either do not have a Pacman package, or it is too old. Not to worry though, just download this script, run it, and pacman will be installed.
Creating a chroot
LiveCD creation is a very messy process, requiring lots of programs to be installed and configuration to be made. Also, these configurations could be incompatible with the host system! Therefore, creating a chroot jail is quite useful. A chroot simply changes the apparent root directory for the programs inside it, preventing them from messing with the real filesystem.
First, get the Cherimoya Buildsystem installer script. Next, make it executable with this command:
chmod +x ch-setup.sh
Now make sure that you've installed Git, and run this command:
./ch-setup.sh chakra-live master <i686 or x86_64>
You can choose to build an i686 chroot to build i686 ISOs on any architecture, and/or run this script again to make a chroot for x86_64 systems.
The script will ask for your user password. Remember your user must have sudo-rights. Here is an example:
[packager@chakra master]$ ./ch-setup.sh cherimoya master i686
Cherimoya Packager's Chroot Setup Script v0.5.1.0
:: Root : /home/iruel/32m/buildroot
:: Chroot Installation : /home/iruel/32m/buildroot/cherimoya-i686
:: Do you want to continue (y/n)_
Check the paths are correct and enter y and Enter to continue.
If you ran the script with c as fourth parameter, you will be then asked for your SSH password for Git.
Once all packages are downloaded and installed, you'll be asked for your password. It is your user password, not root.
Password:
:: configuring system DONE
User setup
:: adding user: anke DONE
:: you will be asked to enter a password for the chroot user
And later, you will be asked for a new password for the chroot user. You can (and probably should) enter your user password, so your user has the same password in and out of the chroot. Then, enter it again to confirm.
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
:: setting up /etc/sudoers DONE
:: setting up device permissions DONE
:: unmounting special dirs DONE
After that, the script installs all needed scripts and sets up Chakra-Live. You may be asked for your full name and your email (This is for Git, you can use a pseudonym and a fake email).
:: enter your full name (eg, John Smith): Anke Boersma
:: and your email (eg, jsmith@chakra-project.org): abveritas@chakra-project.org
:: finishing... DONE
And that's it! You have a chroot created and prepared to manage a repository. You can (and should) repeat the process for a different architecture, so you can build images for those systems.
(k)eep chroot master-x32 and update it?
(d)elete/reinstall chroot master-x32?
(u)ninstall chroot master-x32?
(q)uit this script? _
Entering the Chroot
To enter the chroot, use this command (as the normal user):
cd buildroot ./enter-chroot.sh chakra-live-<arch>
Replacing <arch> with any installed architecture. Example: chakra-live-i686.
You will then be asked for your chroot user's password. Then, you'll enter the chroot. You will see the chroot content, and the prompt will be in red, so you know when you are into the chroot.
Use this command to see the profiles you can build
To ensure your chroot is clean and synced before starting to build and add packages, a good practice is to always use these commands after entering your chroot:
git status # This tells you about the local changes you haven't committed yet. git pull # Updates your Git copy. pacman -Sc pacman -Syu
Post-install Configuration
Sometimes the chroot will put the wrong architecture in the pacman.conf, so make sure to check it out.
First, open /etc/pacman.conf and take a look. If it shows the wrong architecture at the end of a mirror, replace <arch> with either "i686" or "x86_64", depending on your chroot's architecture. The file should then look something like this:
Your chroot is ready! All steps below this should always be done inside this chroot.
Editing the profile
The profile is a folder that contains every setting needed to create a liveCD. It can be zipped up and distributed over the internet, and when built with Chakra-Live, everyone will get the exact same results every time, with a single little command. By editing the profile, the resulting liveCD can be customized as needed.
The profile is composed of multiple parts, the overlay, the package lists, and the build script.
The Package Lists
Packages are the very basis of a Linux system. Once all the packages are installed, the Linux system is ready for use. Therefore, the package list forms the very core of a profile.
The package names are placed in a list, to be read by pacman and installed. It's not more complicated than that. However, you will see that, for most lists, there is a lot of extra text that is ignored by pacman. These are called comments, and explain what a package is, and the reason for it's inclusion.
The following example shows every single possible comment that can be made in a package list:
#--------------------------------------------# # Fonts #--------------------------------------------# xorg-fonts-cyrillic # ui & decorative fonts ttf-liberation ttf-google-webfonts # font metapackage #ttf-droid # part of google webfonts #ttf-anonymous-pro
Pacman ignores everything past the "#" character. This makes it possible to add an explanation right inside the source code or otherwise add some organization, but without screwing everything up. It also becomes possible to easily remove a package while keeping it in the code by "commenting it out", as you see above with the package ttf-anonymous-pro.
It is good practice to add a lot of comments so that others can understand what the packages are, and what they do.
Now that you know that, this is what pacman actually reads:
xorg-fonts-cyrillic ttf-liberation ttf-google-webfonts
All the comments have been removed, and the desired packages are then installed. It's that simple.
Installing Unofficial Packages
Well, in theory. The problem is that (currently), the package list can only fetch packages from binary repositories, not from source-code based User Repositories. And since the binary repositories only include the most important and trusted packages, you're really going to need the unofficial ones.
The solution is to create your own binary repository, precompiling packages from the User Repositories. Rather than getting an http/ftp server, you can just use the Dropbox service. Dropbox is a powerful file synchronizer that can also act as a basic http server, and it is up even when your computer is down.
First, install Dropbox. Then, go to your Dropbox folder, and enter the Public folder within. In this folder, the files can be shared with the world by using the HTTP protocol, meaning you can host downloads, and even a basic website.
We want to host a pacman repository with Dropbox, so create a folder with the name of your repository (make one up). Enter the folder, and then put your packages into it. Once that's done, replace the <repo-name> placeholder with the name of the folder. Then run the following command:
$ repo-add <repo-name>.db.tar.gz *.pkg.tar.gz
This command will add every single package in the same directory to the repository. Since your repository may increase in size, it is best to use this sparingly. Instead, add a package one by one with the below command, replacing the <packagetoadd> placeholder with the package name:
$ repo-add <repo-name>.db.tar.gz <packagetoadd>-1.0-1-i686.pkg.tar.gz
Conversely, to remove a package, type the package name without any file extensions and use repo-remove:
$ repo-remove <repo-name>.db.tar.gz <packagetoremove>
Now, as soon as everything is in sync with Dropbox, your repository is ready to go. Get the public URL (from Dropbox's web interface) and add the repository to the bottom of the file: overlay/etc/pacman.conf. Here is a working example:
[cherimoya] Server = http://dl.dropbox.com/u/22186524/cherimoya/
Save that, and now you can add packages from that repository to the package list.
Overlays
However, there's more to liveCDs than installing packages. The resulting system needs to be configured to work in a desired manner. Most liveCD creators complicate this by using bash scripts, which are extremely abstract, making the changes nearly impossible to understand.
Thankfully, Chakra-Live configures every aspect of the entire system by simply overwriting the originals. By doing this, configuration becomes easier to understand, and works exactly the same way as on a working version.
While this isn't an exhaustive list of what can be configured using the overlay (every single thing can), here are some of the essentials:
System
- etc/rc.conf -- This file is the BSD-style central configuration file, controlling everything from default locales and time zones, to Kernel Modules and Daemons. If your program is started by a daemon, or requires a kernel module, don't forget to add it to the list here!
- etc/pacman.conf -- This file configures the repositories and options of the Pacman package manager.
Global Application Settings
The files in the /etc/skel directory are copied to the home directory of every new user when they are created. They are only used when Cherimoya is installed to disk, not for the live user running the liveCD (as it is created before )
- /etc/skel/.bashrc -- A hidden file that sets variables and alias for Bash. Cherimoya makes many alias and variables to make Bash more convienent, and even friendly.
Making the liveCD
Once you're done with all that, go to the configs folder inside chakra-live.
cd /usr/share/chakraiso/configs
Here, you can place profiles git to get pre-configured profiles from others, or make and build your own.
Preperations
Don't forget that each time you restart the chroot, it will reset /etc/pacman.d/mirrorlist. So just as before, remove the "#" from the mirror server you want, and replace <arch> with either i686 or x86_64.
Also, do the same to the new cherimoya-mirrorlist file if you are building a Cherimoya-based profile.
nano /etc/pacman.d/mirrorlist nano /etc/pacman.d/cherimoya-mirrorlist
And always upgrade your chroot before building with the following command. Failure to do so could cause some severe bugs in the liveCD.
pacman -Syyu
Building
Finally, while inside your chosen profile directory, use this command:
./build.sh
Everything will be totally automated. Once the script completes, you will have your very own ISO!