Merge lp:~evfool/synaptic/lp945997 into lp:synaptic

Proposed by Robert Roth
Status: Superseded
Proposed branch: lp:~evfool/synaptic/lp945997
Merge into: lp:synaptic
Diff against target: 68 lines (+20/-7)
2 files modified
common/rpackage.cc (+18/-7)
gtk/gtkbuilder/window_main.ui (+2/-0)
To merge this branch: bzr merge lp:~evfool/synaptic/lp945997
Reviewer Review Type Date Requested Status
Daniel Hartwig (community) Approve
synaptic-developers Pending
Review via email: mp+135791@code.launchpad.net

This proposal has been superseded by a proposal from 2012-12-10.

Description of the change

This branch contains the following fixes:
* installed version and latest available version field values made selectable in the embedded package properties pane (related to bug #173464)
* installed files listing did not work for multiarch packages as the name() already contained the arch, so i have added a check to make sure we try both with and without the arch suffix (if name contains : we already tried with the arch suffix, try without it, and if the name doesn't contain :, add the arch suffix and try with that). This fixes bug #945997.

To post a comment you must log in.
Revision history for this message
Daniel Hartwig (wigs) wrote :

The comment “try multiarch name next” no longer applies, replaced by the new comment you insert.

The logic here seems ok.

Portability issues:

+ int index = namestr.find_first_of(":");
+ if (index > -1) {

string::find_first_of returns string::size_type, not int. It should not be coerced prior to comparing it to the “char not found“ value, or using it with any string functions. Generally, it is never necessary to explicitly coerce string::size_type.

The “char not found” value is string::npos, not -1. Although equivalent for some implementations of string in some libraries, you can not rely on that:

string::size_type index = namestr.find_first_of(":");
if (index != string::npos) {

review: Needs Fixing
lp:~evfool/synaptic/lp945997 updated
2116. By Robert Roth

Fixed string searching issues based on review feedback

Revision history for this message
Robert Roth (evfool) wrote :

Thanks for the review Daniel, I have made the changes suggested.
I did not make my research,, just simply checked that it works for me for both multiarch and simple packages, I'm not (yet) used to think about portability, but hey, I'm learning :).

Revision history for this message
Daniel Hartwig (wigs) wrote :

> I did not make my research,, just simply checked that it
> works for me for both multiarch and simple packages

Indeed my initial look at the logic was not deep enough either! Consider:

$ apt-cache show bison:i386 bison:amd64 | grep …
Package: bison
Status: install ok installed
Architecture: i386
Multi-Arch: foreign

Package: bison
Architecture: amd64
Multi-Arch: foreign

$ ls /var/lib/dpkg/info/bison*.list
/var/lib/dpkg/info/bison.list

The properties screen for bison:amd64 (which is *not* installed) will display the installed files belonging to bison:i386.

Quick fix: determine whether the package is installed before looking for the files:

const char *RPackage::installedFiles()
{
static string filelist;
static string notInstalled = _("The list of installed files is only available for installed packages");
vector<string> sV;
string s;

if (!(getFlags() & FInstalled))
  return notInstalled.c_str();

[*] The sensible thing to do is not guess where dpkg stores the file list and instead call “dpkg -L PKGNAME”. There are various issues with that (in fact, even the released code has issues such as being ignorant of DPkg::Run-Directory), none of which will be addressed until after Wheezy.

lp:~evfool/synaptic/lp945997 updated
2117. By

Added check to see if package is installed

Revision history for this message
Robert Roth (evfool) wrote :

Updated proposal with the check for installed package.

Revision history for this message
Daniel Hartwig (wigs) wrote :

Looks ok to me, and suitable for now until improvements are made to the libapt–dpkg interface.

review: Approve

Unmerged revisions

2117. By

Added check to see if package is installed

2116. By Robert Roth

Fixed string searching issues based on review feedback

2115. By Robert Roth

Fixed installed files listing for multiarch packages (LP: #945997)

2114. By Robert Roth

Made installed version and available version in the embedded package properties pane selectable (LP: #173464)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'common/rpackage.cc'
2--- common/rpackage.cc 2012-07-12 20:03:08 +0000
3+++ common/rpackage.cc 2012-11-23 09:19:20 +0000
4@@ -213,16 +213,29 @@
5 const char *RPackage::installedFiles()
6 {
7 static string filelist;
8+ static string notInstalled = _("The list of installed files is only available for installed packages");
9 vector<string> sV;
10 string s;
11
12 filelist.erase(filelist.begin(), filelist.end());
13
14+ if (!(getFlags() || FInstalled)) {
15+ return notInstalled.c_str();
16+ }
17 // try normal file first
18- string f = "/var/lib/dpkg/info/" + string(name()) + ".list";
19- // try multiarch name next
20- if (!FileExists(f))
21- f = "/var/lib/dpkg/info/" + string(name()) + ":" + arch() + ".list";
22+ string namestr = string(name());
23+ string f = "/var/lib/dpkg/info/" + namestr + ".list";
24+ if (!FileExists(f)) {
25+ // truncate the multiarch suffix if exists, add it if it does not exist
26+ // to make sure we have tried both multiarch suffixed and simple package name
27+ string::size_type index = namestr.find_first_of(":");
28+ if (index != string::npos) {
29+ namestr = namestr.substr(0, index);
30+ } else {
31+ namestr = namestr + ":" + arch();
32+ }
33+ f = "/var/lib/dpkg/info/" + namestr + ".list";
34+ }
35 if (FileExists(f)) {
36 ifstream in(f.c_str());
37 if (!in != 0)
38@@ -237,9 +250,7 @@
39
40 return filelist.c_str();
41 }
42- filelist = _("The list of installed files is only available for installed packages");
43-
44- return filelist.c_str();
45+ return notInstalled.c_str();
46 }
47 #else
48 const char *RPackage::installedFiles()
49
50=== modified file 'gtk/gtkbuilder/window_main.ui'
51--- gtk/gtkbuilder/window_main.ui 2012-11-21 19:37:43 +0000
52+++ gtk/gtkbuilder/window_main.ui 2012-11-23 09:19:20 +0000
53@@ -1511,6 +1511,7 @@
54 <property name="visible">True</property>
55 <property name="can_focus">False</property>
56 <property name="xalign">0</property>
57+ <property name="selectable">True</property>
58 </object>
59 <packing>
60 <property name="left_attach">1</property>
61@@ -1644,6 +1645,7 @@
62 <property name="visible">True</property>
63 <property name="can_focus">False</property>
64 <property name="xalign">0</property>
65+ <property name="selectable">True</property>
66 </object>
67 <packing>
68 <property name="left_attach">1</property>

Subscribers

People subscribed via source and target branches

to status/vote changes: