This file is indexed.

/usr/bin/pkgos-check-changelog 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
#!/bin/bash

# set -o errexit
# set -x


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

GetoptsVariables() {
	while getopts ":e:s:f:a:h" opt; do
		case ${opt} in
			e)
				LOOK_FOR_FORMAT_ERRORS_MODE=${OPTARG}
				;;
			s)
				SORTING_VERSION_MODE=${OPTARG}
				;;
			a)
				FIND_ANOMALIES=${OPTARG}
				;;
			f)
				INPUT_FILE=${OPTARG}
				;;
			h)
				ShowUsage
				exit 1
				;;
			*)
				echo "Wrong option for the pkgos-check-changelog"
				exit 1
		esac
	done
}

ShowUsage() {
cat << EOF


Using pkgos-check-changelog

	OPTION	POSSIBLE VALUES 	DESCRIPTION
	______	_______________		__________________________

	-a	yes|no			Find anomalies

	-e	disable|		Find format errors
		notification|
		perform

	-f	<path>			Path to the changelog file

	-s 	disable|		Sorting by version
		notification|
		perform

	-h 				Help message

EOF
}

GetPackageName() {
	WORK_FILE=$(mktemp -t WORK_FILE.XXXXX)
	cp ${INPUT_FILE} ${WORK_FILE}
	i=0
	while [ -z "$(head -n 1 ${WORK_FILE})" ]; do
		i=$((i + 1))
		if [ $i -gt 100 ]; then
			echo "Too many empty lines in the beginning"
			exit 1
		fi
		sed -i "1d" "${WORK_FILE}"
	done
	GLOBAL_NAME_OF_PACKAGE="$(head -n 1 ${WORK_FILE} |cut -d" " -f1|cut -d"-" -f1)"
	rm ${WORK_FILE}
}

LookforFormatErrors() {
	FORMAT_ERROR_FLAG=0
	echo "LOOKING FOR FORMAT ERRORS===================================="
	FORMAT_ERROR_WORK_FILE=$(mktemp -t FORMAT_ERROR_WORK_FILE.XXXXX)
	cp ${INPUT_FILE} ${FORMAT_ERROR_WORK_FILE}
	echo >> "${FORMAT_ERROR_WORK_FILE}"
	sed -i "s/ *$//" "${FORMAT_ERROR_WORK_FILE}"
	sed -i "/${GLOBAL_NAME_OF_PACKAGE}.*urgency.*/ s/^ *//" "${FORMAT_ERROR_WORK_FILE}"
	sed -i "/--.*>/ s/^ */ /" "${FORMAT_ERROR_WORK_FILE}"
	if [ "${LOOK_FOR_FORMAT_ERRORS_MODE}" = "perform" ]; then
		FORMAT_ERROR_FLAG=1
		cp ${FORMAT_ERROR_WORK_FILE} ${INPUT_FILE}
	elif [ "${LOOK_FOR_FORMAT_ERRORS_MODE}" = "notification" ]; then
		echo "Check next lines:"
		diff -u ${INPUT_FILE} ${FORMAT_ERROR_WORK_FILE} |grep -e "^-[^-]" |sed "s/^-//g"
	else
		echo "Wrong value of LOOK_FOR_FORMAT_ERRORS_MODE"
 	fi
 	rm ${FORMAT_ERROR_WORK_FILE}
 }

PrintBody() {
	local LINE_1 LINE NAME VERSION FLAG
	local INPUT_ORDER=$1
	while IFS= read LINE_1; do
		if $(echo "${LINE_1}" |grep -q "^${GLOBAL_NAME_OF_PACKAGE}"); then
			NAME="$( echo "${LINE_1}" |cut -d " " -f 1 )"
			VERSION="$( echo "${LINE_1}" |cut -d " " -f 2 | sed -e "s/\((\|)\)//g")"
			FLAG=0
		fi
		while IFS= read -r LINE; do
			if [ "${FLAG}" -eq 1 ]; then
				if echo "${LINE}" | grep "<.*@.*>" | grep -qe "^ -- "; then
					echo "${LINE}"
					echo ""
					break
				fi
				echo "${LINE}"
			fi
			if echo "${LINE}" | grep -q "${NAME}" && echo "${LINE}" | grep -qw "(${VERSION})"; then
				echo "${LINE}"
				FLAG=1
			fi
		done<${INPUT_FILE}
	done<${INPUT_ORDER}
}

SortbyVersion() {
	local LINE
	WORK_FILE=$(mktemp -t WORK_FILE.XXXXX)
	cp ${INPUT_FILE} ${WORK_FILE}
	MY_VER_SORT_TEMP_MOS_SUFFIX=$(mktemp -t MY_VER_SORT_TEMP_MOS_SUFFIX.XXXXX)
	MY_VER_SORT_TEMP_WITHOUT_MOS_SUFFIX=$(mktemp -t MY_VER_SORT_TEMP_WITHOUT_MOS_SUFFIX.XXXXX)
	echo "SORTING_BY_VERSION=========================================="
	if [ ${FORMAT_ERROR_FLAG} -eq 0 ]; then
		echo "For correct work before sorting by version need check file for format errors!"
	fi
	if grep "^${GLOBAL_NAME_OF_PACKAGE}" "${WORK_FILE}" |grep -q ":" ; then
		sed -i "${GLOBAL_NAME_OF_PACKAGE}.*([0-9][^:]/s/(/(0:/g" "${WORK_FILE}"
	fi
	echo "$(grep "^${GLOBAL_NAME_OF_PACKAGE}" "${WORK_FILE}" | cut -d " " -f 1,2 |grep  mos| sort -Vru | sed -e "s/\((\|)\)//g")" > "${MY_VER_SORT_TEMP_MOS_SUFFIX}"
	echo "$(grep "^${GLOBAL_NAME_OF_PACKAGE}" "${WORK_FILE}" | cut -d " " -f 1,2 | grep -v mos| sort -Vru | sed -e "s/\((\|)\)//g")" > "${MY_VER_SORT_TEMP_WITHOUT_MOS_SUFFIX}"
	if [ -n "$(cat ${MY_VER_SORT_TEMP_MOS_SUFFIX})" ];then
		while read LINE; do
			sed -i "/${LINE%~*}/ i\\${LINE}" ${MY_VER_SORT_TEMP_WITHOUT_MOS_SUFFIX}
		done<${MY_VER_SORT_TEMP_MOS_SUFFIX}
	fi
	PrintBody "${MY_VER_SORT_TEMP_WITHOUT_MOS_SUFFIX}" > "${WORK_FILE}"
	sed -i "/^${GLOBAL_NAME_OF_PACKAGE}.*(0:/s/(0:/(/g" "${WORK_FILE}"
	if [ "${SORTING_VERSION_MODE}" = "perform" ]; then
		cp ${WORK_FILE} ${INPUT_FILE}
	elif [ "${SORTING_VERSION_MODE}" = "notification" ]; then
		echo "Proposed variants marked '+', exist variants marked '-'"
		diff -u <(grep "^${GLOBAL_NAME_OF_PACKAGE}" "${INPUT_FILE}" | cut -d" " -f 1,2 | sed -e "s/\((\|)\)//g")  ${MY_VER_SORT_TEMP_WITHOUT_MOS_SUFFIX}
	else
		echo "Wrong value of SORTING_VERSION_MODE"
 	fi
 	rm "${WORK_FILE}" "${MY_VER_SORT_TEMP_WITHOUT_MOS_SUFFIX}" "${MY_VER_SORT_TEMP_MOS_SUFFIX}"
}

LookforAnomalies() {
	local DATE_1 DATE_2 VERSION_1 VERSION_2 LINE LINE_1
	echo "LOOKING FOR ANOMALIES======================================="
	i=0
	j=0
	while read true ; do
		i=$((i + 1))
		if dpkg-parsechangelog -o $i -c 1 --show-field source --format rfc822 -l ${INPUT_FILE} &>/dev/null ; then
			break
		fi
		VERSION_1="$(dpkg-parsechangelog -n $i --show-field version --format rfc822 -l ${INPUT_FILE})"
		DATE_1="$(dpkg-parsechangelog -n $i --show-field date --format rfc822 -l ${INPUT_FILE})"
		while read true; do
			j=$((i + 1))
			if dpkg-parsechangelog -o $j -c 1 --show-field source --format rfc822 -l ${INPUT_FILE} &>/dev/null ; then
				break
			fi
			VERSION_2="$(dpkg-parsechangelog -n $j --show-field version --format rfc822 -l ${INPUT_FILE} )"
			DATE_2="$(dpkg-parsechangelog -n $j --show-field date --format rfc822 -l ${INPUT_FILE})"
			if dpkg --compare-versions "${VERSION_1}" gt "${VERSION_2}" ; then
				if [ `date -d ${DATE_1} +%s` -gt `date -d ${DATE_2} +%s` ]; then
					continue
				else
					echo "anomaly is in a date between :"
					echo "${VERSION_1} ${DATE_1} and ${VERSION_2} ${DATE_2}"
					exit 1
				fi
			elif dpkg --compare-versions "${VERSION_1%~*}" ge "${VERSION_2}" ; then
				if [ `date -d ${DATE_1} +%s` -gt `date -d ${DATE_2} +%s` ]; then
					continue
				else
					echo "anomaly is in a date between :"
					echo "${VERSION_1} ${DATE_1} and ${VERSION_2} ${DATE_2}"
					exit 1
				fi
			fi
			done<${INPUT_FILE}
	done<${INPUT_FILE}
}

GetoptsVariables ${@}
GetPackageName
echo "LOOK_FOR_FORMAT_ERRORS_MODE = ${LOOK_FOR_FORMAT_ERRORS_MODE}"
echo "SORTING_VERSION_MODE = ${SORTING_VERSION_MODE}"
echo "FIND_ANOMALIES = ${FIND_ANOMALIES}"
if [ "${LOOK_FOR_FORMAT_ERRORS_MODE}" != "disable" ]; then
	LookforFormatErrors
fi
if [ "${SORTING_VERSION_MODE}" != "disable" ]; then
	SortbyVersion
fi
if [ "${FIND_ANOMALIES}" != "no" ]; then
	LookforAnomalies
fi