f4=${BLK_DEV[${update_idx}]}
f5=${BLK_OFFSET[${update_idx}]}
- if [ "${f3}" != "EXCLUDED" ]; then
- echo -e "$f1\t\t$f2\t\t$f3\t\t$f4\t\t$f5" >> ${out_file}
- fi
+ echo -e "$f1\t\t$f2\t\t$f3\t\t$f4\t\t$f5" >> ${out_file}
done
return 0
fi
}
+#------------------------------------------------------------------------------
+# Function :
+# fn_get_tar_file_names
+#
+# Description :
+# find tar file name (without path) that contains given partition binary
+#
+
+fn_get_tar_file_names()
+{
+ BIN_TO_FIND=$1
+
+ cd ${DATA_DIR}/${OLD_TAR_DIR}
+ OLD_TAR_LIST=`ls *.tar *.tar.gz *.tgz *.tar.md5 2>/dev/null`
+ cd ${CUR_DIR}
+
+ cd ${DATA_DIR}/${NEW_TAR_DIR}
+ NEW_TAR_LIST=`ls *.tar *.tar.gz *.tgz *.tar.md5 2>/dev/null`
+ cd ${CUR_DIR}
+
+ #--- find which tar contains the binary ---
+ for tar_file in ${OLD_TAR_LIST}
+ do
+ result=`tar -tvf ${DATA_DIR}/${OLD_TAR_DIR}/${tar_file} | grep " ${BIN_TO_FIND}$"`
+ if [ "$?" = "0" ]; then
+ OLD_TAR_FILE=${tar_file}
+ break
+ fi
+ done
+
+ for tar_file in ${NEW_TAR_LIST}
+ do
+ result=`tar -tvf ${DATA_DIR}/${NEW_TAR_DIR}/${tar_file} | grep " ${BIN_TO_FIND}$"`
+ if [ "$?" = "0" ]; then
+ NEW_TAR_FILE=${tar_file}
+ break
+ fi
+ done
+
+}
+
+#------------------------------------------------------------------------------
+# Function :
+# fn_extract_from_image
+#
+# Description :
+# extract some files from given image
+#
+
+fn_extract_from_image()
+{
+ CUR_DIR=`pwd`
+ DATA_DIR=./data
+ IMAGE=$1
+ TARGET_FILE=$2
+ MNT_PNT=TMP_MNT
+ mkdir -p ${MNT_PNT}
+
+ fn_get_tar_file_names $IMAGE
+ tar xvf ${DATA_DIR}/${NEW_TAR_DIR}/${NEW_TAR_FILE} ${IMAGE}
+ if [ "$?" != "0" ]; then
+ return 1;
+ fi
+
+ sudo mount -t ext4 -o loop ${IMAGE} ${MNT_PNT}
+ if [ "$?" != "0" ]; then
+ return 1;
+ fi
+
+ EXTRACT_FILE="${MNT_PNT}${TARGET_FILE}"
+ if [ -e ${EXTRACT_FILE} ]; then
+ sudo cp ${EXTRACT_FILE} ${DELTA_DIR}
+ else
+ echo "There is no ${TARGET_FILE} in ${IMAGE}"
+ fi
+
+ sudo umount ${MNT_PNT}
+ sudo rm -rf ${MNT_PNT}
+ sudo rm -f ${IMAGE}
+}
+
###############################################################################
#==================
# Main Start
PART_OUT=${part_name}_OUT
- if [ "${update_type}" = "EXCLUDED" ]; then
- ${MK_PART_DELTA} ${part_name} ${update_type} ${part_bin} ${delta_bin}
- continue
- elif [ "${update_type}" = "EXTRA" ]; then
+ if [ "${update_type}" = "EXTRA" ]; then
fn_process_extra_delta
else
${MK_PART_DELTA} ${part_name} ${update_type} ${part_bin} ${delta_bin}
sudo rm ${LOG_PATH}
fi
- #--- move delta.ua to delta directory ---
- if [ -r ${DELTA_UA} ]; then
- sudo cp ${DELTA_UA} ${DELTA_DIR}/delta.ua
- sudo rm ${DELTA_UA}
- fi
-
- #--- move update manager script to delta directory ---
- if [ -r ${UPDATE_MANAGER} ]; then
- sudo cp ${UPDATE_MANAGER} ${DELTA_DIR}/upgrade-trigger.sh
- sudo rm ${UPDATE_MANAGER}
- fi
+ #--- extract files which would be appended to delta.tar ---
+ echo "Extract binaries for update from images"
+ fn_extract_from_image rootfs.img /usr/bin/upgrade-trigger.sh
+ fn_extract_from_image ramdisk-recovery.img /usr/bin/delta.ua
#--- archive result directory ---
cd result/$MONDATE
}
-#------------------------------------------------------------------------------
-# Function :
-# extract_from_image
-#
-# Description :
-# extract some file from given image
-#
-
-fn_extract_from_image()
-{
- IMAGE=$1
- TARGET_FILE=$2
- MNT_PNT=${PART_NAME}_MNT
- mkdir -p ${MNT_PNT}
-
- tar xvf ${DATA_DIR}/${NEW_TAR_DIR}/${NEW_TAR_FILE} ${IMAGE}
- if [ "$?" != "0" ]; then
- return 1;
- fi
-
- sudo mount -t ext4 -o loop ${IMAGE} ${MNT_PNT}
- if [ "$?" != "0" ]; then
- return 1;
- fi
-
- EXTRACT_FILE="${MNT_PNT}${TARGET_FILE}"
- if [ -e ${EXTRACT_FILE} ]; then
- sudo cp ${EXTRACT_FILE} ${DATA_DIR}
- else
- echo "There is no ${TARGET_FILE} in ${IMAGE}"
- fi
-
- sudo umount ${MNT_PNT}
- sudo rm -rf ${MNT_PNT}
- sudo rm -f ${IMAGE}
-}
-
-
###############################################################################
#==================
# Main Start
fn_get_tar_file_names ${PART_BIN}
-case "${PART_NAME}" in
- "ramdisk2" | "ramdisk-recovery" )
- fn_extract_from_image ${PART_BIN} /usr/bin/delta.ua
- ;;
- "rootfs" )
- fn_extract_from_image ${PART_BIN} /usr/bin/upgrade-trigger.sh
- ;;
-esac
-
-if [ "${UPDATE_TYPE}" = "EXCLUDED" ]; then
- exit 0
-fi
-
-OLD_TAR_MISSING=
if [ "z${OLD_TAR_FILE}" = "z" ]; then
if [ ! "${UPDATE_TYPE}" = "FULL_IMG" ] && [ ! "${UPDATE_TYPE}" = "PRE_UA" ]; then
echo "[old] tar file does not exist in ${DATA_DIR}/${OLD_TAR_DIR} which contains ${PART_BIN}"