This file is indexed.

/usr/bin/pkgos-parse-requirements is in openstack-pkg-tools 54.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#!/bin/sh

set -e

if ! [ -r /etc/pkgos/pkgos.conf ] ; then
	echo "Could not read /etc/pkgos/pkgos.conf"
	exit 1
else
	. /etc/pkgos/pkgos.conf
fi

if [ "${1}" = "-h" ] ; then
	echo "This utility attemps to parse an OpenStack requirements.txt file"
	echo "as input, and produce a list of Debian dependencies as output."
	echo "Note that this is far from perfect, and that you *WILL* need to"
	echo "manually check for the dependencies. This is only a helper in"
	echo "order to gain some precious development time."
	echo ""
	echo "If this utility is called without a parameter, it will attempt"
	echo "to read the requirements.txt and test-requirements.txt file."
	echo "Otherwise, it takes the first argument as the file to parse."
	exit 0
fi

# Some packages should never be in the dependencies in Debian,
# as they are included in Python 2.7. If you find one that is
# missing, just add it to the list it here.
BLACK_LIST="discover argparse ordereddict doc8 pylint flake8 pyflakes pep8"
is_blacklisted () {
	ISBLACKLISTED="no"
	for i in $BLACK_LIST ; do
		if [ "${i}" = "${1}" ] ; then
			ISBLACKLISTED="yes"
		fi
	done
}

BLACK_LIST_PY3="python3-testrepository python3-oslosphinx python3-coverage python3-concurrent.futures"
is_py3_blacklisted () {
	IS_PY3BLACKLISTED="no"
	for i in $BLACK_LIST_PY3 ; do
		if [ "${i}" = "${1}" ] ; then
			IS_PY3BLACKLISTED="yes"
		fi
	done
}

# Some packages should never make it into the Build-Depends-Indep:,
# because they are already in Build-Depends:. Here's the list for it.
BUILD_DEPENDS_LIST="sphinx pbr"
is_build_depends () {
	ISBUILDDEPENDS="no"
	for i in ${BUILD_DEPENDS_LIST} ; do
		if [ "${i}" = ${1} ] ; then
			ISBUILDDEPENDS="yes"
		fi
	done
}

EPOC_1_IN="python-cinderclient python-keystoneclient python-glanceclient python-swiftclient python-neutronclient python-oslo.config"
has_1_in_epoc () {
	HAS_1_IN_EPOC="no"
	for i in ${EPOC_1_IN} ; do
		if [ "${i}" = ${1} ] ; then
			HAS_1_IN_EPOC="yes"
		fi
	done
}

EPOC_2_IN="python-novaclient"
has_2_in_epoc () {
	HAS_2_IN_EPOC="no"
	for i in ${EPOC_2_IN} ; do
		if [ "${i}" = ${1} ] ; then
			HAS_2_IN_EPOC="yes"
		fi
	done
}

NO_PYTHON_PREFIX="alembic testrepository subunit websockify cliff-tablib"
is_python_prefixed () {
	PY_PREFIX="yes"
	for i in ${NO_PYTHON_PREFIX} ; do
		if [ "${i}" = "${1}" ] ; then
			PY_PREFIX="no"
		fi
	done
}

# Param: $1: input file
#        $2: if set, then the Build-Depends: programs will be removed (for example: sphinx, pbr, etc.)
parse_and_print () {
	INPUT_FILE=$1
	REMOVE_BUILD_DEPENDS="no"
	if [ "${2}" = "build-depends" ] ; then
		REMOVE_BUILD_DEPENDS="yes"
	fi
	PYVERS=${3}
	DEP_LIST=""
#	echo `cat ${INPUT_FILE} | grep -v '^#' | grep -v '^[ \t]*$' | awk '{print $1}' | tr '[:upper:]' '[:lower:]' | sed $EXP`
	for i in `cat ${INPUT_FILE} | grep -v '^#' | grep -v '^[ \t]*$' | awk '{print $1}' | tr '[:upper:]' '[:lower:]' | sed $EXP` ; do
#		echo "Line ---> $i"
		if echo $i | grep -q -e '^http://' ; then
			i=`echo $i | cut -d'=' -f2`
			VERS=""
		else
			TRIM_VERS=`echo $i | sed -e 's/^[-a-zA-Z0-9._]*//'`
			VERS=`echo $TRIM_VERS | sed -e 's/^[-a-zA-Z0-9._]*//' | tr ',|;' '\n' | sort | tr '\n' ',' | sed -e 's/,$//'`
		fi
		if [ -n "$VERS" ] ; then
			PKG=`echo $i | sed -e "s/${TRIM_VERS}//" | sed -e s/python-//`
		else
			PKG=`echo $i | sed -e s/python-//`
		fi
		PKG=`echo ${PKG} | sed -e s/_/-/g`
		is_blacklisted ${PKG}
		ISBUILDDEPENDS="no"
		if [ REMOVE_BUILD_DEPENDS="yes" ] ; then
			is_build_depends ${PKG}
		fi
		if [ $ISBLACKLISTED = "no" ] && [ ${ISBUILDDEPENDS} = "no" ]; then
			is_python_prefixed ${PKG}
			if [ ${PY_PREFIX} = "yes" ] ; then
				PKG=python-${PKG}
			fi
			# Convert the package name into lowercase, as Debian
			# doesn't have any upper case in package names
			PKG=`echo ${PKG} | tr '[:upper:]' '[:lower:]'`
			if [ -n "$VERS" ] && [ ${PKG} != "python-hacking" ] ; then
				# If there's a a version-depends, convert the pip style
				# of dependency to the Debian one (ie: >> instead of >)
				FIRST_CONSTR=`echo $VERS | cut -d, -f1`
				FIRST_NUMS=`echo $FIRST_CONSTR | sed -e 's/[<>=\!]*//'`
				FIRST_SIGN=`echo $FIRST_CONSTR | sed -e "s/${FIRST_NUMS}//"`
				if [ "${FIRST_SIGN}" = '<' ] ; then
					FIRST_SIGN='<<'
				fi
				if [ "${FIRST_SIGN}" = '>' ] ; then
					FIRST_SIGN='>>'
				fi
				has_1_in_epoc ${PKG}
				if [ "${HAS_1_IN_EPOC}" = "yes" ] ; then
					FIRST_NUMS="1:${FIRST_NUMS}"
				fi
				has_2_in_epoc ${PKG}
				if [ "${HAS_2_IN_EPOC}" = "yes" ] ; then
					FIRST_NUMS="2:${FIRST_NUMS}"
				fi
				# If there's a fake-jessie-mirror folder in /etc/pkgos
				# use that one with madison-lite to check if the version
				# of the package is already in Jessie.
				if [ -d /etc/pkgos/fake-jessie-mirror ] ; then
					STABLE_VERSION=`madison-lite -a all,amd64 --mirror /etc/pkgos/fake-${TARGET_DISTRO}-mirror ${PKG} | awk '{print $3}'`
					# Make sure that the package is in the stable repo
					if [ -z "${STABLE_VERSION}" ] ; then
						VERSION_TO_DEPEND_ON=" (${FIRST_SIGN} ${FIRST_NUMS})"
					else
						#echo "Comparing for ${PKG}: dpkg --compare-versions ${STABLE_VERSION} gt ${FIRST_NUMS}"
						if dpkg --compare-versions ${STABLE_VERSION} gt ${FIRST_NUMS} ; then
							VERSION_TO_DEPEND_ON=""
						else
							VERSION_TO_DEPEND_ON=" (${FIRST_SIGN} ${FIRST_NUMS})"
						fi
					fi
				else
					VERSION_TO_DEPEND_ON=" (${FIRST_SIGN} ${FIRST_NUMS})"
				fi
				if [ "${PYVERS}" = 3 ] ; then
					PKG=`echo ${PKG} | sed s/python-/python3-/`
					is_py3_blacklisted ${PKG}
					if [ ${IS_PY3BLACKLISTED} = "yes" ] ; then
						continue
					fi
				fi
				if [ -z "${DEP_LIST}" ] ; then
					DEP_LIST="${PKG}${VERSION_TO_DEPEND_ON}"
					#echo " ${PKG} (${FIRST_SIGN} ${FIRST_NUMS}),"
				else
					DEP_LIST="${DEP_LIST}\n${PKG}${VERSION_TO_DEPEND_ON}"
				fi
			else
				if [ -z "${DEP_LIST}" ] ; then
					DEP_LIST="${PKG}"
				else
					#echo " ${PKG},"
					DEP_LIST="${DEP_LIST}\n${PKG}"
				fi
			fi
			#echo "Package: ${PKG}\t\tFirst sign: ${FIRST_SIGN}\t\tFirst num: ${FIRST_NUMS}..."
		fi
	done
}

# Param: $DEPS: the dependency list, one package per line
#        $1: the word for the package dep (ie: Depends: or Build-Depends-Indep:)
format_output () {
#	set -x
	SPACES_IN_FRONT=`echo "${1} " | sed -e 's/[a-zBDI:-]/ /g'`
	CNT="0"
	echo $DEPS | LC_COLLATE=C sort -u | while read i ; do
		if [ "${CNT}" = "0" ] ; then
			echo "${1} ${i},"
		else
			echo -n "${1}" | sed -e 's/[a-zBDI:-]/ /g'
			echo " ${i},"
		fi
		CNT=$(($CNT + 1))
	done
	if [ $1 = "Depends:" ] ; then
		echo "         \${misc:Depends},"
		echo "         \${python:Depends},"
	fi
}

calc_substitue_list () {
	if [ -r /etc/pkgos/substitute ] ; then
		while read i ; do
			SOURCE=`echo $i | cut -d" " -f1`
			DEST=`echo $i | cut -d" " -f2`
			EXP="$EXP -e s/$SOURCE/$DEST/"
		done </etc/pkgos/substitute
	fi
#	echo \'$EXP\'
}

calc_substitue_list

if [ "${1}" ] ; then
	parse_and_print ${1}
	format_output "Build-Depends:"
else
	# Check if we declared Python3 support in debian/control
	HAS_PY3_SUPPORT="no"
	if [ -r debian/control ] ; then
		HAS_PYTHON3_PKG_IN_CTRL=`cat debian/control | grep "Package: python3" || true`
		if [ -n "${HAS_PYTHON3_PKG_IN_CTRL}" ] ; then
			HAS_PY3_SUPPORT="yes"
		fi
	fi
	# If there's a debian/*.init.in, then we want dh-systemd as build-depends
	INIT=`find debian/ -iname '*init.in'`
	if [ -n "${INIT}" ] ; then
		DH_SYSTEMD="\n               dh-systemd,"
		OSTACK_PKG_TOOLS_VERS=" (>= 23~)"
	else
		DH_SYSTEMD=""
		OSTACK_PKG_TOOLS_VERS=""
	fi
	TEMPLATES=`find debian/ -iname '*.templates'`
	if [ -n "${TEMPLATES}" ] ; then
		PO_DEBCONF="\n               po-debconf,"
	else
		PO_DEBCONF=""
	fi
	echo "Build-Depends: debhelper (>= 9),
               dh-python,${DH_SYSTEMD}
               openstack-pkg-tools${OSTACK_PKG_TOOLS_VERS},${PO_DEBCONF}
               python-all,
               python-pbr,
               python-setuptools,
               python-sphinx,"
	# Adds python3 support packages
	if [ "${HAS_PY3_SUPPORT}" = "yes" ] ; then
		echo "               python3-all,
               python3-pbr,
               python3-setuptools,"
	fi

	# Gather the dependencies.
	if [ -e test-requirements-py2.txt ] ; then
		parse_and_print test-requirements-py2.txt build-depends 2
	else
		parse_and_print test-requirements.txt build-depends 2
	fi
	DEP_LIST_TESTS=${DEP_LIST}
	if [ -r requirements-py2.txt ] ; then
		parse_and_print requirements-py2.txt depends
	else
		parse_and_print requirements.txt depends
	fi
	DEP_LIST_RUNTIME=${DEP_LIST}

	# If the package has python3 support, let's try to also print python3 build-depends
	if [ "${HAS_PY3_SUPPORT}" = "yes" ] ; then
		parse_and_print requirements.txt depends 3
		DEP_LIST_TESTS="${DEP_LIST_TESTS}\n${DEP_LIST}"
		if [ -e test-requirements-py3.txt ] ; then
			parse_and_print test-requirements-py3.txt build-depends 3
		else
			parse_and_print test-requirements.txt build-depends 3
		fi
		DEP_LIST_TESTS="${DEP_LIST_TESTS}\n${DEP_LIST}"
	fi

	if [ -r .testr.conf ] ; then
		DEP_LIST_TESTS="${DEP_LIST_TESTS}\ntestrepository\nsubunit"
		if [ -r debian/control ] && [ -n "${HAS_PYTHON3}" ] ; then
			DEP_LIST_TESTS="${DEP_LIST_TESTS}\npython3-subunit"
		fi
	fi

	# Format the output
	DEPS="${DEP_LIST_RUNTIME}\n${DEP_LIST_TESTS}"
	format_output "Build-Depends-Indep:"

	DEPS=${DEP_LIST_RUNTIME}
	format_output "Depends:"
fi