problems about making our own package of mongodb on Ubtunu

Asked by liuyang

Hi guys:
         Who is familiar with packing on Ubtunu, please help me.
       I want to create my own deb package on Ubtunu 14.04 using dh_make,dh_install and so on. I put the postinst file in mongodbdebbuild-1.0/debian/postinst. And I have no problem to create the deb. But when I install it using "dpkg -i mongodbdebbuild_1.0-1_all.deb", there are some errors below:
Selecting previously unselected package mongodbdebbuild.
(Reading database ... 170486 files and directories currently installed.)
Preparing to unpack mongodbdebbuild_1.0-1_all.deb ...
Unpacking mongodbdebbuild (1.0-1) ...
Setting up mongodbdebbuild (1.0-1) ...
dpkg (subprocess): unable to execute installed post-installation script (/var/lib/dpkg/info/mongodbdebbuild.postinst): No such file or directory
dpkg: error processing package mongodbdebbuild (--install):
subprocess installed post-installation script returned error exit status 2
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
mongodbdebbuild
The message shows /var/lib/dpkg/info/mongodbdebbuild.postinst doesnot exist. But it exists in fact.
root@root-VM:/etc# ls -al /var/lib/dpkg/info/mongodbdebbuild.postinst
-rwxr-xr-x 1 root root 2704 Nov 8 02:18 /var/lib/dpkg/info/mongodbdebbuild.postinst
The comment of postinst:
#!/bin/bash

set -x

SOURCEFILE2=init.d-mongod
SOURCEFILE4=mongod.sysconfig

while IFS='' read -r line || [[ -n "$line" ]];do
  read -r key value <<< "$line"
  if [[ ! $line =~ ^# && $line ]]; then
      #echo "Key:$key -Value:$value"
      declare -A array
      array[$key]="$value"
  fi
done < "/etc/install.conf"
for keyname in "${!array[@]}";do
        case $keyname in
            "DBServiceName") dbservicename=${array[$keyname]} ;;
            "DBSystemUser") dbsystemuser=${array[$keyname]} ;;
            "DBSystemGroup") dbsystemgroup=${array[$keyname]} ;;
            "RootPath") rootpath=${array[$keyname]} ;;
            "DBPath") dbpath=${array[$keyname]} ;;
            "DataPath") datapath=${array[$keyname]} ;;
            "LogPath") logpath=${array[$keyname]} ;;
            "BindIp") bindip=${array[$keyname]} ;;
            "DBPort") dbport=${array[$keyname]} ;;
            "ReplicaSetName") replicasetname=${array[$keyname]} ;;
            "CPULimit") cpulimit=${array[$keyname]} ;;
            "MemoryLimit") memorylimit=${array[$keyname]} ;;
            "UninstallSaveData") uninstallsavedata=${array[$keyname]} ;;
            "RequireSSL") requiressl=${array[$keyname]} ;;
            "CertPath") certpath=${array[$keyname]} ;;
            "KeyPath") keypath=${array[$keyname]} ;;
            "DBUser") dbuser=${array[$keyname]} ;;
            "DBPassword") dbpassword=${array[$keyname]} ;;
            "SingleNode") singlenode=${array[$keyname]} ;;
            "ReplicaSetMembers") replicasetmembers=${array[$keyname]} ;;
            "ReplicaSetKeyFile") replicasetkeyfile=${array[$keyname]} ;;
        esac
        #echo "key : $keyname"
        #echo "value: ${array[$keyname]}"
done;
echo "DBServiceName value is :$dbservicename"
echo "DBSystemUser value is :$dbsystemuser"
echo "DBSystemGroup value is :$dbsystemgroup"
echo "RootPath value is :$rootpath"
echo "DBPath value is :$dbpath"
echo "DataPath value is :$datapath"
echo "LogPath value is :$logpath"
echo "BindIp value is :$bindip"
echo "DBPort value is :$dbport"
echo "ReplicaSetName value is :$replicasetname"
echo "CPULimit value is :$cpulimit"
echo "MemoryLimit value is :$memorylimit"
echo "UninstallSaveData value is :$uninstallsavedata"
echo "RequireSSL value is :$requiressl"
echo "CertPath value is :$certpath"
echo "KeyPath value is :$keypath"
echo "SingleNode value is :$singlenode"
echo "ReplicaSetMembers value is :$replicasetmembers"
echo "ReplicaSetKeyFile value is :$replicasetkeyfile"

chmod a+x $dbpath
mv -f $SOURCEFILE2 $dbservicename
chmod a+x $dbservicename
mv -f $SOURCEFILE4 mongod
mkdir -p $datapath
mkdir -p $logpath
touch $logpath/mongod.log

echo "Hello World!"
echo "Hello World!"
echo "Hello World!"

exit 0
I have no idea. The errors are the same on Ubuntu 14.04 and Ubuntu 16.04

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu dpkg Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

Are you sure that the file /etc/install.conf is existing at the time that the postinst script is running?
I do not think that it is good practice to refer to other files from inside the postinst script the way you do.
And using the file name "/etc/install.conf" for package-specific settings is also questionable. What if another package overwrites that file with its own contents?

Revision history for this message
liuyang (finalha) said :
#2

Hi m-hampl,I am sure that the file /etc/install.conf exists.
"/etc/install.conf" is used for other people changing the settings of the package, and it is for testing.
Do you have a better way to solve it ? Please tell me, thank you

Can you help with this problem?

Provide an answer of your own, or ask liuyang for more information if necessary.

To post a message you must log in.