{"id":349,"date":"2011-08-02T10:18:57","date_gmt":"2011-08-02T08:18:57","guid":{"rendered":"http:\/\/tronche.com\/blog\/less-technical\/uncategorized\/2011\/08\/readline-on-closed-filehandle-files-at-usr-sbin-popularity-contest-line-104-not-solved-yet-but-at-least-we-understand-and-how-popularity-contest-works\/"},"modified":"2011-08-02T10:18:57","modified_gmt":"2011-08-02T08:18:57","slug":"readline-on-closed-filehandle-files-at-usr-sbin-popularity-contest-line-104-not-solved-yet-but-at-least-we-understand-and-how-popularity-contest-works","status":"publish","type":"post","link":"https:\/\/tronche.com\/blog\/2011\/08\/readline-on-closed-filehandle-files-at-usr-sbin-popularity-contest-line-104-not-solved-yet-but-at-least-we-understand-and-how-popularity-contest-works\/","title":{"rendered":"readline() on closed filehandle FILES at \/usr\/sbin\/popularity-contest line 104 (not solved yet, but at least we understand) and how popularity-contest works"},"content":{"rendered":"<p>This is bug [https:\/\/bugs.launchpad.net\/ubuntu\/+source\/popularity-contest\/+bug\/742017 #742017]<\/p>\n<p>The solution is yet to be devised, but at least we know<\/p>\n<p>= How popularity-contest works =<\/p>\n<p>&#8221;&#8217;popularity-contest&#8221;&#8217; is a script that sends a periodic report to Ubuntu (or Debian) about the installed and &#8221;&#8217;used&#8221;&#8217; packages. At the time of this writing (popularity-contest version 1.51 on Ubuntu 11 \/ Natty Narwhal), popularity-contest is a Perl script.<\/p>\n<p>How does it work ?<\/p>\n<p>At the heart of the script are two imbricated loops.<br \/>\n<!--more--><br \/>\nThis is bug [https:\/\/bugs.launchpad.net\/ubuntu\/+source\/popularity-contest\/+bug\/742017 #742017]<\/p>\n<p>The solution is yet to be devised, but at least we know<\/p>\n<p>= How popularity-contest works =<\/p>\n<p>&#8221;&#8217;popularity-contest&#8221;&#8217; is a script that sends a periodic report to Ubuntu (or Debian) about the installed and &#8221;&#8217;used&#8221;&#8217; packages. At the time of this writing (popularity-contest version 1.51 on Ubuntu 11 \/ Natty Narwhal), popularity-contest is a Perl script.<\/p>\n<p>How does it work ?<\/p>\n<p>At the heart of the script are two imbricated loops. The outer one runs through all the installed packages and is fed with something like<br \/>\n dpkg-query &#8211;show<br \/>\nThe inner loop then takes each package and run through all the installed files of the said package, checking for the &#8221;atime&#8221; (the last access time) of each file. If one file has been accessed, said, more recently than the last 30 days, the package is declared &#8220;used&#8221;.<\/p>\n<p>(Side note: that means that &#8221;&#8217;popularity-contest&#8221;&#8217; performs a stat on every file installed on your machine via the packaging system, a rather heavy task).<\/p>\n<p>The inner loop get the file list by opening directly the package repository, thus &#8221;&#8217;popularity-contest&#8221;&#8217; depends on its knowledge of the structure of the repository. Traditionally, the repository is in<br \/>\n \/var\/lib\/dpkg\/info<br \/>\nwhere lives (among others) a file <package-name>.list, with the list of the files from the package.<\/p>\n<p>== This is were things go awry ==<\/p>\n<p>The point is that some packages are architecture-dependent: the list of files depends on your processor, for example. For those packages, the name of the file list is not <package-name>.list, but <package-name>: < architecture > .list. <\/p>\n<p>For example, in my case, the list of files of the base package for gcc v4.5  is called gcc-4.5-base&#8221;&#8217;:386&#8221;&#8217;.list. &#8221;&#8217;popularity-contest&#8221;&#8217; looks fot gcc-4.5-base.list and doesn&#8217;t get it right (for a reason unknown to me at the time of this writing), hence the error in the log.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>This is bug [https:\/\/bugs.launchpad.net\/ubuntu\/+source\/popularity-contest\/+bug\/742017 #742017] The solution is yet to be devised, but at least we know = How popularity-contest works = &#8221;&#8217;popularity-contest&#8221;&#8217; is a <a class=\"mh-excerpt-more\" href=\"https:\/\/tronche.com\/blog\/2011\/08\/readline-on-closed-filehandle-files-at-usr-sbin-popularity-contest-line-104-not-solved-yet-but-at-least-we-understand-and-how-popularity-contest-works\/\" title=\"readline() on closed filehandle FILES at \/usr\/sbin\/popularity-contest line 104 (not solved yet, but at least we understand) and how popularity-contest works\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[200,206,210,208,202,204],"class_list":["post-349","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-debian","tag-natty-narwhal","tag-perl","tag-popularity-contest","tag-ubuntu","tag-ubuntu-11"],"_links":{"self":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts\/349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/comments?post=349"}],"version-history":[{"count":0,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts\/349\/revisions"}],"wp:attachment":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/media?parent=349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/categories?post=349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/tags?post=349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}