Packaging .deb using a simple script: Explained
---date: May 25, 2018
tags:
- Linux Packaging
- Ubuntu
- Debian
language: English
---
TL;DR
This post goes over the creation of a debian package containing only executives using the only the built-in commands and dpkg
to build packages. I created this article since I have read several articles like this trying to simplify the process of packaging, but as I encountered the script used by celebrate, it actually interested me and I managed to simplified the function to minimum, and thus created this script. The script posted belongs to my project wslu.
the script
1 |
|
build script by executing the command: sudo ./make-deb.sh
.
Explained
Set variables and create build structure
1 | BUILD_DIR=`mktemp --tmpdir --directory wslu-build-debian.XXXX` |
BUILD_DIR
will create a temp dolder and pass the full path to BUILD_DIR
.
BUILD_VER
will get the version number from my script. You can set your own version here.
CURRENT_DIR
will get the current folder just because I still don’t know how popd
and pushd
work.(Just… don’t blame me here)
mkdir
command will create the build structure in the temp folder.
Create control
file
1 |
|
these lines are creating control
file. Actually, you can ignore the first touch
line, as my bash have a problem making complaints that file doesn’t exist. for the content of control
, you can check the offical Debian packing guide to complete this part.
copying executables and creating md5sums
file
1 | cp ../src/wsl* $BUILD_DIR/usr/bin/ |
the cp
command is obiviously copying the executables to $BUILD_DIR/usr/bin/
.
the next two line will enter the build folder and output their md5sum
to DEBIAN/md5sums
.
Change permission
1 | find $BUILD_DIR -type d -exec chmod 0755 {} \; |
This is to change all folder to permission 755
and the executables to permission 555
.
Build and cleanup
1 | cd $CURRENT_DIR/../release/debian |
This is also pretty obivious. It will go to a desired output location, build the package, remove the temp build folder, and go back to original location.