Brim­ming with fea­tures

Remix a Fe­dora in­stal­la­tion into a dis­tributable dis­tri­bu­tion.

Linux Format - - HOTTEST DISTROS -

The se­cret for cre­at­ing Fe­dora-based dis­tros is the livecd-cre­ator script that’s part of the livecd-tools pack­age. Grab it from the Fe­dora repos­i­to­ries with dnf in­stall livecd-tools . Un­like Bod­hibuilder, livecd-cre­ator works solely on the com­mand line.

The scripts use a def­i­ni­tion in a Kick­start file to set up your cus­tomised Fe­dora-based dis­tro. In sim­ple terms, a Kick­start file is a text file that con­tains a list of ac­tions such as the name of pack­ages to in­stall (or re­move). The livecd-cre­ator tool com­piles your dis­tro as per the in­struc­tions in this file. To help you get started, you can down­load the Kick­start files for sev­eral Fe­dora spins by grab­bing the spin-kick­starts pack­age from the Fe­dora repos­i­to­ries with dnf in­stall spin-kick­starts . Once this is in­stalled, you’ll have a bunch of Kick­start files un­der the /usr/share/spin-kick­starts direc­tory. You can cus­tomise any of these Kick­start files by edit­ing them. They are well doc­u­mented and fairly easy to com­pre­hend; browse the Fe­dora wiki ( http:// fe­do­rapro­ject.org/wiki/Ana­conda/Kick­start) to get a hang of the var­i­ous op­tions. If you need to gen­er­ate one from scratch, you can save your­self a lot of time by grab­bing the Kick­startCon­fig­u­ra­tor tool with dnf in­stall sys­tem-con­fig-kick­start . This tool has an easy-tonav­i­gate graph­i­cal in­ter­face to help cre­ate a Kick­start file.

Kick-start the process

For our pur­pose we’ll cre­ate a Mate-based Fe­dora remix by mod­i­fy­ing the fe­dora-live-mate_­com­piz.ks file. The three main pa­ram­e­ters in a kick­start file are %pre, %post and %pack­ages. You can also pull in in­struc­tions from an­other kick­start file by spec­i­fy­ing its name and lo­ca­tion with the %in­clude pa­ram­e­ter, such as %in­clude fe­dora-mate-com­mon.ks . You’ll no­tice three such lines at the top of the fe­dora-live-mate_­com­piz.ks file.

The first one calls the fe­dora-live-base.ks file. This file de­scribes the ba­sic skele­ton for cre­at­ing a Fe­dora Live CD. The pa­ram­e­ters are self-ex­plana­tory. There’s one each for the de­fault lan­guage, key­board and time­zone fol­lowed by se­cu­rity set­tings that dic­tate the use of stan­dard shadow pass­words and so on. Here, we’d like to note that while the de­fault for SELinux is set to en­forc­ing mode, it hin­dered with the smooth func­tion­ing of some our builds and we had to change the de­fault SELinux pol­icy for the cus­tomised dis­tro to the per­mis­sive mode.

The xcon­fig set to --startx­on­boot asks the live CD to boot straight to a graph­i­cal lo­gin screen. There’s also an en­try to cre­ate a root (/) par­ti­tion and an­other to en­able and dis­able the de­fault ser­vices.

Also in­cluded in the fe­dora-live-mate_­com­piz.ks file is the fe­dora-mate-com­mon.ks file that con­tains a list of pack­ages for the Mate desk­top with the Com­piz com­pos­i­tor. Any pack­ages you want in­side your cus­tom dis­tro needs to be listed un­der the %pack­ages sec­tion. In ad­di­tion to in­di­vid­ual pack­ages, you can also spec­ify groups of pack­ages such as @mate and @li­breof­fice. If you in­stall a group of pack­ages you can re­move in­di­vid­ual com­po­nents in­side it by pre­fix­ing a mi­nus (-) sign to their name, such as -fe­dora-icon-theme. These pack­ages are

fetched from Fe­dora repos­i­to­ries men­tioned in the fe­dora-repo.ks file. You can ei­ther di­rectly spec­ify the ex­act URL for a repos­i­tory (with the --baseurl op­tion) or let it choose one from a list of mir­rors (with the --mir­rorlist op­tion).

In case you pull in pack­ages from third-party repos­i­to­ries like RPMFu­sion or those for fetch­ing pro­pri­etary soft­ware like the Steam client, Google Chrome, Nvidia graph­ics and the like, Fe­dora guide­lines man­date you to re­brand your cre­ation. But they’ve made the process sim­ple. All you need to do is re­move a bunch of Fe­dora brand­ing pack­ages, namely -fe­dora-lo­gos and -fe­do­rarelease* , and then re­place them with generic ones, generic-re­lease* and generic-lo­gos .

Post haste

Lastly there’s the %post sec­tion that en­ables you to run com­mands af­ter all the pack­ages have been down­loaded and in­stalled to the tem­po­rary direc­tory. You can add cus­tom users, copy files, con­fig­ure the net­work, and do a lot more in­ter­est­ing stuff in this sec­tion.

To cor­rectly iden­tify our remixed dis­tro, we’ll re­name it in the /etc/fe­dora-re­lease file, with: %post sed -i -e ‘s/Generic re­lease/LXF Fe­dora Remix/g’ /etc/fe­dora-re­lease %end

The com­mands in the %post sec­tion by de­fault run in­side a ch­root en­vi­ron­ment against the new filesys­tem in the Live CD. But there’s also a mech­a­nism for adding files to the LiveCD’s filesys­tem. The %post --ch­root sec­tion en­ables you to in­ter­act with your cus­tom dis­tro’s en­vi­ron­ment from out­side. This en­ables you to copy files from your host Fe­dora in­stal­la­tion to the cus­tomised dis­tro.

Kick­start of­fers two vari­ables for in­ter­act­ing with the cus­tom dis­tro en­vi­ron­ment. The $IN­STAL­L_­ROOT points to the root (/) of the cus­tomised dis­tro where all the pack­ages are in­stalled dur­ing the build process. This comes in handy for copy­ing files you need in your Live en­vi­ron­ment. For ex­am­ple: %post --noch­root cp -r /home/bodhi/Pic­tures/wall­pa­pers/ $IN­STAL­L_­ROOT/etc/skel/Pic­tures/ %end

This will copy a bunch of images housed in­side the wall­pa­pers direc­tory on the host to the cus­tom dis­tro. We’ve placed it in­side the skele­ton direc­tory (/ etc/skel) so that it’s avail­able to all users in the cus­tom dis­tro. You can use the same mech­a­nism to copy over your desk­top cus­tomi­sa­tions to the cus­tom dis­tro. First, just like be­fore, con­fig­ure your desk­top as per your re­quire­ments on an in­stalled sys­tem. When you’re done, sim­ply scoot over the con­fig­u­ra­tion files from your home direc­tory to the /etc/skel direc­tory on the live CD: %post --noch­root cp -r /home/bodhi/.con­fig $IN­STAL­L_­ROOT/ etc/skel/ cp -r /home/bodhi/.lo­cal $IN­STAL­L_­ROOT/ etc/skel/ %end

The other vari­able is $LIVE_­ROOT . This is the root of the Live CD and any files placed here will be avail­able with­out hav­ing to boot the me­dia. Think of all the HTML files in the Lin­uxFor­mat DVD that you can view with­out boot­ing into the month’s fea­tured dis­tro. For in­stance: %post --noch­root cp -r /home/bodhi/Mu­sic $LIVE_­ROOT/ Mu­sic %end

This will copy over all mu­sic files from the host to the root of the cus­tomised me­dia. You can also use both vari­ables to­gether to move files from in­side the root of the com­pressed filesys­tem to the root of the me­dia: %post --noch­root cp $IN­STAL­L_­ROOT/usr/share/doc/*- re­lease-*/GPL $LIVE_­ROOT/GPL %end

This will ex­tract the GPL li­cense file from your cus­tomised dis­tro’s filesys­tem and place it in the root of the cus­tomised me­dia.

Af­ter you’ve as­sem­bled the kick­start files, you can pass them on to livecd-cre­ator to com­pile the ISO image of your cus­tomised dis­tro. First en­sure SELinux on the host is set to the per­mis­sive mode with the seten­force 0 com­mand, be­fore you call the livecd-cre­ator script: $ livecd-cre­ator --con­fig=cus­tom-fe­dora.ks --fs­la­bel=LXF-Remix-28 --cache=/var/cache/ live --ver­bose

Here, the --con­fig op­tion iden­ti­fies our cus­tom kick­start file and the --fs­la­bel de­fines the name of the vol­ume as well as the ISO image. The --cache op­tion de­fines the direc­tory where the script will down­load the pack­ages from the repos­i­to­ries and as­sem­ble them into a Live en­vi­ron­ment. Re­mem­ber to use this cache direc­tory for sub­se­quent builds to avoid hav­ing to down­load the same pack­ages again. The script will only down­load pack­ages if you’ve added any new ones to the kick­start file af­ter run­ning the ini­tial build.

The time it takes to com­pile the dis­tro de­pends, as usual, on the num­ber-crunch­ing prow­ess of your com­puter and the num­ber of pack­ages that need to be fetched from the In­ter­net. When it’s done, it’ll leave an ISO file for your cus­tomised Fe­dora remix in the cur­rent direc­tory. You can then test it on a vir­tual ma­chine be­fore pass­ing it around to friends, fam­ily and in­ter­ested col­leagues.

The Kick­start Con­fig­u­ra­tion tool is a real time-saver, es­pe­cially when you want to gen­er­ate a kick-start file from scratch.

Fe­dora’s LiveCD tools have been ported to other RPM-based dis­tri­bu­tions like Mageia.

Newspapers in English

Newspapers from Australia

© PressReader. All rights reserved.