πŸ“œ ⬆️ ⬇️

Adding packages to the standalone installer Lubuntu Alternate ISO

Introduction


When creating offline installation media for an automated installation of Lubuntu OS 14.04 using preseed , I was faced with the fact that I need to add packages to the installation media that are missing from the original alternate distribution . I tried many different ways to create my own autonomous distributions, but they turned out to be:


As a result, I stopped at the method described in the Ubuntu community .

I want to talk about what I did.

Training


To supplement the distribution, we need the original alternate distribution , to which we will add packages. As well as a computer running Ubuntu or Lubuntu, on which we will do it.
')

Creating a directory structure and copying files


Create a directory in which we will work with this distribution:

mkdir -p /opt/cd-image 

Download the distribution:

 wget http://cdimages.ubuntu.com/lubuntu/releases/trusty/release/lubuntu-14.04.1-alternate-i386.iso 

Unzip the downloaded iso-image:

 mkdir /mnt/iso mount -o loop lubuntu-14.04.1-alternate-i386.iso /mnt/iso cp -rT /mnt/iso /opt/cd-image umount /mnt/iso 

Create a directory for the packages we want to add to the distribution:

 mkdir -p /opt/cd-image/pool/extras 

The entire directory structure
 tree -d -L 3 /opt /opt β”œβ”€β”€ apt-ftparchive β”œβ”€β”€ build β”‚ └── ubuntu-keyring-2012.05.19 β”‚ β”œβ”€β”€ debian β”‚ └── keyrings β”œβ”€β”€ cd-image β”‚ β”œβ”€β”€ boot β”‚ β”‚ └── grub β”‚ β”œβ”€β”€ dists β”‚ β”‚ └── trusty β”‚ β”œβ”€β”€ doc β”‚ β”‚ └── install β”‚ β”œβ”€β”€ install β”‚ β”‚ └── netboot β”‚ β”œβ”€β”€ isolinux β”‚ β”œβ”€β”€ pics β”‚ β”œβ”€β”€ pool β”‚ β”‚ β”œβ”€β”€ extras β”‚ β”‚ β”œβ”€β”€ main β”‚ β”‚ └── universe β”‚ └── preseed └── indices 

Preparation of encryption keys


If you do not have a public-private key pair, you will need to create it with gpg . The key is desirable to set a comment like "XXX Signing Key".

gpg --gen-key
 gpg --gen-key gpg (GnuPG) 1.4.16; Copyright (C) 2013 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Please select what kind of key you want: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (sign only) (4) RSA (sign only) Your selection? 1 RSA keys may be between 1024 and 4096 bits long. What keysize do you want? (2048) Requested keysize is 2048 bits Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) Key does not expire at all Is this correct? (y/N) y You need a user ID to identify your key; the software constructs the user ID from the Real Name, Comment and Email Address in this form: "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>" Real name: Alexandr Petrenko Email address: *********@gmail.com Comment: My Signing Key You selected this USER-ID: "Alexandr Petrenko (My Signing Key) <*********@gmail.com>" Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o You need a Passphrase to protect your secret key. 


We will use the private key to sign the release files of the repository. For the following steps, you will need the fakeroot package, install it if it is not on your system.

Now you need to add your key to the ubuntu-keyring package
 mkdir /opt/build cd /opt/build #       apt-get source ubuntu-keyring #     cd ubuntu-keyring-2012.05.19/keyrings/ gpg --import < ubuntu-archive-keyring.gpg #   ,  "Signing Key"  ,  gpg --list-keys "Signing Key" pub 1024D/437D05B5 2004-09-12 uid Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com> sub 2048g/79164387 2004-09-12 pub 1024D/FBB75451 2004-12-30 uid Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com> pub 2048R/YOURKEYID 2015-01-28 uid My Signing Key <*********@gmail.com> sub 2048R/KEYID 2015-01-28 #      gpg --export FBB75451 437D05B5 YOURKEYID > ubuntu-archive-keyring.gpg #       ubuntu-keyring-2012.05.19       cd .. dpkg-buildpackage -rfakeroot -m"  <your.email@your.host>" -kYOURKEYID #         cd .. cp ubuntu-keyring*deb /opt/cd-image/pool/main/u/ubuntu-keyring 


Copying files to the repository


You can simply add several packages manually to the / opt / cd-image / pool / extras directory.

If you need to update the installer kernel modules, you can do this by:

 cd /opt/cd-image/pool/main/l/linux/ wget -r -nd --no-parent --accept '*-modules-3.13.0-24*i386.udeb' ftp://security.ubuntu.com/ubuntu/pool/main/l/linux/ 

where instead of 3.13.0-24 * i386, you can specify the desired version of the kernel that you use to boot, and the architecture of the modules.

To download all the packages installed in the current OS on the reference computer, you can do this

script
 #!/bin/bash dpkg --get-selections | while read line do package=`expr "$line" : '\(.*\)install'` echo $package apt-get download $package done for i in *; do mv $i ${i/'1%3a'/''}; done 


And add the downloaded packages from the apt cache to the repository.

Creating a standalone local repository using apt-ftparchive


The apt-ftparchive utility is contained in the apt-utils package.
All settings are given for Lubuntu 14.04 Trusty and i386 architecture. If the version or architecture of your distribution is different, then you need to correct the corresponding values ​​in the configuration files and scripts.

Repository description for apt-ftparchive


In the / opt / apt-ftparchive directory you need to create the following configuration files:

Settings for main and universe pockets:

apt-ftparchive-deb.conf
 Dir { ArchiveDir "/opt/cd-image/"; }; TreeDefault { Directory "pool/"; }; BinDirectory "pool/main" { Packages "dists/trusty/main/binary-i386/Packages"; BinOverride "/opt/indices/override.trusty.main"; ExtraOverride "/opt/indices/override.trusty.extra.main"; }; BinDirectory "pool/universe" { Packages "dists/trusty/universe/binary-i386/Packages"; BinOverride "/opt/indices/override.trusty.universe"; }; Default { Packages { Extensions ".deb"; Compress ". gzip"; }; }; Contents { Compress "gzip"; }; 


Settings for debian-installer installer modules in main and universe pockets:
apt-ftparchive-udeb.conf
 Dir { ArchiveDir "/opt/cd-image/"; }; TreeDefault { Directory "pool/"; }; BinDirectory "pool/main" { Packages "dists/trusty/main/debian-installer/binary-i386/Packages"; BinOverride "/opt/indices/override.trusty.main.debian-installer"; }; BinDirectory "pool/universe" { Packages "dists/trusty/universe/debian-installer/binary-i386/Packages"; BinOverride "/opt/indices/override.trusty.universe.debian-installer"; }; Default { Packages { Extensions ".udeb"; Compress ". gzip"; }; }; Contents { Compress "gzip"; }; 


Settings for our pocket extras:
apt-ftparchive-extras.conf
 Dir { ArchiveDir "/opt/cd-image/"; }; TreeDefault { Directory "pool/"; }; BinDirectory "pool/extras" { Packages "dists/trusty/extras/binary-i386/Packages"; }; Default { Packages { Extensions ".deb"; Compress ". gzip"; }; }; Contents { Compress "gzip"; }; 


Settings for creating a release repository file:

release.conf
 APT::FTPArchive::Release::Origin "Ubuntu"; APT::FTPArchive::Release::Label "Ubuntu"; APT::FTPArchive::Release::Suite "trusty"; APT::FTPArchive::Release::Version "14.04"; APT::FTPArchive::Release::Codename "trusty"; APT::FTPArchive::Release::Architectures "i386"; APT::FTPArchive::Release::Components "main restricted extras"; APT::FTPArchive::Release::Description "Ubuntu 14.04 LTS"; 


Index loading


get-indices.bash
 #!/bin/bash cd /opt/indices/ DIST=trusty for SUFFIX in extra.main main main.debian-installer universe universe.debian-installer; do wget http://archive.ubuntu.com/ubuntu/indices/override.$DIST.$SUFFIX done 


Creating Packages and Release repository files


The script that starts the creation of Packages and Release files of the repository with the apt-ftparchive utility, taking into account our settings, and then signs the Release file and writes the checksums of the files in md5sum.txt:

make-iso-repo.bash
 BUILD=/opt/cd-image APTCONF=/opt/apt-ftparchive/release.conf DISTNAME=trusty pushd $BUILD apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-deb.conf apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-udeb.conf apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-extras.conf apt-ftparchive -c $APTCONF release $BUILD/dists/$DISTNAME > $BUILD/dists/$DISTNAME/Release gpg --default-key "YOURKEYID" --output $BUILD/dists/$DISTNAME/Release.gpg -ba $BUILD/dists/$DISTNAME/Release find . -type f -print0 | xargs -0 md5sum > md5sum.txt 


Creating and using an ISO image


Creating an ISO image


make-iso-image.bash
 IMAGE=custom.iso BUILD=/opt/cd-image/ mkisofs -r -V "Custom Ubuntu Install CD" \ -cache-inodes \ --iso-level 3 -J -l -b isolinux/isolinux.bin \ -c isolinux/boot.cat -no-emul-boot \ -boot-load-size 4 -boot-info-table \ -o $IMAGE $BUILD 


Boot from ISO


Now you can boot using the created ISO image, burn the image to a CD / DVD-ROM, or from removable media.

Creating a bootable USB drive


For the boot, you need to format the disk in FAT32. Install a bootloader on disk, for example grub2:

 sudo grub-install --no-floppy --root-directory=/media/multiboot /dev/sdb 


where / media / multiboot is the path to the mounted partition on the bootable USB disk; / dev / sdb - boot disk device.

After that, configure the bootloader. Approximate grub2 config:

/media/multiboot/boot/grub/grub.cfg
 #   set timeout=10 #     set default=0 #   insmod ext2 insmod loopback insmod iso9660 insmod fat insmod part_msdos menuentry "Boot from first hard disk" { set root=(hd1) chainloader +1 } set iso="/custom.iso" menuentry "Custom.iso" { linux /vmlinuz debconf/priority=high shared/ask_device=manual shared/enter_device=/dev/disk/by-label/DISKLABEL iso-scan/filename=$iso auto-install/enable=true debian-installer/language=ru debian-installer/locale=ru_RU.UTF-8 debian-installer/country=RU preseed/file=/cdrom/preseed/custom.seed DEBCONF_DEBUG=5 -- initrd /initrd.gz } 


You also need to add vmlinuz and initrd to the root of the USB disk.

In the udeb.list file you can find out the versions of modules that are required by the kernel and which need to be placed in the distribution (see above).

It remains to boot from the created disk, and run the OS installation.

Source: https://habr.com/ru/post/273255/


All Articles