I investigated how to make a deb package with the motive of wanting to manage my own utility with apt. If you want to do it seriously, you have to gather various information, but I will write it step by step instead of preparing all of it suddenly. The author's environment is Ubuntu 18.04 LTS.
As a first sample, consider packaging the following shell script.
#!/bin/sh
echo " ^ ^"
echo "=o.o="
echo " m m_|~"
exit 0
If you manage this with the file name/usr/bin/mycat, you can always call a cute cat by typing mycat on the shell. Great.
% which mycat
mycat not found
Now, the minimum configuration conditions for creating a deb package are as follows.
--There is a fake root directory under the package management directory (any name you like) --Further below --There is an installation image --There is a DEBIAN directory (permission attribute 755 or 775) --Furthermore, there is a control file under it
Here, let's make the directory structure as follows.
mycat
└── Debian
├── DEBIAN
│ └── control
└── usr
└── bin
└── mycat
The first "mycat" is the package management directory and the "Debian" under it is the fake root directory. Furthermore, usr/bin/mycat under it is an image that becomes/usr/bin/mycat after apt installation. Please set the permission attribute of mycat to 755.
% mkdir -p mycat/Debian
% cd Debian
% mkdir -m 755 DEBIAN
% mkdir -p usr/bin
% cd usr/bin
(~ Edit mycat to the above contents ~)
% chmod 755 mycat
% cd ../../DEBIAN
(Create control as follows)
The contents of control must contain at least the following 5 items.
--Package --Package name --Version --Package version number --Description --Package description --Maintainer --Maintainer's name and contact information --Architecture --Executable architecture
Each item is written after being separated by a':' (colon). For example:
Package: mycat
Version: 1.0
Description: Call your lovely cat!
Maintainer:(Your name)<(Your e-mail address)>
Architecture: all
Then go back to the package management directory mycat and use the dpkg-deb command to create a deb file.
% cd ../..
% fakeroot dpkg-deb --build Debian .
The fakeroot command is in the fakeroot package and the dpkg-deb command is in the dpkg-dev package. If you don't have the command, install the above.
% apt install fakeroot dpkg-dev
If dpkg-deb succeeds, you should have a deb package file mycat_1.0_all.deb. Let's install it using the dpkg command.
% sudo dpkg -i mycat_1.0_all.deb
On the way, you will be asked to enter your password. If successful, try the mycat command right away.
% which mycat
/usr/bin/mycat
% mycat
^ ^
=o.o=
m m_|~
A cute cat is displayed! Try uninstalling as well.
% sudo dpkg -r mycat
% which mycat
mycat not found
If you don't intend to publish the package to anyone and just want to make it easy to install and uninstall, I think it's enough to create a stray package as shown here. However, if you want to manage the package properly even if you do not disclose it to anyone, you should still maintain the information. From the next time, I will explain it little by little.
Recommended Posts