Difference between revisions of "Create or Update a Debian package"
m (moved Create a Debian package to Create or Update a Debian package) |
m (formatting) |
||
Line 8: | Line 8: | ||
=== Working directory structure === | === Working directory structure === | ||
Here's an example directory structure for a package which replaces the apache default config file and sets up default php and html files in ''/var/www''. | Here's an example directory structure for a package which replaces the apache default config file and sets up default php and html files in ''/var/www''. | ||
− | {{#tree:root=example-package| | + | {{code|{{#tree:root=example-package| |
*DEBIAN | *DEBIAN | ||
**control | **control | ||
Line 23: | Line 23: | ||
***index.html | ***index.html | ||
***index.php5 | ***index.php5 | ||
− | }} | + | }}}} |
The ''control'' file in the DEBIAN sub-directory is where all the main configuration is done. The other three files in that sub-directory are scripts which execute on installation and removal of the package. | The ''control'' file in the DEBIAN sub-directory is where all the main configuration is done. The other three files in that sub-directory are scripts which execute on installation and removal of the package. | ||
Line 34: | Line 34: | ||
To turn the directory structure into a proper ''.deb'' package file, use: | To turn the directory structure into a proper ''.deb'' package file, use: | ||
− | + | {{code|<pre> | |
+ | dpkg -b /var/www/domains/packages/source/<package-name> | ||
+ | </pre>}} | ||
+ | |||
+ | |||
The package will be created with the same name but with the ''.deb'' extension in the same directory as the package directory. It should be moved into the correct subdirectory of such as ''/var/www/domains/packages/main''. | The package will be created with the same name but with the ''.deb'' extension in the same directory as the package directory. It should be moved into the correct subdirectory of such as ''/var/www/domains/packages/main''. | ||
− | + | {{code|<pre> | |
− | + | dpkg -b /var/www/domains/packages/source/organicdesign-workstation | |
− | + | mv /var/www/domains/packages/source/organicdesign-workstation.deb /var/www/domains/packages/main/organicdesign-workstation.deb | |
− | + | </pre>}} | |
=== Adding to a package repository === | === Adding to a package repository === | ||
All the ''.deb'' package files must be added to the ''main'' repository on the server which is in ''/var/www/packages/main''. Ensure that this repository is included in your ''/etc/apt/sources.list'': | All the ''.deb'' package files must be added to the ''main'' repository on the server which is in ''/var/www/packages/main''. Ensure that this repository is included in your ''/etc/apt/sources.list'': | ||
− | + | {{code|<pre> | |
+ | echo "deb http://packages.organicdesign.co.nz main/" >> /etc/apt/sources.list | ||
+ | </pre>}} | ||
+ | |||
Whenever any of the packages in the repository change, the ''Packages.gz'' index file must be updated which can be done as follows. | Whenever any of the packages in the repository change, the ''Packages.gz'' index file must be updated which can be done as follows. | ||
− | + | {{code|<pre> | |
− | + | cd /var/www/domains/packages | |
+ | dpkg-scanpackages main /dev/null | gzip > main/Packages.gz | ||
+ | </pre>}} | ||
== See also == | == See also == |
Revision as of 04:16, 23 May 2009
Create or Update a Debian package Organic Design procedure |
General procedure
Working directory structure
Here's an example directory structure for a package which replaces the apache default config file and sets up default php and html files in /var/www.
The control file in the DEBIAN sub-directory is where all the main configuration is done. The other three files in that sub-directory are scripts which execute on installation and removal of the package.
The rest of the directory structure outside the DEBIAN sub-directory define the directory structure which will be merged with the root of the filesystem when the package is installed.
Our packages at Organic Design are in /var/www/domains/packages and the source directory structures for them are in the sources subdirectory.
Building or updating a package
Next the source needs to be built into a .deb file, if this is being done for an existing package which is being updated, then don't forget to ensure that the version number in the control file is larger.
To turn the directory structure into a proper .deb package file, use:
The package will be created with the same name but with the .deb extension in the same directory as the package directory. It should be moved into the correct subdirectory of such as /var/www/domains/packages/main.
Adding to a package repository
All the .deb package files must be added to the main repository on the server which is in /var/www/packages/main. Ensure that this repository is included in your /etc/apt/sources.list:
Whenever any of the packages in the repository change, the Packages.gz index file must be updated which can be done as follows.
See also
- Packages - we plan to manage our IT infrastructure using APT
- LinuxDevices instructions
- TLDP HOWTO
- Google:creating Debian packages
- Format of sources.list file