6

I have created a package based on http://packaging.ubuntu.com/html/packaging-new-software.html sample. In this sample, sources are c++ files. I want to create my new package from executable jar files source. I found maven, ANT and dhBuild tools but I don't want to use this tools. So I need a way to create my package with command line. please give me some hints or samples to know most about that.

Shaho Amini
  • 390
  • 4
  • 11

2 Answers2

8

The goal is to create a package that simply puts a shell script where I want it.

  1. Create a directory to build your packages in. Some use "deb" and others use "packages". Others create a directory structure for making multiple packages under "deb" (or whatever).

mkdir deb

  1. Create the directory structure in deb that represents where you want the script to be placed1

mkdir -p ./deb/usr/local/bin

3.Copy the script into your new directory

cp /path/to/my/script/myscript.sh ./deb/usr/local/bin/

4.Make a subdirectory called "DEBIAN", this will host the package control file.

mkdir -p ./deb/DEBIAN
Create a control file.
touch ./deb/DEBIAN/control

5.Open the control file and enter the text below.

Package: myPackagename (no spaces or underscores allowed) 
Priority: optional
Section: misc
Maintainer: Maintainer Name <user@mail.com> 
Architecture: all 
Version: 1.0       
Depends: package1, package2, .........
Description: short description here 
 long description here (don't remove space at the beginning of 
 line(replace this with an empty line)

Change ownership:

sudo chown -R root:root ./deb

6.Create the debian package.

dpkg -b ./deb /my/output/destination/packagename.deb
Shon
  • 3,989
  • 1
  • 22
  • 35
Shaho Amini
  • 390
  • 4
  • 11
0

i fail to understand how "not using debhelper" and "creating a package from the cmdline" are contradictory.

however, since you explicitely asked about creating packages "without using any tools and scripts", here you go:

  • dissect an existing package

    • a .deb file is really just a renamed archive, so you can do $ ar xf /path/to/package.deb
  • study the contents of the package $ ls debian-binary control.tar.gz data.tar.gz the debian-binary file contains the format-version of the package (usually 2.0)

    the data.tar.gz file contains the actual data files.

    the control.tar.gz contains control information about the package, including it's name (and description), it's dependencies; but also pre-installation and post-installation scripts and the like.

  • once you've learned the inner workings of a .deb-file, you can create one by inversing the above process:

    • tar your data into a data.tar.gz

    • create the control information for your deb and tar it into a control.tar.gz

    • create a debian-binary file containing the binary-version your are using: $ echo "2.0" > debian-binary

    • create a deb out of these files by running: $ ar q /tmp/mypackage.deb debian-binary control.tar.gz data.tar.gz

however, you should do the above only if you really know what you are doing. creating packages is not a trivial task. that's why people have created a number of tools to help with the repetitive tasks.

use them!

umläute
  • 28,885
  • 9
  • 68
  • 122
  • The tar concept is not about jar file. – Shaho Amini Sep 05 '14 at 19:30
  • the `deb` concept is about `tar` (and `ar`). whether the archives (and tar-files) that form the `deb` contain `jar`, `zip`, binary magic or otherwise is unrelated to your question. – umläute Sep 08 '14 at 09:27