Add more than one metadata to prepatched iso
This change add the possibility to accept more than one patch as argument when creating the Debian pre-patched ISO. Test-Plan: Pass: Create prepatched ISO with 1 patch, e.g.: patch-iso-debian -i ./starlingx-intel-x86-64-cd.iso \ -o prepatched.iso -p rebootrequired1.patch Pass: Create prepatched ISO with 2 patchs, e.g.: patch-iso-debian -i ./starlingx-intel-x86-64-cd.iso \ -o prepatched.iso -p rebootrequired1.patch \ -p rebootrequired2.patch Story: 2009969 Task: 48421 Change-Id: If1d8745f9c452472ccb2733d609ab4fb593af48d Signed-off-by: Dostoievski Batista <dostoievski.albinobatista@windriver.com>
This commit is contained in:
parent
fc286603cf
commit
4a95931aeb
@ -31,19 +31,20 @@ OSTREE_REPO="${DEPLOY_DIR}/ostree_repo"
|
||||
function usage() {
|
||||
echo ""
|
||||
echo "Usage: "
|
||||
echo " $(basename $0) -i <input filename.iso> -o <output filename.iso> [ -u ] <patch> ..."
|
||||
echo " $(basename $0) -i <input filename.iso> -o <output filename.iso> [ -p ] <patch> ..."
|
||||
echo " -i <file>: Specify input ISO file"
|
||||
echo " -o <file>: Specify output ISO file"
|
||||
echo " -p <file>: Patch file"
|
||||
echo " -p <file>: Patch files. You can call it multiple times."
|
||||
echo ""
|
||||
}
|
||||
|
||||
function extract_metada() {
|
||||
function extract_metadata() {
|
||||
local patchesdir=${BUILDDIR}/patches
|
||||
local patchfile=$1
|
||||
local patchid=$(basename $patchfile .patch)
|
||||
local ostree_ref=$(cat ${BUILDDIR}/ostree_repo/refs/heads/starlingx)
|
||||
local ostree_log=$(ostree --repo=${BUILDDIR}/ostree_repo log starlingx)
|
||||
|
||||
echo "Extracting ${patchfile}"
|
||||
# Extract it
|
||||
tar xf ${patchfile} -O metadata.tar | tar x -O > ${patchesdir}/${patchid}-metadata.xml
|
||||
if [ $? -ne 0 ]; then
|
||||
@ -51,13 +52,13 @@ function extract_metada() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify if ostree_repo ref matches the metadata.xml top commit
|
||||
# commit1 tag contains the top commit sha
|
||||
# Verify if top commit from metadata exist in ostree log
|
||||
xml_base=$(xmllint --xpath "string(//contents/ostree/commit1/commit)" ${patchesdir}/${patchid}-metadata.xml)
|
||||
if [ "$xml_base" != "$ostree_ref" ]; then
|
||||
echo "Error, ostree head ref and patch xml base commit does not match."
|
||||
echo "ostree head: ${ostree_ref}"
|
||||
if [[ "$ostree_log" != *"$xml_base"* ]]; then
|
||||
echo "Error, xml base commit does not exist in ostree log."
|
||||
echo "patch base: ${xml_base}"
|
||||
echo "ostree log:"
|
||||
ostree --repo=${BUILDDIR}/ostree_repo log starlingx
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@ -76,7 +77,7 @@ while getopts "i:o:p:" opt; do
|
||||
OUTPUT_ISO=$OPTARG
|
||||
;;
|
||||
p)
|
||||
PATCH_FILE=$OPTARG
|
||||
PATCH_FILES+=($OPTARG)
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
@ -100,15 +101,18 @@ if [ -f ${OUTPUT_ISO} ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f ${PATCH_FILE} ]; then
|
||||
echo "Patch file dos not exists: ${PATCH_FILE}"
|
||||
for PATCH in "${PATCH_FILES[@]}";
|
||||
do
|
||||
if [ ! -f ${PATCH} ]; then
|
||||
echo "Patch file dos not exists: ${PATCH}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! ${PATCH_FILE} =~ \.patch$ ]]; then
|
||||
echo "Specified file ${PATCH_FILE} does not have .patch extension"
|
||||
if [[ ! ${PATCH} =~ \.patch$ ]]; then
|
||||
echo "Specified file ${PATCH} does not have .patch extension"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
@ -227,8 +231,9 @@ unmount_iso
|
||||
chmod +w ${BUILDDIR}
|
||||
chmod -R +w ${BUILDDIR}/isolinux
|
||||
chmod -R +w ${BUILDDIR}/ostree_repo
|
||||
# Extract patch xml
|
||||
# Create the directory where metadata will be stored
|
||||
mkdir ${BUILDDIR}/patches
|
||||
chmod -R +w ${BUILDDIR}/patches
|
||||
|
||||
echo "Updating ostree_repo..."
|
||||
ostree --repo=${BUILDDIR}/ostree_repo pull-local ${OSTREE_REPO} starlingx
|
||||
@ -237,7 +242,10 @@ echo "Updated iso ostree commit:"
|
||||
ostree --repo=${BUILDDIR}/ostree_repo log starlingx
|
||||
|
||||
echo "Extracting patch metadata"
|
||||
extract_metada $PATCH_FILE
|
||||
for PATCH in "${PATCH_FILES[@]}";
|
||||
do
|
||||
extract_metadata $PATCH
|
||||
done
|
||||
|
||||
echo "Packing iso..."
|
||||
# get the install label
|
||||
|
Loading…
x
Reference in New Issue
Block a user