2

I've made a deb package which contains binaries of my software. Also I've made a repo and configured it so user can install updates using sudo apt-get update mypackage && sudo apt-get install mypackage. After installation binaries of my application will be extracted to /opt/mypackage and .desktop file will be extracted to /usr/share/applications so user can launch the application without issues.

What I want to know is how can I install updates of my application from code when they are available in the user system as it's done in other applications? I'm asking because it requires root password when running apt-get install or sudo gdebi mypackage.

At the moment when I want to push new updates - I build new .deb package and put it to the repository. Should I do it in the other way? Or maybe I was wrong when decided to put binaries in /opt directory?

Any help will be appreciated. If you know some open-source projects where this part of the functionality is implemented could you please share it? Also, I can create a simple repository which reproduces what I tried to explain here.

muru
  • 69,900
  • 13
  • 192
  • 292
  • "how can I install updates of my application from code... as it's done in other applications" ... which other applications? – muru Jun 20 '20 at 03:17
  • 1
    @muru for example VS Code. When a new version is available - it shows a popup where I can click on the Update button - updates will be installed. The same for Github Desktop, Firefox, Google Chrome, and many other applications – Sergey Anisimov Jun 20 '20 at 03:21
  • It'd be cool to see the answer. Not because I'm trying to do the same thing, but because browser update attempts always fail for me on apt-based distros and I'd like to see how they're supposed to work. – user1717828 Jun 20 '20 at 03:27
  • I don't use VSCode or GitHub Desktop, but at least when installed via deb packages, Firefox and Chrome don't update themselves. – muru Jun 20 '20 at 04:07
  • @muru, I've downloaded older version of firefox using this command `wget sourceforge.net/projects/ubuntuzilla/files/mozilla/apt/pool/main/f/firefox-mozilla-build/firefox-mozilla-build_39.0.3-0ubuntu1_amd64.deb` then installed it with `sudo dpkg -i firefox-mozilla-build_39.0.3-0ubuntu1_amd64.deb`. After first launch it coudn't install update because of permissions. Then I restarted it with `sudo firefox` - openned Home->About tab. Then application downloaded updates and installed it – Sergey Anisimov Jun 20 '20 at 04:40
  • That's kinda twisting things about by running it as root in the first place. And try the official debs (from Ubuntu or Debian) - iirc those come with the update mechanism disabled. Indeed, I'd think it's a bug if Ff or Chrome updated on my system without using the package management system. – muru Jun 20 '20 at 06:48
  • @muru, got it, thank you – Sergey Anisimov Jun 20 '20 at 07:30

1 Answers1

5

Providing software as a package (of the .deb or RPM variety) and allowing software to update itself on its own are mutually exclusive. As you noticed, installing or upgrading packaged software can only be done by the administrator, and it’s expected that the system will be kept updated by its administrator. On many systems this is made easier by tools such as GNOME Software which will tell the user about pending updates and take care of applying them without manually running apt update etc.

“Other” programs you mention, which can update themselves, can only do so if the user they’re running as can write to the locations they’re installed in. This is often the case with manually-installed binaries, but many larger programs have moved away from this in recent years — Google Chrome, and VS Code, now install from package repositories and behave as expected.

You worked around the limitations in Firefox’s case but that’s a bad idea. Running software as root when it doesn’t need to be root isn’t recommended, and letting a packaged piece of software update itself means the packaging system is no longer aware of what’s installed.

Another point is that most distribution-packaged software explicitly disables update checks — for one thing, they’re useless because they can’t be acted upon directly, and for another, disabling update checks means the software doesn’t need to “phone home”, which many users care about.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
  • Yes, I know that it wasn't a great idea to launch Firefox as sudo but I could modify permissions on the directory where it's installed. As I can see there are two options for me - change permissions on installation directories so that application will be able to modify it or distribute the application via *snap*. Am I correct at this point? – Sergey Anisimov Jun 20 '20 at 07:23
  • The first isn’t an option, letting a packaged application modify itself behind the package manager’s back is asking for trouble. So I guess that leaves snaps or flatpaks, yes. – Stephen Kitt Jun 20 '20 at 08:12