Merge lp:~manchicken/kubuntu-debug-installer/kubuntu-debug-installer into lp:kubuntu-debug-installer

Proposed by Michael D. Stemle, Jr.
Status: Superseded
Proposed branch: lp:~manchicken/kubuntu-debug-installer/kubuntu-debug-installer
Merge into: lp:kubuntu-debug-installer
Diff against target: 551 lines (+396/-12)
8 files modified
src/CMakeLists.txt (+2/-0)
src/DebugFinder.cpp (+140/-6)
src/DebugFinder.h (+28/-4)
src/DebugInstaller.cpp (+3/-2)
src/LSBRelease.cpp (+66/-0)
src/LSBRelease.h (+43/-0)
src/QAptDecorator.cpp (+80/-0)
src/QAptDecorator.h (+34/-0)
To merge this branch: bzr merge lp:~manchicken/kubuntu-debug-installer/kubuntu-debug-installer
Reviewer Review Type Date Requested Status
Harald Sitter Needs Fixing
Jonathan Thomas Pending
Review via email: mp+176318@code.launchpad.net

This proposal supersedes a proposal from 2013-07-17.

This proposal has been superseded by a proposal from 2013-07-27.

Description of the change

This includes the reloadCache() call that JT recommended.

To post a comment you must log in.
Revision history for this message
Philip Muškovac (yofel) wrote : Posted in a previous version of this proposal

I only took a quick glance on the merge, but I think you missed the "release" repository. You have X-updates, X-security and X-proposed, but I see no place where you add X without a suffix

Revision history for this message
Michael D. Stemle, Jr. (manchicken) wrote : Posted in a previous version of this proposal

I've added that base repository now, please re-review.

Revision history for this message
Jonathan Thomas (echidnaman) wrote : Posted in a previous version of this proposal

One comment, when the cache update transaction finishes, you'll need to call m_backend->reload() to ensure the new package is available. (Build a new cache based on the new source info) Strange things can happen if you don't.

Looks good otherwise. Sorry for the delay in reviewing; real life has been a bit crazy lately...

review: Needs Fixing
Revision history for this message
Harald Sitter (apachelogger) wrote :

Do you want a codestyle review as well? Because I am really good at that :P

Also, Jonathan, what is up with the decorator. It looks like libqapt got shot in the head and now its brainz are spread all over debug-installer's code :O

Revision history for this message
Michael D. Stemle, Jr. (manchicken) wrote :

On Jul 23, 2013 2:53 AM, "Harald Sitter" <email address hidden> wrote:
>
> Do you want a codestyle review as well? Because I am really good at that
:P

I'll accept style criticism as long as there's a "why" which isn't
arbitrary :-)

>
> Also, Jonathan, what is up with the decorator. It looks like libqapt got
shot in the head and now its brainz are spread all over debug-installer's
code :O

QApt doesn't have error strings, I put that decorator there to give me some
(credit to JT, I did just sin and paste it mostly verbatim).

> --
>
https://code.launchpad.net/~manchicken/kubuntu-debug-installer/kubuntu-debug-installer/+merge/176318
> You are the owner of
lp:~manchicken/kubuntu-debug-installer/kubuntu-debug-installer.

Revision history for this message
Harald Sitter (apachelogger) wrote :

Yeah I don't think that decorator thing makes sense at all, but that's a library thing and libqapts fault really. Why would every application using qapt have to carry a verbatim code copy with strings around?

As for style... here comes the style PITA police :P

Please note that we use 4 space indent in the source code. Also please review your added includes, just from looking at the diff it seems like they are not actually all necessary.

> m_txn = NULL;

By convention we use 0 in Qt software. No clue what a txn is, perhaps a more descriptive name would be good.

> QString headerText = i18n("<b>Adding debug symbol sources</b>");

please have a look at i18nc [1] and in particular you'd want to get rid of the <b> and use <title> for example [2]. this applies to the entire diff.

also, why not simply merge the i18nc() into the next line
m_progress.setLabelText(i18nc(...));

and on that note I would make m_progress a pointer to get it out of the header for compile time's sake and to reduce overall startup workload

> hcRepoList

same as with m_txn, no clue what hc stands for....

> QString(DDEB_REPO_FILE)

constructing using QString::fromLatin1(..) is faster.

> int sourceCount = sourceList.entries().count();

I reckon this value is const, yet the code doesn't say so.

> foreach (QApt::SourceEntry repo, hcRepoList)

Not sure whether that is possible, but generally speaking that should be const QApt::SourceEntry &repo to avoid pointless copying.

By convention this should be foreach (...) { ... i.e. opening angle braces on the same line [3]

> m_srcUpdated

variable name again, I guess this should be something like m_srcsListUpdated

> this->find();

convention again, no this unless necessary.

> int m_srcCount;

unused it seems

> add_definitions(-DKDE_DEFAULT_DEBUG_AREA=8675309)

I don't think we'd want a set debug area (seems unnecessary and is only advised for libs/plugins), at any rate we'd not want a static debug area but register one dynamically [4]

> headerText = i18n("<b>Downloading Packages</b>");
like above and indeed it seems like not using headertext to begin with would be a good idea

[1] http://techbase.kde.org/Development/Tutorials/Localization/i18n#Adding_Context_with_i18nc.28.29
[2] http://techbase.kde.org/Development/Tutorials/Localization/i18n_Semantics
[3] https://wiki.kubuntu.org/Kubuntu/Specs/MaverickCodestylePolicy
[4] http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKDebug.html#a40c55b7ae17e62f18fa5e44349496e33

Revision history for this message
Michael D. Stemle, Jr. (manchicken) wrote :

Doh. I'll be making many of the changes you mentioned. I'll make them
Saturday. Do we have the ability to test now so we can see if it works like
we want it to? I want to get as much lined up for my hackathon Saturday as
I can.
On Jul 24, 2013 4:33 PM, "Harald Sitter" <email address hidden> wrote:

> Yeah I don't think that decorator thing makes sense at all, but that's a
> library thing and libqapts fault really. Why would every application using
> qapt have to carry a verbatim code copy with strings around?
>
> As for style... here comes the style PITA police :P
>
> Please note that we use 4 space indent in the source code. Also please
> review your added includes, just from looking at the diff it seems like
> they are not actually all necessary.
>
> > m_txn = NULL;
>
> By convention we use 0 in Qt software. No clue what a txn is, perhaps a
> more descriptive name would be good.
>
> > QString headerText = i18n("<b>Adding debug symbol sources</b>");
>
> please have a look at i18nc [1] and in particular you'd want to get rid of
> the <b> and use <title> for example [2]. this applies to the entire diff.
>
> also, why not simply merge the i18nc() into the next line
> m_progress.setLabelText(i18nc(...));
>
> and on that note I would make m_progress a pointer to get it out of the
> header for compile time's sake and to reduce overall startup workload
>
> > hcRepoList
>
> same as with m_txn, no clue what hc stands for....
>
> > QString(DDEB_REPO_FILE)
>
> constructing using QString::fromLatin1(..) is faster.
>
> > int sourceCount = sourceList.entries().count();
>
> I reckon this value is const, yet the code doesn't say so.
>
> > foreach (QApt::SourceEntry repo, hcRepoList)
>
> Not sure whether that is possible, but generally speaking that should be
> const QApt::SourceEntry &repo to avoid pointless copying.
>
> By convention this should be foreach (...) { ... i.e. opening angle
> braces on the same line [3]
>
> > m_srcUpdated
>
> variable name again, I guess this should be something like
> m_srcsListUpdated
>
> > this->find();
>
> convention again, no this unless necessary.
>
> > int m_srcCount;
>
> unused it seems
>
> > add_definitions(-DKDE_DEFAULT_DEBUG_AREA=8675309)
>
> I don't think we'd want a set debug area (seems unnecessary and is only
> advised for libs/plugins), at any rate we'd not want a static debug area
> but register one dynamically [4]
>
> > headerText = i18n("<b>Downloading Packages</b>");
> like above and indeed it seems like not using headertext to begin with
> would be a good idea
>
> [1]
> http://techbase.kde.org/Development/Tutorials/Localization/i18n#Adding_Context_with_i18nc.28.29
> [2]
> http://techbase.kde.org/Development/Tutorials/Localization/i18n_Semantics
> [3] https://wiki.kubuntu.org/Kubuntu/Specs/MaverickCodestylePolicy
> [4]
> http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKDebug.html#a40c55b7ae17e62f18fa5e44349496e33
> --
>
> https://code.launchpad.net/~manchicken/kubuntu-debug-installer/kubuntu-debug-installer/+merge/176318
> You are the owner of
> lp:~manchicken/kubuntu-debug-installer/kubuntu-debug-installer.
>

Revision history for this message
Harald Sitter (apachelogger) wrote :

mh I'll do some QA (been doing that all morning anyway :S)

fwiw, I think I changed some stuff in my LSBRelease, also you may want to use the q_asserts :P

Revision history for this message
Harald Sitter (apachelogger) wrote :
Download full text (4.4 KiB)

krazy2 Analysis

Checkers Run = 39
Files Processed = 37
Total Issues = 13 ...as of July 25 2013 15:07:17 CEST

== messages: For File Type messages ==
1. Check for appending to rc.cpp [rcappend]... Ok!

== cmake: For File Type cmake ==
1. Check for an acceptable copyright [copyright]... Ok!

2. Check that file ends with a newline [endswithnewline]... Ok!

3. Check for an acceptable license [license]... Ok!

4. Check for spelling errors [spelling]... Ok!

== c++: For File Type c++ ==
1. Check for TRUE and FALSE macros [captruefalse]... Ok!

2. Check for methods that return 'const' refs in public classes [constref]... Ok!

3. Check for an acceptable copyright [copyright]... Ok!

4. Check for cpp macros and usage [cpp]... Ok!

5. Check for code that should be considered crashy. [crashy]... Ok!

6. Check single-char QString operations for efficiency [doublequote_chars]... Ok!

7. Check for unwanted doxygen tags in major versions [doxytags]... Ok!

8. Check public classes with private members or d-pointer issues [dpointer]... Ok!

9. Check for QString compares to "" [emptystrcompare]... Ok!

10. Check that file ends with a newline [endswithnewline]... 2 issues found
        ./src/QAptDecorator.cpp: line# 80 (1)
        ./src/LSBRelease.cpp: line# 66 (1)
        Files that do not end with a newline character can cause problems.
        Please add a newline character to the end of the file.

11. Check for C++ ctors that should be declared 'explicit' [explicit]... Ok!

12. Check for foreach loop issues [foreach]... 1 issue found
        ./src/DebugFinder.cpp: non-const ref iterator line#136 (1)
        When not using POD types (int, double, pointer, ...) you should use
        const & for your foreach variables. There are two reasons for this:
        1) Prevents you from the mistake of writing foreach loops that
        modify the list, that is 'foreach(Foo f, list) f.a = f.b = f.c =
        0;' compiles but does not modify the contents of list 2) Saves a
        copy constructor call for each of the list elements

13. Check validity of i18n calls [i18ncheckarg]... 9 issues found
        ./src/LSBRelease.cpp: single adjective as message, probably ambiguous; explain what it refers to following the KUIT context marker line#33
        ./src/DebugFinder.cpp: missing KUIT context marker line#116,196,200,207
        ./src/DebugFinder.cpp: HTML tag 'b' is not advised with KUIT markup line#116,196,200,207
        Make the translators' job easier and detect problems in the usage
        of the i18n() calls. When the fix is not clear, check the Techbase
        article at
        <http://techbase.kde.org/Development/Tutorials/Localization/i18n_Kr
        azy> for more information.

14. Check for invalid icon names [iconnames]... Ok!

15. Check for proper include directives [includes]... 1 issue found
        ./src/QAptDecorator.cpp: include own header first line#26
        Use <..> to include installed headers; cpp file should include
        their own headers first (but below config.h); other rules apply,
        see
        <http://techbase.kde.org/Policies/Library_Code_Policy#Getting_.23in
        cludes_right>. Use include guards in headers with appropriat...

Read more...

Revision history for this message
Michael D. Stemle, Jr. (manchicken) wrote :

Maybe we should package the LSB stuff into its own thing so we can link to
it.
On Jul 25, 2013 8:07 AM, "Harald Sitter" <email address hidden> wrote:

> mh I'll do some QA (been doing that all morning anyway :S)
>
> fwiw, I think I changed some stuff in my LSBRelease, also you may want to
> use the q_asserts :P
>
>
> --
>
> https://code.launchpad.net/~manchicken/kubuntu-debug-installer/kubuntu-debug-installer/+merge/176318
> You are the owner of
> lp:~manchicken/kubuntu-debug-installer/kubuntu-debug-installer.
>

Revision history for this message
Harald Sitter (apachelogger) wrote :

please have a look at the cmake macro macro_ensure_version to make sure an appropriate version of libqapt is installed [1]

[1] https://projects.kde.org/projects/kdesupport/phonon/phonon-gstreamer/repository/revisions/master/entry/CMakeLists.txt#L8

Revision history for this message
Harald Sitter (apachelogger) wrote :

clang-analyzer is happy

Revision history for this message
Michael D. Stemle, Jr. (manchicken) wrote :

That may be tricky until JT gets libqapt ready, yeah?
On Jul 25, 2013 8:21 AM, "Harald Sitter" <email address hidden> wrote:

> please have a look at the cmake macro macro_ensure_version to make sure an
> appropriate version of libqapt is installed [1]
>
> [1]
> https://projects.kde.org/projects/kdesupport/phonon/phonon-gstreamer/repository/revisions/master/entry/CMakeLists.txt#L8
> --
>
> https://code.launchpad.net/~manchicken/kubuntu-debug-installer/kubuntu-debug-installer/+merge/176318
> You are the owner of
> lp:~manchicken/kubuntu-debug-installer/kubuntu-debug-installer.
>

Revision history for this message
Harald Sitter (apachelogger) wrote :

smoke results:

- clicked cancel while it was 'updating software softwares' -> cancels only that so it continues looking for debug packages
- adds ddebs entires regardless of whether they are there already
- repeatedly going from 0 to 100 % progress while saying "Updating software sources" is confusing
- debug output needs serious reduction as right now it is flooding .xsession-errors with a bazillion percent values when in debug mode
- canceling the authenticate for the software source changes makes the dailog re-appear, canceling again makes it appear again etc.etc. (in short: there is no way to get rid of it other than actually providing credentials)
- entries to ddebs.list are added 4 times, i.e. after one run I get 4 saucy, 4 saucy-updates, 4 saucy-security etc.etc.
- the update software sources dialog should probably reuse the existing one instead of creating a new one, as it is right now a user will get up to 4 cascaded windows (drkonqi < dbginstallerdialog < debugfinder < software sources)
- when the installer ask whether the new dbg packages should be installed and one cancels the application doesn't actually exit() or anything (also not when actually looking for the packages - may actually be entirely un-exitable)
- conseqeuently to above (presumably) the ddebs.list file is not removed on exit etc.
- entries to ddebs.list are added regardless of whether they are already there, i.e. every run another 4x4 entires will be added to the file
- not sure this is related to the chnanges but worrying regardless....when looking for rekonq and qt the finder will only offer to install libqt4-dbg (no clue why it goes for that, but IIRC we may have special handling that makes that happen), removing the qt bits form the file list will make it recommend rekonq-dbgsym as well

testing cmd:
kubuntu-debug-installer "/usr/bin/rekonq" "/usr/lib/x86_64-linux-gnu/libQtCore.so.4" "/usr/lib/kde4/libkdeinit/libkdeinit4_rekonq.so" "/usr/lib/x86_64-linux-gnu/libQtGui.so.4

Revision history for this message
Harald Sitter (apachelogger) wrote :

About the LSB thing... /etc/lsb-release is not backed by a spec or anything and long-term will be replaced by /etc/os-release which is backed by a spec so I should hope that we get a KDElibs way to get os-release data. So, I am not sure it is worth the effort TBH.

Revision history for this message
Harald Sitter (apachelogger) wrote :

QA done :P

review: Needs Fixing
Revision history for this message
Harald Sitter (apachelogger) wrote :

> That may be tricky until JT gets libqapt ready, yeah?

Yes. No. Maybe. :P

It seems to me libqapt 2.0.65 has the sourceslist API so I guess that would be the required version right now.

I just did the analysis, how/whether the issue can be resolved or whether they were even caused by the diff at hand, I did not look at ;)

Revision history for this message
Michael D. Stemle, Jr. (manchicken) wrote :

OK. My hackathon is Saturday the 27th at 12:30 for four hours (in
Champaign, IL USA if anyone wants to join), I should be able to get
something done.
On Jul 25, 2013 8:54 AM, "Harald Sitter" <email address hidden> wrote:

> > That may be tricky until JT gets libqapt ready, yeah?
>
> Yes. No. Maybe. :P
>
> It seems to me libqapt 2.0.65 has the sourceslist API so I guess that
> would be the required version right now.
>
> I just did the analysis, how/whether the issue can be resolved or whether
> they were even caused by the diff at hand, I did not look at ;)
> --
>
> https://code.launchpad.net/~manchicken/kubuntu-debug-installer/kubuntu-debug-installer/+merge/176318
> You are the owner of
> lp:~manchicken/kubuntu-debug-installer/kubuntu-debug-installer.
>

105. By Michael D. Stemle, Jr. <email address hidden>

Made a series of changes requested by Harold.

106. By Michael D. Stemle, Jr. <email address hidden>

Fixed some text formatting.

107. By Michael D. Stemle, Jr. <email address hidden>

Fixed some code indentation.

108. By Michael D. Stemle, Jr. <email address hidden>

Made a number of changes per Harald's list: https://code.launchpad.net/~manchicken/kubuntu-debug-installer/kubuntu-debug-installer/+merge/177273/comments/399863

Unmerged revisions

108. By Michael D. Stemle, Jr. <email address hidden>

Made a number of changes per Harald's list: https://code.launchpad.net/~manchicken/kubuntu-debug-installer/kubuntu-debug-installer/+merge/177273/comments/399863

107. By Michael D. Stemle, Jr. <email address hidden>

Fixed some code indentation.

106. By Michael D. Stemle, Jr. <email address hidden>

Fixed some text formatting.

105. By Michael D. Stemle, Jr. <email address hidden>

Made a series of changes requested by Harold.

104. By Michael D. Stemle, Jr. <email address hidden>

Made change per JT's recommendation.

103. By Michael D. Stemle, Jr. <email address hidden>

Added the base repo.

102. By Michael D. Stemle, Jr. <email address hidden>

Fixed a small bug when debug packages weren't found.

101. By Michael D. Stemle, Jr. <email address hidden>

Added the changes for sources.list and refreshing cache: https://wiki.ubuntu.com/DebuggingProgramCrash#Debug_Symbol_Packages

100. By Michael D. Stemle, Jr. <email address hidden>

I now have the sources add working.

99. By Michael D. Stemle, Jr. <email address hidden>

Adding LSB stuff from Herald Sitter (THANKS!) and adding some code to set up repos.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CMakeLists.txt'
2--- src/CMakeLists.txt 2010-09-16 14:19:01 +0000
3+++ src/CMakeLists.txt 2013-07-27 22:26:24 +0000
4@@ -2,6 +2,8 @@
5 include_directories(${CMAKE_CURRENT_BINARY_DIR})
6
7 set(installdbgsymbols_SRCS
8+ QAptDecorator.cpp
9+ LSBRelease.cpp
10 DebugFinder.cpp
11 DebugInstaller.cpp
12 main.cpp
13
14=== modified file 'src/DebugFinder.cpp'
15--- src/DebugFinder.cpp 2012-10-30 15:16:47 +0000
16+++ src/DebugFinder.cpp 2013-07-27 22:26:24 +0000
17@@ -2,6 +2,7 @@
18 Copyright © 2010 Harald Sitter <apachelogger@ubuntu.com>
19 Copyright © 2010 Felix Geyer <debfx@fobos.de>
20 Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org>
21+ Copyright © 2013 Michael D. Stemle, Jr. <themanchicken@gmail.com>
22
23 This program is free software; you can redistribute it and/or
24 modify it under the terms of the GNU General Public License as
25@@ -21,18 +22,29 @@
26 */
27
28 #include "DebugFinder.h"
29-
30-#include <QtCore/QStringList>
31-#include <QtCore/QThread>
32+#include "LSBRelease.h"
33+#include "QAptDecorator.h"
34
35 #include <LibQApt/Backend>
36+#include <LibQApt/SourceEntry>
37+#include <LibQApt/SourcesList>
38+#include <LibQApt/Transaction>
39+#include <iostream>
40+
41+#include <KDebug>
42+#include <KLocalizedString>
43+#include <KMessageBox>
44
45 DebugFinder::DebugFinder(QObject *parent) :
46 QObject(parent),
47 m_backend(new QApt::Backend(this)),
48+ m_progress(new KProgressDialog()),
49 m_stop(false)
50 {
51+ kDebug() << "INIT!!!!!\n";
52 m_backend->init();
53+
54+ m_aptTxn = 0;
55 }
56
57 QApt::Package *DebugFinder::getDbgPkg(QApt::Package *package)
58@@ -69,17 +81,18 @@
59 return 0;
60 }
61
62-void DebugFinder::find(const QString &file)
63+void DebugFinder::find()
64 {
65 if (m_stop) {
66 return;
67 }
68
69- QApt::Package *package = m_backend->packageForFile(file);
70+ QApt::Package *package = m_backend->packageForFile(m_file);
71
72 QApt::Package *dbgPkg = getDbgPkg(package);
73 if (!dbgPkg) {
74- emit foundNoDbgPkg(file);
75+ kDebug() << "No debug package found for: " << m_file;
76+ emit foundNoDbgPkg(m_file);
77 } else if (dbgPkg->isInstalled()) {
78 emit alreadyInstalled();
79 } else {
80@@ -91,3 +104,124 @@
81 {
82 m_stop = true;
83 }
84+
85+void DebugFinder::startFinding(const QString &file)
86+{
87+ m_progress->setLabelText(i18nc("@title:dialog", "Adding debug symbol sources"));
88+ m_file = file;
89+ connect(this, SIGNAL(updateFinishing()), this, SLOT(onUpdateFinished()));
90+// connect(this, SIGNAL(sourcesModificationFinished()), m_backend, SLOT(updateCache()));
91+
92+ // Construct our list hard-coded sources...
93+ LSBRelease lsb;
94+ QString codename(lsb.codename());
95+ QApt::SourceEntryList hardCodedRepoList;
96+ hardCodedRepoList.append(QApt::SourceEntry(QString(REPO_ARG_BASE).arg(codename), QString(DDEB_REPO_FILE)));
97+ hardCodedRepoList.append(QApt::SourceEntry(QString(REPO_ARG_UPDATES).arg(codename), QString(DDEB_REPO_FILE)));
98+ hardCodedRepoList.append(QApt::SourceEntry(QString(REPO_ARG_SECURITY).arg(codename), QString(DDEB_REPO_FILE)));
99+ hardCodedRepoList.append(QApt::SourceEntry(QString(REPO_ARG_PROPOSED).arg(codename), QString(DDEB_REPO_FILE)));
100+
101+ // First, see if the source exists...
102+ QApt::SourcesList sourceList(this);
103+
104+ const int sourceCount = sourceList.entries().count();
105+
106+ foreach (const QApt::SourceEntry &repo, hardCodedRepoList)
107+ {
108+ sourceList.addEntry(repo); // This method has a dup check
109+ }
110+ m_progress->progressBar()->setMaximum(100);
111+
112+ // If we affected the list, save!
113+ if (sourceList.entries().count() > sourceCount) {
114+ sourceList.save();
115+ kDebug() << "Entries saved, updating backend cache...";
116+
117+ m_aptTxn = m_backend->updateCache();
118+
119+ m_aptTxn->setLocale(QLatin1String(setlocale(LC_MESSAGES, 0)));
120+
121+ connect(m_progress, SIGNAL(cancelClicked()), m_aptTxn, SLOT(cancel()));
122+ connect(m_aptTxn, SIGNAL(errorOccurred(QApt::ErrorCode)), this, SLOT(onAptError(QApt::ErrorCode)));
123+ connect(m_aptTxn, SIGNAL(statusChanged(QApt::TransactionStatus)), this, SLOT(onTxnStatusChanged(QApt::TransactionStatus)));
124+ connect(m_aptTxn, SIGNAL(progressChanged(int)), this, SLOT(onProgressChanged(int)));
125+ connect(m_aptTxn, SIGNAL(finished(QApt::ExitStatus)), this, SLOT(onUpdateFinished()));
126+
127+ m_aptTxn->run();
128+ kDebug() << "FinishedStatus: " << QApt::FinishedStatus;
129+ } else {
130+ emit updateFinishing();
131+ }
132+
133+ kDebug() << "Done with startFinding()!";
134+}
135+
136+// The update is finished!
137+void DebugFinder::onUpdateFinished()
138+{
139+ kDebug() << "Done with updateCache(), reloading cache...";
140+ m_backend->reloadCache();
141+
142+ kDebug() << "I'm done.";
143+ m_progress->progressBar()->setValue(100);
144+
145+ find();
146+
147+ return;
148+}
149+
150+void DebugFinder::onTxnStatusChanged(QApt::TransactionStatus status)
151+{
152+ kDebug() << "cache widget: transaction status changed" << status;
153+
154+ if (!m_aptTxn) {
155+ kDebug() << "No valid transaction.";
156+ return;
157+ }
158+
159+ switch (status) {
160+ case QApt::DownloadingStatus:
161+ if (m_aptTxn->role() == QApt::UpdateCacheRole)
162+ {
163+ m_progress->setLabelText(i18nc("@title:dialog", "Updating software sources"));
164+ }
165+ else
166+ {
167+ m_progress->setLabelText(i18nc("@title:dialog", "Downloading Packages"));
168+ }
169+
170+ break;
171+
172+ case QApt::FinishedStatus:
173+ m_progress->setLabelText(i18nc("@title:dialog", "Finished."));
174+ break;
175+
176+ default:
177+ break;
178+ }
179+}
180+
181+void DebugFinder::onAptError(QApt::ErrorCode errcode)
182+{
183+ QString errmsg = QAptDecorator::errorText(errcode, m_aptTxn);
184+ kDebug() << "Got an error: " << errmsg;
185+
186+ KMessageBox::error(
187+ NULL,
188+ i18nc("@info Error message", "Error updating sources"
189+ " after configuring debug sources"),
190+ i18nc("@title:window", "Failed updating sources")
191+ );
192+}
193+
194+void DebugFinder::onProgressChanged(int progress)
195+{
196+ kDebug() << "Progress changed to " << progress;
197+
198+ int presentProgress = progress;
199+
200+ if (progress >= 100) {
201+ presentProgress = 0;
202+ }
203+ m_progress->progressBar()->setValue(presentProgress);
204+}
205
206=== modified file 'src/DebugFinder.h'
207--- src/DebugFinder.h 2012-10-30 15:16:47 +0000
208+++ src/DebugFinder.h 2013-07-27 22:26:24 +0000
209@@ -1,6 +1,7 @@
210 /*
211 Copyright © 2010 Harald Sitter <apachelogger@ubuntu.com>
212 Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org>
213+ Copyright © 2013 Michael D. Stemle, Jr. <themanchicken@gmail.com>
214
215 This program is free software; you can redistribute it and/or
216 modify it under the terms of the GNU General Public License as
217@@ -22,13 +23,25 @@
218 #ifndef DEBUGFINDER_H
219 #define DEBUGFINDER_H
220
221+#include <LibQApt/Globals>
222+
223 #include <QtCore/QObject>
224 #include <QtCore/QStringList>
225+#include <KProgressDialog>
226+
227+#define REPO_ARG_BASE "deb http://ddebs.ubuntu.com %1 main restricted universe multiverse"
228+#define REPO_ARG_UPDATES "deb http://ddebs.ubuntu.com %1-updates main restricted universe multiverse"
229+#define REPO_ARG_SECURITY "deb http://ddebs.ubuntu.com %1-security main restricted universe multiverse"
230+#define REPO_ARG_PROPOSED "deb http://ddebs.ubuntu.com %1-proposed main restricted universe multiverse"
231+#define DDEB_REPO_FILE "/etc/apt/sources.list.d/ddebs.list"
232
233 namespace QApt {
234 class Backend;
235 class Package;
236-}
237+ class SourceEntry;
238+ class SourcesList;
239+ class Transaction;
240+};
241
242 class DebugFinder : public QObject
243 {
244@@ -36,18 +49,29 @@
245 public:
246 explicit DebugFinder(QObject *parent = 0);
247
248+ void performUpdate();
249+
250 public slots:
251- void find(const QString &file);
252+ void startFinding(const QString &file);
253+ void find();
254 void stop();
255-
256+ void onTxnStatusChanged(QApt::TransactionStatus status);
257+ void onAptError(QApt::ErrorCode errcode);
258+ void onUpdateFinished();
259+ void onProgressChanged(int progress);
260+
261 signals:
262 void foundDbgPkg(const QString &dbgpkg);
263- void foundNoDbgPkg(const QString &file);
264+ void foundNoDbgPkg(const QString &dbgpkg);
265 void alreadyInstalled();
266+ void updateFinishing();
267
268 private:
269 QApt::Package *getDbgPkg(QApt::Package *package);
270 QApt::Backend *m_backend;
271+ QApt::Transaction *m_aptTxn;
272+ KProgressDialog *m_progress;
273+ QString m_file;
274
275 bool m_stop;
276 };
277
278=== modified file 'src/DebugInstaller.cpp'
279--- src/DebugInstaller.cpp 2011-09-26 13:35:14 +0000
280+++ src/DebugInstaller.cpp 2013-07-27 22:26:24 +0000
281@@ -1,6 +1,7 @@
282 /*
283 Copyright © 2010 Harald Sitter <apachelogger@ubuntu.com>
284 Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org>
285+ Copyright © 2013 Michael D. Stemle, Jr. <themanchicken@gmail.com>
286
287 This program is free software; you can redistribute it and/or
288 modify it under the terms of the GNU General Public License as
289@@ -163,7 +164,7 @@
290 progressBar()->setMaximum(m_args.count());
291 incrementProgress();
292
293- m_finder = new DebugFinder;
294+ m_finder = new DebugFinder(this);
295 connect(m_finder, SIGNAL(foundDbgPkg(QString)), this, SLOT(foundDbgPkg(QString)));
296 connect(m_finder, SIGNAL(foundNoDbgPkg(QString)), this, SLOT(foundNoDbgPkg(QString)));
297 connect(m_finder, SIGNAL(alreadyInstalled()), this, SLOT(alreadyInstalled()));
298@@ -173,7 +174,7 @@
299 m_finderThread->start();
300
301 foreach (const QString &file, m_args) {
302- QMetaObject::invokeMethod(m_finder, "find", Qt::QueuedConnection,
303+ QMetaObject::invokeMethod(m_finder, "startFinding", Qt::QueuedConnection,
304 Q_ARG(QString, file));
305 }
306 }
307
308=== added file 'src/LSBRelease.cpp'
309--- src/LSBRelease.cpp 1970-01-01 00:00:00 +0000
310+++ src/LSBRelease.cpp 2013-07-27 22:26:24 +0000
311@@ -0,0 +1,66 @@
312+/*
313+ Copyright (C) 2012 Harald Sitter <apachelogger@ubuntu.com>
314+
315+ This program is free software; you can redistribute it and/or
316+ modify it under the terms of the GNU General Public License as
317+ published by the Free Software Foundation; either version 2 of
318+ the License or (at your option) version 3 or any later version
319+ accepted by the membership of KDE e.V. (or its successor approved
320+ by the membership of KDE e.V.), which shall act as a proxy
321+ defined in Section 14 of version 3 of the license.
322+
323+ This program is distributed in the hope that it will be useful,
324+ but WITHOUT ANY WARRANTY; without even the implied warranty of
325+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
326+ GNU General Public License for more details.
327+
328+ You should have received a copy of the GNU General Public License
329+ along with this program. If not, see <http://www.gnu.org/licenses/>.
330+*/
331+
332+#include "LSBRelease.h"
333+
334+#include <QtCore/QFile>
335+
336+#include <KDebug>
337+#include <KLocalizedString>
338+
339+LSBRelease::LSBRelease()
340+{
341+ QFile file("/etc/lsb-release");
342+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
343+ kDebug() << "Could not open /etc/lsb-release, aborting LSB";
344+ QString unknown = i18nc("@label", "Unknown");
345+ m_id = unknown;
346+ m_release = unknown;
347+ m_codename = unknown;
348+ m_description = unknown;
349+ return;
350+ }
351+
352+ // List of valid column identifiers
353+ QString line;
354+ QStringList comps;
355+ while (!file.atEnd()) {
356+ line = file.readLine();
357+ comps = line.split(QChar('='));
358+// #warning unknown set?
359+ Q_ASSERT(comps.size() == 2);
360+ QString key = comps.at(0);
361+ QString value = comps.at(1).trimmed();
362+ if (key == QLatin1String("DISTRIB_ID"))
363+ m_id = value;
364+ else if (key == QLatin1String("DISTRIB_RELEASE"))
365+ m_release = value;
366+ else if (key == QLatin1String("DISTRIB_CODENAME"))
367+ m_codename = value;
368+ else if (key == QLatin1String("DISTRIB_DESCRIPTION"))
369+ m_description = value;
370+ else
371+ Q_ASSERT(false); // Should not happen!
372+ }
373+
374+// #warning unknown set?
375+ if (m_id.isEmpty() || m_release.isEmpty())
376+ Q_ASSERT(false); // meh.
377+}
378\ No newline at end of file
379
380=== added file 'src/LSBRelease.h'
381--- src/LSBRelease.h 1970-01-01 00:00:00 +0000
382+++ src/LSBRelease.h 2013-07-27 22:26:24 +0000
383@@ -0,0 +1,43 @@
384+/*
385+ Copyright (C) 2012 Harald Sitter <apachelogger@ubuntu.com>
386+
387+ This program is free software; you can redistribute it and/or
388+ modify it under the terms of the GNU General Public License as
389+ published by the Free Software Foundation; either version 2 of
390+ the License or (at your option) version 3 or any later version
391+ accepted by the membership of KDE e.V. (or its successor approved
392+ by the membership of KDE e.V.), which shall act as a proxy
393+ defined in Section 14 of version 3 of the license.
394+
395+ This program is distributed in the hope that it will be useful,
396+ but WITHOUT ANY WARRANTY; without even the implied warranty of
397+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
398+ GNU General Public License for more details.
399+
400+ You should have received a copy of the GNU General Public License
401+ along with this program. If not, see <http://www.gnu.org/licenses/>.
402+*/
403+
404+#ifndef LSBRELEASE_H
405+#define LSBRELEASE_H
406+
407+#include <QtCore/QString>
408+
409+class LSBRelease
410+{
411+public:
412+ LSBRelease();
413+
414+ QString id() { return m_id; }
415+ QString release() { return m_release; }
416+ QString codename() { return m_codename; }
417+ QString description() { return m_description; }
418+
419+private:
420+ QString m_id;
421+ QString m_release;
422+ QString m_codename;
423+ QString m_description;
424+};
425+
426+#endif // LSBRELEASE_H
427
428=== added file 'src/QAptDecorator.cpp'
429--- src/QAptDecorator.cpp 1970-01-01 00:00:00 +0000
430+++ src/QAptDecorator.cpp 2013-07-27 22:26:24 +0000
431@@ -0,0 +1,80 @@
432+/*
433+ Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org> (cacheupdate example in QApt)
434+ Copyright © 2013 Michael D. Stemle, Jr. <themanchicken@gmail.com>
435+
436+ This program is free software; you can redistribute it and/or
437+ modify it under the terms of the GNU General Public License as
438+ published by the Free Software Foundation; either version 2 of
439+ the License or (at your option) version 3 or any later version
440+ accepted by the membership of KDE e.V. (or its successor approved
441+ by the membership of KDE e.V.), which shall act as a proxy
442+ defined in Section 14 of version 3 of the license.
443+
444+ This program is distributed in the hope that it will be useful,
445+ but WITHOUT ANY WARRANTY; without even the implied warranty of
446+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
447+ GNU General Public License for more details.
448+
449+ You should have received a copy of the GNU General Public License
450+ along with this program. If not, see <http://www.gnu.org/licenses/>.
451+*/
452+
453+#include <QtCore/QString>
454+
455+#include <LibQApt/Globals>
456+#include <KLocalizedString>
457+#include "QAptDecorator.h"
458+
459+QString QAptDecorator::errorText(QApt::ErrorCode error, QApt::Transaction *trans)
460+{
461+ QString text;
462+
463+ switch (error) {
464+ case QApt::InitError:
465+ text = i18nc("@label", "The package system could not be initialized, your "
466+ "configuration may be broken.");
467+ break;
468+ case QApt::LockError:
469+ text = i18nc("@label",
470+ "Another application seems to be using the package "
471+ "system at this time. You must close all other package "
472+ "managers before you will be able to install or remove "
473+ "any packages.");
474+ break;
475+ case QApt::DiskSpaceError:
476+ text = i18nc("@label",
477+ "You do not have enough disk space in the directory "
478+ "at %1 to continue with this operation.", trans->errorDetails());
479+ break;
480+ case QApt::FetchError:
481+ text = i18nc("@label", "Could not download packages");
482+ break;
483+ case QApt::CommitError:
484+ text = i18nc("@label", "An error occurred while applying changes:");
485+ break;
486+ case QApt::AuthError:
487+ text = i18nc("@label",
488+ "This operation cannot continue since proper "
489+ "authorization was not provided");
490+ break;
491+ case QApt::WorkerDisappeared:
492+ text = i18nc("@label", "It appears that the QApt worker has either crashed "
493+ "or disappeared. Please report a bug to the QApt maintainers");
494+ break;
495+ case QApt::UntrustedError:
496+ text = i18ncp("@label",
497+ "The following package has not been verified by its author. "
498+ "Downloading untrusted packages has been disallowed "
499+ "by your current configuration.",
500+ "The following packages have not been verified by "
501+ "their authors. "
502+ "Downloading untrusted packages has "
503+ "been disallowed by your current configuration.",
504+ trans->untrustedPackages().size());
505+ break;
506+ default:
507+ break;
508+ }
509+
510+ return text;
511+}
512\ No newline at end of file
513
514=== added file 'src/QAptDecorator.h'
515--- src/QAptDecorator.h 1970-01-01 00:00:00 +0000
516+++ src/QAptDecorator.h 2013-07-27 22:26:24 +0000
517@@ -0,0 +1,34 @@
518+/*
519+ Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org> (cacheupdate example in QApt)
520+ Copyright © 2013 Michael D. Stemle, Jr. <themanchicken@gmail.com>
521+
522+ This program is free software; you can redistribute it and/or
523+ modify it under the terms of the GNU General Public License as
524+ published by the Free Software Foundation; either version 2 of
525+ the License or (at your option) version 3 or any later version
526+ accepted by the membership of KDE e.V. (or its successor approved
527+ by the membership of KDE e.V.), which shall act as a proxy
528+ defined in Section 14 of version 3 of the license.
529+
530+ This program is distributed in the hope that it will be useful,
531+ but WITHOUT ANY WARRANTY; without even the implied warranty of
532+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
533+ GNU General Public License for more details.
534+
535+ You should have received a copy of the GNU General Public License
536+ along with this program. If not, see <http://www.gnu.org/licenses/>.
537+*/
538+
539+#ifndef QAPTDECORATOR_H
540+#define QAPTDECORATOR_H
541+
542+#include <LibQApt/Globals>
543+#include <LibQApt/Transaction>
544+
545+class QAptDecorator
546+{
547+public:
548+ static QString errorText(QApt::ErrorCode error, QApt::Transaction *trans);
549+};
550+
551+#endif // QAPTDECORATOR_H

Subscribers

People subscribed via source and target branches