-
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?
-
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
-
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
-
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
-
Benefit 5: Dependencies are verified during uninstallation
$ sudo dpkg -r def dpkg: dependency problems prevent removal of def: abc depends on def.
-
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.
-
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
-
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.
-
Installing packages with deps can be tedious
-
Those deps can have further deps, and so on
-
This is solved by
-
Repository of packages: APT repository
-
Tool to Automatically downloading and install packages and its dependencies:
apt-get
-
Releases
-
Contains information about the repository
Packages
-
Contains list of packages and their meta information
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
-
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"
-
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
-
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
-
dpkg
andapt-get
install packages into system root -
multistrap
installs packages into a directory -
Can be used for creating root filesystem from pre-built packages
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