This post is more than 4 years old. If this is a technical post, the post will most likely not working, but feel free to try it and see if it works.
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.
cat <<EOF >>$BUILD_DIR/DEBIAN/control Package: wslu Architecture: all Maintainer: patrick330602 <wotingwu@live.com> Depends: bc, wget, unzip, lsb-release Recommends: git Suggests: ppa-purge, build-essential Priority: optional Version: $BUILD_VER Description: A collection of utilities for Windows 10 Linux Subsystem This is a collection of utilities for Windows 10 Linux Subsystem, such as enabling sound in WSL or creating your favorite linux app shortcuts on Windows 10 Desktop. Requires Windows 10 Creators Update and higher. EOF
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 2 3 4 5 6 7 8 9 10 11 12 13 14 15
touch$BUILD_DIR/DEBIAN/control
cat <<EOF >>$BUILD_DIR/DEBIAN/control Package: wslu Architecture: all Maintainer: patrick330602 <wotingwu@live.com> Depends: bc, wget, unzip, lsb-release Recommends: git Suggests: ppa-purge, build-essential Priority: optional Version: $BUILD_VER Description: A collection of utilities for Windows 10 Linux Subsystem This is a collection of utilities for Windows 10 Linux Subsystem, such as enabling sound in WSL or creating your favorite linux app shortcuts on Windows 10 Desktop. Requires Windows 10 Creators Update and higher. EOF
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.
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 2
find $BUILD_DIR -type d -execchmod 0755 {} \; find $BUILD_DIR/usr/bin -type f -execchmod 0555 {} \;
This is to change all folder to permission 755 and the executables to permission 555.
Build and cleanup
1 2 3 4 5 6
cd$CURRENT_DIR/../release/debian
sudo dpkg -b $BUILD_DIR/ wslu-${BUILD_VER}.deb
rm -rf $BUILD_DIR cd$CURRENT_DIR
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.