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: 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 Needs Fixing
Jonathan Thomas 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.
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 : 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

Revision history for this message
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.

Revision history for this message
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

Revision history for this message
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.
>

Revision history for this message
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

Revision history for this message
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...

Revision history for this message
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.
>

Revision history for this message
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

Revision history for this message
Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal

clang-analyzer is happy

Revision history for this message
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.
>

Revision history for this message
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

Revision history for this message
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.

Revision history for this message
Harald Sitter (apachelogger) wrote : Posted in a previous version of this proposal

QA done :P

review: Needs Fixing
Revision history for this message
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 ;)

Revision history for this message
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.
>

Revision history for this message
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
Revision history for this message
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>

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
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2010-09-16 14:19:01 +0000
+++ src/CMakeLists.txt 2013-08-04 08:01:27 +0000
@@ -2,6 +2,8 @@
2include_directories(${CMAKE_CURRENT_BINARY_DIR})2include_directories(${CMAKE_CURRENT_BINARY_DIR})
33
4set(installdbgsymbols_SRCS4set(installdbgsymbols_SRCS
5 QAptDecorator.cpp
6 LSBRelease.cpp
5 DebugFinder.cpp7 DebugFinder.cpp
6 DebugInstaller.cpp8 DebugInstaller.cpp
7 main.cpp9 main.cpp
810
=== modified file 'src/DebugFinder.cpp'
--- src/DebugFinder.cpp 2012-10-30 15:16:47 +0000
+++ src/DebugFinder.cpp 2013-08-04 08:01:27 +0000
@@ -2,6 +2,7 @@
2 Copyright © 2010 Harald Sitter <apachelogger@ubuntu.com>2 Copyright © 2010 Harald Sitter <apachelogger@ubuntu.com>
3 Copyright © 2010 Felix Geyer <debfx@fobos.de>3 Copyright © 2010 Felix Geyer <debfx@fobos.de>
4 Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org>4 Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org>
5 Copyright © 2013 Michael D. Stemle, Jr. <themanchicken@gmail.com>
56
6 This program is free software; you can redistribute it and/or7 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as8 modify it under the terms of the GNU General Public License as
@@ -21,17 +22,45 @@
21*/22*/
2223
23#include "DebugFinder.h"24#include "DebugFinder.h"
2425#include "LSBRelease.h"
25#include <QtCore/QStringList>26#include "QAptDecorator.h"
26#include <QtCore/QThread>
2727
28#include <LibQApt/Backend>28#include <LibQApt/Backend>
29#include <LibQApt/SourceEntry>
30#include <LibQApt/SourcesList>
31#include <LibQApt/Transaction>
32#include <iostream>
33
34#include <KDebug>
35#include <KLocalizedString>
36#include <KProgressDialog>
37#include <KMessageBox>
38#include <qfile.h>
2939
30DebugFinder::DebugFinder(QObject *parent) :40DebugFinder::DebugFinder(QObject *parent) :
31 QObject(parent),41 QObject(parent),
32 m_backend(new QApt::Backend(this)),42 m_backend(new QApt::Backend(this)),
33 m_stop(false)43 m_progress(new KProgressDialog()),
44 m_ddebsSources(new QApt::SourceEntryList()),
45 m_sourcesList(new QApt::SourcesList(this)),
46 m_stop(false),
47 m_sourcesChangedSinceChecked(false)
34{48{
49 kDebug() << "INIT!!!!!\n";
50 m_aptTransaction = 0;
51 m_progress->progressBar()->setMaximum(100);
52 QString repoFile(QString::fromLatin1(DDEB_REPO_FILE));
53
54 // Construct our list hard-coded sources...
55 if (m_ddebsSources->count() == 0) {
56 LSBRelease lsb;
57 QString codename = lsb.codename();
58 m_ddebsSources->append(QApt::SourceEntry(QString::fromLatin1(REPO_ARG_BASE).arg(codename), repoFile));
59 m_ddebsSources->append(QApt::SourceEntry(QString::fromLatin1(REPO_ARG_UPDATES).arg(codename), repoFile));
60 m_ddebsSources->append(QApt::SourceEntry(QString::fromLatin1(REPO_ARG_SECURITY).arg(codename), repoFile));
61 m_ddebsSources->append(QApt::SourceEntry(QString::fromLatin1(REPO_ARG_PROPOSED).arg(codename), repoFile));
62 }
63
35 m_backend->init();64 m_backend->init();
36}65}
3766
@@ -69,17 +98,18 @@
69 return 0;98 return 0;
70}99}
71100
72void DebugFinder::find(const QString &file)101void DebugFinder::find()
73{102{
74 if (m_stop) {103 if (m_stop) {
75 return;104 return;
76 }105 }
77106
78 QApt::Package *package = m_backend->packageForFile(file);107 QApt::Package *package = m_backend->packageForFile(m_file);
79108
80 QApt::Package *dbgPkg = getDbgPkg(package);109 QApt::Package *dbgPkg = getDbgPkg(package);
81 if (!dbgPkg) {110 if (!dbgPkg) {
82 emit foundNoDbgPkg(file);111 kDebug() << "No debug package found for: " << m_file;
112 emit foundNoDbgPkg(m_file);
83 } else if (dbgPkg->isInstalled()) {113 } else if (dbgPkg->isInstalled()) {
84 emit alreadyInstalled();114 emit alreadyInstalled();
85 } else {115 } else {
@@ -90,4 +120,178 @@
90void DebugFinder::stop()120void DebugFinder::stop()
91{121{
92 m_stop = true;122 m_stop = true;
123 removeDdebs();
124}
125
126void DebugFinder::startFinding(const QString &file)
127{
128 m_progress->setLabelText(i18nc("@title", "Adding debug symbol sources"));
129 m_file = file;
130 connect(this, SIGNAL(aptCacheUpdateFinished()),
131 this, SLOT(onAptCacheUpdateFinished()));
132
133 if (hasDdebs()) {
134 // We already have debs...
135 kDebug() << "SKIPPING DDEBS!";
136 emit aptCacheUpdateFinished();
137 } else {
138 installDdebs();
139 }
140
141 kDebug() << "Done with startFinding()!";
142}
143
144// The update is finished!
145void DebugFinder::onAptCacheUpdateFinished()
146{
147 kDebug() << "Done with updateCache(), reloading cache...";
148 m_backend->reloadCache();
149
150 kDebug() << "I'm done.";
151 m_progress->progressBar()->setValue(100);
152
153 find();
154
155 return;
156}
157
158void DebugFinder::onTxnStatusChanged(QApt::TransactionStatus status)
159{
160 kDebug() << "cache widget: transaction status changed" << status;
161
162 if (!m_aptTransaction) {
163 kDebug() << "No valid transaction.";
164 return;
165 }
166
167 switch (status) {
168 case QApt::DownloadingStatus:
169 if (m_aptTransaction->role() == QApt::UpdateCacheRole) {
170 m_progress->setLabelText(i18nc("@title", "Updating software sources"));
171 } else {
172 m_progress->setLabelText(i18nc("@title", "Downloading Packages"));
173 }
174
175 break;
176
177 case QApt::FinishedStatus:
178 m_progress->setLabelText(i18nc("@title", "Finished."));
179 break;
180
181 default:
182 break;
183 }
184}
185
186void DebugFinder::onAptError(QApt::ErrorCode errcode)
187{
188 QString errmsg = QAptDecorator::errorText(errcode, m_aptTransaction);
189 kDebug() << "Got an error: " << errmsg;
190
191 KMessageBox::error(
192 NULL,
193 i18nc("@info Error message", "Error updating sources"
194 " after configuring debug sources"),
195 i18nc("@title Error dialog", "Failed updating sources")
196 );
197}
198
199void DebugFinder::onProgressChanged(int progress)
200{
201 int presentProgress = progress;
202
203 if (progress >= 100) {
204 presentProgress = 0;
205 }
206 m_progress->progressBar()->setValue(presentProgress);
207}
208
209bool DebugFinder::hasDdebs()
210{
211 static int ddeb_count = 0;
212
213 if (!m_sourcesChangedSinceChecked && (ddeb_count == m_ddebsSources->count())) {
214 kDebug() << "m_sourcesChangedSinceChecked == " << m_sourcesChangedSinceChecked << " and m_ddebsSources->count() == " << m_ddebsSources->count() << " and ddeb_count == " << ddeb_count;
215 return true;
216 }
217
218 const QApt::SourceEntryList &existingEntries = m_sourcesList->entries();
219
220 foreach (const QApt::SourceEntry &repo, *m_ddebsSources) {
221 if (existingEntries.contains(repo)) {
222 kDebug() << "LOOP, CONTAINS!";
223 ddeb_count += 1;
224 }
225 else { kDebug() << "LOOP, DOESNT CONTAIN!"; }
226 }
227 kDebug() << "(2) m_sourcesChangedSinceChecked == " << m_sourcesChangedSinceChecked << " and m_ddebsSources->count() == " << m_ddebsSources->count() << " and ddeb_count == " << ddeb_count;
228
229 m_sourcesChangedSinceChecked = false;
230
231 return (ddeb_count == m_ddebsSources->count());
232}
233
234void DebugFinder::updateAptCache()
235{
236 m_progress->progressBar()->setValue(0);
237 m_aptTransaction = m_backend->updateCache();
238
239 m_aptTransaction->setLocale(QLatin1String(setlocale(LC_MESSAGES, 0)));
240
241 connect(m_progress, SIGNAL(cancelClicked()),
242 m_aptTransaction, SLOT(cancel()));
243 connect(m_aptTransaction, SIGNAL(errorOccurred(QApt::ErrorCode)),
244 this, SLOT(onAptError(QApt::ErrorCode)));
245 connect(m_aptTransaction, SIGNAL(statusChanged(QApt::TransactionStatus)),
246 this, SLOT(onTxnStatusChanged(QApt::TransactionStatus)));
247 connect(m_aptTransaction, SIGNAL(progressChanged(int)),
248 this, SLOT(onProgressChanged(int)));
249 connect(m_aptTransaction, SIGNAL(finished(QApt::ExitStatus)),
250 this, SLOT(onAptCacheUpdateFinished()));
251
252 m_aptTransaction->run();
253 kDebug() << "FinishedStatus: " << QApt::FinishedStatus;
254}
255
256void DebugFinder::installDdebs()
257{
258 // If it's already there, don't do it!
259 if (hasDdebs()) {
260 return;
261 }
262
263 foreach (const QApt::SourceEntry &repo, *m_ddebsSources) {
264 m_sourcesList->addEntry(repo); // This method has a dup check
265 }
266
267 m_sourcesList->save();
268 m_sourcesChangedSinceChecked = true;
269
270 kDebug() << "Entries saved, updating backend cache...";
271 updateAptCache();
272
273 return;
274}
275
276void DebugFinder::removeDdebs()
277{
278 m_progress->setLabelText(i18nc("@title", "Cleaning up sources"));
279 // If it's NOT already there, don't do it!
280 if (!hasDdebs()) {
281 return;
282 }
283 kDebug() << "Has DDEBS! Cleaning!";
284
285 foreach (const QApt::SourceEntry &repo, *m_ddebsSources) {
286 kDebug() << "Removing " << repo.toString();
287 m_sourcesList->removeEntry(repo);
288 }
289
290 m_sourcesList->save();
291 m_sourcesChangedSinceChecked = true;
292
293 kDebug() << "Entries saved, updating backend cache...";
294 updateAptCache();
295
296 return;
93}297}
94298
=== modified file 'src/DebugFinder.h'
--- src/DebugFinder.h 2012-10-30 15:16:47 +0000
+++ src/DebugFinder.h 2013-08-04 08:01:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
2 Copyright © 2010 Harald Sitter <apachelogger@ubuntu.com>2 Copyright © 2010 Harald Sitter <apachelogger@ubuntu.com>
3 Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org>3 Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org>
4 Copyright © 2013 Michael D. Stemle, Jr. <themanchicken@gmail.com>
45
5 This program is free software; you can redistribute it and/or6 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as7 modify it under the terms of the GNU General Public License as
@@ -22,13 +23,26 @@
22#ifndef DEBUGFINDER_H23#ifndef DEBUGFINDER_H
23#define DEBUGFINDER_H24#define DEBUGFINDER_H
2425
26#include <LibQApt/Globals>
27
25#include <QtCore/QObject>28#include <QtCore/QObject>
26#include <QtCore/QStringList>29#include <QtCore/QStringList>
2730
31#define REPO_ARG_BASE "deb http://ddebs.ubuntu.com %1 main restricted universe multiverse"
32#define REPO_ARG_UPDATES "deb http://ddebs.ubuntu.com %1-updates main restricted universe multiverse"
33#define REPO_ARG_SECURITY "deb http://ddebs.ubuntu.com %1-security main restricted universe multiverse"
34#define REPO_ARG_PROPOSED "deb http://ddebs.ubuntu.com %1-proposed main restricted universe multiverse"
35#define DDEB_REPO_FILE "/etc/apt/sources.list.d/ddebs.list"
36
37class KProgressDialog;
38
28namespace QApt {39namespace QApt {
29 class Backend;40 class Backend;
30 class Package;41 class Package;
31}42 class SourceEntry;
43 class SourcesList;
44 class Transaction;
45};
3246
33class DebugFinder : public QObject47class DebugFinder : public QObject
34{48{
@@ -36,20 +50,38 @@
36public:50public:
37 explicit DebugFinder(QObject *parent = 0);51 explicit DebugFinder(QObject *parent = 0);
3852
53 void performUpdate();
54
39public slots:55public slots:
40 void find(const QString &file);56 void startFinding(const QString &file);
57 void find();
41 void stop();58 void stop();
4259 void onTxnStatusChanged(QApt::TransactionStatus status);
60 void onAptError(QApt::ErrorCode errcode);
61 void onAptCacheUpdateFinished();
62 void onProgressChanged(int progress);
63 bool hasDdebs();
64 void installDdebs();
65 void removeDdebs();
66 void updateAptCache();
67
43signals:68signals:
44 void foundDbgPkg(const QString &dbgpkg);69 void foundDbgPkg(const QString &dbgpkg);
45 void foundNoDbgPkg(const QString &file);70 void foundNoDbgPkg(const QString &dbgpkg);
46 void alreadyInstalled();71 void alreadyInstalled();
72 void aptCacheUpdateFinished();
4773
48private:74private:
49 QApt::Package *getDbgPkg(QApt::Package *package);75 QApt::Package *getDbgPkg(QApt::Package *package);
76
50 QApt::Backend *m_backend;77 QApt::Backend *m_backend;
5178 QApt::Transaction *m_aptTransaction;
79 KProgressDialog *m_progress;
80 QList<QApt::SourceEntry> *m_ddebsSources;
81 QApt::SourcesList *m_sourcesList;
82 QString m_file;
52 bool m_stop;83 bool m_stop;
84 bool m_sourcesChangedSinceChecked;
53};85};
5486
55#endif // DEBUGFINDER_H87#endif // DEBUGFINDER_H
5688
=== modified file 'src/DebugInstaller.cpp'
--- src/DebugInstaller.cpp 2011-09-26 13:35:14 +0000
+++ src/DebugInstaller.cpp 2013-08-04 08:01:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
2 Copyright © 2010 Harald Sitter <apachelogger@ubuntu.com>2 Copyright © 2010 Harald Sitter <apachelogger@ubuntu.com>
3 Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org>3 Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org>
4 Copyright © 2013 Michael D. Stemle, Jr. <themanchicken@gmail.com>
45
5 This program is free software; you can redistribute it and/or6 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as7 modify it under the terms of the GNU General Public License as
@@ -68,6 +69,8 @@
68 if (install.exitCode() != 0) {69 if (install.exitCode() != 0) {
69 EXIT(ERR_RANDOM_ERR);70 EXIT(ERR_RANDOM_ERR);
70 }71 }
72
73 m_finder->removeDdebs();
7174
72 close();75 close();
73}76}
@@ -163,17 +166,20 @@
163 progressBar()->setMaximum(m_args.count());166 progressBar()->setMaximum(m_args.count());
164 incrementProgress();167 incrementProgress();
165168
166 m_finder = new DebugFinder;169 m_finder = new DebugFinder(this);
167 connect(m_finder, SIGNAL(foundDbgPkg(QString)), this, SLOT(foundDbgPkg(QString)));170 connect(m_finder, SIGNAL(foundDbgPkg(QString)),
168 connect(m_finder, SIGNAL(foundNoDbgPkg(QString)), this, SLOT(foundNoDbgPkg(QString)));171 this, SLOT(foundDbgPkg(QString)));
169 connect(m_finder, SIGNAL(alreadyInstalled()), this, SLOT(alreadyInstalled()));172 connect(m_finder, SIGNAL(foundNoDbgPkg(QString)),
173 this, SLOT(foundNoDbgPkg(QString)));
174 connect(m_finder, SIGNAL(alreadyInstalled()),
175 this, SLOT(alreadyInstalled()));
170176
171 m_finderThread = new QThread(this);177 m_finderThread = new QThread(this);
172 m_finder->moveToThread(m_finderThread);178 m_finder->moveToThread(m_finderThread);
173 m_finderThread->start();179 m_finderThread->start();
174180
175 foreach (const QString &file, m_args) {181 foreach (const QString &file, m_args) {
176 QMetaObject::invokeMethod(m_finder, "find", Qt::QueuedConnection,182 QMetaObject::invokeMethod(m_finder, "startFinding", Qt::QueuedConnection,
177 Q_ARG(QString, file));183 Q_ARG(QString, file));
178 }184 }
179}185}
180186
=== added file 'src/LSBRelease.cpp'
--- src/LSBRelease.cpp 1970-01-01 00:00:00 +0000
+++ src/LSBRelease.cpp 2013-08-04 08:01:27 +0000
@@ -0,0 +1,66 @@
1/*
2 Copyright (C) 2012 Harald Sitter <apachelogger@ubuntu.com>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License or (at your option) version 3 or any later version
8 accepted by the membership of KDE e.V. (or its successor approved
9 by the membership of KDE e.V.), which shall act as a proxy
10 defined in Section 14 of version 3 of the license.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#include "LSBRelease.h"
22
23#include <QtCore/QFile>
24
25#include <KDebug>
26#include <KLocalizedString>
27
28LSBRelease::LSBRelease()
29{
30 QFile file("/etc/lsb-release");
31 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
32 kDebug() << "Could not open /etc/lsb-release, aborting LSB";
33 QString unknown = i18nc("@label", "Unknown Release");
34 m_id = unknown;
35 m_release = unknown;
36 m_codename = unknown;
37 m_description = unknown;
38 return;
39 }
40
41 // List of valid column identifiers
42 QString line;
43 QStringList comps;
44 while (!file.atEnd()) {
45 line = file.readLine();
46 comps = line.split(QChar('='));
47 Q_ASSERT(comps.size() == 2);
48 QString key = comps.at(0);
49 QString value = comps.at(1).trimmed();
50 if (key == QLatin1String("DISTRIB_ID"))
51 m_id = value;
52 else if (key == QLatin1String("DISTRIB_RELEASE"))
53 m_release = value;
54 else if (key == QLatin1String("DISTRIB_CODENAME"))
55 m_codename = value;
56 else if (key == QLatin1String("DISTRIB_DESCRIPTION"))
57 m_description = value;
58 else
59 Q_ASSERT(false); // Should not happen!
60 }
61
62 if (m_id.isEmpty() || m_release.isEmpty()) {
63 Q_ASSERT(false); // meh.
64 }
65}
66
067
=== added file 'src/LSBRelease.h'
--- src/LSBRelease.h 1970-01-01 00:00:00 +0000
+++ src/LSBRelease.h 2013-08-04 08:01:27 +0000
@@ -0,0 +1,43 @@
1/*
2 Copyright (C) 2012 Harald Sitter <apachelogger@ubuntu.com>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License or (at your option) version 3 or any later version
8 accepted by the membership of KDE e.V. (or its successor approved
9 by the membership of KDE e.V.), which shall act as a proxy
10 defined in Section 14 of version 3 of the license.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#ifndef LSBRELEASE_H
22#define LSBRELEASE_H
23
24#include <QtCore/QString>
25
26class LSBRelease
27{
28public:
29 LSBRelease();
30
31 QString id() { return m_id; }
32 QString release() { return m_release; }
33 QString codename() { return m_codename; }
34 QString description() { return m_description; }
35
36private:
37 QString m_id;
38 QString m_release;
39 QString m_codename;
40 QString m_description;
41};
42
43#endif // LSBRELEASE_H
044
=== added file 'src/QAptDecorator.cpp'
--- src/QAptDecorator.cpp 1970-01-01 00:00:00 +0000
+++ src/QAptDecorator.cpp 2013-08-04 08:01:27 +0000
@@ -0,0 +1,81 @@
1/*
2 Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org> (cacheupdate example in QApt)
3 Copyright © 2013 Michael D. Stemle, Jr. <themanchicken@gmail.com>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3 or any later version
9 accepted by the membership of KDE e.V. (or its successor approved
10 by the membership of KDE e.V.), which shall act as a proxy
11 defined in Section 14 of version 3 of the license.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "QAptDecorator.h"
23
24#include <QtCore/QString>
25
26#include <LibQApt/Globals>
27#include <KLocalizedString>
28
29QString QAptDecorator::errorText(QApt::ErrorCode error, QApt::Transaction *trans)
30{
31 QString text;
32
33 switch (error) {
34 case QApt::InitError:
35 text = i18nc("@label", "The package system could not be initialized, your "
36 "configuration may be broken.");
37 break;
38 case QApt::LockError:
39 text = i18nc("@label",
40 "Another application seems to be using the package "
41 "system at this time. You must close all other package "
42 "managers before you will be able to install or remove "
43 "any packages.");
44 break;
45 case QApt::DiskSpaceError:
46 text = i18nc("@label",
47 "You do not have enough disk space in the directory "
48 "at %1 to continue with this operation.", trans->errorDetails());
49 break;
50 case QApt::FetchError:
51 text = i18nc("@label", "Could not download packages");
52 break;
53 case QApt::CommitError:
54 text = i18nc("@label", "An error occurred while applying changes:");
55 break;
56 case QApt::AuthError:
57 text = i18nc("@label",
58 "This operation cannot continue since proper "
59 "authorization was not provided");
60 break;
61 case QApt::WorkerDisappeared:
62 text = i18nc("@label", "It appears that the QApt worker has either crashed "
63 "or disappeared. Please report a bug to the QApt maintainers");
64 break;
65 case QApt::UntrustedError:
66 text = i18ncp("@label",
67 "The following package has not been verified by its author. "
68 "Downloading untrusted packages has been disallowed "
69 "by your current configuration.",
70 "The following packages have not been verified by "
71 "their authors. "
72 "Downloading untrusted packages has "
73 "been disallowed by your current configuration.",
74 trans->untrustedPackages().size());
75 break;
76 default:
77 break;
78 }
79
80 return text;
81}
082
=== added file 'src/QAptDecorator.h'
--- src/QAptDecorator.h 1970-01-01 00:00:00 +0000
+++ src/QAptDecorator.h 2013-08-04 08:01:27 +0000
@@ -0,0 +1,34 @@
1/*
2 Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org> (cacheupdate example in QApt)
3 Copyright © 2013 Michael D. Stemle, Jr. <themanchicken@gmail.com>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3 or any later version
9 accepted by the membership of KDE e.V. (or its successor approved
10 by the membership of KDE e.V.), which shall act as a proxy
11 defined in Section 14 of version 3 of the license.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#ifndef QAPTDECORATOR_H
23#define QAPTDECORATOR_H
24
25#include <LibQApt/Globals>
26#include <LibQApt/Transaction>
27
28class QAptDecorator
29{
30public:
31 static QString errorText(QApt::ErrorCode error, QApt::Transaction *trans);
32};
33
34#endif // QAPTDECORATOR_H

Subscribers

People subscribed via source and target branches