diff --git a/build-tools/patch-iso-debian b/build-tools/patch-iso-debian index 6f37a1db..6559e740 100755 --- a/build-tools/patch-iso-debian +++ b/build-tools/patch-iso-debian @@ -31,19 +31,20 @@ OSTREE_REPO="${DEPLOY_DIR}/ostree_repo" function usage() { echo "" echo "Usage: " - echo " $(basename $0) -i -o [ -u ] ..." + echo " $(basename $0) -i -o [ -p ] ..." echo " -i : Specify input ISO file" echo " -o : Specify output ISO file" - echo " -p : Patch file" + echo " -p : 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}" - exit 1 -fi +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" - exit 1 -fi + 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