I am trying to use the dpkg -b to build a package . The package directory structure looks like :

ubuntu@ip-10-241-62-56:~/USB_RnD_DEB/BACKUP/usblinux1.1$ tree
│   └── control
└── usr
    ├── bin
    │   └── usblinux-runner.sh
    └── share
        └── usblinux
               |--> LOTS AND LOTS OF FILES

The usblinux-runner.sh consists of a small shell script which holds :

echo "Installing the USB REDIRECTOR as Client !"
echo "-----------------------------------------"
sudo apt-get update
sudo apt-get install build-essential
sudo /usr/share/usblinux/./installer.sh install-client

Now this gets packed into the

ubuntu@ip-10-241-62-56:~/USB_RnD_DEB/BACKUP$ sudo dpkg -b usblinux1.1/
dpkg-deb: building package `usblinux' in `usblinux1.1.deb'.
ubuntu@ip-10-241-62-56:~/USB_RnD_DEB/BACKUP$ ls
usblinux1.1  usblinux1.1.deb

Now this works absolutely fine and when I install the package it just unpacks it and puts the usblinux-runner.sh in /usr/bin & usblinux in /usr/bin/share

It DOESN'T INSTALL or RUN the the usblinux-runner.sh file . I simply UNPACKS and doesn't RUN the shell script also i don't see any OUTPUT on console :

sudo dpkg -i usblinux1.1.deb 
Selecting previously unselected package usblinux.
(Reading database ... 82106 files and directories currently installed.)
Preparing to unpack usblinux1.1.deb ...
Unpacking usblinux (1.1) ...
Setting up usblinux (1.1) ...

Can someone help me on finding whats wrong?


That's normal, installing a package doesn't run any of its binaries by default (otherwise imagine what fun we'd have installing e2fsprogs and the like!).

If you want the usblinux-runner.sh script to run automatically after the package is installed, you need to add a postinst script, which will run usblinux-runner.sh. There is one caveat: you can't install other packages from a maintainer script, so you'd need to remove the apt-get lines. But that's fine, because the correct way of declaring a dependency (your package depends on build-essential) is to declare it in the Depends: entry of the control file. Given all that, you might as well just have your postinst script run

/usr/share/usblinux/installer.sh install-client

You don't need sudo here, the maintainer scripts run as root anyway.

  • oh , i understand now , so this postinst script also gets packaged inside the .deb ? and then when the whole debian package UNPACKS itself it is ran. correct ?/ – Nishant Singh Oct 18 '16 at 9:51
  • Also where should i put this postinst script ? – Nishant Singh Oct 18 '16 at 9:58
  • You'd put it in the DEBIAN directory, alongside control. Check out the requirements in the link in my answer, you'll need to check the arguments given to the postinst script; this page on the wiki might be helpful too. – Stephen Kitt Oct 18 '16 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.