Merge lp:~jibel/synaptic/bug.153966.452564 into lp:synaptic

Proposed by Jean-Baptiste Lallement
Status: Merged
Merged at revision: 1771
Proposed branch: lp:~jibel/synaptic/bug.153966.452564
Merge into: lp:synaptic
Diff against target: 224 lines (+123/-45)
3 files modified
common/rpackage.cc (+59/-32)
common/rpackage.h (+3/-0)
debian/patches/01_ubuntu_changelog.dpatch (+61/-13)
To merge this branch: bzr merge lp:~jibel/synaptic/bug.153966.452564
Reviewer Review Type Date Requested Status
synaptic-developers Pending
Review via email: mp+23429@code.launchpad.net

Description of the change

Tested with changelogs.ubuntu.com and medibuntu repo.

2 points still remains and need a fix:
- TODO: Need to use supportedOrigins instead of hard coded "Ubuntu". This is a problem for Debian.
- BUG: When pkgAcquire::Run() fails the item is not dequeued. Only visible if a changelog completely failed and the next succeeded, the messages are overwritten in the changelog dialog.

help would be much appreciated.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks, diff looks good. For the todos:
1) is not too bad, the hardcoded value is there, but its all about LP, should prbably be a patch or a distro specific thing, but ok for now
2) sounds like a bug in libapt actually :/ Do you have steps to reproduce?

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks! I merged it into the lucid branch, the next step is to merge into trunk/ and upload to debian.

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 2010-02-17 22:12:04 +0000
3+++ common/rpackage.cc 2010-04-14 20:00:37 +0000
4@@ -892,49 +892,76 @@
5 return filename;
6 }
7
8-
9-string RPackage::getChangelogFile(pkgAcquire *fetcher)
10+string RPackage::getChangelogURI()
11 {
12- string prefix;
13- string srcpkg = srcPackage();
14- string descr("Changelog for ");
15- descr+=name();
16-
17- string src_section=section();
18- if(src_section.find('/')!=src_section.npos)
19- src_section=string(src_section, 0, src_section.find('/'));
20- else
21- src_section="main";
22-
23- prefix+=srcpkg[0];
24- if(srcpkg.size()>3 && srcpkg[0]=='l' && srcpkg[1]=='i' && srcpkg[2]=='b')
25- prefix=std::string("lib")+srcpkg[3];
26-
27- string verstr;
28- if(availableVersion() != NULL)
29- verstr = availableVersion();
30-
31- if(verstr.find(':')!=verstr.npos)
32- verstr=string(verstr, verstr.find(':')+1);
33 char uri[512];
34- snprintf(uri,512,"http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog",
35+ //FIXME: get the supportedOrigins from pkgStatus
36+ if(origin() == "Debian") {
37+ string prefix;
38+ string srcpkg = srcPackage();
39+
40+ string src_section=section();
41+ if(src_section.find('/')!=src_section.npos)
42+ src_section=string(src_section, 0, src_section.find('/'));
43+ else
44+ src_section="main";
45+
46+ prefix+=srcpkg[0];
47+ if(srcpkg.size()>3 && srcpkg[0]=='l' && srcpkg[1]=='i' && srcpkg[2]=='b')
48+ prefix=std::string("lib")+srcpkg[3];
49+
50+ string verstr;
51+ if(availableVersion() != NULL)
52+ verstr = availableVersion();
53+
54+ if(verstr.find(':')!=verstr.npos)
55+ verstr=string(verstr, verstr.find(':')+1);
56+
57+ snprintf(uri,512,"http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog",
58 src_section.c_str(),
59 prefix.c_str(),
60 srcpkg.c_str(),
61 srcpkg.c_str(),
62 verstr.c_str());
63-
64- //cout << "uri is: " << uri << endl;
65-
66+ } else {
67+ string pkgfilename = findTagFromPkgRecord("Filename");
68+ pkgfilename = pkgfilename.substr(0, pkgfilename.find_last_of('.')) + ".changelog";
69+ snprintf(uri,512,"http://%s/%s",
70+ getCandidateOriginSiteUrl().c_str(),
71+ pkgfilename.c_str());
72+ }
73+ return string(uri);
74+}
75+
76+string RPackage::getChangelogFile(pkgAcquire *fetcher)
77+{
78+ string descr("Changelog for ");
79+ descr+=name();
80+
81+ string uri = getChangelogURI();
82 // no need to translate this, the changelog is in english anyway
83 string filename = RTmpDir()+"/tmp_cl";
84+
85+ new pkgAcqFileSane(fetcher, uri, descr, name(), filename);
86+ //cerr << "**DEBUG** origin: " << origin() << endl;
87+ //cerr << "**DEBUG** uri: " << uri << endl;
88+ //cerr << "**DEBUG** filename: " << filename << endl;
89+
90 ofstream out(filename.c_str());
91- out << "Failed to fetch the changelog for " << name() << endl;
92- out << "URI was: " << uri << endl;
93+ if(fetcher->Run() == pkgAcquire::Failed) {
94+ out << "Failed to download the list of changes. " << endl;
95+ out << "Please check your Internet connection." << endl;
96+ // FIXME: Need to dequeue the item
97+ } else {
98+ struct stat filestatus;
99+ stat(filename.c_str(), &filestatus );
100+ if (filestatus.st_size == 0) {
101+ out << "This change is not coming from a source that supports changelogs.\n" << endl;
102+ out << "Failed to fetch the changelog for " << name() << endl;
103+ out << "URI was: " << uri << endl;
104+ }
105+ };
106 out.close();
107- new pkgAcqFileSane(fetcher, uri, descr, name(), filename);
108-
109- fetcher->Run();
110
111 return filename;
112 }
113
114=== modified file 'common/rpackage.h'
115--- common/rpackage.h 2010-01-25 10:17:45 +0000
116+++ common/rpackage.h 2010-04-14 20:00:37 +0000
117@@ -244,6 +244,9 @@
118 RPackage(RPackageLister *lister, pkgDepCache *depcache,
119 pkgRecords *records, pkgCache::PkgIterator &pkg);
120 ~RPackage();
121+
122+ private:
123+ string getChangelogURI();
124 };
125
126
127
128=== modified file 'debian/patches/01_ubuntu_changelog.dpatch'
129--- debian/patches/01_ubuntu_changelog.dpatch 2009-06-04 16:12:33 +0000
130+++ debian/patches/01_ubuntu_changelog.dpatch 2010-04-14 20:00:37 +0000
131@@ -5,19 +5,58 @@
132 ## DP: No description.
133
134 @DPATCH@
135-diff -urNad synaptic-0.56/common/rpackage.cc /tmp/dpep.Ri9fRS/synaptic-0.56/common/rpackage.cc
136---- synaptic-0.56/common/rpackage.cc 2005-02-18 13:28:43.000000000 +0100
137-+++ /tmp/dpep.Ri9fRS/synaptic-0.56/common/rpackage.cc 2005-02-18 14:39:17.005309176 +0100
138-@@ -810,7 +810,7 @@
139- if(verstr.find(':')!=verstr.npos)
140- verstr=string(verstr, verstr.find(':')+1);
141+diff -urNad bug.153966.452564~/common/rpackage.cc bug.153966.452564/common/rpackage.cc
142+--- bug.153966.452564~/common/rpackage.cc 2010-04-14 00:16:09.000000000 +0200
143++++ bug.153966.452564/common/rpackage.cc 2010-04-14 00:20:52.000000000 +0200
144+@@ -896,7 +896,7 @@
145+ {
146 char uri[512];
147-- snprintf(uri,512,"http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog",
148-+ snprintf(uri,512,"http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/changelog",
149+ //FIXME: get the supportedOrigins from pkgStatus
150+- if(origin() == "Debian") {
151++ if(origin() == "Ubuntu") {
152+ string prefix;
153+ string srcpkg = srcPackage();
154+
155+@@ -917,7 +917,7 @@
156+ if(verstr.find(':')!=verstr.npos)
157+ verstr=string(verstr, verstr.find(':')+1);
158+
159+- snprintf(uri,512,"http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog",
160++ snprintf(uri,512,"http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/changelog",
161 src_section.c_str(),
162 prefix.c_str(),
163 srcpkg.c_str(),
164-@@ -1293,7 +1293,7 @@
165+@@ -956,9 +956,23 @@
166+ struct stat filestatus;
167+ stat(filename.c_str(), &filestatus );
168+ if (filestatus.st_size == 0) {
169+- out << "This change is not coming from a source that supports changelogs.\n" << endl;
170+- out << "Failed to fetch the changelog for " << name() << endl;
171+- out << "URI was: " << uri << endl;
172++ // FIXME: Use supportedOrigins
173++ if(origin() == "Ubuntu") {
174++ string verstr;
175++ if(availableVersion() != NULL)
176++ verstr = availableVersion();
177++
178++ if(verstr.find(':')!=verstr.npos)
179++ verstr=string(verstr, verstr.find(':')+1);
180++ out << "The list of changes is not available yet.\n" << endl;
181++ out << "Please use http://launchpad.net/ubuntu/+source/"<< srcPackage() <<
182++ "/" << verstr << "/+changelog" << endl;
183++ out << "until the changes become available or try again later." << endl;
184++ } else {
185++ out << "This change is not coming from a source that supports changelogs.\n" << endl;
186++ out << "Failed to fetch the changelog for " << name() << endl;
187++ out << "URI was: " << uri << endl;
188++ }
189+ }
190+ };
191+ out.close();
192+diff -urNad bug.153966.452564~/common/rpackagestatus.cc bug.153966.452564/common/rpackagestatus.cc
193+--- bug.153966.452564~/common/rpackagestatus.cc 2010-04-13 23:31:39.000000000 +0200
194++++ bug.153966.452564/common/rpackagestatus.cc 2010-04-14 00:18:59.000000000 +0200
195+@@ -69,7 +69,7 @@
196 markUnsupported = true;
197
198 // read supported labels
199@@ -26,12 +65,21 @@
200 stringstream sst1(labels);
201 while(!sst1.eof()) {
202 sst1 >> s;
203-@@ -1301,7 +1301,7 @@
204+@@ -77,7 +77,7 @@
205+ }
206+
207+ // read supported origins
208+- origin = _config->Find("Synaptic::supported-origins", "Debian");
209++ origin = _config->Find("Synaptic::supported-origins", "Ubuntu");
210+ stringstream sst2(origin);
211+ while(!sst2.eof()) {
212+ sst2 >> s;
213+@@ -85,7 +85,7 @@
214 }
215
216 // read supported components
217 - components = _config->Find("Synaptic::supported-components", "main updates/main");
218 + components = _config->Find("Synaptic::supported-components", "main updates/main restricted");
219- stringstream sst2(components);
220- while(!sst2.eof()) {
221- sst2 >> s;
222+ stringstream sst3(components);
223+ while(!sst3.eof()) {
224+ sst3 >> s;

Subscribers

People subscribed via source and target branches

to status/vote changes: