bug: apt-ppa-noninteractive #327

Merged
nico merged 2 commits from romain-dartigues/cdist:apt-ppa-noninteractive into master 2022-05-20 12:57:09 +00:00
Contributor

I'm currently subject to a strange bug where the __apt_ppa type fail expecting an interactive input.

Note this pull-request address two distincts issues, I'll split them if you ask.

  1. the add-apt-repository command thinking it's running in interactive mode
  2. the remove-apt-repository command which is not available in my Ubuntus

For both cases, the Ubuntu manual seems to allow my patch, but it might need testing under other Debian derivates:
http://manpages.ubuntu.com/manpages/trusty/man1/add-apt-repository.1.html

Environment

Target:

  • Ubuntu bionic 18.04.6
  • Ubuntu focal 20.04
  • Linux Mint uma (based on Ubuntu focal)

Manifest:

while read -r pkg ppa
do
	__apt_ppa "$ppa" --state present
	require="__apt_ppa/$ppa __apt_update_index" __package "$pkg" --state present
done <<-'EOF'
	git ppa:git-core/ppa
	inkscape ppa:inkscape.dev/stable
	keepassxc ppa:phoerious/keepassxc
EOF

Error:

ERROR: localhost: ssh -o User=root -o ControlPath=/tmp/tmpuzgzz26l/s
-o ControlMaster=auto -o ControlPersist=2h localhost /bin/sh -c '
export __object=/var/lib/cdist/object/__apt_ppa/ppa:phoerious/keepassxc/.cdist-_8xa0_3o;
 export __object_id=ppa:phoerious/keepassxc;/bin/sh -e
/var/lib/cdist/object/__apt_ppa/ppa:phoerious/keepassxc/.cdist-_8xa0_3o/code-remote':
['ssh', '-o', 'User=root', '-o', 'ControlPath=/tmp/tmpuzgzz26l/s',
'-o', 'ControlMaster=auto', '-o', 'ControlPersist=2h', 'localhost',
"/bin/sh -c ' export
__object=/var/lib/cdist/object/__apt_ppa/ppa:phoerious/keepassxc/.cdist-_8xa0_3o;
 export __object_id=ppa:phoerious/keepassxc;/bin/sh -e
/var/lib/cdist/object/__apt_ppa/ppa:phoerious/keepassxc/.cdist-_8xa0_3o/code-remote'"]

Error processing object '__apt_ppa/ppa:phoerious/keepassxc'
===========================================================
name: __apt_ppa/ppa:phoerious/keepassxc
path: /tmp/tmpcyuudjy2/421aa90e079fa326b6494f812ad13e79/data/object/__apt_ppa/ppa:phoerious/keepassxc/.cdist-_8xa0_3o
source: manifest
type: /home/rdartigues/.local/lib/python3.8/site-packages/cdist/conf/type/__apt_ppa

code-remote:stdout
------------------
You are about to add the following PPA:
 KeePassXC Password Manager (official upstream PPA)

https://keepassxc.org/download/
 More info: https://launchpad.net/~phoerious/+archive/ubuntu/keepassxc
Unable to prompt for response.  Please run with -y

code-remote:stderr
------------------
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
I'm currently subject to a strange bug where the `__apt_ppa` type fail expecting an interactive input. Note this pull-request address **two** distincts issues, I'll split them if you ask. 1. the `add-apt-repository` command thinking it's running in interactive mode 2. the `remove-apt-repository` command which is not available in my Ubuntus For both cases, the Ubuntu manual seems to allow my patch, but it might need testing under other Debian derivates: http://manpages.ubuntu.com/manpages/trusty/man1/add-apt-repository.1.html ## Environment Target: - Ubuntu bionic 18.04.6 - Ubuntu focal 20.04 - Linux Mint uma (based on Ubuntu focal) Manifest: ```sh while read -r pkg ppa do __apt_ppa "$ppa" --state present require="__apt_ppa/$ppa __apt_update_index" __package "$pkg" --state present done <<-'EOF' git ppa:git-core/ppa inkscape ppa:inkscape.dev/stable keepassxc ppa:phoerious/keepassxc EOF ``` Error: ``` ERROR: localhost: ssh -o User=root -o ControlPath=/tmp/tmpuzgzz26l/s -o ControlMaster=auto -o ControlPersist=2h localhost /bin/sh -c ' export __object=/var/lib/cdist/object/__apt_ppa/ppa:phoerious/keepassxc/.cdist-_8xa0_3o; export __object_id=ppa:phoerious/keepassxc;/bin/sh -e /var/lib/cdist/object/__apt_ppa/ppa:phoerious/keepassxc/.cdist-_8xa0_3o/code-remote': ['ssh', '-o', 'User=root', '-o', 'ControlPath=/tmp/tmpuzgzz26l/s', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=2h', 'localhost', "/bin/sh -c ' export __object=/var/lib/cdist/object/__apt_ppa/ppa:phoerious/keepassxc/.cdist-_8xa0_3o; export __object_id=ppa:phoerious/keepassxc;/bin/sh -e /var/lib/cdist/object/__apt_ppa/ppa:phoerious/keepassxc/.cdist-_8xa0_3o/code-remote'"] Error processing object '__apt_ppa/ppa:phoerious/keepassxc' =========================================================== name: __apt_ppa/ppa:phoerious/keepassxc path: /tmp/tmpcyuudjy2/421aa90e079fa326b6494f812ad13e79/data/object/__apt_ppa/ppa:phoerious/keepassxc/.cdist-_8xa0_3o source: manifest type: /home/rdartigues/.local/lib/python3.8/site-packages/cdist/conf/type/__apt_ppa code-remote:stdout ------------------ You are about to add the following PPA: KeePassXC Password Manager (official upstream PPA) https://keepassxc.org/download/ More info: https://launchpad.net/~phoerious/+archive/ubuntu/keepassxc Unable to prompt for response. Please run with -y code-remote:stderr ------------------ Unable to init server: Could not connect: Connection refused Unable to init server: Could not connect: Connection refused ```
romain-dartigues added 2 commits 2021-12-24 15:48:47 +00:00
c98a63451e use add-apt-repository instead of add-apt-repository
In Ubuntu Bionic 18.04 and Focal 20.04, the command remove-apt-repository
either does not exists or fail in a default installation with the error:

    ModuleNotFoundError: No module named 'softwareproperties'

But add-apt-repository allow removal through the `-r` flag.
First-time contributor

As @ssrq pointed out in chat, remove-apt-repository is a script installed in /usr/local/bin/ by this type itself. The given script will remove the repository via the python API. It looks like at the time where the type was written (11 years ago - 2011), there was no clean method of removing such a repository.

I think we can obsolete this old script as it's feature is provided by the official script. I coudn't find a point in changelog where the remove feature was added. As your manual quote is from Ubuntu trusty (14.04) with no older ones at record, it looks like an accurate time it was added. I've found a Stackoverflow anwser which describes workarounds for Ubuntu precise (12.04) in 2015, so I guess it was around this time. Ubuntu trusty is EOL since 2019.

As this is old legacy, I don't think we need to care about backward compatibility. To make this PR complete, it would require to remove the pieces from remove-apt-repository out of the manifest and the files/ directory.

Fun fact: as digging though the changelog, i've noticed that the add-apt-repository was added in 2009 and the -y parameter was added at the 19th April 2011 - while the type was added at 23th March 2011.

As @ssrq pointed out in chat, `remove-apt-repository` is a script installed in `/usr/local/bin/` by this type itself. The given script will remove the repository via the python API. It looks like at the time where the type was written (11 years ago - 2011), there was no clean method of removing such a repository. I think we can obsolete this old script as it's feature is provided by the official script. I coudn't find a point in changelog where the remove feature was added. As your manual quote is from Ubuntu trusty (14.04) with no older ones at record, it looks like an accurate time it was added. I've found a [Stackoverflow anwser](https://unix.stackexchange.com/a/219344) which describes workarounds for Ubuntu precise (12.04) in 2015, so I guess it was around this time. Ubuntu trusty is EOL since 2019. As this is old legacy, I don't think we need to care about backward compatibility. To make this PR complete, it would require to remove the pieces from `remove-apt-repository` out of the manifest and the `files/` directory. Fun fact: *as digging though the changelog, i've noticed that the `add-apt-repository` was added in 2009 and the `-y` parameter was added at the 19th April 2011 - while the type was added at 23th March 2011.*
Owner

The existing PR does not look bad to me, don't have an ubuntu at hand right now. I guess if it works with Ubuntu 18.04, then we can merge it - as anything older is ancient anyway.

The existing PR does not look bad to me, don't have an ubuntu at hand right now. I guess if it works with Ubuntu 18.04, then we can merge it - as anything older is ancient anyway.
Owner

cc @steven who is maintaining Ubuntu clusters.

cc @steven who is maintaining Ubuntu clusters.
Owner

@romain-dartigues if using your PR, it would make sense to remove the script remove-apt-repository as well.

@romain-dartigues if using your PR, it would make sense to remove the script `remove-apt-repository` as well.
Author
Contributor

I missed @matze review and just caught it with your notification nico... I'll work on it quickly; thank you for your feedback.

Edit: (and ping @nico) let me know if it is suffisent.

I missed @matze review and just caught it with your notification nico... I'll work on it quickly; thank you for your feedback. Edit: (and ping @nico) let me know if it is suffisent.
romain-dartigues force-pushed apt-ppa-noninteractive from c98a63451e to 54a5cb17b7 2022-04-11 19:15:35 +00:00 Compare
nico merged commit e5adcf451b into master 2022-05-20 12:57:09 +00:00
romain-dartigues deleted branch apt-ppa-noninteractive 2024-02-10 20:02:36 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ungleich-public/cdist#327
No description provided.