EzDevInfo.com

dpkg interview questions

Top dpkg frequently asked interview questions

What is alternative to -dpkg for Mac?

I'm trying to use dpkg command but in Mac OS X it doesn't seem to work for me

dpkg -scanpackages -m . /dev/null -->Packages

-bash: dpkg: command not found
dns:Administrator$ man dpkg
No manual entry for dpkg

I wonder how can I use the dpkg in Mac??


Source: (StackOverflow)

How to check the version before install packages using apt-get

I'm thinking to install hylafax+ version 5.5.4 which was release last month on my Debian PC.

I checked dpkg -l | grep "hylafax" and found out that the current version is 5.5.3. Then I checked apt-cache search hylafax and saw the packages are available, but I can't see any version number.

How can I find the version of packages available in the apt-get?


Source: (StackOverflow)

Advertisements

What does the colon (:) and dash (-) in a dpkg version number mean?

I'm trying to get the version number of an already installed package, in order to build a dependencies list for a dpkg.

If I type "dpkg -l | grep libqtcore4" into my terminal I get the following result:

ii  libqtgui4       4:4.7.4-0ubuntu8      Qt 4 GUI module
ii  libqtgui4:i386  4:4.7.4-0ubuntu8      Qt 4 GUI module

My question is; what on earth does the colon (:) mean in the version number, and what does the -0ubuntu mean on the end?


Source: (StackOverflow)

dpkg : how to ignore error in post/pre scripts

I've develop debian packages and have syntax mistake in my post/pre script (postrm in my case). I install package successfully, but now i can't remove this package :

/var/lib/dpkg/info/blablabla.postrm: 11: Syntax error: ";;" unexpected
dpkg: error processing blablabla (--remove):
 subprocess installed post-removal script returned error exit status 2

How can ignore it and completely remove package?


Source: (StackOverflow)

How do I preserve installed applications when migrating Ubuntu to another platform?

I'm looking at maybe moving from an older AMD64 to a new Intel dual-core which is 32 bit. Installation isn't a problem but can I transfer all the installed apps? I haven't been able to find anything so far on Google except where the migration is to a similar platform and file-system. I won't change the filesystem but the platform will be different. Is there something on the lines of the "World" file in Gentoo?


Source: (StackOverflow)

Ansible Command module says that '|' is illegal character

I am using Ansible to deploy my project and I trying to check if an specified package is installed, but I have a problem with it task, here is the task:

- name: Check if python-apt is installed
  command: dpkg -l | grep python-apt
  register: python_apt_installed
  ignore_errors: True

And here is the problem:

$ ansible-playbook -i hosts idempotent.yml

PLAY [lxc-host] *************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [10.0.3.240]

TASK: [idempotent | Check if python-apt is installed] ************************* 
failed: [10.0.3.240] => {"changed": true, "cmd": ["dpkg", "-l", "|", "grep", "python-apt"], "delta": "0:00:00.015524", "end": "2014-07-10 14:41:35.207971", "rc": 2, "start": "2014-07-10 14:41:35.192447"}
stderr: dpkg-query: error: package name in specifier '|' is illegal: must start with an alphanumeric character
...ignoring

PLAY RECAP ******************************************************************** 
10.0.3.240                 : ok=2    changed=1    unreachable=0    failed=0 

Why is illegal this character '|' .


Source: (StackOverflow)

How do you prevent a dpkg installation task to notify a changed state when it runs for the second time?

There isn't a module for installing .deb packages directly. When you have to run dpkg as a command, it always mark the installation task as one that has changed. I'd some trouble configuring it correctly, so I'm posting here as a public notebook.

Here is the task to install with dpkg:

- name: Install old python 
  command: dpkg -i {{ temp_dir }}/{{ item }}
  with_items: 
    - python2.4-minimal_2.4.6-6+precise1_i386.deb
    - python2.4_2.4.6-6+{{ ubuntu_release }}1_i386.deb
    - libpython2.4_2.4.6-6+{{ ubuntu_release }}1_i386.deb
    - python2.4-dev_2.4.6-6+{{ ubuntu_release }}1_i386.deb

The files where uploaded to {{temp_dir}} in another task.


Source: (StackOverflow)

Any ways to define grouped conditional dependencies in debian/control?

I'm debianizing a Python package, which has a bit weird dependencies. It either:

  • Depends on python2.7
  • Depends on python2.6 and python-ordereddict (my self-built package for ordereddict on PyPI)

For example, in my setup.py I have:

deps = ["Flask >=0.8"]
if not hasattr(collections, "OrderedDict"): # Python 2.6
    deps.append("ordereddict")

setup(
    …
    install_requires=deps,
    …
)

I haven't found anything in Debian packaging documentation on this matter. Just out of the blue I've tried writing

Depends: ..., python2.7 | (python2.6, python-ordereddict)

But, no surprisingly, it is a wrong syntax that didn't work:

dpkg-gencontrol: warning: can't parse dependency (python2.6

I'm using dh_python2 and ${python:Depends} provides quite unreasonable list like

Depends: python2.7 | python2.6, python (>= 2.7.1-0ubuntu2),
    python (<< 2.8), python-flask, python-ordereddict

With such dependency list, it'll require python-ordereddict for python2.7, that does not exist. And obviously I can't patch python2.7-minimal to say Provides: python-ordereddict (like it's done with python-argparse).

Any suggestions on how to correctly package such library, please?


Source: (StackOverflow)

How can I list the minimal set of Debian packages needed to recreate a set of installed packages?

Is there a way of getting dpkg, apt-get or aptitude to produce a list of the packages which need to be installed on a second machine to duplicate the packages installed on a first?

i.e. If I've installed a plain Ubuntu server, chose the sshd option at install time, then installed build-essential I would expect the output to look something like:

#ubuntu 9.10 server
openssh-sshd
build-essential

As far as I can see, all the available packaging tools will produce a verbose list of the packages on a box. I'm not interested in openssh libs, ld, gcc, and all the other packages pulled in by sshd and build-essential, as they will be installed when I install sshd and build-essential.

I would like to see just the list of the package which I need to install to recreate my current set of packages on another machine.

Is this possible?


Source: (StackOverflow)

Is there a way to automatically determine dependencies when setting up a dpkg control file?

Most of the fields in a dpkg (Debian) control file are straightforward. The tricky one is determining the list of dependencies (Depends:). I was hoping that dpkg-gencontrol could do this for me by looking at the ldd output for the executables in the package directory. Perhaps it can, but I can't get it to work.

If this is what dpkg-gencontrol is for, the error I am getting is:

dpkg-gencontrol: error: syntax error in control_template at line 7: first block lacks a source field.

For reference, the command is dpkg-gencontrol -v1.1 -ccontrol_template -lchangelog -Pdebian. The control_template file contains this:

Package: my-package
Maintainer: Joe Coder <joe@coder.com>
Description: The my-package system
 A longer description that runs to the end of one line and then 
 extends to another line.
Priority: optional

If this is not what dpkg-gencontrol is for, does anyone have any suggestions as to what I can do, or advice on how to set up the dependencies list, ideally automatically?

Admittedly, inferring dependencies in a general way is probably a very difficult problem, especially if you extend the search to scripts and other programs. I am hoping that some tools exists that works most of the time.

Note that this is for internal distribution only. I am not building a package to go into a Linux distribution or even to be downloaded by the general public, so I am happy to bend/break standard rules if needed.


Source: (StackOverflow)

apt preferences pin: origin local?

I have dropped fglrx from my notebook and return to the free drivers but xfce4-power-manager fails to start. it was a known bug

I got apt-get source, apply the patch, build and install it. now all works perfect, I have reported this bug to debian. but now I want to hold this package to prevent upgrades for some time

I know that clumsy way is to bump the package build version part. for example 1.0.10-5 and then hold package by a version:

Package: xfce4-power-manager
Pin: version 1.0.10-5
Pin-priority: 1001

I think the best way is to hold packages by the origin:

Package: xfce4-power-manager
Pin: origin "local origin?"
Pin-priority: 1001

Is this possible? I cant find this in docs


Source: (StackOverflow)

Why is my debian postinst script not being run?

I have made a .deb of my app using fpm:

fpm -s dir -t deb -n myapp -v 9 -a all -x "*.git" -x "*.bak" -x "*.orig" \
--after-remove debian/postrm  --after-install debian/postinst \
--description "Automated build." -d mysql-client -d python-virtualenv home

Among other things, the postinst script is supposed to create a user for the app:

#!/bin/sh

    set -e

    APP_NAME=myapp

    case "$1" in
        configure)
            virtualenv /home/$APP_NAME/local
            #supervisorctl start $APP_NAME
        ;;

    # http://www.debian.org/doc/manuals/securing-debian-howto/ch9.en.html#s-bpp-lower-privs
       install|upgrade)

       # If the package has default file it could be sourced, so that
       # the local admin can overwrite the defaults

       [ -f "/etc/default/$APP_NAME" ] && . /etc/default/$APP_NAME

       # Sane defaults:

       [ -z "$SERVER_HOME" ] && SERVER_HOME=/home/$APP_NAME
       [ -z "$SERVER_USER" ] && SERVER_USER=$APP_NAME
       [ -z "$SERVER_NAME" ] && SERVER_NAME=""
       [ -z "$SERVER_GROUP" ] && SERVER_GROUP=$APP_NAME

       # Groups that the user will be added to, if undefined, then none.
       ADDGROUP=""

       # create user to avoid running server as root
       # 1. create group if not existing
       if ! getent group | grep -q "^$SERVER_GROUP:" ; then
          echo -n "Adding group $SERVER_GROUP.."
          addgroup --quiet --system $SERVER_GROUP 2>/dev/null ||true
          echo "..done"
       fi
       # 2. create homedir if not existing
       test -d $SERVER_HOME || mkdir $SERVER_HOME
       # 3. create user if not existing
       if ! getent passwd | grep -q "^$SERVER_USER:"; then
         echo -n "Adding system user $SERVER_USER.."
         adduser --quiet \
                 --system \
                 --ingroup $SERVER_GROUP \
                 --no-create-home \
                 --disabled-password \
                 $SERVER_USER 2>/dev/null || true
         echo "..done"
       fi

       # … and a bunch of other stuff.

It seems like the postinst script is being called with configure, but not with install, and I am trying to understand why. In /var/log/dpkg.log, I see the lines I would expect:

2012-06-30 13:28:36 configure myapp 9 9
2012-06-30 13:28:36 status unpacked myapp 9
2012-06-30 13:28:36 status half-configured myapp 9
2012-06-30 13:28:43 status installed myapp 9

I checked that /etc/default/myapp does not exist. The file /var/lib/dpkg/info/myapp.postinst exists, and if I run it manually with install as the first parameter, it works as expected.

Why is the postinst script not being run with install? What can I do to debug this further?


Source: (StackOverflow)

How to override dpkg-buildflags CFLAGS?

I got a package with:

$ apt-get source <pkg-name>

and now I am trying to build it with:

$ dpkg-buildpackage -uc -us -j8

At the beginning of the output, there is stated:

dpkg-buildpackage: export CFLAGS from dpkg-buildflags (origin: vendor): -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
dpkg-buildpackage: export CPPFLAGS from dpkg-buildflags (origin: vendor): -D_FORTIFY_SOURCE=2
dpkg-buildpackage: export CXXFLAGS from dpkg-buildflags (origin: vendor): -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
dpkg-buildpackage: export FFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export LDFLAGS from dpkg-buildflags (origin: vendor): -Wl,-Bsymbolic-functions -Wl,-z,relro

I would like to override these CFLAGS (also, the LDFLAGS). I have tried exporting the CFLAGS envvar, the same way we do with plain configure, at no avail. How can I override these values?


Source: (StackOverflow)

Can't remove, purge, unistall mongodb from debian

I'm trying to reinstall it, because it has problems. For example, I can't install Chromium because mongodb-org-server is not configured. But I can't even remove it for the same reason.

apt-get autoremove --purge mongodb

Or:

apt-get purge mongodb

Or:

apt-get remove --purge mongodb

All end in the same way:

 dpkg: error processing package mongodb-org-server (--configure):
  subprocess installed post-installation script returned error exit status 102
 Errors were encountered while processing:
  mongodb-org-server
 E: Sub-process /usr/bin/dpkg returned an error code (1)

Some data about my machine from hostnamectl:

  Operating System: Debian GNU/Linux 8 (jessie)
  Kernel: Linux 3.14-2-amd64
  Architecture: x86_64

How can I fix this?

Updates: things I tried/I'm trying

apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 973 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mongodb-org-server (3.0.2) ...
dpkg: error processing package mongodb-org-server (--configure):
 subprocess installed post-installation script returned error exit status 102
Errors were encountered while processing:
 mongodb-org-server

Source: (StackOverflow)

dpkg error: contains ununderstood data member

I'm trying to install a jailbreak tweak using make package install but I'm receiving this error from dpkg:

dpkg-deb: file `/tmp/_theos_install.deb' contains ununderstood data member data.tar.xz     , giving up
dpkg: error processing /tmp/_theos_install.deb (--install):
subprocess dpkg-deb --fsys-tarfile returned error exit status 2
Errors were encountered while processing:
/tmp/_theos_install.deb
make: *** [internal-install] Error 1

So as far as I can tell it isn't able to understand the .xz extension, but I'm not sure why that file is being created. Thanks for the help.


Source: (StackOverflow)