Skip to content

Latest commit

 

History

History
258 lines (198 loc) · 5.03 KB

slides.asciidoc

File metadata and controls

258 lines (198 loc) · 5.03 KB

Debian Packaging

Packages

Distributing Software

  • Binary software can be distributed as Tar / Zip Archive

  • Firefox for example is distributed as Tar archive

  • Tar archives are simple, can be extracted into some path in the system

  • Software can also be distributed as a package, .deb or .rpm

  • Advantages of packages over Tar archives?

Install and Remove

  • Benefit 1: Package manager tracks packages installed in the system

    $ sudo dpkg -i hello_1.0.0_all.deb
    $ hello
    $ dpkg --list
    $ dpkg --list | grep hello
  • Benefit 2: Packages can be easily uninstalled

    $ sudo dpkg -r hello

Upgrade

  • Benefit 3: Easy to upgrade the package to a new version

    $ sudo dpkg -i hello_1.1.0_all.deb
    $ dpkg --list | grep hello
    $ hello

Dependencies

  • Benefit 4: Packages can have dependencies and are verified during installation

    $ sudo dpkg -i abc_1.0.0_all.deb
    dpkg: dependency problems prevent configuration of abc:
     abc depends on def; however:
      Package def is not installed.
    
    $ sudo dpkg -i def_1.0.0_all.deb
    $ sudo dpkg -i abc_1.0.0_all.deb

Dependencies (Contd.)

  • Benefit 5: Dependencies are verified during uninstallation

    $ sudo dpkg -r def
    dpkg: dependency problems prevent removal of def:
     abc depends on def.

Disecting a Package

  • Debian packages use the "archive" format

  • Extracting contents of "archive".

    $ mkdir ~/yp/packaging/hello
    $ cd ~/yp/packaging/hello
    $ ar x ../hello_1.0.0_all.deb
  • debian-binary: version of .deb file format

  • control.tar.gz: contains meta information like name, version, dependencies, description, etc.

  • data.tar.gz: contains the files to be installed.

Creating Packages

  • Create the folder structure.

    $ mkdir -p ~/yp/fpm/xyz
    $ mkdir -p ~/yp/fpm/xyz/bin
    $ touch ~/yp/fpm/xyz/bin/x
    $ touch ~/yp/fpm/xyz/bin/y
    $ touch ~/yp/fpm/xyz/bin/z

Creating Packages (Contd.)

  • Create the package using FPM

    $ cd ~/yp/fpm
    $ fpm -s dir -t deb -C ~/yp/fpm/xyz
  • Specifying additional meta information

    $ fpm -s dir -t deb -n "xyz" -v 1.0.0 -a all \
          -C ~/yp/fpm/xyz                        \
          --description "My first package."
  • FPM is a simple tool to create .deb and .rpm packages.

  • Install and verify the files.

Package Repositories

Understanding Repos

  • Installing packages with deps can be tedious

  • Those deps can have further deps, and so on

  • This is solved by

    1. Repository of packages: APT repository

    2. Tool to Automatically downloading and install packages and its dependencies: apt-get

Repo Structure

repo structure
Releases

Contains information about the repository

Packages

Contains list of packages and their meta information

Repo Commands

Command are available for the following operations

  • Adding a repostiory

  • Updating the local APT cache

  • Installing a package and its dependencies from the repo

  • Searching the local APT cache, for packages

Adding a Repo

  • Repository can be added using add-apt-repository command

  • Repository information should be specified as

    deb <repo-url> <distro> <component>...
  • Add the local repository of packages

    $ cd ~/yp/repos/myrepo
    $ sudo add-apt-repository  "deb file://$PWD wheezy main"

Using the Repo

  • Fetch packages list and meta information

  • Used later on for locating package dependencies

  • Also used for searching packages matching a keyword

    $ sudo apt-get update
    $ apt-cache search mypkg
  • Install packages and their dependencies from the repo

    $ sudo apt-get install mypkg1

Creating Repositories

  • Custom repositories can be created from a set of packages

  • mypkgs contains the packages

    $ cd ~/yp/repos/
    $ ls mypkgs
  • Create the repository folder myrepo2

    $ mkdir myrepo2

Creating Repositories (Contd.)

  • Create a repository configuration file conf/distributions

    Codename: wheezy
    Architectures: i386 amd64
    Components: main
  • Create the repository

    $ reprepro --outdir ./myrepo2 includedeb wheezy mypkgs/*.deb

Building a RootFS

Install into RootFS

  • dpkg and apt-get install packages into system root

  • multistrap installs packages into a directory

  • Can be used for creating root filesystem from pre-built packages

Multistrap

multistrap requires a configuration file that specifies

  • the APT repo location

  • the packages to install

Create a file called ~/yp/multistrap/multistrap.conf

[General]
noauth=true
bootstrap=Packages

[Packages]
packages=bash coreutils
source=copy:////home/vagrant/yp/multistrap/myrepo
suite=mydistro
omitdebsrc=true

Multistrap (Contd.)

Invoke multistrap, to install the packages

$ mkdir rootfs
$ /usr/sbin/multistrap -a arm -d rootfs -f multistrap.conf