linuxmint / mintsources

53 stars 72 forks source link

Support same options as upstream apt-add-repository #171

Open assarbad opened 5 years ago

assarbad commented 5 years ago

First off, here's the system I am working on.

$ apt policy mintsources
mintsources:
  Installed: 1.8.4
  Candidate: 1.8.4
  Version table:
 *** 1.8.4 700
        700 http://packages.linuxmint.com tessa/upstream amd64 Packages
        700 http://packages.linuxmint.com tessa/upstream i386 Packages
        100 /var/lib/dpkg/status
$ lsb_release -a
No LSB modules are available.
Distributor ID: LinuxMint
Description:    Linux Mint 19.1 Tessa
Release:        19.1
Codename:       tessa

Some time ago I had noticed that apt-add-repository on Mint was using a Python wrapper script instead of the apt-add-repository I've been used to.

I have now noticed two issues, the bigger one for me being that the mintsources version doesn't accept the same command line options (which makes it harder to write scripts usable both on upstream Ubuntu and Mint).

Anyway, the first issue is that executing apt-add-repository without a command line switch makes the Python code barf. In the upstream version the result is the following error message Error: need a repository as argument and an exit code of 1. The Mint version gives the following:

$ apt-add-repository
Traceback (most recent call last):
  File "/usr/bin/apt-add-repository", line 9, in <module>
    if os.geteuid() != 0 and sys.argv[1] not in ("-h", "--help"):
IndexError: list index out of range

I guess it should first check that sys.argv is non-empty (e.g. via len(sys.argv)).

... (and oddly enough the Mint version does not require root, whereas the upstream version does with Error: must run as root).

The second issue is that Mint's version of apt-add-repository does not accept -u or --update. But on closer inspection this also seems to be true for several other command line switches supported by the upstream apt-add-repository.


I've been comparing with the upstream version of apt-add-repository from Ubuntu 18.04.

$ apt policy software-properties-common
software-properties-common:
  Installed: 0.96.24.32.7
  Candidate: 0.96.24.32.7
  Version table:
 *** 0.96.24.32.7 500
        500 http://de.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     0.96.24.32.1 500
        500 http://de.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

For reference, the following help output is given by that version of apt-add-repository:

$ apt-add-repository --help
Usage: apt-add-repository <sourceline>

apt-add-repository is a script for adding apt sources.list entries.
It can be used to add any repository and also provides a shorthand
syntax for adding a Launchpad PPA (Personal Package Archive)
repository.

<sourceline> - The apt repository source line to add. This is one of:
  a complete apt line in quotes,
  a repo url and areas in quotes (areas defaults to 'main')
  a PPA shortcut.
  a distro component

  Examples:
    apt-add-repository 'deb http://myserver/path/to/repo stable myrepo'
    apt-add-repository 'http://myserver/path/to/repo myrepo'
    apt-add-repository 'https://packages.medibuntu.org free non-free'
    apt-add-repository http://extras.ubuntu.com/ubuntu
    apt-add-repository ppa:user/repository
    apt-add-repository ppa:user/distro/repository
    apt-add-repository multiverse

If --remove is given the tool will remove the given sourceline from your
sources.list

Options:
  -h, --help            show this help message and exit
  -m, --massive-debug   Print a lot of debug information to the command line
  -r, --remove          remove repository from sources.list.d directory
  -s, --enable-source   Allow downloading of the source packages from the
                        repository
  -y, --yes             Assume yes to all queries
  -n, --no-update       Do not update package cache after adding
  -u, --update          Update package cache after adding (legacy option)
  -k KEYSERVER, --keyserver=KEYSERVER
                        Legacy option, unused.
tsharitt commented 5 years ago

As far as the issue of the error when running without arguments, i may have introduced that when I made a change to allow -h and --help without root, I'm looking into that now. I think this may be what leads you to believe root is not required, nut it is if you actually add or remove a repository. As far as the features go, that's a question of either emulating upstream or just using the upstream package. I believe the mint version was just meant to be a simple wrapper to give some cli support to the gui tools, but not sure. Probably needs to be looked at from further up. I can certainly look into emulating the upstream features on this wrapper if that is deemed a worthy course of action.

xenopeek commented 4 years ago

The first issue is solved:

$ sudo apt-add-repository
Error: need a repository as argument

For the second issue, these are the supported options:

$ apt-add-repository --help
Usage: apt-add-repository [options] repository

Options:
  -h, --help    show this help message and exit
  -y, --yes     force yes on all confirmation questions
  -r, --remove  Remove the specified repository

apt-add-repository doesn't update the package cache after updating.

Jackenmen commented 2 years ago

Is this feature request accepted and can be PRed?