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

Replaced/improved Linux install and uninstall scripts. #3226

Closed
wants to merge 8 commits into from
Closed

Replaced/improved Linux install and uninstall scripts. #3226

wants to merge 8 commits into from

Conversation

fiechr
Copy link
Contributor

@fiechr fiechr commented May 25, 2015

This install script adds a menu item, desktop icon and file association (mime type) for the current user on Linux - even if the Arduino installation is placed outside of the user's home dir (such as in /opt or /usr/local) - which didn't worked before.

If the xdg-utils aren't available on the target system, a more basic approach is used (just generate and copy the file).

The uninstall script is a simple wrapper and calls the install script to undo the changes.

Also added three more icon resolutions (64px, 72px, 96px) - by using the 256px file - maybe there is a better (vector based) source available for exporting to these resolutions...

Modified build.xml for copying the existing/added icons and existing mime.xml file, both changed/added scripts and adjusted file permissions (ugo+x) for all *.sh files to be executable by others by default after archive extraction. A more conservative approach would be to set only install/uninstall.sh ugo+x.

I tested this on different machines and it works fine so far.

Install script adds menu item, desktop icon, file association for
the current user - even if the Arduino installation was placed
outside of the user's home dir (such as in /opt or /usr/local).

Added three more icon resolutions (64px, 72px, 96px) - by using
the 256px file - maybe there is a better source available for this...

Modified build.xml for copying the existing icons and mime.xml file,
both scripts and adjusted file permissions (ugo+x) for *.sh files to
be executable by others by default.
@ffissore
Copy link
Contributor

@ArduinoBot build this please

@ffissore ffissore self-assigned this May 25, 2015
@ffissore ffissore added the Component: IDE The Arduino IDE label May 25, 2015
@ffissore ffissore added this to the Release 1.6.5 milestone May 25, 2015
@fiechr
Copy link
Contributor Author

fiechr commented May 26, 2015

Tested the 32bit and 64bit Linux builds in- and outside the users home dir. Works as expected.

@NicoHood
Copy link
Contributor

NicoHood commented Jun 1, 2015

Is there any documenation on how to run those scripts?
Do I have to call the 1.6.3 uninstall script if I have 1.6.3 installed or can I use the 1.6.4 uninstall script or even run the install script without uninstalling?

@fiechr
Copy link
Contributor Author

fiechr commented Jun 1, 2015

Basically install.sh will add entries and icons for the current user, uninstall.sh will remove them. There shouldn't be any way to break anything which can't be restored by the script itself.

There is no need to uninstall first, because these these functions are called anyway when installing.
If there is an existing menu entry created by the current install script, it will be removed, too.

@NicoHood
Copy link
Contributor

NicoHood commented Jun 2, 2015

I've downloaded the PR and only added those two .sh files to my current nightly built (from today).
It deleted my menu bar icon which I created on my own. It added a desktop icon which cannot be executed and has no icon.

Before I added a .desktop entry into the application dir of ubuntu myself. It worked and I could pin it to the menu bar. It opened another instance which wasnt perfect but it worked.

Not sure what I am doing wrong.

@fiechr
Copy link
Contributor Author

fiechr commented Jun 2, 2015

To copy the scripts won't be enough. You also need the icon dir and the desktop.template file in the lib/ subdir. Both are in the pull request, too.
I only tested the complete build with all changes applied, so I can't guarantee if it will work this way - but it should.

@NicoHood
Copy link
Contributor

NicoHood commented Jun 2, 2015

Used the full PR now. The desktop icon is now working. I moved this to the menu bar as well.

The menu item is opening another instance of the IDE once again.
So I have the shortcut and the actual instance in my menu bar, 2 icons.

How do I fix this?

@fiechr
Copy link
Contributor Author

fiechr commented Jun 2, 2015

The install script adds two independent links. One in the general apps menu (Unity Dash menu for Ubuntu) and an additional one onto the desktop.

The script does not create a shortcut in the launcher. If the user wants it there, he/she has to start the app via the menu and then choose "lock to launcher" (or similar). This part is entirely distribution depended (in this case Ubuntu Unity).

If you drop the desktop icon into the launcher, its like adding a second app with the same name. So the behavior you describe is no surprise.

Personally I already thought of not adding the desktop icon at all, because it's kind of redundant anyway.

@NicoHood
Copy link
Contributor

NicoHood commented Jun 4, 2015

There is no "lock to launcher" option. I can only drag an drop and this opens a second icon.

@fiechr
Copy link
Contributor Author

fiechr commented Jun 5, 2015

You have to right click on the icon after you opened the program from the Dash menu:
arduinoideunitlauncher

@NicoHood
Copy link
Contributor

NicoHood commented Jun 5, 2015

Sadly i cannot create a screenshot when the sebmenu is opened.
Where you have "Arduino IDE" I have "sketch_jun05a [...]" like the name in the opened window. And if O lock this icon the IDE wont start on a click. If I move the desktop icon there it works but opens another instance as described in my last post.

@fiechr
Copy link
Contributor Author

fiechr commented Jun 5, 2015

Hmm... this is interesting. This seems to be a Java related issue, like it is described here:
http://askubuntu.com/a/367851

Many Java-based applications have the problem where the windows created by the application are not associated with the shortcut used to start the application (so the dock contains multiple copies of the same icon).

"Unfortunately" my Arduino windows already get automatically grouped by Unity if I open more than one sketch. Maybe because I use the Sun JDK instead of the OpenJDK? I'm using Ubuntu 14.04.

Using xprop on the Arduino window gives me:

$ xprop WM_CLASS
WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "processing-app-Base"

You could try adding

StartupWMClass=processing-app-Base

to the arduino-arduinoide.desktop file in ~/.local/share/applications

If this helps, I could add this to the .desktop file.

@NicoHood
Copy link
Contributor

NicoHood commented Jun 6, 2015

I am using java 8 due to this bug (used the linked installation instructions) #3174
I am also using the stable Ubuntu release which you can download from the website. I thinks it has a lower version number than yours.

 xprop WM_CLASS
WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "processing-app-Base"

StartupWMClass=processing-app-Base

This helps!
So if you add this it should be fine. +1 to merge this!

Edit: By the way: I think the new IDE nightly already has some new high res pictures somewhere. Because the icon in the menu bar is also better now. Not sure about that, just want to say it to not dupe the pics.

This should group all open Arduino IDE windows together under one icon (i.e. Ubuntu Unity launcher)
@NicoHood
Copy link
Contributor

NicoHood commented Jun 7, 2015

.ino files now open with the IDE, it would be nice to add the icon to the file as well (if possible).
Is there also a recommended location where the IDE should be placed? I have it somewhere in my home folder.

@fiechr
Copy link
Contributor Author

fiechr commented Jun 7, 2015

AFAIK file icons can only be changed by writing to a dir outside the user's home dir - which I wanted to avoid, because everything else works fine without root access. Also I would need a scalable image file (SVG) of the used IDE icon for this.

I guess most people put it in the home folder - which is absolutely fine. I like to put additional "external" software in /opt - but that's mostly a matter of taste.

@NicoHood
Copy link
Contributor

NicoHood commented Jun 7, 2015

So I have to put the arduino folder there and run the script from this location again?
/opt makes totally sense. Thanks

So the script now works fine. I havent checked the script itself since I dont know enough about scripts. But it works and should be added to the IDE.

@fiechr
Copy link
Contributor Author

fiechr commented Jun 7, 2015

So I have to put the arduino folder there and run the script from this location again?

Yes, that should do it.

@NicoHood
Copy link
Contributor

@ffissore can you please review this so we see it in the new 1.6.5 release?

@ffissore ffissore modified the milestones: Release 1.6.5, Release 1.6.6 Jun 15, 2015
@NicoHood
Copy link
Contributor

Cant anyone review this?

@matthijskooijman
Copy link
Collaborator

I just reviewed the code, looks ok to me. I wonder if the "legacy" code really needs to be kept around in this script? I'd say that if you want to use XDG-style shortcuts, it is ok to just require xdg-utils to be installed. If you really don't want xdg-utils, you can still just create the .desktop manually. @cmaglie, any view on this?

Regarding the startup wmclass thing, having that set to "processing" probably isn't ideal, since it might conflict with the actual processing. Any idea if we can change that? Or is that tied to the main class name perhaps?

Finally, I think the script should support the -h and --help options. When I have an unknown script, I usually run it with --help to see what it will be doing exactly and I expect either help output, or an error that --help isn't supported. Right now, the script just proceeds with installing, which isn't so great.

I just tested the current build on Debian Jessie, which works as expected :-)

@NicoHood
Copy link
Contributor

I aggree with the -h option.

The script works perfectly for me. Ive used it once and the shortcut just keeps working since then, even with newer builds. I used Elementary OS here, based on ubuntu, based on debian.

@fiechr
Copy link
Contributor Author

fiechr commented Oct 29, 2015

Regarding the startup wmclass thing, having that set to "processing" probably isn't ideal, since it might conflict with the actual processing. Any idea if we can change that? Or is that tied to the main class name perhaps?

Yeah, I agree, that bothered me a little bit, too - it's definitely not ideal. But it seems the only reliable ID a (Java) window/app can be identified by. I have no idea how much effort it would be to change this.

I just reviewed the code, looks ok to me. I wonder if the "legacy" code really needs to be kept around in this script?

The main reason I put this in in the first place, is for removing existing links/symbols created by the existing install script.
But I also don't know how many distributions come with XDG tools (installed), so I wanted to make sure that a least something useful is created - which, I guess, is better than giving an error message or do nothing.

About the --help / -h option:
I also think that's a good idea - I will add this. :-)

(First I thought about asking the user before doing anything - but then user interaction would be required - and I also don't wanted it to be too complicated.)

@matthijskooijman
Copy link
Collaborator

The main reason I put this in in the first place, is for removing existing links/symbols created by the existing install script.
It doesn't seem unreasonable to expect people to uninstall the old version before installing this one, though it might be good to also uninstall it before installing, indeed.

But I also don't know how many distributions come with XDG tools (installed), so I wanted to make sure that a least something useful is created - which, I guess, is better than giving an error message or do nothing.

Having an error message that says "please install xdg-utils" seems reasonable to me? The end result is actually better than falling back to a short-cut-only install.

@matthijskooijman
Copy link
Collaborator

About the --help / -h option:
I also think that's a good idea - I will add this. :-)

It's probably a good idea to also error out when any unknown options are given?

@fiechr
Copy link
Contributor Author

fiechr commented Nov 2, 2015

I added a help option:

$ ./install -h

This script will add an Arduino IDE menu entry, icons and
file associations for the current user.

Optional arguments are:

    -u, --uninstall          Removes icons and menu item.

    -h, --help               Shows this help again.

All other arguments will produce an error:

$ ./install.sh --unknown

Invalid option -- '--unknown'

(and after this show the help above)

If xdg-utils isn't found on the system the help will also show a note that they are recommended.

@matthijskooijman
Copy link
Collaborator

Help option looks good to me!

@jonnius
Copy link

jonnius commented Nov 17, 2015

Please fix issue #4168, too! In your PR it still persists.

@fiechr
Copy link
Contributor Author

fiechr commented Nov 18, 2015

Thanks! I will look into it!

@fiechr
Copy link
Contributor Author

fiechr commented Nov 20, 2015

I changed the script so it will (basically) use the following method to find the correct Desktop directory:
http://www.freedesktop.org/wiki/Software/xdg-user-dirs/
This should also work for different languages/names of this folder.
If nothing is found this way, it will fall back to ~/Desktop (if it exists).

This change only affects the "simple install" mode, because the default install using the xdg-utils should already figure out the correct target directory by itself.

It would be nice if someone could test this on a system where the desktop folder's name isn't "Desktop" (and/or isn't placed in $HOME).

If you already have xdg-utils installed and also want to test the script without it, just edit the install.sh script file and replace
return 0
with
return 1
on line 182.

@jonnius
Copy link

jonnius commented Nov 20, 2015

The path is correct now. But the created desktop file on desktop is empty. Here is the output: https://gist.github.com/jonnius/1a4c75ba012b8baab090

@fiechr
Copy link
Contributor Author

fiechr commented Nov 21, 2015

Just to be sure: Can you shortly describe how you tested this? Did you just take the script files or rebuild the whole package including all changes? Because there are other files included which are needed.

For example:
sed claims "[...]/Arduino/build/linux/dist/lib/desktop.template" can't be found. But it's part of the Arduino package/archive (of this PR) - so it has to be there.

The same is true for all the icon files and the mime xml file.

@jonnius
Copy link

jonnius commented Nov 21, 2015

I cloned this branch and just started the script.

  • The icons seem to be located in build/shared/icons, but it is looking for it in build/linux/dist/lib/icons.
  • The desktop.template is located in build/linux/dist/desktop.template, but it is looking for build/linux/dist/lib/desktop.template.
  • I cannot find any arduino-arduinoide.xml in the branch at all...

@fiechr
Copy link
Contributor Author

fiechr commented Nov 21, 2015

Ok, that explains it. You need to build the dist package first!

Go to Arduino/build in the cloned repo/branch and start the provided build-all-dist.bash script. This will create two archives in the Arduino dir (32 and 64bit) which are the archives you want to install/extract (like the official ones you can download on the website). You only need one of these - depending on your system.
The script will also try to build the Windows version, which will most likely fail - just ignore that.

@jonnius
Copy link

jonnius commented Nov 21, 2015

I ran the build-all script and as you mentioned, linux build was successful and windows build was not. But after that I still have the same issue as before.

@fiechr
Copy link
Contributor Author

fiechr commented Nov 21, 2015

Where exactly did you extract the created archive? If it's really the exact same error as before, then it seems you are still starting the script from within the repository structure.

@jonnius
Copy link

jonnius commented Nov 21, 2015

Sorry, i was in the wrong directory. I can confirm that it works as expected! Thanks!

@ffissore
Copy link
Contributor

@fiechr I've rebased your PR and pushed it to master. It will be available in next hourly build http://www.arduino.cc/en/Main/Software#hourly. Thank you very much for your time and patience

@ffissore ffissore closed this Nov 23, 2015
@ffissore ffissore added this to the Release 1.6.7 milestone Nov 23, 2015
@NicoHood
Copy link
Contributor

NicoHood commented Dec 4, 2015

Except that my raspberry pi (arm) IDE doesnt start at all the install script adds a few warnings:

pi@raspberrypi ~/Documents/Arduino/Arduino/build $ ./linux/work/install.sh 
Adding desktop shortcut, menu item and file associations for Arduino IDE...touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
touch: cannot touch ‘/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy’: No such file or directory
 done!

Might be related to the LXDE desktop, idk. Just want to mention it here. Hope I can get #3549 running some day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE The Arduino IDE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants