Merge lp://qastaging/~mterry/unity-scopes-api/snap-root into lp://qastaging/unity-scopes-api/devel

Proposed by Michael Terry
Status: Merged
Approved by: Michi Henning
Approved revision: 375
Merged at revision: 692
Proposed branch: lp://qastaging/~mterry/unity-scopes-api/snap-root
Merge into: lp://qastaging/unity-scopes-api/devel
Diff against target: 155 lines (+36/-9)
7 files modified
data/scope-registry.conf.in (+1/-1)
data/smart-scopes-proxy.conf.in (+1/-1)
include/unity/scopes/internal/ConfigBase.h (+2/-0)
src/scopes/internal/ConfigBase.cpp (+18/-1)
src/scopes/internal/RegistryConfig.cpp (+2/-2)
src/scopes/internal/RuntimeConfig.cpp (+4/-4)
src/scopes/internal/ScopeConfig.cpp (+8/-0)
To merge this branch: bzr merge lp://qastaging/~mterry/unity-scopes-api/snap-root
Reviewer Review Type Date Requested Status
Michi Henning (community) Approve
unity-api-1-bot continuous-integration Approve
Review via email: mp+308609@code.qastaging.launchpad.net

This proposal supersedes a proposal from 2016-10-06.

Commit message

Handle running inside a snap by paying attention to the $SNAP prefix.

Description of the change

Handle running inside a snap by paying attention to the $SNAP prefix.

To post a comment you must log in.
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote : Posted in a previous version of this proposal

Thanks Michael! Michi and I do acknowledged this MP, but we'd like to investigate the possibility of a cleaner approach whereby we reduce some of the redundancy (especially with getenv()) that's introduced here.

This is not a stab at your work by any means ;) Thanks for your help with this!

Revision history for this message
Michi Henning (michihenning) wrote : Posted in a previous version of this proposal

Could you re-target this MR at the devel branch instead of trunk please? That allows us to use our normal staging process.

Is $SNAP always going to have a trailing slash? If not, constructs such as

$SNAP@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@UNITY_SCOPES_LIB@/scoperegistry

and

snap_root + base_dflt_file

won't create the path name correctly. Wouldn't it be safer to append a slash regardless? If we end up with two adjacent slashes, they won't do any harm.

This does not work:

const string snap_root = getenv("SNAP");

If SNAP isn't set, getenv() returns a nullptr, which causes the string constructor to throw. That causes a bunch of tests to fail.

The repeated calls to getenv("SNAP") are a bit of a pain (and dangerous because of the needed check for a nullptr return). It would be better to do this is ConfigBase and and provide a protected accessor for the value. That puts the code to sanitize the value in a single place.

review: Needs Fixing
Revision history for this message
Michi Henning (michihenning) wrote : Posted in a previous version of this proposal

Here is a diff against this branch that makes some changes. Could you review please?

Thanks,

Michi.

Revision history for this message
Michael Terry (mterry) wrote : Posted in a previous version of this proposal

> Is $SNAP always going to have a trailing slash? If not, constructs such as
> [snip[
> won't create the path name correctly. Wouldn't it be safer to append a slash
> regardless? If we end up with two adjacent slashes, they won't do any harm.

@CMAKE_INSTALL_PREFIX@ is guaranteed to either be empty or start with a slash, right? So that's fine. And base_dflt_file always starts with a slash. So I think we're fine there.

> If SNAP isn't set, getenv() returns a nullptr, which causes the string
> constructor to throw. That causes a bunch of tests to fail.

Ick, right you are. I wrote so many of these in a row, I got confused between QString and std::string.

> It would be better to do this is ConfigBase and and provide a protected
> accessor for the value. That puts the code to sanitize the value in a single
> place.

OK.

> Here is a diff against this branch that makes some changes. Could you review please?

I would go make your suggested changes, but it sounds like you were trying to upload a diff to make them for me? I don't see one. I don't think LP MPs can have attachments.

Revision history for this message
Michi Henning (michihenning) wrote : Posted in a previous version of this proposal

So sorry, got distracted by my wife with an imap issue in the middle of things.

It's a it of a let-down that I can't add an attachment to comments here.

Here's a link to the diff:

https://www.dropbox.com/s/qbbs3yeo6f5ovom/snap_root.diff?dl=0

Revision history for this message
Michi Henning (michihenning) wrote : Posted in a previous version of this proposal

> @CMAKE_INSTALL_PREFIX@ is guaranteed to either be empty or start with a slash,
> right? So that's fine. And base_dflt_file always starts with a slash. So I
> think we're fine there.

Not necessarily. I can set it to anything when I run the configure step.

I think having the slash there is safer, and it won't do any harm if there is an extra one.

Revision history for this message
Michael Terry (mterry) wrote : Posted in a previous version of this proposal

Thanks! I've applied your patch.

Revision history for this message
Michi Henning (michihenning) wrote : Posted in a previous version of this proposal

Still need to re-target this at the devel branch, otherwise Jenkins won't test it. Could you do that please?

Revision history for this message
Michael Terry (mterry) wrote :

Whoops, done.

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:375
https://jenkins.canonical.com/unity-api-1/job/lp-unity-scopes-api-ci/50/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/889
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/896
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/702
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/702/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/702
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/702/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/702
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/702/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/702
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/702/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/702
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/702/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/702
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/702/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/702
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/702/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/702
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/702/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/702
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/702/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-unity-scopes-api-ci/50/rebuild

review: Approve (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Cool, all good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: