Skip to content

Commit 8ecb175

Browse files
sameluchSam Meluch
andauthored
Filter out debuginfo packages when running sodiff (#6698)
Co-authored-by: Sam Meluch <sam.meluch@microsoft.com>
1 parent 5e921ee commit 8ecb175

3 files changed

Lines changed: 71 additions & 21 deletions

File tree

.pipelines/templatesWithCheckout/SodiffCheck.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ parameters:
1313
type: string
1414
default: "rpms.tar.gz"
1515

16+
- name: sodiffRepoCommand
17+
type: string
18+
default: "sodiff-repo"
19+
20+
- name: sodiffRepoFile
21+
type: string
22+
default: "sodiff.repo"
23+
1624
- name: sourcesWorkspace
1725
type: string
1826
default: "$(Agent.TempDirectory)/SourcesWorkspace"
@@ -52,16 +60,16 @@ steps:
5260
sodiff_out_dir="${{ parameters.buildRepoRoot }}/out/sodiff"
5361
mkdir -p $sodiff_out_dir
5462
55-
echo "Generate sodiff.repo file"
56-
sudo make -sC "$toolkit_dir" sodiff-repo
63+
echo "Generate sodiff repo file"
64+
sudo make -sC "$toolkit_dir" ${{ parameters.sodiffRepoCommand }}
5765
5866
echo "Generate input file"
5967
find $sodiff_rpms_dir -type f -name '*.rpm' -exec basename {} \; > ./sodiff-rpms
6068
6169
sodiff_release_ver=`cat ${{ parameters.buildRepoRoot }}/SPECS/mariner-release/mariner-release.spec | grep "Version:" | cut -d " " -f 1 --complement | xargs`
6270
echo "sodiff release ver: $sodiff_release_ver"
6371
64-
$toolkit_dir/scripts/sodiff/mariner-sodiff.sh $sodiff_rpms_dir/ $toolkit_dir/scripts/sodiff/sodiff.repo $sodiff_release_ver $sodiff_out_dir < ./sodiff-rpms
72+
$toolkit_dir/scripts/sodiff/mariner-sodiff.sh -r $sodiff_rpms_dir/ -f ${{ parameters.buildRepoRoot }}/build/sodiff/${{ parameters.sodiffRepoFile }} -v $sodiff_release_ver -o $sodiff_out_dir -e true < ./sodiff-rpms
6573
6674
67-
displayName: "Sodiff check"
75+
displayName: "Sodiff check"

toolkit/scripts/analysis.mk

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ ifneq ($(build_arch),x86_64)
2020
# Microsoft repository only exists for x86_64 - skip that .repo file;
2121
# otherwise package manager will signal an error due to being unable to make contact
2222
SODIFF_REPO_SOURCES="mariner-official-base.repo"
23+
SODIFF_REPO_SOURCES_EXTENDED="mariner-official-base.repo mariner-extended.repo"
2324
else
2425
SODIFF_REPO_SOURCES="mariner-official-base.repo mariner-microsoft.repo"
26+
SODIFF_REPO_SOURCES_EXTENDED="mariner-official-base.repo mariner-microsoft.repo mariner-extended.repo"
2527
endif
2628

27-
SODIFF_REPO_FILE=$(SCRIPTS_DIR)/sodiff/sodiff.repo
29+
30+
SODIFF_REPO_FILE=$(BUILD_DIR)/sodiff/sodiff.repo
31+
SODIFF_REPO_FILE_EXTENDED=$(BUILD_DIR)/sodiff/sodiff-extended.repo
2832
# An artifact containing a list of packages that need to be dash-rolled due to their dependency having a new .so version
2933
SODIFF_SUMMARY_FILE=$(SODIFF_OUTPUT_FOLDER)/sodiff-summary.txt
3034
# A script doing the sodiff work
@@ -69,9 +73,16 @@ fake-built-packages-list: | $(SODIFF_OUTPUT_FOLDER)
6973
.PHONY: sodiff-repo
7074
sodiff-repo: $(SODIFF_REPO_FILE)
7175

72-
$(SODIFF_REPO_FILE):
76+
$(SODIFF_REPO_FILE): $(SODIFF_OUTPUT_FOLDER)
7377
echo $(SODIFF_REPO_SOURCES) | sed -E 's:([^ ]+[.]repo):$(SPECS_DIR)/mariner-repos/\1:g' | xargs cat > $(SODIFF_REPO_FILE)
7478

79+
# sodiff-repo-extended: Generate just the sodiff.repo file
80+
.PHONY: sodiff-repo-extended
81+
sodiff-repo-extended: $(SODIFF_REPO_FILE_EXTENDED)
82+
83+
$(SODIFF_REPO_FILE_EXTENDED): $(SODIFF_OUTPUT_FOLDER)
84+
echo $(SODIFF_REPO_SOURCES_EXTENDED) | sed -E 's:([^ ]+[.]repo):$(SPECS_DIR)/mariner-repos/\1:g' | xargs cat > $(SODIFF_REPO_FILE_EXTENDED)
85+
7586
# sodiff-setup: populate gpg-keys from SPECS/mariner-repos for mariner official repos for ubuntu
7687
.PHONY: sodiff-setup
7788
sodiff-setup:
@@ -83,6 +94,6 @@ sodiff-setup:
8394
.SILENT .PHONY: sodiff-check
8495

8596
sodiff-check: $(BUILT_PACKAGES_FILE) | $(SODIFF_REPO_FILE)
86-
<$(BUILT_PACKAGES_FILE) $(SODIFF_SCRIPT) $(RPMS_DIR)/ $(SODIFF_REPO_FILE) $(RELEASE_MAJOR_ID) $(SODIFF_OUTPUT_FOLDER)
97+
<$(BUILT_PACKAGES_FILE) $(SODIFF_SCRIPT) -r $(RPMS_DIR)/ -f $(SODIFF_REPO_FILE) -v $(RELEASE_MAJOR_ID) -o $(SODIFF_OUTPUT_FOLDER)
8798

8899
package-toolkit: $(SODIFF_REPO_FILE)

toolkit/scripts/sodiff/mariner-sodiff.sh

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,37 @@
11
#!/bin/bash
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
5+
sodiff_script_error=false
6+
while getopts "r:f:v:o:e:" opt; do
7+
case $opt in
8+
r) rpms_folder="$OPTARG";;
9+
f) repo_file_path="$OPTARG";;
10+
v) mariner_version="$OPTARG";;
11+
o) sodiff_out_dir="$OPTARG";;
12+
e) sodiff_script_error="$OPTARG";;
13+
esac
14+
done
15+
16+
if [[ -z "$rpms_folder" ]]; then
17+
echo "INVALID ARGUMENT: RPMS_FOLDER is empty. It can be specified via the -r command line option."
18+
exit 1
19+
fi
220

3-
# Required binaries:
4-
# rpm and dnf
21+
if [[ -z "$repo_file_path" ]]; then
22+
echo "INVALID ARGUMENT: REPO_FILE_PATH is empty. It can be specified via the -f command line option."
23+
exit 1
24+
fi
525

6-
rpms_folder="$1"
7-
repo_file_path="$2"
8-
mariner_version="$3"
9-
sodiff_out_dir="$4"
26+
if [[ -z "$mariner_version" ]]; then
27+
echo "INVALID ARGUMENT: MARINER_VERSION is empty. It can be specified via the -v command line option."
28+
exit 1
29+
fi
30+
31+
if [[ -z "$sodiff_out_dir" ]]; then
32+
echo "INVALID ARGUMENT: SODIFF_OUT_DIR is empty. It can be specified via the -o command line option."
33+
exit 1
34+
fi
1035
sodiff_log_file="${sodiff_out_dir}/sodiff.log"
1136

1237
# Setup output dir
@@ -16,22 +41,26 @@ mkdir -p "$sodiff_out_dir"
1641

1742
common_options="-c $repo_file_path --releasever $mariner_version"
1843

19-
DNF_COMMAND=dnf
44+
dnf_command=dnf
2045
# Cache RPM metadata
21-
>/dev/null dnf $common_options -y makecache
46+
>/dev/null $dnf_command $common_options -y makecache
2247

2348
# Get packages from stdin
2449
pkgs=`cat`
50+
echo "$pkgs"
2551

2652
for rpmpackage in $pkgs; do
53+
package_debuginfo=$(echo "$rpmpackage" | rev | cut -f3 -d'-' | rev)
54+
if [[ "$package_debuginfo" == "debuginfo" ]]; then
55+
continue
56+
fi
2757
package_path=$(find "$rpms_folder" -name "$rpmpackage" -type f)
2858
package_provides=`2>/dev/null rpm -qP "$package_path" | grep -E '[.]so[(.]' `
2959
echo "Processing ${rpmpackage}..."
3060
echo ".so's provided: $package_provides"
3161
for sofile in $package_provides; do
3262
# Query local metadata for provides
33-
sos_found=$( 2>/dev/null $DNF_COMMAND repoquery $common_options --whatprovides $sofile | wc -l )
34-
echo "Number of .so files found: $sos_found"
63+
sos_found=$( 2>/dev/null $dnf_command repoquery $common_options --whatprovides $sofile | wc -l )
3564
if [ "$sos_found" -eq 0 ] ; then
3665
# SO file not found, meaning this might be a new .SO
3766
# or a new version of a preexisting .SO.
@@ -41,14 +70,13 @@ for rpmpackage in $pkgs; do
4170
sofile_no_ver=$(echo "$sofile" | sed -E 's/[.]so[(.].+/.so/')
4271

4372
# check for generic .so in the repo
44-
sos_found=$( 2>/dev/null $DNF_COMMAND repoquery $common_options --whatprovides "${sofile_no_ver}*" | wc -l )
45-
echo "Number of non-versioned .so files found: $sos_found"
73+
sos_found=$( 2>/dev/null $dnf_command repoquery $common_options --whatprovides "${sofile_no_ver}*" | wc -l )
4674
if ! [ "$sos_found" -eq 0 ] ; then
4775
# Generic version of SO was found.
4876
# This means it's a new version of a preexisting SO.
4977
# Log which packages depend on this functionality
5078
echo "Packages that require $sofile_no_ver:"
51-
2>/dev/null $DNF_COMMAND repoquery $common_options -s --whatrequires "${sofile_no_ver}*" | sed -E 's/[.][^.]+[.]src[.]rpm//' | tee "$sodiff_out_dir"/"require_${sofile}"
79+
2>/dev/null $dnf_command repoquery $common_options -s --whatrequires "${sofile_no_ver}*" | sed -E 's/[.][^.]+[.]src[.]rpm//' | tee "$sodiff_out_dir"/"require_${sofile}"
5280
fi
5381
fi
5482
done
@@ -58,7 +86,7 @@ done
5886
# Obtain a list of unique packages to be updated
5987
2>/dev/null cat "$sodiff_out_dir"/require* | sort -u > "$sodiff_out_dir"/sodiff-intermediate-summary.txt
6088

61-
rm "$sodiff_out_dir"/require*
89+
rm -f "$sodiff_out_dir"/require*
6290
touch "$sodiff_out_dir"/sodiff-summary.txt
6391

6492
# Remove packages that have been dash-rolled already.
@@ -86,6 +114,9 @@ echo "######################"
86114
if [[ $pkgsFound -gt 0 ]]; then
87115
echo "The Following Packages Are in Need of an Update:"
88116
cat "$sodiff_out_dir"/sodiff-summary.txt
117+
if [[ "$sodiff_script_error" -eq "true" ]]; then
118+
exit 1
119+
fi
89120
else
90121
echo "No Packages with Conflicting .so Files Found."
91122
fi

0 commit comments

Comments
 (0)