2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
12 echo "---> package-listing.sh"
14 # Ensure we fail the job if any steps fail
17 set -x # Trace commands for this script to make debugging easier
19 OS_FAMILY=$(facter osfamily | tr '[:upper:]' '[:lower:]')
21 # Capture the CI WORKSPACE safely in the case that it doesn't exist
22 workspace="${WORKSPACE:-}"
24 START_PACKAGES=/tmp/packages_start.txt
25 END_PACKAGES=/tmp/packages_end.txt
26 DIFF_PACKAGES=/tmp/packages_diff.txt
28 # Swap to creating END_PACKAGES if we are running in a CI job (determined by if
29 # we have a workspace env) or if the starting packages listing already exists.
30 PACKAGES="${START_PACKAGES}"
31 if ( [ "${workspace}" ] || [ -f "${START_PACKAGES}" ] )
33 PACKAGES="${END_PACKAGES}"
36 case "${OS_FAMILY}" in
38 # RedHat and Suse flavors all use rpm at the package level
39 rpm -qa | sort > "${PACKAGES}"
42 # Debian derived flavors all use dpkg at the package level
43 dpkg -l | grep '^ii' > "${PACKAGES}"
50 if ( [ -f "${START_PACKAGES}" ] && [ -f "${END_PACKAGES}" ] )
52 diff "${START_PACKAGES}" "${END_PACKAGES}" > "${DIFF_PACKAGES}"
55 # If running in a Jenkins job, then copy the created files to the archives
59 mkdir -p "${workspace}/archives/"
60 cp -f /tmp/packages_*.txt "${workspace}/archives/"