My requirement is to install sample binaries as per user's yes/no to question Do you want to install to sample binaries? If user give input yes/y then mypackage.deb will install sample binaries to location otherwise won't.
I have created a config file, postinst file and template file but not able to achieve this yet during installation time. It is asking me "Do you want to install to sample binaries?" during deb package creation time.
following are the files.
I have googled some possible thing, some suggest to use debconf set selection but was not able to fit it in my requirement.
Any suggestion to achieve this??
"mypackage.config"
#!/bin/bash
# Source debconf library.
. /usr/share/debconf/confmodule
echo "My package repo path: $1"
echo "Creating My package dir"
mkdir my_package
cd my_package
echo "Copy debian control file"
mkdir DEBIAN
cp $1/debian/control DEBIAN/
cp $1/debian/mypackage.postinst DEBIAN/
cp $1/debian/mypackage.templates DEBIAN/
echo "Copy include files"
mkdir -p usr/include/local
cp $1/MyLib.h usr/include/local/
echo "Copy lib"
mkdir -p usr/local/lib
cp $1/build/src/mylib.so usr/local/lib/
mkdir usr/local/sample
cp $1/build/examples/sample_all usr/local/sample/
#Do you want to install sample binaries?
db_unregister mypackage/sample
db_input high mypackage/sample
# Check their answer.
db_get mypackage/sample
if [ "$RET" = "true" ];
then
echo "Copy Sample Binaries"
mkdir -p home/$USER/My_Package/examples/bin
mv usr/local/sample/sample_all home/$USER/My_Package/examples/bin/
sudo rm -rf /usr/local/sample
db_go
else
echo "Installing deb package without sample binaries"
sudo rm -rf /usr/local/sample
db_go
fi
echo "Create debian package"
cd $1/debian
dpkg-deb --build --root-owner-group mypackage
"my_package.templates"
Template: my_package/sample
Type: boolean
Description: Do you want to install sample binaries as well [true/false] ..?
"my_package.postinst"
#!/bin/sh
# Make sure this script fails if any unexpected errors happen
set -e
# Load debconf library
. /usr/share/debconf/confmodule
db_purge
"control"
Package: my_package
Version: 1.0
Section: custom
Priority: optional
Architecture: all
Pre-Depends: debconf
Essential: no
Installed-Size: 1024
Maintainer: package
Description: My package framework