apt-build fails to install if `grep processors /proc/cpuinfo` don't find anything

Bug #1065678 reported by Dawid Wróbel
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt-build (Ubuntu)
Fix Released
Low
Dominique Lasserre

Bug Description

I was trying to install the apt-build today. After being shown a ncurses dialog to choose whether to add apt-build repository and then an optimization level, the dialog was closed and an error shown:

Setting up apt-build (0.12.43) ...
dpkg: error processing apt-build (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 apt-build

I tried to narrow the problem down by repeatedly editing the apt-build.postinst file, removing code parts and running "dpkg --reconfigure -a". It turnes out that it's enough to just leave the .postinst as following to trigger the bug:

#!/bin/sh
if [ "$1" = "configure" ] ; then
        . /usr/share/debconf/confmodule
fi

Even though I do not know perl almost at all, I tried to read the code in and try to find the real culprit, however whole debconf and thinking behind it is way too complicated for me to get the glimpse fast enough, hence my not-so-much-detailed bug report.
I will be happy, though, to get instructed by someone else and do some more investigation on the matter.

PS. Please note that I do not have my /tmp mounted with noexec, as this I believe is the most common cause for this kind of errors with debconf.

ProblemType: Bug
DistroRelease: Ubuntu 12.10
Package: apt-build 0.12.43
Uname: Linux 3.0.42+ armv7l
ApportVersion: 2.6.1-0ubuntu3
Architecture: armhf
Date: Thu Oct 11 21:18:49 2012
SourcePackage: apt-build
UpgradeStatus: Upgraded to quantal on 2012-09-29 (12 days ago)
---
Architecture: armhf
DistroRelease: Ubuntu 12.10
Package: debconf 1.5.46ubuntu1
PackageArchitecture: all
Uname: Linux 3.0.42+ armv7l
UserGroups:

Revision history for this message
Dawid Wróbel (dawidw) wrote :
Revision history for this message
Dawid Wróbel (dawidw) wrote : Dependencies.txt

apport information

tags: added: apport-collected
description: updated
Revision history for this message
Dawid Wróbel (dawidw) wrote : ProcEnviron.txt

apport information

Revision history for this message
Dominique Lasserre (lasall) wrote : Re: Unable to install apt-build, apparently a bug in debconf

Hi Dawid, thank you for reporting this bug!

Please show verbose debconf information:
debconf-show apt-fast debconf

And during upgrade/installation please export DEBCONF_DEBUG to developer (with unmodified postinst):
DEBCONF_DEBUG=developer dpkg --configure -a

Revision history for this message
Dominique Lasserre (lasall) wrote :

Arg, not apt-fast, apt-build of course ;) .

Revision history for this message
Dawid Wróbel (dawidw) wrote :

root@mele:~# debconf-show apt-build debconf
  debconf-apt-progress/preparing:
  debconf/frontend: Dialog
  debconf-apt-progress/title:
  debconf/priority: high
  debconf-apt-progress/info:
  debconf-apt-progress/media-change:

root@mele:~# DEBCONF_DEBUG=developer dpkg --configure -a
Setting up apt-build (0.12.43) ...
debconf (developer): frontend started
debconf (developer): frontend running, package name is apt-build
debconf (developer): starting /var/lib/dpkg/info/apt-build.config configure
debconf (developer): <-- INPUT medium apt-build/build_dir
debconf (developer): --> 30 question skipped
debconf (developer): <-- GO
debconf (developer): --> 0 ok
debconf (developer): <-- GET apt-build/build_dir
debconf (developer): --> 0 /var/cache/apt-build/build
debconf (developer): <-- INPUT medium apt-build/repository_dir
debconf (developer): --> 30 question skipped
debconf (developer): <-- GO
debconf (developer): --> 0 ok
debconf (developer): <-- GET apt-build/repository_dir
debconf (developer): --> 0 /var/cache/apt-build/repository
debconf (developer): <-- SUBST apt-build/add_to_sourceslist repo /var/cache/apt-build/repository
debconf (developer): --> 0
debconf (developer): <-- SET apt-build/add_to_sourceslist true
debconf (developer): --> 0 value set
debconf (developer): <-- INPUT critical apt-build/add_to_sourceslist
debconf (developer): --> 0 question will be asked
debconf (developer): <-- INPUT critical apt-build/olevel
debconf (developer): --> 0 question will be asked
debconf (developer): <-- INPUT medium apt-build/options
debconf (developer): --> 30 question skipped
debconf (developer): <-- GO
debconf (developer): --> 0 ok
dpkg: error processing apt-build (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 apt-build

Revision history for this message
Dominique Lasserre (lasall) wrote :

I assume this is a debconf issue. config script fails when question should be shown. Are there debconf related problems with other packages? E.g. try: dpkg-reconfigure debconf

Please add "set -x" to /var/lib/dpkg/info/apt-build.config (2nd line) and again show:
DEBCONF_DEBUG=developer dpkg --configure -a

Revision history for this message
Dawid Wróbel (dawidw) wrote :
Download full text (5.6 KiB)

dpkg-reconfigure debconf worked just fine. BTW. I switched the priority level for ignored questions to low. This caused the apt-get configuration dialog to be shown for more advanced options, too (compilation tuning, etc.). I previously thought these questions were not shown because of the bug (I was asked these on another quantal system I use).

After adding the "set -x":

root@mele:~# DEBCONF_DEBUG=developer dpkg --configure -a
Setting up apt-build (0.12.43) ...
debconf (developer): frontend started
debconf (developer): frontend running, package name is apt-build
debconf (developer): starting /var/lib/dpkg/info/apt-build.config configure
+ set -e
+ CONFFILE=/etc/apt/apt-build.conf
+ build_dir=
+ repository_dir=
+ Olevel=
+ mtune=
+ options=
+ make_options=
+ . /usr/share/debconf/confmodule
+ [ ! 1 ]
+ [ -z ]
+ exec
+ [ ]
+ exec
+ DEBCONF_REDIR=1
+ export DEBCONF_REDIR
+ [ -e /etc/apt/apt-build.conf ]
+ ok=
+ [ -z ]
+ db_input medium apt-build/build_dir
+ _db_cmd INPUT medium apt-build/build_dir
+ _db_internal_IFS=

+ IFS=
+ printf %s\n INPUT medium apt-build/build_dir
+ IFS=

+ IFS=
 read -r _db_internal_line
debconf (developer): <-- INPUT medium apt-build/build_dir
debconf (developer): --> 0 question will be asked
+ RET=question will be asked
+ return 0
+ db_go
+ _db_cmd GO
+ _db_internal_IFS=

+ IFS=
+ printf %s\n GO
+ IFS=

+ IFS=
 read -r _db_internal_line
debconf (developer): <-- GO
debconf (developer): --> 0 ok
+ RET=ok
+ return 0
+ db_get apt-build/build_dir
+ _db_cmd GET apt-build/build_dir
+ _db_internal_IFS=

+ IFS=
+ printf %s\n GET apt-build/build_dir
+ IFS=

+ IFS=
 read -r _db_internal_line
debconf (developer): <-- GET apt-build/build_dir
debconf (developer): --> 0 /var/cache/apt-build/build
+ RET=/var/cache/apt-build/build
+ return 0
+ [ -z /var/cache/apt-build/build ]
+ ok=0
+ [ -z 0 ]
+ repository_dir=
+ [ -z ]
+ db_input medium apt-build/repository_dir
+ _db_cmd INPUT medium apt-build/repository_dir
+ _db_internal_IFS=

+ IFS=
+ printf %s\n INPUT medium apt-build/repository_dir
+ IFS=

+ IFS=
 read -r _db_internal_line
debconf (developer): <-- INPUT medium apt-build/repository_dir
debconf (developer): --> 0 question will be asked
+ RET=question will be asked
+ return 0
+ db_go
+ _db_cmd GO
+ _db_internal_IFS=

+ IFS=
+ printf %s\n GO
+ IFS=

+ IFS=
 read -r _db_internal_line
debconf (developer): <-- GO
debconf (developer): --> 0 ok
+ RET=ok
+ return 0
+ db_get apt-build/repository_dir
+ _db_cmd GET apt-build/repository_dir
+ _db_internal_IFS=

+ IFS=
+ printf %s\n GET apt-build/repository_dir
+ IFS=

+ IFS=
 read -r _db_internal_line
debconf (developer): <-- GET apt-build/repository_dir
debconf (developer): --> 0 /var/cache/apt-build/repository
+ RET=/var/cache/apt-build/repository
+ return 0
+ [ -z /var/cache/apt-build/repository ]
+ repository_dir=/var/cache/apt-build/repository
+ [ -z /var/cache/apt-build/repository ]
+ db_subst apt-build/add_to_sourceslist repo /var/cache/apt-build/repository
+ _db_cmd SUBST apt-build/add_to_sourceslist repo /var/cache/apt-build/repository
+ _db_internal_IFS=

+ IFS=
+ printf %s\n SUBST apt-build/add_to_sourceslist repo /var/cache/apt-build/r...

Read more...

Revision history for this message
Dawid Wróbel (dawidw) wrote :

Sorry, I meant "This caused the apt-build configuration dialog to be shown for more advanced options (...)".

Revision history for this message
Dominique Lasserre (lasall) wrote :

Hm, perhabs this is an arm/sh issue. Please show:

multithreaded="-j$(grep -c processor /proc/cpuinfo)"
echo "${multithreaded#-j}"
case "${multithreaded#-j}" in ''|*[!0-9]*|0*) echo foobar;; esac
echo end

What happends when you change shebang in /var/lib/dpkg/info/apt-build.config from #!/bin/sh to #!/bin/bash and rerun dpkg --configure -a again?

Revision history for this message
Dominique Lasserre (lasall) wrote :

Sorry, forget to mention, change into sh-shell before running those commands, e.g.:
sh

Revision history for this message
Dawid Wróbel (dawidw) wrote :

root@mele:~# sh test.sh
0
foobar
end

Switching to bash didn't help, same error.

Revision history for this message
Dominique Lasserre (lasall) wrote :

Please run atteched script with sh. I have commented all debconf stuff, so we should see all other errors.

Revision history for this message
Dawid Wróbel (dawidw) wrote :

Seems like no error this time?

root@mele:~# sh test2.sh
+ set -e
+ CONFFILE=/etc/apt/apt-build.conf
+ build_dir=
+ repository_dir=
+ Olevel=
+ mtune=
+ options=
+ make_options=
+ echo . /usr/share/debconf/confmodule
. /usr/share/debconf/confmodule
+ [ -e /etc/apt/apt-build.conf ]
+ ok=
+ [ -z ]
+ echo db_input medium apt-build/build_dir
db_input medium apt-build/build_dir
+ echo db_go
db_go
+ echo db_get apt-build/build_dir
db_get apt-build/build_dir
+ RET=buildir
+ [ -z buildir ]
+ ok=0
+ [ -z 0 ]
+ repository_dir=
+ [ -z ]
+ echo db_input medium apt-build/repository_dir
db_input medium apt-build/repository_dir
+ echo db_go
db_go
+ echo db_get apt-build/repository_dir
db_get apt-build/repository_dir
+ RET=repodir
+ [ -z repodir ]
+ repository_dir=repodir
+ [ -z repodir ]
+ echo db_subst apt-build/add_to_sourceslist repo repodir
db_subst apt-build/add_to_sourceslist repo repodir
+ apt-config shell etcdir Dir::Etc
+ eval etcdir='etc/apt/'
+ etcdir=etc/apt/
+ apt-config shell sourceslist Dir::Etc::sourcelist
+ eval sourceslist='sources.list'
+ sourceslist=sources.list
+ apt-config shell sourcesparts Dir::Etc::sourceparts
+ eval sourcesparts='sources.list.d'
+ sourcesparts=sources.list.d
+ [ ! -e /etc/apt/apt-build.conf ]
+ echo db_set apt-build/add_to_sourceslist true
db_set apt-build/add_to_sourceslist true
+ echo db_input critical apt-build/add_to_sourceslist
db_input critical apt-build/add_to_sourceslist
+ echo db_input critical apt-build/olevel
db_input critical apt-build/olevel
+ echo db_input medium apt-build/options
db_input medium apt-build/options
+ echo db_go
db_go
+ multithreaded=
+ [ -n ]
+ [ -r /proc/cpuinfo ]
+ [ ! -e /etc/apt/apt-build.conf ]
+ grep -c processor /proc/cpuinfo
+ multithreaded=-j0
root@mele:~#

Revision history for this message
Dominique Lasserre (lasall) wrote :

I don't know why it ends there (there should come some more steps). I'll try to get an arm machine this weekend to reproduce this.

summary: - Unable to install apt-build, apparently a bug in debconf
+ apt-build fails to install (post-installation/config script) on armel
Changed in apt-build (Ubuntu):
assignee: nobody → Dominique Lasserre (lasall)
status: New → In Progress
Revision history for this message
Dominique Lasserre (lasall) wrote :

Hi Dawid thank you very much again to report this bug and help to find the cause of this bug! The problem is very simple: grep try to get count of processors but if it don't find anything it returns 0 -> script fails. A workarround is: Search the "grep -c processors /proc/cpuinfo" line in /var/lib/dpkg/info/apt-build.config and add "|| true" at the end.

summary: - apt-build fails to install (post-installation/config script) on armel
+ apt-build fails to install if `grep processors /proc/cpuinfo` don't find
+ anything
Revision history for this message
Dominique Lasserre (lasall) wrote :

*it (grep) returns 1

Revision history for this message
Dominique Lasserre (lasall) wrote :

I have pushed a fix to lp:~lasall/ubuntu/quantal/apt-build/1065678-fix .
This not only fixes this bug but even make APT path buildings more robust (e.g.: apt-config shell var Dir::Etc::sourcesparts->>/d<<-).

I will file a request in BTS too, but the Quantal release is coming, so there wouldn't be time to sync it from Debian.

Ubuntu release team subscribed.

Revision history for this message
Dawid Wróbel (dawidw) wrote :

Dominique, thank you very much for your assistance, the workaround worked as expected!

Revision history for this message
Scott Kitterman (kitterman) wrote :

It is too late to get this into quantal prior to release. It could be done as an early post-release update (and fixed in "Q"). Unsubscribing the release team and adding the SRU team.

Revision history for this message
Sebastien Bacher (seb128) wrote :

There is no patch attached to this bug ... could you get a debdiff or a merge request up for it? Did you manage to send the bug and the patch you came with to Debian? Could you share the bug number?

Changed in apt-build (Ubuntu):
importance: Undecided → Low
Revision history for this message
Dominique Lasserre (lasall) wrote :

Thank you Sebastien to push this issue. I have filed the Debian bugs (#694554 and #694557) and have proposed it for unblock.

The new package version is now approved and in queue so in a few hours it is possible to sync it from Debian to Ubuntu.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apt-build - 0.12.44

---------------
apt-build (0.12.44) unstable; urgency=low

  * QA upload.
  * Don't fail on postinstallation if no "processor" found in /proc/cpuinfo.
    LP: #1065678 (Thanks to Dawid Wróbel.) Closes: #694554
  * Generate APT paths properly with apt-config shell .../f .../d .
    Closes: #694557

 -- Dominique Lasserre <email address hidden> Tue, 27 Nov 2012 18:43:18 +0100

Changed in apt-build (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.