Development/Howto/Use mkcd

From Mandriva Community Wiki

Jump to: navigation, search
How to Use mkcd

Goal of this document is to learn how to use MKCD. It's just an example of how I use it to create an IGGI ISO. I use MKCD-4.1.7 and keep in mind that the MKCD configuration can change between releases (before the 4.1.X release).

External links to MKCD found at qa.mandriva.com :

Contents


IMPORTANT NOTE: This document is written in docbook, because I am not a fan of WIKI and I wrote various documentation in docbook format. So if you want to contribute or convert it to a wiki, you are welcome, but I will not write it in WIKI format, and don't bother me about this.

[edit] Needed directories

In your home directory you can create various directories, to store ISO, configuration files, logs etc... this is not a requirement, because the path to store data only depends on the mkcd configuration file. We only create those directories to "organise" the MKCD configuration. Note: build and iso directories are created by MKCD if they don't exist.

  • input : configuration files
  • log : all logs
  • pieces : RPM repository, extra files, path to installer (gi)
  • build : path to store CDROM, ISO will be built from there
  • iso : generated ISO

[edit] input directory

In this directory we create a sub-directory with the name of our project. Why ? Because if I want to store various configurations for other projects, I just have to put them in their own folder. Lets create the iggi directory, and in this directory an x86 directory, an iggi.conf file (the main MKCD's configuration file) and the public key of the RPMS. In the iggi/x86/ directory we store the files that are lists of needed RPMs and SRPMS.

[edit] iggi.conf : MKCD main configuration file

The main configuration file of MKCD is a bit strange at first sight, but in fact it's very easy to modify it.

iggi

VERSION=iggi

list 1 -k input/iggi/pubkey_main input/iggi/x86/main
rpmlist -b pieces/iggi/x86/main pieces/iggi/x86/main_updates pieces/iggi/x86/main_backport

list 10 -k input/iggi/pubkey_main input/iggi/x86/rpmcluster
rpmlist -b pieces/iggi/x86/rpmcluster

list 20 -k input/iggi/pubkey_main input/iggi/x86/contrib
rpmlist -b pieces/iggi/x86/contrib

list 30 -k input/iggi/pubkey_main input/iggi/x86/cdcom
rpmlist -b pieces/iggi/x86/cdcom

list 40 -k input/iggi/pubkey_main input/iggi/x86/modules
rpmlist -b pieces/iggi/x86/modules

list 50 -k input/iggi/pubkey_main input/iggi/x86/firmwares
rpmlist -b pieces/iggi/x86/firmwares

list 60 -k input/iggi/pubkey_main input/iggi/x86/dkms
rpmlist -b pieces/iggi/x86/dkms pieces/iggi/x86/main

list 70 -k input/iggi/pubkey_main input/iggi/x86/wm
rpmlist -b pieces/iggi/x86/main

##############################
## 2 CD version
##############################

disc 1 700m iggi_cd1 "(X86_32)" "Iggi CD1" -v "4" -p Mandriva
dir main media/main
dir rpmcluster media/rpmcluster
dir contrib media/contrib
generic --synthesis main 1
generic --synthesis rpmcluster 10
generic --synthesis contrib 20

installation --version iggi --branch cooker --arch i586 --nosrcfit \
--synthesis -l fr,en -t iggi -i pieces/install/iggi/x86/ \
-d 1/main 1/rpmcluster 1/contrib 2/main 2/cdcom 2/modules 2/firmwares 2/dkms 2/wm \
-r pieces/install/iggi/x86/media/media_info/rpmsrate

boot --udf --isolinux -b isolinux/isolinux.bin \
-f --first pieces/install/iggi/x86/isolinux \
-f --dest install/images pieces/install/iggi/x86/install/images

disc 2 700m iggi_cd2 "(X86_32)" "Iggi CD2" -v "4" -p Mandriva
dir cdcom media/cdcom
dir modules media/modules
dir firmwares media/firmwares
dir dkms media/dkms
dir main media/main2
dir wm media/wm
generic --synthesis main 1
generic --synthesis cdcom 30
generic --synthesis modules 40
generic --synthesis firmwares 50
generic --synthesis dkms 60
generic --synthesis wm 70

######################
## mini-cd
######################

disc 3 700m iggi_mini-cd1 "(X86_32)" "Iggi mini-CD1" -v "4" -p Mandriva
dir main media/main
dir rpmcluster media/rpmcluster
dir contrib media/contrib
generic --synthesis main 1
generic --synthesis rpmcluster 10
generic --synthesis contrib 20

installation --version iggi --branch cooker --arch i586 --nosrcfit \
--synthesis -l fr,en -t iggi -i pieces/install/iggi/x86/ -d 3/main 3/rpmcluster 3/contrib \
-r pieces/install/iggi/x86/media/media_info/rpmsrate

boot --udf --isolinux -b isolinux/isolinux.bin -f --first pieces/install/iggi/x86/isolinux \
-f --dest install/images pieces/install/iggi/x86/install/images

cp pieces/iggi/extra/patch-oem.pl /install/stage2/patch-oem.pl


##########################
## DVD version
#########################

disc 4 4.37g iggi_dvd "(X86_32)" "Iggi DVD" -v "4" -p Mandriva
dir main media/main
dir rpmcluster media/rpmcluster
dir contrib media/contrib
dir cdcom media/cdcom
dir modules media/modules
dir firmwares media/firmwares
dir dkms media/dkms
#dir main media/main2
dir wm media/wm
generic --synthesis main 1
generic --synthesis rpmcluster 10
generic --synthesis contrib 20
generic --synthesis cdcom 30
generic --synthesis modules 40
generic --synthesis firmwares 50
generic --synthesis dkms 60
generic --synthesis wm 70

installation --version iggi --branch cooker --arch i586 --nosrcfit --synthesis -l fr,en -t iggi -i pieces/install/iggi/x86/ -d 4/main 4/main2 \
4/rpmcluster 4/contrib 4/cdcom 4/modules 4/firmwares 4/dkms 4/wm -r pieces/install/iggi/x86/media/media_info/rpmsrate
boot --udf --isolinux -b isolinux/isolinux.bin -f --first pieces/install/iggi/x86/isolinux -f --dest install/images pieces/install/iggi/x86/install/images
cp pieces/iggi/extra/patch-oem.pl /install/stage2/patch-oem.pl

where:

  • iggi : name of the CDROM
  • list 1 -k path_to_key/key rpm_list rpm_list2 : define list number X, and use this key for rpm --checksig, and last arguments are the list of the rpms
  • rpmlist -b path_to_RPM : path to RPMS, you can put here more than one directory
  • rpmlist -s path_to_SRPM : path to SRPMS
  • disc X size cdrom_name "arch" "label" -v volume_name -p publisher : define disc number X, with a size (ie: 700m, 4.4g)
  • dir main media/main : create an alias name "main" to the directory media/main
  • generic --synthesis rpms X : create a synthesis hdlist number X for RPMS in media/main
  • installation --version iggi --branch cooker --arch i586 --nosrcfit --synthesis -l fr,en -t iggi -i pieces/install/iggi/x86/ -d 1/main 1/rpmcluster -r pieces/install/iggi/x86/media/media_info/rpmsrate
    • installation : this disc is an install CDROM
    • --version iggi : branch could be cooker/2006/stable
    • --arch i586 : specify the architecture
    • --nosrcfit : do not stop if source discs are full
    • --synthesis : synthesis will be present
    • -l fr,en  : language on CD will be FR and EN
    • -t iggi : tag added to the VERSION file
    • -d 1/main 1/rpmcluster : Selected rpms dir to take into account. 1 is a reference to Disc1, and main a reference to the name of the directory on Disc1
    • -d 1/main 1/rpmcluster 1/contrib 2/main 2/cdcom 2/modules 2/firmwares 2/dkms 2/wm : specify to put main rpmcluster contrib on first disc, and cdcom modules firmwares dkms and wm on second disc. Note: hdlists and synthesis will be store on the first disc
    • -r rpmsrate : specify a custom rpmsrate
    • boot --isolinux -b isolinux/isolinux.bin -f --first pieces/install/iggi/x86/isolinux -f --dest install/images pieces/install/iggi/x86/install/images
    • cp pieces/iggi/extra/patch-oem.pl /install/stage2/patch-oem.pl : if you want to put files on disc, just copy them. You need to specify the full name, because it is not the cp of the system

[edit] x86/main : list of RPM

List files allow to select which packages will be included in the discs. The syntax is "[package] ,". Options are not mandatory. Available options:

  • regexp : the package is a regular expression
  • rate X : increase the packages rpmsrate value to X.
  • section : the given package is a section name of the rpmsrate
  • nodeps : do not handle these packages' dependencies
  • noalternatives : do not use these packages to resolve dependencies in alternatives
  • force : put given packages before anything else on the discs
  • needed X : put given packages not after the Xth rpms directory
  • limit : only put given packages if there is space left at the end of the build
  • nosrc : do not put in sources of the given packages

Several options can be used, separated with a "," but without spaces. Last release of MKCd tells if an error occurs while reading the list. If you want to exclude an RPM, put it at the top of the configuration file, i.e.: if you want to exclude a specific kernel, because you use an update kernel, the SYSTEM section 1,force will force the use of the first kernel in the list (kernel-2.6.12-12mdk in 2006.0), so if you want to use the kernel-2.6.12-17mdk, just put the exclude before the SYSTEM section 1,force. This tip is available for all packages: always put exclude rules at the top of configuration's file list.

[edit] a typical x86/main file

kernel-2.6.12.12mdk.* regexp,exclude
kernel-2.6.12.15mdk.* regexp,exclude
kernel-2.6.12.17mdk.* regexp,needed 1
kernel-source-2.6-2.6.12-17mdk.* regexp,noalternatives,needed 1
kernel-smp-2.6.12.12mdk.* regexp,exclude
kernel-smp-2.6.12.15mdk.* regexp,exclude
kernel-smp-2.6.12.17mdk.* regexp,needed 1
kernel-i586-up-1GB.* regexp,exclude

# exclude
libpq4-8.0.7.* regexp,exclude
postgresql-8.0.4.* regexp,exclude
postgresql-contrib-8.0.4.* regexp,exclude

# needed basesystem
INSTALL section 1,force
SYSTEM section 1,force
GAMES section 1,exclude
AUDIO section 1,exclude
acpi needed 1
acpid needed 1
alsa-utils needed 1
aspell-fr needed 1
autoconf needed 2
autologin needed 2
automake1.4 needed 2
basesystem needed 1
bash needed 1
bc needed 1
bdflush needed 1
bind needed 1
bind-utils needed 1
......

[edit] tree view of input directory

input/
|-- 2006
|   `-- x86
|-- clustering
|   `-- x86
|       `-- temp
|-- iggi
|   `-- x86
`-- mercury
    `-- x86
        `-- temp
        

[edit] Log directory

MKCD can create a verbose log. We store them into the log directory. It is very useful to create a verbose log because it explains how the disc was created, and why it rejects some RPMS/SRPMS. -verbose X where X can be 1 (less) to 10 (more).

Another log option is --printdiscsfiles name. It creates a file which contains all RPMS available on each disc.

[edit] Pieces directory

This directory contains various subdirectories. One for each project (here iggi), and one called install which links to the installer directory (a built gi, i.e.: /export). In the iggi directory, two subdirectories: extra wich contains all extra things (freedos.img, patch-oem.pl), and x86 directory where you can find the link/path to the RPMS/SRPMS repository. Ok it's a bit confusing to explain, so the tree will help us:

|-- 2006
|   |-- extra
|   `-- x86
|       |-- CONTRIBL
|       |-- RPMSL
|       |-- SPECIAL
|       `-- rpmcluster -> /home/nis/guibo/Build/pieces/iggi/x86/RPMCLUSTER
|-- clustering
|   |-- SRPMS-CLUSTER -> /home/nis/guibo//SRPMS-CLUSTER
|   |-- extra
|   `-- x86
|       |-- RPMCLUSTER
|       `-- kernel
|-- iggi
|   |-- extra
|   `-- x86
|       |-- RPMCLUSTER
|       |-- RPMS
|       |-- contrib -> /mnt/ken/dis/2006.0/i586/media/contrib
|       |-- main -> /mnt/ken/dis/2006.0/i586/media/main
|       |-- main_updates -> /mnt/ken/dis/updates/2006.0/main_updates
|       `-- x86
|           `-- RPMS
|-- install
|   |-- 2006
|   |   `-- x86 -> /home/nis/guibo/export_2006
|   |-- clustering
|   |   `-- x86 -> /home/nis/guibo/export_clustering
|   |-- iggi
|   |   `-- x86 -> /home/nis/guibo/export_iggi
|   `-- mercury
|       `-- x86 -> /home/nis/guibo/export_mercury
`-- mercury
    |-- extra
    `-- x86
    

You can see that I have various directories for each project: IGGI, 2006, clustering, mercury, and one called install.

[edit] build directory

It contains all needed to build ISO.

build/
|---iggi
    |-- 1
    |   |-- install
    |   |   |-- images
    |   |   `-- stage2
    |   |-- media
    |   |   |-- contrib
    |   |   |   `-- media_info
    |   |   |-- main
    |   |   |   `-- media_info
    |   |   |-- media_info
    |   |   `-- rpmcluster
    |   |       `-- media_info
    |   `-- misc
    |       |-- Distribconf
    |       |-- URPM
    |       `-- auto
    |           `-- URPM
    `-- first
        `-- 1
*            `-- isolinux
                |-- alt0
                `-- test

[edit] Iso directory

It contains all ISO.

iso/
|-- 2006_guibo
|-- clusteringIII-x86_32
`-- iggi

[edit] MKCD help

A MKCD help exists for each function. Use them if you want more explanations about any of MKCD's functions. For example:

mkcd -h installtion
mkcd -h generic
mkcd -h boot
mkcd -h disc
mkcd -h list
mkcd -h dir
mkcd -h rpmlist

[edit] Build script

A simple script to build ISO. MKCD options used are:

  • --printdiscsfiles name_fil : print the contains of each disc into name_fil
  • --noiso : do not create iso images of the discs
  • --verbose X : print more messages (the higher the more, 5 is the highest)
  • -s input/$NAME/$NAME.conf : configuration file
  • -m 1,2 : build the disc 1 and 2 (defined in the MKCD configuration file
  • -l : use it if you want to rebuild a Disc, leave untouched others (Advanced option)
#!/bin/bash

NAME=iggi
DATE=`date "+20%y%m%d-%H%M"`

clean_old_data() {
    echo "- Cleaning old builds"
# comment this if you dont want to erase old mkcd_build_list
#rm -rf ~/Build/tmp/.mkcd_build_hdlist
#rm -rf tmp/*

    rm -rf build/$NAME
    rm -rf log/*
    rm -rf iso/$NAME/1*
}

build_cdrom() {
    echo "- Building CD"
    mkcd --printdiscsfiles log/printdiscfiles1-$NAME --noiso --verbose 5 -f -s input/$NAME/$NAME.conf -m 1 >log/$NAME-1.log 2>&1
}

list_cdrom() {
    echo "- list RPM on CD"
    mkcd --testlist input/$NAME/$NAME.conf 1 input/$NAME/x86/rpmsrate --printdiscsfiles log/printdiscfiles-$NAME
}


build_cdrom_iso() {
    echo "- Building CD + ISO"
    mkcd --printdiscsfiles log/printdiscfiles1-$NAME --cpu 2 --verbose 9 -f -s input/$NAME/$NAME.conf -m 1 >log/$NAME-1.log 2>&1
    mv iso/$NAME/1-$NAME.iso iso/$NAME/1-$NAME-$DATE.iso
    create_md5sum
}


create_md5sum() {
    echo "- Creating md5sum"
    md5sum iso/$NAME/*.iso > iso/$NAME/$NAME-$DATE.md5sum
}

# MAIN
clean_old_data
#list_cdrom
#build_cdrom
build_cdrom_iso
Personal tools