2022-01-10 18:36:38 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#########################################################################################
|
2022-02-02 15:53:46 +00:00
|
|
|
# Setup for platform certificates for testing
|
|
|
|
# Copies platform certs (Base and Delta) to the tcg directory
|
2022-02-17 19:50:10 +00:00
|
|
|
# usage pc_setup.sh <profile> <test>
|
2022-01-10 18:36:38 +00:00
|
|
|
#########################################################################################
|
|
|
|
|
|
|
|
profile=$1
|
|
|
|
test=$2
|
2024-06-07 10:28:25 +00:00
|
|
|
ciTestDir="/ci_test"
|
|
|
|
tcgDir="$ciTestDir/boot/efi/EFI/tcg/cert/platform/"
|
|
|
|
|
|
|
|
# Profile selections
|
|
|
|
profileDir="/hirs/.ci/system-tests/profiles/$profile"
|
|
|
|
testDir="$profileDir/$test"
|
|
|
|
pcDir="$testDir/platformcerts"
|
|
|
|
dmiZip="$profileDir/$profile"_dmi.zip
|
|
|
|
hwJsonFileName="$profile"_"$test"_hw.json
|
|
|
|
hwJsonFile="$testDir/$hwJsonFileName"
|
|
|
|
ciTestHwJsonFile="$ciTestDir/hw.json"
|
|
|
|
|
2024-07-06 14:40:45 +00:00
|
|
|
# Use default settings if profile does not have specific changes
|
|
|
|
if [ ! -f "$hwJsonFile" ]; then
|
|
|
|
echo "Test is using a profile with no hardware manifest file. Using default."
|
|
|
|
hwJsonFile="$profileDir"/default/laptop_default_hw.json
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$dmiZip" ]; then
|
|
|
|
echo "Test is using a profile with no DMI data. Using default."
|
|
|
|
dmiZip="$profileDir"/default/laptop_dmi.zip
|
|
|
|
fi
|
|
|
|
|
2024-06-07 10:28:25 +00:00
|
|
|
# Current TCG folder for platform certs
|
2022-02-02 15:53:46 +00:00
|
|
|
mkdir -p $tcgDir; # Create the platform cert folder if its not there
|
|
|
|
rm -f $tcgDir*; # Clear out any previous data
|
2022-01-10 18:36:38 +00:00
|
|
|
|
2022-01-12 15:26:52 +00:00
|
|
|
echo "Test is using platform cert(s) from $profile : $test"
|
2024-06-07 10:28:25 +00:00
|
|
|
# Step 1: Copy hw json file, if it exists.
|
|
|
|
if [ -f "$hwJsonFile" ]; then
|
2024-07-06 14:40:45 +00:00
|
|
|
echo "hw file used was $hwJsonFile"
|
|
|
|
cp "$hwJsonFile" "$ciTestHwJsonFile"
|
2022-02-01 23:27:05 +00:00
|
|
|
fi
|
|
|
|
|
2024-06-07 10:28:25 +00:00
|
|
|
# Can remove this once unzip is added to the image
|
|
|
|
dnf install -y unzip &> /dev/null
|
2022-02-01 23:27:05 +00:00
|
|
|
|
2024-06-07 10:28:25 +00:00
|
|
|
# Step 2: Unpack the dmi files.
|
2024-07-06 14:40:45 +00:00
|
|
|
echo "dmi file used was $dmiZip"
|
2024-06-07 10:28:25 +00:00
|
|
|
unzip -o "$dmiZip" -d "$ciTestDir"
|
2022-01-10 18:36:38 +00:00
|
|
|
|
2024-06-07 10:28:25 +00:00
|
|
|
# Step 3: Copy the platform cert to tcg folder
|
2022-02-03 20:30:10 +00:00
|
|
|
if [[ ! -d $pcDir ]]; then
|
|
|
|
pcDir=$profileDir/default/platformcerts;
|
|
|
|
fi
|
|
|
|
pushd $pcDir > /dev/null
|
2022-02-02 15:53:46 +00:00
|
|
|
# Skip copy of platform cert if .gitigore exists (empty profile)
|
2022-01-12 15:26:52 +00:00
|
|
|
if [[ ! -f ".gitignore" ]]; then
|
|
|
|
for cert in * ; do
|
2022-02-02 15:53:46 +00:00
|
|
|
cp -f $cert $tcgDir$cert;
|
2022-01-10 18:36:38 +00:00
|
|
|
done
|
2022-01-12 15:26:52 +00:00
|
|
|
fi
|
2022-01-10 20:13:51 +00:00
|
|
|
|
2022-01-10 18:36:38 +00:00
|
|
|
popd > /dev/null
|