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

Proposed by Michael D. Stemle, Jr. on 2013-07-27
Status: Superseded
Proposed branch: lp:~manchicken/kubuntu-debug-installer/kubuntu-debug-installer
Merge into: lp:kubuntu-debug-installer
Diff against target: 649 lines (+485/-17)
8 files modified
src/CMakeLists.txt (+2/-0)
src/DebugFinder.cpp (+211/-7)
src/DebugFinder.h (+37/-5)
src/DebugInstaller.cpp (+11/-5)
src/LSBRelease.cpp (+66/-0)
src/LSBRelease.h (+43/-0)
src/QAptDecorator.cpp (+81/-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 2013-07-27 Needs Fixing on 2013-07-30
Jonathan Thomas 2013-07-27 Pending
Review via email: mp+177273@code.launchpad.net

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

This proposal has been superseded by a proposal from 2013-08-04.

Description of the change

This includes the reloadCache() call that JT recommended. Includes all of the fixes from Harold.

To post a comment you must log in.
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

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

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

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
Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal

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

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

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.

Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal

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

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

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.
>

Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal

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

Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal
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...

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

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.
>

Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal

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

Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal

clang-analyzer is happy

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

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.
>

Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal

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

Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal

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.

Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal

QA done :P

review: Needs Fixing
Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal

> 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 ;)

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

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.
>

Harald Sitter (apachelogger) wrote :
Download full text (5.8 KiB)

much better. I reran the entire test set but there are still some issues, in particular the krazy and smoke issues are blocking for me...

------------------ style ------------------

- indention in DebugFinder changes still has lines with 0 spaces, 2 spaces, tabs, 4 spaces. should all be 4 spaces
- also please note that our style guides says for/foreach/if/swtich-case have their opening curly braces on the same line as the keyword (foreach(...) {)
- numerous lines with indention but nothing after the indention

> m_aptTxn = 0;

better, but not perfect (http://finance.yahoo.com/q?s=TXN). please call it m_transaction or m_aptTransaction :P

> QString(DDEB_REPO_FILE)

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

new:
> QApt::SourceEntryList hardCodedRepoList;

if it is hardcoded, then it probably should be static and only be built/filled once.

> #include <KProgressDialog>

in DebugFinder.h this can now be a forward decl

> connect(m_progress, SIGNAL(cancelClicked()), m_aptTxn, SLOT(cancel()));

I personally like to line break after the signal to make it easier to spot which objects are being wired here...

connect(m_progress, SIGNAL(cancelClicked()),
        m_aptTxn, SLOT(cancel()));

------------------ smoke ------------------

(see previous smoke results
- Authentication still can not be cancelled
- ddebs entries are still added ad infinitum
- debug output still too excessive with percent values being debugged :P
- ddebs.list is still not removed at exit() if it was initially created by debug-installer

new:
- Crash when cancelling adding of sources and package lookup (http://paste.kde.org/p256c29ae/)

------------------ clang-analyzer ------------------

still happy xD

------------------ krazy2 ------------------

still issues:

krazy2 Analysis

Checkers Run = 39
Files Processed = 13
Total Issues = 9 ...as of July 30 2013 13:25:14 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 ...

Read more...

review: Needs Fixing
Michael D. Stemle, Jr. (manchicken) wrote :

In trying to get the entries removed, it looks like libqapt doesn't fully remove entries if you put them into a sources.list file... at least not the way I'm doing it. My next submission will include code to remove those sources lines, let me know if - upon testing - the file still doesn't go away. Right now I'm seeing that libqapt is expanding the sources list directory as ".", which I think may be more related to how my environment is set up.

108. By Michael D. Stemle, Jr. <email address hidden> on 2013-08-04

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> on 2013-08-04

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> on 2013-07-27

Fixed some code indentation.

106. By Michael D. Stemle, Jr. <email address hidden> on 2013-07-27

Fixed some text formatting.

105. By Michael D. Stemle, Jr. <email address hidden> on 2013-07-27

Made a series of changes requested by Harold.

104. By Michael D. Stemle, Jr. <email address hidden> on 2013-07-22

Made change per JT's recommendation.

103. By Michael D. Stemle, Jr. <email address hidden> on 2013-07-17

Added the base repo.

102. By Michael D. Stemle, Jr. <email address hidden> on 2013-07-16

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

101. By Michael D. Stemle, Jr. <email address hidden> on 2013-07-16

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> on 2013-07-06

I now have the sources add working.

99. By Michael D. Stemle, Jr. <email address hidden> on 2013-07-05

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

Subscribers

People subscribed via source and target branches