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 START_PACKAGES=/tmp/packages_start.txt
22 END_PACKAGES=/tmp/packages_end.txt
23 DIFF_PACKAGES=/tmp/packages_diff.txt
25 # This script may be run during system boot, if that is true then there will be
26 # a starting_packages file. We will want to create a diff if we have a starting
28 PACKAGES="${START_PACKAGES}"
29 if [ -f "${PACKAGES}" ]
31 PACKAGES="${END_PACKAGES}"
35 case "${OS_FAMILY}" in
37 # RedHat and Suse flavors all use rpm at the package level
38 rpm -qa | sort > "${PACKAGES}"
41 # Debian derived flavors all use dpkg at the package level
42 dpkg -l | grep '^ii' > "${PACKAGES}"
49 if [ "${CREATEDIFF}" ]
51 diff "${START_PACKAGES}" "${END_PACKAGES}" > "${DIFF_PACKAGES}"
54 # If running in a Jenkins job, then copy the created files to the archives
58 mkdir -p "${WORKSPACE}/archives/"
59 cp -f /tmp/packages_*.txt "${WORKSPACE}/archives/"