It packages one single command, that just echos some line.
Go to home directory (or any location you have all permissions to)
Code: Select all
cd ~
The file structure inside 'testpackage' will be re-created in the real file hierarchy, all files included, once the package gets installed.
Code: Select all
mkdir -p testpackage/usr/bin
Code: Select all
echo '#!/bin/sh
echo "Running Some Command..."' > testpackage/usr/bin/somecommand
Inspect it:
Code: Select all
cat testpackage/usr/bin/somecommand
Run it with bash:#!/bin/sh
echo "Running Some Command..."
Code: Select all
bash testpackage/usr/bin/somecommand
Run it 'as is'Running Some Command...
Code: Select all
testpackage/usr/bin/somecommand
We have already hinted to use #!/bin/sh in the first line (the shebang). But to invoke it directly we also, as superuser, have to set the 'allow execution' flag of the file with chmod: for owner (Read+Write+eXecute=7), group-members (Read+eXecute=5), and the rest (Read+eXecute=5) (See http://en.wikipedia.org/wiki/Chmod#Command_syntax ) like this:bash: testpackage/usr/bin/somecommand: Permission denied
Code: Select all
sudo chmod 755 testpackage/usr/bin/somecommand
Code: Select all
testpackage/usr/bin/somecommand
Try to build it:Running Some Command...
Code: Select all
dpkg-deb --build testpackage
To create control file, first create DEBIAN folder:dpkg-deb: error: failed to open package info file `testpackage/DEBIAN/control' for reading: No such file or directory
Code: Select all
mkdir -p testpackage/DEBIAN
Code: Select all
echo 'Package: testpackage
Version: 1.1-1
Section: education
Priority: optional
Architecture: all
Maintainer: Your Name <your@email.com>
Description: Almost empty test package.
This package is only used
to show how packages work.' > testpackage/DEBIAN/control
Code: Select all
dpkg-deb --build testpackage
So, all is fine? Not so! Lets install lintian:dpkg-deb: building package `testpackage' in `testpackage.deb'.
Code: Select all
sudo apt-get install -y lintian
Code: Select all
lintian testpackage.deb
To handle the E: testpackage: debian-changelog-file-missing, create folder /usr/share/doc/PACKAGENAME inside package:E: testpackage: debian-changelog-file-missing
E: testpackage: no-copyright-file
E: testpackage: wrong-file-owner-uid-or-gid usr/ 1000/1000
E: testpackage: wrong-file-owner-uid-or-gid usr/bin/ 1000/1000
E: testpackage: wrong-file-owner-uid-or-gid usr/bin/somecommand 1000/1000
W: testpackage: binary-without-manpage usr/bin/somecommand
Code: Select all
mkdir -p testpackage/usr/share/doc/testpackage
Code: Select all
echo 'testpackage (1.1-1) unstable; urgency=low
* Initial Release. Closes: #14223
-- Your Name <your@email.com> Fri, 11 Apr 2014 08:38:32 +0100' > testpackage/usr/share/doc/testpackage/changelog.Debian
Code: Select all
gzip -9 testpackage/usr/share/doc/testpackage/changelog.Debian
(no compressing is allowed on this file, it should be readily readable):
Code: Select all
echo 'This package was first put together by Your Name <your@email.com> in 2014.
testpackage is Copyright (C) 2014 Your Name <your@email.com>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the
Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
On Debian GNU/Linux systems, the complete text of the GNU General
Public License can be found in "/usr/share/common-licenses/GPL-2".' > testpackage/usr/share/doc/testpackage/copyright
Code: Select all
mkdir -p testpackage/usr/share/man/man1
Code: Select all
echo '.\" Manpage for somecommand.
.\" Contact your@email.com to correct errors or typos.
.TH SOMECOMMAND 1 "11 Apr 2014" "1.1-1" "somecommand man page"
.SH NAME
somecommand \- just some command.
.SH SYNOPSIS
.B somecommand
.SH DESCRIPTION
Somecommand is an stub command to show how a packages works. It simply echoes "Running Some Command..."
.SH OPTIONS
Somecommand does not take any options.
.SH BUGS
No known bugs.
.SH AUTHOR
Your Name (your@email.com)' > testpackage/usr/share/man/man1/somecommand.1
Code: Select all
man -l testpackage/usr/share/man/man1/somecommand.1
Code: Select all
gzip -9 testpackage/usr/share/man/man1/somecommand.1
Code: Select all
sudo chown -R root:root testpackage
Code: Select all
dpkg-deb --build testpackage
Code: Select all
lintian testpackage.deb
No errors or warnings! Hurray!
Now we can install package as superuser (admin):
Code: Select all
sudo dpkg -i testpackage.deb
Code: Select all
/usr/bin/somecommand
Check your PATH variable for /usr/binRunning Some Command...
Code: Select all
echo $PATH
Code: Select all
somecommand
And try the manual-page for it like so:Running Some Command...
Code: Select all
man somecommand