Converting Packages

D

DevynCJohnson

Guest
Once developers have made their package file whether it be a *.deb, *.rpm, *.pet, etc., it may be desirable to make other package types for their software. Thankfully, there are utilities available such as "alien", “fpm”, and others that can convert package types.


Alien

Alien is relatively easy to use. Type "alien [parameters] pkg" where "pkg" is the pathname of the package to convert.

Accepted parameters that specify the package to create include

--to-deb
- convert to a Debian file (*.deb)
--to-rpm - convert to a RedHat file (*.rpm)
--to-slp - convert to a Stampede file (*.slp)
--to-tgz - convert to a Slackware file (*.tgz)
--to-pkg - convert to a Solaris installation file (*.pkg)

Other parameters -

--description=[text] - make a new package description
--fixperms - fix the permissions of the contained files
--target=[arch] - specify an architecture

More parameters are available, but those are the most important ones.

Keep in mind that the conversions may not be perfect. Source code packages commonly have issues. Run alien as the Root user (or use the sudo command) so the permissions are correctly set. Alien is a Perl program, so be sure that Perl is installed on the system.

rpm.jpg


convert.jpg


For more info:
https://wiki.debian.org/Alien
http://en.wikipedia.org/wiki/Alien_(software)
http://manpages.ubuntu.com/manpages/trusty/man1/alien.1p.html
https://launchpad.net/ubuntu/trusty/amd64/alien/8.90


rpm2cpio

RPM packages can be converted to CPIO files using the rpm2cpio tool. To use rpm2cpio, type something like one of the commands below.

Code:
rpm2cpio pkg.rpm > new-file.cpio
rpm2cpio pkg.rpm
cat pkg.rpm | rpm2cpio > new-file.cpio
rpm2cpio pkg.rpm  | cpio -t

This utility can also be used to extract a file from the RPM package.

rpm2cpio pkg.rpm |cpio -ivd usr/man/man1/file.1.gz

For more info:
https://packages.debian.org/sid/rpm2cpio
http://www.rpm.org/max-rpm/s1-rpm-miscellania-rpm2cpio.html
http://linux.about.com/library/cmd/blcmdl8_rpm2cpio.htm


F* Package Management (fpm)


The F* Package Management (also called Effing Package management and other implied names) converts various package types from one to another. Accepted sources include gem (Ruby), Python modules, pear (PHP), directories, tar (.gz) archives, RPM, Debian files (*.deb), node packages (npm; JavaScript packages). The output may be Debian packages, RPM, Solaris (pkg), tar files, directories, and OS X packages (pkg; osxpkg).

To use fpm, type something in a terminal using this format "fpm -s <source type> -t <target> [options]". Replace "<source type>" with one of the listed flags below and "<target>" with one of the listed flags below. The parameters are listed when typing "fpm --help".

Source Types:
dir
- directories or files
rpm - RPM
gem - Rubygem
python - Python module (needs easy_install or setup.py)
empty - empty package, like a meta-package
tar - tarball
deb - Debian package

Target:
rpm - RPM
deb - Debian package
solaris - Solaris package
puppet - puppet module

Examples:

fpm -s rpm -t deb -n "name" -v 1.0 -p name-1.0-ARCH.deb -C /path/to/search/for/rpms
fpm -s python -t rpm --python-package-name-prefix python34 module # module will be downloaded for Python3.4
fpm -s python -t rpm /path/setup.py # local module
fpm -s gem -t deb ruby-module # download module and create Debian file
fpm -s cpan -t deb Fennec # Perl => Deb

To install fpm on your system, install the Ruby Developer's files and GCC, first.

apt-get install ruby-dev gcc
# or
yum install ruby-devel gcc

Then, run "gem install fpm".

alien-fpm.png


For more info:
https://github.com/jordansissel/fpm
https://github.com/jordansissel/fpm/wiki


Stdeb

This Python module that is found on the PyPI (https://pypi.python.org/pypi/stdeb) can convert Python modules to Debian files. This module provides various tools that help convert various packages.

To convert a Python source package to a Debian source package, run “py2dsc <params> pkg-version.tar.gz”.

To convert a Python source package to a Debian package, run “py2dsc-deb <params> pkg-version.tar.gz”.

To download a Python package and convert it to a Debian and then install the Debian file (all in one command), run “pypi-install <params> pkg”.

Users can also convert from a Python project that has a “setup.py” file to a Debian source file by running “python setup.py --command-packages=stdeb.command sdist_dsc”. This will produce pkg_verion.orig.tar.gz, pkg_verion-debianversion.dsc, and pkg_verion-debianversion.diff.gz. With these, developers can use dh_make and dpkg-buildpackage to generate the Debian file.

NOTE: Users could replace “python” with “python3” if needed.

To convert straight from a Python project that has a “setup.py” file to a Debian source file, run “python setup.py --command-packages=stdeb.command bdist_deb”.

Many parameters are available to allow stdeb's tools to produce better Debian files that require less manual work. For instance, “--with-python3” creates a package for a Python3 module. “-m” can be used to define the maintainer, “--section” for the package section, “--uploaders” defines the uploaders, and many others exist.

Below is an example of usage.
Code:
wget http://pypi.python.org/packages/source/SOME/URL/pkg-version.tar.gz
py2dsc pkg-version.tar.gz
cd deb_dist/pkg-version/
dpkg-buildpackage -rfakeroot -uc -us
cd ..
sudo dpkg -i python-pkg_version-1_all.deb

For more info:
https://pypi.python.org/pypi/stdeb


NOTE: When packaging a Python file as a Debian package, be sure to specify in the control file which Python versions are compatible. Unless the Debian-packaging standards state otherwise in future standards-versions.

X-Python-Version: >= 2.6
X-Python3-Version: >= 3.2
 

Attachments

  • slide.jpg
    slide.jpg
    54.9 KB · Views: 156,965


Top