I made this for a particular "product", change the directory variables and final archived .deb filename per your needs.
debian.build.install.sh
#!/usr/bin/env bash
# this.is.lance.miller@gmail.com
clear;
basedir='/home/';
microdir=$basedir"micro/";
chmod 0775 $microdir'DEBIAN/postinst';
myfile=$microdir'DEBIAN/control';
echo $myfile;
myversion=`cat $myfile | grep Version | cut -d' ' -f2`;
echo $myfile' declares version '$myversion;
dpkg-deb --build $microdir;
ls -l $basedir*.deb;
sleep 5;
dpkg -i $basedir'micro.deb';
ls -l $basedir*.deb;
newfile='our_product_name_'$myversion'_all.deb';
echo 'creating this versioned deb archive: '$newfile;
mv $basedir'micro.deb' $basedir$newfile;
ls -l $basedir*.deb;
Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts
Thursday, December 1, 2016
Tuesday, September 6, 2016
Perform post install scripting for Debian packages. Especially useful for setting file permissions
There are plenty of thorough references for creating Debian .deb packages, but not enough short examples that present the bare essentials. This is a minimal example with post install scripting
-especially useful for setting file permissions- which is done specifically with the DEBIAN/postinst file.
The files that configure and command the Debian packaging and subsequent installation all reside in a directory named DEBIAN. Here are all the files I include in my DEBIAN directory:
Below are the contents of the files (contents changed to protect the proprietary)
cd /home/
dpkg-deb --build FOOBAR
The above dpkg-deb would create a file named FOOBAR.deb
To install the FOOBAR.deb package on a machine, you would run:
dpkg -i FOOBAR.deb
A parting note. I would rename my FOOBAR.deb to FOOBAR.1.0.40.deb to make evident the version number of the package.
The files that configure and command the Debian packaging and subsequent installation all reside in a directory named DEBIAN. Here are all the files I include in my DEBIAN directory:
- DEBIAN/conffiles
- DEBIAN/control
- DEBIAN/postinst
- DEBIAN/rules
Below are the contents of the files (contents changed to protect the proprietary)
-
DEBIAN/conffiles
...blank...
-
DEBIAN/control
Package: foo-for-bar Version: 1.0.40 Section: Network Priority: optional Architecture: all Depends: Maintainer: Jane Doe jane.doe@example.com Description: Acme FooBar WWW UI User interface for Acme FooBar.
-
DEBIAN/postinst
#!/usr/bin/env bash cat $0 chmod 777 /var/lib/foobar/conf/www/* chmod 777 /var/lib/foobar/* chmod 777 /var/lib/foobar/foobaringdaemon.py chmod 777 /etc/local.d/80_figlets_with_foobar.sh echo "hello there from postinst file"
-
DEBIAN/rules
...blank...
General File Structure
Let's say I want a .deb package to install files that will reside in the /var/www and /etc/local.d directories. In my case I'll create everything in the /home/ directory. Here is the root and first layer of directories.- /home/FOOBAR/DEBIAN
- /home/FOOBAR/etc
- /home/FOOBAR/var
cd /home/
dpkg-deb --build FOOBAR
The above dpkg-deb would create a file named FOOBAR.deb
To install the FOOBAR.deb package on a machine, you would run:
dpkg -i FOOBAR.deb
A parting note. I would rename my FOOBAR.deb to FOOBAR.1.0.40.deb to make evident the version number of the package.
Subscribe to:
Posts (Atom)