{"action":"created","comment":{"url":"https://api.github.com/repos/chef/chef/pulls/comments/92702523","pull_request_review_id":13223471,"id":92702523,"diff_hunk":"@@ -0,0 +1,87 @@\n+#!/usr/bin/env python3\n+# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4\n+\n+import sys\n+import dnf\n+import hawkey\n+import signal\n+import os\n+import json\n+\n+from pprint import pprint\n+\n+base = None\n+\n+def get_sack():\n+    global base\n+    if base is None:\n+        base = dnf.Base()\n+        base.read_all_repos()\n+        base.fill_sack()\n+    return base.sack\n+\n+# FIXME: leaks memory and does not work\n+def flushcache():\n+    try:\n+        os.remove('/var/cache/dnf/@System.solv')\n+    except OSError:\n+        pass\n+    get_sack().load_system_repo(build_cache=True)\n+\n+def query(command):\n+    sack = get_sack()\n+\n+    subj = dnf.subject.Subject(command['provides'])\n+    q = subj.get_best_query(sack, with_provides=True)\n+\n+    if command['action'] == \"whatinstalled\":\n+        q = q.installed()\n+\n+    if command['action'] == \"whatavailable\":\n+        q = q.available()\n+\n+    if 'epoch' in command:\n+        q = q.filterm(epoch=int(command['epoch']))\n+    if 'version' in command:\n+        q = q.filterm(version__glob=command['version'])\n+    if 'release' in command:\n+        q = q.filterm(release__glob=command['release'])\n+\n+    if 'arch' in command:\n+        q = q.filterm(arch__glob=command['arch'])\n+\n+    # only apply the default arch query filter if it returns something\n+    archq = q.filter(arch=[ 'noarch', hawkey.detect_arch() ])\n+    if len(archq.run()) > 0:\n+        q = archq\n+\n+    pkgs = dnf.query.latest_limit_pkgs(q, 1)\n+\n+    if not pkgs:\n+        sys.stdout.write('{} nil nil\\n'.format(command['provides'].split().pop(0)))\n+    else:\n+        pkg = pkgs.pop(0)\n+        sys.stdout.write('{} {}:{}-{} {}\\n'.format(pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch))\n+\n+def exit_handler(signal, frame):\n+    sys.exit(0)\n+\n+signal.signal(signal.SIGINT, exit_handler)\n+signal.signal(signal.SIGHUP, exit_handler)\n+signal.signal(signal.SIGPIPE, exit_handler)\n+signal.signal(signal.SIGCHLD, exit_handler)\n+\n+while 1:\n+    ppid = os.getppid()\n+    if ppid == 1:\n+        sys.exit(0)","path":"lib/chef/provider/package/dnf_helper.py","position":77,"original_position":77,"commit_id":"1e50b9e35f0135df3cf5ad1fa102849757e1303a","original_commit_id":"1e50b9e35f0135df3cf5ad1fa102849757e1303a","user":{"login":"lamont-granquist","id":454857,"avatar_url":"https://avatars.githubusercontent.com/u/454857?v=3","gravatar_id":"","url":"https://api.github.com/users/lamont-granquist","html_url":"https://github.com/lamont-granquist","followers_url":"https://api.github.com/users/lamont-granquist/followers","following_url":"https://api.github.com/users/lamont-granquist/following{/other_user}","gists_url":"https://api.github.com/users/lamont-granquist/gists{/gist_id}","starred_url":"https://api.github.com/users/lamont-granquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamont-granquist/subscriptions","organizations_url":"https://api.github.com/users/lamont-granquist/orgs","repos_url":"https://api.github.com/users/lamont-granquist/repos","events_url":"https://api.github.com/users/lamont-granquist/events{/privacy}","received_events_url":"https://api.github.com/users/lamont-granquist/received_events","type":"User","site_admin":false},"body":"yeah i actually found i was getting orphaned subprocesses due to bugs when i was hammering on it with tests, and this code cleaned them all up (plus i went and fixed the bugs)\r\n\r\nthe dnf helper kind of tries to be very 'brittle' and die if anything goes wrong -- hence this code, plus the exit handler, etc.  trying very hard to avoid littering customer's process tables...","created_at":"2016-12-15T21:22:35Z","updated_at":"2016-12-15T21:22:35Z","html_url":"https://github.com/chef/chef/pull/4894#discussion_r92702523","pull_request_url":"https://api.github.com/repos/chef/chef/pulls/4894","_links":{"self":{"href":"https://api.github.com/repos/chef/chef/pulls/comments/92702523"},"html":{"href":"https://github.com/chef/chef/pull/4894#discussion_r92702523"},"pull_request":{"href":"https://api.github.com/repos/chef/chef/pulls/4894"}}},"pull_request":{"url":"https://api.github.com/repos/chef/chef/pulls/4894","id":68951017,"html_url":"https://github.com/chef/chef/pull/4894","diff_url":"https://github.com/chef/chef/pull/4894.diff","patch_url":"https://github.com/chef/chef/pull/4894.patch","issue_url":"https://api.github.com/repos/chef/chef/issues/4894","number":4894,"state":"open","locked":false,"title":"DNF Provider PR #2","user":{"login":"lamont-granquist","id":454857,"avatar_url":"https://avatars.githubusercontent.com/u/454857?v=3","gravatar_id":"","url":"https://api.github.com/users/lamont-granquist","html_url":"https://github.com/lamont-granquist","followers_url":"https://api.github.com/users/lamont-granquist/followers","following_url":"https://api.github.com/users/lamont-granquist/following{/other_user}","gists_url":"https://api.github.com/users/lamont-granquist/gists{/gist_id}","starred_url":"https://api.github.com/users/lamont-granquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamont-granquist/subscriptions","organizations_url":"https://api.github.com/users/lamont-granquist/orgs","repos_url":"https://api.github.com/users/lamont-granquist/repos","events_url":"https://api.github.com/users/lamont-granquist/events{/privacy}","received_events_url":"https://api.github.com/users/lamont-granquist/received_events","type":"User","site_admin":false},"body":"- should fully support globbing, arches, versions and all other syntax in the name of the package:\r\n\r\n```ruby\r\ndnf_package \"tcpd*-4*\"\r\ndnf_package \"tcpd\\*.x86_64\"\r\n```\r\n\r\n- supports provides syntax in the name:\r\n\r\n```ruby\r\ndnf_package \"tcpdump >= 4.7\"\r\n```\r\n\r\n- supports version and arch properties, with globs in the version\r\n\r\n```ruby\r\ndnf_package \"tcpdump\" do\r\n  version \"4.7*\"\r\n  arch \"x86_64\"\r\nend\r\n\r\ndnf_package \"tcpdump\" do\r\n  version \"4.7.4\"\r\nend\r\n\r\ndnf_package \"tcpdump\" do\r\n  version \"4.7.4-4.fc24\"\r\nend\r\n\r\ndnf_package \"tcpdump\" do\r\n  version \"0:4.7.4-4.fc24\"\r\nend\r\n```\r\n\r\nNOTE: release globs are not supported (\"4.7.4-4*\") but that is because it doesn't work on the command line with DNF either\r\n\r\n\r\n- supports source argument and paths to rpms:\r\n   (NOTE: multipackage with source arguments is busted, it is also busted with yum, the stuff i did for dpkg needs to be rethought.)\r\n\r\n```ruby\r\ndnf_package \"/a/path/to/tcpdump-4.7.10-1.fc23.x86_64.rpm\"\r\ndnf_package \"tcpdump\" do\r\n  source  \"/a/path/to/tcpdump-4.7.10-1.fc23.x86_64.rpm\"\r\nend\r\n```\r\n\r\n- NOTE: will not support groups\r\n\r\ncloses #3201\r\ncloses #1640","created_at":"2016-05-05T00:01:52Z","updated_at":"2016-12-15T21:22:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a997cc7546f79fba9e8a64e0711e4653f40c4526","assignee":{"login":"lamont-granquist","id":454857,"avatar_url":"https://avatars.githubusercontent.com/u/454857?v=3","gravatar_id":"","url":"https://api.github.com/users/lamont-granquist","html_url":"https://github.com/lamont-granquist","followers_url":"https://api.github.com/users/lamont-granquist/followers","following_url":"https://api.github.com/users/lamont-granquist/following{/other_user}","gists_url":"https://api.github.com/users/lamont-granquist/gists{/gist_id}","starred_url":"https://api.github.com/users/lamont-granquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamont-granquist/subscriptions","organizations_url":"https://api.github.com/users/lamont-granquist/orgs","repos_url":"https://api.github.com/users/lamont-granquist/repos","events_url":"https://api.github.com/users/lamont-granquist/events{/privacy}","received_events_url":"https://api.github.com/users/lamont-granquist/received_events","type":"User","site_admin":false},"assignees":[{"login":"lamont-granquist","id":454857,"avatar_url":"https://avatars.githubusercontent.com/u/454857?v=3","gravatar_id":"","url":"https://api.github.com/users/lamont-granquist","html_url":"https://github.com/lamont-granquist","followers_url":"https://api.github.com/users/lamont-granquist/followers","following_url":"https://api.github.com/users/lamont-granquist/following{/other_user}","gists_url":"https://api.github.com/users/lamont-granquist/gists{/gist_id}","starred_url":"https://api.github.com/users/lamont-granquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamont-granquist/subscriptions","organizations_url":"https://api.github.com/users/lamont-granquist/orgs","repos_url":"https://api.github.com/users/lamont-granquist/repos","events_url":"https://api.github.com/users/lamont-granquist/events{/privacy}","received_events_url":"https://api.github.com/users/lamont-granquist/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/chef/chef/milestones/13","html_url":"https://github.com/chef/chef/milestone/13","labels_url":"https://api.github.com/repos/chef/chef/milestones/13/labels","id":975715,"number":13,"title":"Accepted Minor","description":"Bucket to pull issues from for next minor. These issues should be fixable without needing a *major* version bump per semver; they're unlikely to cause a compatibility break or an API change.","creator":{"login":"lamont-granquist","id":454857,"avatar_url":"https://avatars.githubusercontent.com/u/454857?v=3","gravatar_id":"","url":"https://api.github.com/users/lamont-granquist","html_url":"https://github.com/lamont-granquist","followers_url":"https://api.github.com/users/lamont-granquist/followers","following_url":"https://api.github.com/users/lamont-granquist/following{/other_user}","gists_url":"https://api.github.com/users/lamont-granquist/gists{/gist_id}","starred_url":"https://api.github.com/users/lamont-granquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamont-granquist/subscriptions","organizations_url":"https://api.github.com/users/lamont-granquist/orgs","repos_url":"https://api.github.com/users/lamont-granquist/repos","events_url":"https://api.github.com/users/lamont-granquist/events{/privacy}","received_events_url":"https://api.github.com/users/lamont-granquist/received_events","type":"User","site_admin":false},"open_issues":307,"closed_issues":185,"state":"open","created_at":"2015-02-11T18:42:48Z","updated_at":"2016-12-12T14:47:32Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/chef/chef/pulls/4894/commits","review_comments_url":"https://api.github.com/repos/chef/chef/pulls/4894/comments","review_comment_url":"https://api.github.com/repos/chef/chef/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chef/chef/issues/4894/comments","statuses_url":"https://api.github.com/repos/chef/chef/statuses/1e50b9e35f0135df3cf5ad1fa102849757e1303a","head":{"label":"chef:lcg/dnf-provider","ref":"lcg/dnf-provider","sha":"1e50b9e35f0135df3cf5ad1fa102849757e1303a","user":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"repo":{"id":108278,"name":"chef","full_name":"chef/chef","owner":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chef/chef","description":"A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.","fork":false,"url":"https://api.github.com/repos/chef/chef","forks_url":"https://api.github.com/repos/chef/chef/forks","keys_url":"https://api.github.com/repos/chef/chef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chef/chef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chef/chef/teams","hooks_url":"https://api.github.com/repos/chef/chef/hooks","issue_events_url":"https://api.github.com/repos/chef/chef/issues/events{/number}","events_url":"https://api.github.com/repos/chef/chef/events","assignees_url":"https://api.github.com/repos/chef/chef/assignees{/user}","branches_url":"https://api.github.com/repos/chef/chef/branches{/branch}","tags_url":"https://api.github.com/repos/chef/chef/tags","blobs_url":"https://api.github.com/repos/chef/chef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chef/chef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chef/chef/git/refs{/sha}","trees_url":"https://api.github.com/repos/chef/chef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chef/chef/statuses/{sha}","languages_url":"https://api.github.com/repos/chef/chef/languages","stargazers_url":"https://api.github.com/repos/chef/chef/stargazers","contributors_url":"https://api.github.com/repos/chef/chef/contributors","subscribers_url":"https://api.github.com/repos/chef/chef/subscribers","subscription_url":"https://api.github.com/repos/chef/chef/subscription","commits_url":"https://api.github.com/repos/chef/chef/commits{/sha}","git_commits_url":"https://api.github.com/repos/chef/chef/git/commits{/sha}","comments_url":"https://api.github.com/repos/chef/chef/comments{/number}","issue_comment_url":"https://api.github.com/repos/chef/chef/issues/comments{/number}","contents_url":"https://api.github.com/repos/chef/chef/contents/{+path}","compare_url":"https://api.github.com/repos/chef/chef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chef/chef/merges","archive_url":"https://api.github.com/repos/chef/chef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chef/chef/downloads","issues_url":"https://api.github.com/repos/chef/chef/issues{/number}","pulls_url":"https://api.github.com/repos/chef/chef/pulls{/number}","milestones_url":"https://api.github.com/repos/chef/chef/milestones{/number}","notifications_url":"https://api.github.com/repos/chef/chef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chef/chef/labels{/name}","releases_url":"https://api.github.com/repos/chef/chef/releases{/id}","deployments_url":"https://api.github.com/repos/chef/chef/deployments","created_at":"2009-01-15T20:40:48Z","updated_at":"2016-12-15T08:44:41Z","pushed_at":"2016-12-15T01:07:41Z","git_url":"git://github.com/chef/chef.git","ssh_url":"git@github.com:chef/chef.git","clone_url":"https://github.com/chef/chef.git","svn_url":"https://github.com/chef/chef","homepage":"http://www.chef.io/chef/","size":96253,"stargazers_count":4574,"watchers_count":4574,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1928,"mirror_url":null,"open_issues_count":515,"forks":1928,"open_issues":515,"watchers":4574,"default_branch":"master"}},"base":{"label":"chef:master","ref":"master","sha":"673f733fe5d469ba025393b06544fbcabeca0cc9","user":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"repo":{"id":108278,"name":"chef","full_name":"chef/chef","owner":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chef/chef","description":"A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.","fork":false,"url":"https://api.github.com/repos/chef/chef","forks_url":"https://api.github.com/repos/chef/chef/forks","keys_url":"https://api.github.com/repos/chef/chef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chef/chef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chef/chef/teams","hooks_url":"https://api.github.com/repos/chef/chef/hooks","issue_events_url":"https://api.github.com/repos/chef/chef/issues/events{/number}","events_url":"https://api.github.com/repos/chef/chef/events","assignees_url":"https://api.github.com/repos/chef/chef/assignees{/user}","branches_url":"https://api.github.com/repos/chef/chef/branches{/branch}","tags_url":"https://api.github.com/repos/chef/chef/tags","blobs_url":"https://api.github.com/repos/chef/chef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chef/chef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chef/chef/git/refs{/sha}","trees_url":"https://api.github.com/repos/chef/chef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chef/chef/statuses/{sha}","languages_url":"https://api.github.com/repos/chef/chef/languages","stargazers_url":"https://api.github.com/repos/chef/chef/stargazers","contributors_url":"https://api.github.com/repos/chef/chef/contributors","subscribers_url":"https://api.github.com/repos/chef/chef/subscribers","subscription_url":"https://api.github.com/repos/chef/chef/subscription","commits_url":"https://api.github.com/repos/chef/chef/commits{/sha}","git_commits_url":"https://api.github.com/repos/chef/chef/git/commits{/sha}","comments_url":"https://api.github.com/repos/chef/chef/comments{/number}","issue_comment_url":"https://api.github.com/repos/chef/chef/issues/comments{/number}","contents_url":"https://api.github.com/repos/chef/chef/contents/{+path}","compare_url":"https://api.github.com/repos/chef/chef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chef/chef/merges","archive_url":"https://api.github.com/repos/chef/chef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chef/chef/downloads","issues_url":"https://api.github.com/repos/chef/chef/issues{/number}","pulls_url":"https://api.github.com/repos/chef/chef/pulls{/number}","milestones_url":"https://api.github.com/repos/chef/chef/milestones{/number}","notifications_url":"https://api.github.com/repos/chef/chef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chef/chef/labels{/name}","releases_url":"https://api.github.com/repos/chef/chef/releases{/id}","deployments_url":"https://api.github.com/repos/chef/chef/deployments","created_at":"2009-01-15T20:40:48Z","updated_at":"2016-12-15T08:44:41Z","pushed_at":"2016-12-15T01:07:41Z","git_url":"git://github.com/chef/chef.git","ssh_url":"git@github.com:chef/chef.git","clone_url":"https://github.com/chef/chef.git","svn_url":"https://github.com/chef/chef","homepage":"http://www.chef.io/chef/","size":96253,"stargazers_count":4574,"watchers_count":4574,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1928,"mirror_url":null,"open_issues_count":515,"forks":1928,"open_issues":515,"watchers":4574,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chef/chef/pulls/4894"},"html":{"href":"https://github.com/chef/chef/pull/4894"},"issue":{"href":"https://api.github.com/repos/chef/chef/issues/4894"},"comments":{"href":"https://api.github.com/repos/chef/chef/issues/4894/comments"},"review_comments":{"href":"https://api.github.com/repos/chef/chef/pulls/4894/comments"},"review_comment":{"href":"https://api.github.com/repos/chef/chef/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chef/chef/pulls/4894/commits"},"statuses":{"href":"https://api.github.com/repos/chef/chef/statuses/1e50b9e35f0135df3cf5ad1fa102849757e1303a"}}}}
{"actor":{"display_login":"lamont-granquist"}}