File: dpkg-query

package info (click to toggle)
lsb 11.6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 236 kB
  • sloc: python: 1,162; sh: 143; perl: 6; makefile: 2
file content (26 lines) | stat: -rwxr-xr-x 723 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/python3

# Fake dpkg-query  python script to emulate output for test usage

import sys
import os
import random

if len(sys.argv) < 5:
	sys.exit("Not enough arguments.")

if sys.argv[1] != '-f' or \
   sys.argv[2] != '${Version} ${Provides}\n' or \
   sys.argv[3] != '-W':
	sys.exit("Wrong input arguments.")

if os.environ.get('TEST_DPKG_QUERY_NONE') == '1':
	for package in sys.argv[4::]:
		print('No packages found matching ' + package + '.',file=sys.stderr)

if os.environ.get('TEST_DPKG_QUERY_ALL') == '1':
	arch = 'TESTarch'
	for package in sys.argv[4::]:
		vers_sep = random.choice('-+~')
		vers = '9.8' + vers_sep + 'Debian7ubuntu6'
		print(vers + ' ' + package + '-' + arch + ', ' + package + '-noarch')