|
|
|
# Copyright 2022 Northern.tech AS
|
feat(MEN-3052): Automatic decompression of input files
Previously the user would have to manually decompress an input image prior to
handing it over to mender-convert. With this change, files compressed in the
formats: lzma, gzip, or zip archives will be automatically decompressed,
converted, and then recompressed.
Note that the zip archive can only contain one image file, otherwise the
conversion will fail. Thus if the archive contains multiple files, human
interaction is required. This simply involves unzipping the archive yourself,
and then pass in the image, just like in the old workflow.
Ticket: https://tracker.mender.io/browse/MEN-3052
Changelog: Added automatic decompression of input images, so that the convert
tool now accepts compressed input images in the formats: lzma, gzip, and zip.
The images will also be recompressed to the input format automatically.
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
5 years ago
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
feat(MEN-3052): Automatic decompression of input files
Previously the user would have to manually decompress an input image prior to
handing it over to mender-convert. With this change, files compressed in the
formats: lzma, gzip, or zip archives will be automatically decompressed,
converted, and then recompressed.
Note that the zip archive can only contain one image file, otherwise the
conversion will fail. Thus if the archive contains multiple files, human
interaction is required. This simply involves unzipping the archive yourself,
and then pass in the image, just like in the old workflow.
Ticket: https://tracker.mender.io/browse/MEN-3052
Changelog: Added automatic decompression of input images, so that the convert
tool now accepts compressed input images in the formats: lzma, gzip, and zip.
The images will also be recompressed to the input format automatically.
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
5 years ago
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
feat(MEN-3052): Automatic decompression of input files
Previously the user would have to manually decompress an input image prior to
handing it over to mender-convert. With this change, files compressed in the
formats: lzma, gzip, or zip archives will be automatically decompressed,
converted, and then recompressed.
Note that the zip archive can only contain one image file, otherwise the
conversion will fail. Thus if the archive contains multiple files, human
interaction is required. This simply involves unzipping the archive yourself,
and then pass in the image, just like in the old workflow.
Ticket: https://tracker.mender.io/browse/MEN-3052
Changelog: Added automatic decompression of input images, so that the convert
tool now accepts compressed input images in the formats: lzma, gzip, and zip.
The images will also be recompressed to the input format automatically.
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
5 years ago
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
feat(MEN-3052): Automatic decompression of input files
Previously the user would have to manually decompress an input image prior to
handing it over to mender-convert. With this change, files compressed in the
formats: lzma, gzip, or zip archives will be automatically decompressed,
converted, and then recompressed.
Note that the zip archive can only contain one image file, otherwise the
conversion will fail. Thus if the archive contains multiple files, human
interaction is required. This simply involves unzipping the archive yourself,
and then pass in the image, just like in the old workflow.
Ticket: https://tracker.mender.io/browse/MEN-3052
Changelog: Added automatic decompression of input images, so that the convert
tool now accepts compressed input images in the formats: lzma, gzip, and zip.
The images will also be recompressed to the input format automatically.
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
5 years ago
|
|
|
|
|
|
|
#
|
|
|
|
# Parse the filename from the zipped output
|
|
|
|
#
|
|
|
|
# $1 - Zip archive path
|
|
|
|
#
|
|
|
|
# @return - Name of the img contained in the archive
|
|
|
|
#
|
|
|
|
function zip_get_imgname() {
|
|
|
|
if [[ $# -ne 1 ]]; then
|
|
|
|
log_fatal "zip_get_imgname requires one argument"
|
|
|
|
fi
|
|
|
|
local -r disk_image="${1}"
|
|
|
|
# Assert that the archive holds only one file
|
|
|
|
nfiles="$(unzip -l ${disk_image} | awk '{nfiles=$2} END {print nfiles}')"
|
|
|
|
[[ "$nfiles" -ne 1 ]] && log_fatal "Zip archive has more than one file. Needs to be unzipped by a human. nfiles: $nfiles"
|
|
|
|
local -r filename="$(unzip -lq ${disk_image} | awk 'NR==3 {filename=$NF} END {print filename}')"
|
|
|
|
[[ ${filename} == *.img ]] || log_fatal "no img file found in the zip archive ${disk_image}."
|
|
|
|
echo "$(basename ${filename})"
|
feat(MEN-3052): Automatic decompression of input files
Previously the user would have to manually decompress an input image prior to
handing it over to mender-convert. With this change, files compressed in the
formats: lzma, gzip, or zip archives will be automatically decompressed,
converted, and then recompressed.
Note that the zip archive can only contain one image file, otherwise the
conversion will fail. Thus if the archive contains multiple files, human
interaction is required. This simply involves unzipping the archive yourself,
and then pass in the image, just like in the old workflow.
Ticket: https://tracker.mender.io/browse/MEN-3052
Changelog: Added automatic decompression of input images, so that the convert
tool now accepts compressed input images in the formats: lzma, gzip, and zip.
The images will also be recompressed to the input format automatically.
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
5 years ago
|
|
|
}
|