Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intent to package: Snaps are universal Linux packages #221

Closed
brlin-tw opened this issue Sep 14, 2020 · 43 comments
Closed

Intent to package: Snaps are universal Linux packages #221

brlin-tw opened this issue Sep 14, 2020 · 43 comments

Comments

@brlin-tw
Copy link
Contributor

brlin-tw commented Sep 14, 2020

Dear maintainer(s),

Snaps are universal Linux packages that can be installed and run on many GNU+Linux distributions with ease. I've been following the Snapcrafters instructions and have built a working snap on the Snap Store, you may try it by running the following commands after installing snapd:

sudo snap install --channel=beta universal-update-utility
universal-update-utility -H
# sudo snap alias universal-update-utility uuu
# uuu -H

Update: Connecting to the raw-usb interface is no longer required as the store auto-connection is now active.

I'm also looking forward to working with you to make the packaging work upstream (if you're interested). You may want to check out the current packaging recipe, the documentation, registering a developer account on the Snap Store, and get in touch with us to transfer the work under your control.

Thanks for your time and attention.

@nxpfrankli
Copy link
Contributor

Thank you very much. It think it may not be too late. I just realize it is quite good features.
I just start learn snap.

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 2, 2021

I can prepare a PR to add the packaging recipe to the repo and initiate the ownership transfer process.

@nxpfrankli
Copy link
Contributor

Thanks. I requested the new name "uuu" and wait for review. universal-update-utility is too long.

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 2, 2021

I requested the new name "uuu" and wait for review. universal-update-utility is too long.

I've previously attempted to register 3-letter snap names for other snaps but was since been retracted following the store staffs' recommendation:

We're trying to limit the amount of 3-letter snap names because they are not very descriptive unless they're very high-profile software (git, vim). Would you consider using a longer more descriptive name for the snap? as you know we can still assign an alias so a "bfg" command will be available once installed, but naming the snap "big-fantastic-gun" or something more descriptive is preferred.

Could you perhaps use bfg-repo-cleaner as the snap's name? we discussed internally and while rather popular, it's not comparable to vim and git in terms of ubiquitousness, so the 3-letter name may still be uninformative for people not already familiar with it.

I assume uuu falls under this case and thus did not attempt it in the first place.

@nxpfrankli
Copy link
Contributor

Thank you for your comments.

@nxpfrankli
Copy link
Contributor

Feedback:

Three-letter and shorter snap names are too generic and nondescript and don't provide a good idea of what the snap actually is or does. For that reason, we prefer and suggest you pick a more descriptive name for your snap (universal-update-utility-uuu for example). Keep in mind that even if the snap has one of those names, a command called "uuu" can still be provided by the snap - this needs creating an "alias" but it's entirely feasible to do so.

Let me know if some of the suggested names are OK with you or if you want to pick a new one; in any case, you can simply register the new name and it should be automatically approved - only 3-letter or shorter names (well and a few other exceptions) require manual name review/approval."

Maybe we, can use universal-update-utility-uuu, or uuu-universal-update-utility, so user can use keywords uuu to search it.

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

Maybe we, can use universal-update-utility-uuu, or uuu-universal-update-utility, so user can use keywords uuu to search it

I've added search keywords to the universal-update-utility snap's listing page and can verify that the snap is now searchable from the store website and the CLI, does that work for you?

new snap description

Snap Store search result

brlin@brlin-musicha-mz-530:~$ snap find uuu
Name                      Version          Publisher  Notes  Summary
universal-update-utility  1.4.95+pkg-021c  brlin      -      Freescale/NXP I.MX Chip image deploy tools
brlin@brlin-musicha-mz-530:~$ snap find nxp
Name                                    Version          Publisher    Notes  Summary
zephyr-crosstool-xtensa-nxp-imx-adsp    1.24.0.4         stephanosio  -      Zephyr Xtensa NXP i.MX ADSP Cross Compiler Toolchain
zephyr-crosstool-xtensa-nxp-imx8m-adsp  1.24.0.4         stephanosio  -      Zephyr Xtensa NXP i.MX 8M ADSP Cross Compiler Toolchain
universal-update-utility                1.4.95+pkg-021c  brlin        -      Freescale/NXP I.MX Chip image deploy tools

Also, I would like to request to add your Ubuntu One account e-mail address to the universal-update-utility snap's collaborator list so that you can access the current snap's backstage.

backstage preview

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

I've also fixed the build failure and update the current snap to 1.4.95

@nxpfrankli
Copy link
Contributor

My account is frank.li@nxp.com

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

Collaborator invited, please check your mail.

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

I've also added your GitHub account to the source repo's collaborator list, you may push code changes and trigger the automated snap building.

@nxpfrankli
Copy link
Contributor

I can push code into your repo.
How to trigger snap build if change source in uuu repo?

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

How to trigger snap build if change source in uuu repo?

This is currently not possible if the snap recipe is in another repo, we can work around it by:

  1. Merging the snap recipe to the uuu repo.
  2. Transfer the snap's ownership to your developer account (probably not required with contributor access)
  3. Setup snap building with the uuu repo at https://snapcraft.io/universal-update-utility/builds.

@nxpfrankli
Copy link
Contributor

@nxpfrankli
Copy link
Contributor

About 1. Just need copy everything under snap into uuu repo?

brlin-tw added a commit to brlin-tw/mfgtools that referenced this issue Mar 4, 2021
This patch implements the necessary bits to package uuu as a snap.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

404 for link https://snapcraft.io/universal-update-utility/builds.

Probably no permission as a snap collaborator, then the snap ownership transfer process must be done. Here is the process:

  1. Register an account on the snapcraft forum
  2. Post a snap name transfer request under the store topic category of the Snapcraft Forum, you'll have to mention either your snap account id listed in https://dashboard.snapcraft.io/dev/account/ or the associated e-mail address. You may check out this example: Transfer brook - store - snapcraft.io
    I can also make the post for you, in this case simply mention the aforementioned account details here.
  3. After the name transfer is completed, the build page should be accessible.

About 1. Just need copy everything under snap into uuu repo?

I've filed a PR (#255) that adds the necessary files.

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

I've found more issues while using the uuu snap:

  • If the user has no write access to the target device node, one has to run the uuu snap command as root (the raw-usb interface connection is, unfortunately, not enough, as it only lifts the snapd's side of confinement)
  • If the uuu snap command is run as root then due to the current implementation of the home interface's security confinement, the program can't access files under the user home directory (i.e. uuu scripts can't be read)

Refer Libusb application can't access device even after the raw-usb interface is connected - snapcraft - snapcraft.io for more info.

A dirty workaround is to make the user modify the permission of the target device mode manually(0666) and run uuu as the user instead of root or install an udev rule that fixes the permission.

nxpfrankli pushed a commit that referenced this issue Mar 4, 2021
This patch implements the necessary bits to package uuu as a snap.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
@nxpfrankli
Copy link
Contributor

pull request merged.

I created snapcraft account, email is frank.li@nxp.com. please help post transfer request for me

About sudo access usb device problem.

1: put above udev run into /etc/udev/rules.d/70-uuu.rules
sudo sh -c "uuu -udev >> /etc/udev/rules.d/70-uuu.rules"
2: update udev rule
sudo udevadm control --reload

I am not sure how to integrate into snap

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

pull request merged.

Please merge #256 which fixes errors in the original PR.

I created snapcraft account, email is frank.li@nxp.com. please help post transfer request for me

Great, please provide the snap account ID listed in https://dashboard.snapcraft.io/dev/account/.

I am not sure how to integrate into snap

Unfortunately, it doesn't seem to be supported as of now. You might want to add the instructions to the snap's launcher https://github.com/NXPmicro/mfgtools/blob/master/snap/local/launchers/universal-update-utility-launch so that the user will be notified of the workaround (example).

@nxpfrankli
Copy link
Contributor

Snap account-id
NxFU2gRxjZ0LR5Ma7eNl05ZapIZtsxoK

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

Thanks! The snap ownership transfer request is filed at https://forum.snapcraft.io/t/please-transfer-universal-update-utility-to-nxpfrankli/23120

@nxpfrankli
Copy link
Contributor

Our license team require add your MIT license file under snap

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

Our license team require add your MIT license file under snap

I filed a new PR (#257) which should meet the requirement.

@nxpfrankli
Copy link
Contributor

Thank very much

@nxpfrankli
Copy link
Contributor

Sorry, license team review and find one more thing.

Please add copyright at yaml file

Copyright (c) 2017 Snapcrafters

@nxpfrankli
Copy link
Contributor

One more question:
how to distinguish beta and stable package? Most people should get stable package default.

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

Please add copyright at yaml file

Done. (#258)

how to distinguish beta and stable package? Most people should get stable package default.

The snap ecosystem features channels and tracks for this purpose. The new builds will always land in the edge channel and can be promoted to other channels afterward via the store backstage or the snapcraft promote command.

$ snapcraft status universal-update-utility
Track    Arch     Channel    Version          Revision
latest   amd64    stable     -                -
                  candidate  -                -
                  beta       1.4.95+pkg-021c  37
                  edge       1.4.95+pkg-021c  37
(stripped)

Snap promotion example

This snap implementation also integrates a selective-checkout script which, will help ensure that stable/candidate/beta snap revision will always be built for promotion, however, it relies on distinguishable naming of git tags so it doesn't work for uuu. Refer Selective-checkout: Check out the tagged release revision if it isn't promoted to the stable channel - doc - snapcraft.io for more details.

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

Also, I would like to request to add your Ubuntu One account e-mail address to the universal-update-utility snap's collaborator list so that you can access the current snap's backstage.

Please accept the snap collaboration invite in order to proceed with the ownership transfer according to the store staffs' request.

current collaboration invite status

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

I've found more issues while using the uuu snap:

  • If the uuu snap command is run as root then due to the current implementation of the home interface's security confinement, the program can't access files under the user home directory (i.e. uuu scripts can't be read)

I found that this is no longer the case as the home interface supports a read attribute which, when set to all, also allows reading non-hidden files in the home directories of all users as traditional file permissions allow. However, setting this attribute will make the interface non-auto-connect and requires a manual interface connection(sudo snap connect universal-update-utility:home) or a store approval for autoconnect by default. Refer Process for aliases, auto-connections and tracks - store-requests - snapcraft.io for details.

I've initiated the interface auto-connect request: Interface auto-connect request for the universal-update-utility snap - store-requests - snapcraft.io

@nxpfrankli
Copy link
Contributor

accepted invite

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 4, 2021

accepted invite

I've updated the request's status.

@nxpfrankli
Copy link
Contributor

image

I see. https://snapcraft.io/universal-update-utility/builds

I have not seen edit button.

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 5, 2021

I have not seen edit button

To set up a new repo for snap building, disconnect the old repo and connect to the new one.

@nxpfrankli
Copy link
Contributor

After I update selective-checkout part, get below error.

Staging selective-checkout

  • snapcraftctl stage
    Sorry, an error occurred in Snapcraft:
    [Errno 2] No such file or directory: '/build/universal-update-utility/parts/selective-checkout/install/scriptlets'
    Traceback (most recent call last):
    File "/snap/snapcraft/6120/bin/snapcraft", line 33, in
    sys.exit(load_entry_point('snapcraft==4.5.4', 'console_scripts', 'snapcraft')())
    File "/snap/snapcraft/6120/lib/python3.6/site-packages/click/core.py", line 829, in call
    return self.main(*args, **kwargs)
    File "/snap/snapcraft/6120/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
    File "/snap/snapcraft/6120/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/snap/snapcraft/6120/lib/python3.6/site-packages/snapcraft/cli/_command.py", line 89, in invoke
    return super().invoke(ctx)

@nxpfrankli nxpfrankli reopened this Mar 5, 2021
@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 5, 2021

After I update selective-checkout part, get below error.

Please revert 6cffef2 as the part isn't meant to be used like that.

This snap implementation also integrates a selective-checkout script which, will help ensure that stable/candidate/beta snap revision will always be built for promotion, however, it relies on distinguishable naming of git tags so it doesn't work for uuu. Refer Selective-checkout: Check out the tagged release revision if it isn't promoted to the stable channel - doc - snapcraft.io for more details.

Currently, the part will not do much else than always making the latest tagged release snap built at least once.

@nxpfrankli
Copy link
Contributor

nxpfrankli commented Mar 5, 2021

reverted. Do you why there are dirty at package name universal-update-utility_1.4.107-1-g8f92a02-**dirty_**s390x.snap?

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 5, 2021

Do you why there are dirty at package name universal-update-utility_1.4.107-1-g8f92a02-**dirty_**s390x.snap?

The selective-checkout script somehow determines the repo is modified, I'll check it out.

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 6, 2021

Do you why there are dirty at package name universal-update-utility_1.4.107-1-g8f92a02-**dirty_**s390x.snap?

I'm unable to reproduce the problem after fixing the selective-checkout part (#259), please verify.

@nxpfrankli
Copy link
Contributor

Still have dirty v1.4.107-7-g1b9a4d1-dirty (66)
https://snapcraft.io/universal-update-utility/releases

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 6, 2021

Still have dirty v1.4.107-7-g1b9a4d1-dirty (66)

I still unable to reproduce the problem locally:

Pulling main 
+ set -o nounset
+ snapcraftctl pull
+ /root/stage/scriptlets/selective-checkout --release-tag-pattern=uuu_[[:digit:]]+(\.[[:digit:]]+){2} --release-tag-prefix=uuu_
selective-checkout: The last tagged stable release(1.4.107) hasn't been promoted to the stable channel(1.4.107-1-g8f92a02-dirty) on the Snap Store yet, checking out 1.4.107.
Note: checking out 'uuu_1.4.107'.

However, after examining the build log (https://snapcraft.io/universal-update-utility/builds/1323496) I found it was the libusb submodule clone failure that causes the unclean state of the repo(#252):

Cloning into 'libusb'...
[06/Mar/2021:14:57:29 +0000] "CONNECT github.com:443 HTTP/1.1" 200 4080981 "-" "git/2.7.4"
[06/Mar/2021:14:57:29 +0000] "CONNECT github.com:443 HTTP/1.1" 200 27358 "-" "git/2.7.4"
fatal: reference is not a tree: e782eeb2514266f6738e242cdcb18e3ae1ed06fa
Cloning into 'zlib'...
[06/Mar/2021:14:57:30 +0000] "CONNECT github.com:443 HTTP/1.1" 200 3947446 "-" "git/2.7.4"
Submodule path 'zlib': checked out 'cacf7f1d4e3d44d871b605da3b647f07d718623f'
Unable to checkout 'e782eeb2514266f6738e242cdcb18e3ae1ed06fa' in submodule path 'libusb'
'git submodule update --init --recursive failed with exit code 1 (build may fail later)
snapcraft-universal-update-utility ../parts/main/src# git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

        modified:   libusb (new commits, modified content)

no changes added to commit (use "git add" and/or "git commit -a")

It appears to be a deficiency/bug in Git <2.8 that makes Git unable to check-out the submodule hash:

git 2.7.4(ubuntu 16.04) - failure
git 2.17.1 (ubuntu 18.04) - success
git 2.25.1 (ubuntu 20.04) - success
git 2.27.0 - success

Possible solution:

  • Upgrade Git before checking out submodule
  • Migrate to a recent Ubuntu Core base(core18) that ships a recent Git distribution

Reference

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Mar 6, 2021

Still have dirty v1.4.107-7-g1b9a4d1-dirty (66)

#262 PR should fix the problem.

@brlin-tw
Copy link
Contributor Author

I found that this is no longer the case as the home interface supports a read attribute which, when set to all, also allows reading non-hidden files in the home directories of all users as traditional file permissions allow. However, setting this attribute will make the interface non-auto-connect and requires a manual interface connection(sudo snap connect universal-update-utility:home) or a store approval for autoconnect by default. Refer Process for aliases, auto-connections and tracks - store-requests - snapcraft.io for details.

I've initiated the interface auto-connect request: Interface auto-connect request for the universal-update-utility snap - store-requests - snapcraft.io

Due to the snap ownership change and in order to accelerate the review process, I would like to ask for an additional confirmation that I am requesting the new interface assertion on behalf of you.

@nxpfrankli
Copy link
Contributor

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants