简体   繁体   中英

How to create deb that install another deb before installation?

I want to create.deb file that could be installed on a out-of-box Ubuntu.

I have prepeared control, preinst, postinst files. But when I try to install my package on a fresh Ubuntu it says that "Could not get lock /var/lib/dpkg/lock". I know that it is a common problem when people want to install different software at the same time. But how do I install python3-pip and nginx?

Sure, I can create 2 files: mysofr.deb and install.sh. But the point is to have only one file, so user could install my soft with only one command.

Here is my preinst:

dpkg -s "python3-pip" >/dev/null 2>&1 && {
    echo "python3-pip is installed."
    echo
  } || {
    echo "ERROR: python3-pip is not installed. Now it will be installed from default repo"
#    rm /var/lib/dpkg/lock
#    dpkg --configure -a
    sudo apt install python3-pip
  }

As you can see, I have tried to unlock dpkg. But it was a bad idea to do it during installation.

Here is my postinst:

#!/bin/bash
cd *directory*
dpkg -i nginx_1.14.2-1_stretch_amd64.deb
rm nginx_1.14.2-1_stretch_amd64.deb
systemctl enable nginx
service nginx start

In short: I want to create deb that could check if there is a python3-pip and nginx and if there is no such software - install it: nginx from.deb file, python3-pip from default repo.

if you get comments like that, it means that before you cancel the installation, for this problem you can use the following command "$rm /var/lib/dpkg/lock",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM