Commit 78b272b8 authored by fuyanbin's avatar fuyanbin
Browse files

支持打包allwiner镜像

parent 7344bff6
Pipeline #50737 passed with stages
in 10 seconds
......@@ -24,7 +24,7 @@ URL_TAG=""
CHROOT_TYPE="androidrom"
DEPLOY="elf"
export PATH=${PATH}:$(pwd)/tools/:$(pwd)/tools/amlogic_tool:$(pwd)/tools/rockchip_tool:$(pwd)/tools/rockchip_tool/obsutil
export PATH=$(pwd)/tools/android-tools:$(pwd)/tools/:$(pwd)/tools/amlogic_tool:$(pwd)/tools/rockchip_tool:$(pwd)/tools/rockchip_tool/obsutil:$(pwd)/tools/allwinner:$PATH
PARSED_ARUGMENTS=$(getopt -a -n "$0" -o 'x' --long help,build-directory:,vendor:,orgcode:,channel-id:,package-type:,project-id:,pipeline-id:,url-tag: -- "$@")
eval set -- "${PARSED_ARUGMENTS}"
while :
......@@ -52,28 +52,92 @@ system_mount_point=""
system_path=""
systemfile=""
systemfile_ext4=""
super_file=""
super_file_ext4=""
update_img_tmp_dir="$build_dir/img_dir"
super_img_tmp_dir="$build_dir/img_dir/super"
is_amlogic=1
is_amlogic=0
is_allwinner=0
outfile_path=""
get_group_name() {
local group_name
local partition_info_dump
local c_super_file="$1"
partition_info_dump=$(lpdump -j "$c_super_file" | jq -c -r '.partitions[]')
for item in $partition_info_dump
do
if [[ "$(echo "$item" | jq -r '.name')" == "system_a" ]]
then
group_name=$(echo "$item" | jq -r '.group_name')
fi
done
printf "%s" "$group_name"
}
resize_system_image() {
local c_system_file="$1"
local image_size
local loopdev
image_size="$(stat -c "%s" "$c_system_file")"
image_size=$((image_size+314572800)) # +300M
qemu-img resize -f raw "$c_system_file" "$image_size"
loopdev=$(losetup -P -f --show "$c_system_file")
yes | e2fsck -f "$loopdev"
resize2fs "$loopdev"
losetup -d "$loopdev"
}
unpack_and_mount_image() {
local img="$1"
local loopdev
mkdir -p "$update_img_tmp_dir"
mkdir -p "$super_img_tmp_dir"
if aml_image_v2_packer -c "$img"
then
echo "Amlogic Image Format Detected.."
is_amlogic=1
systemfile="$build_dir/system.PARTITION"
systemfile_ext4="$build_dir/system.PARTITION.ext4"
aml_image_v2_packer -d "$img" "$build_dir"
elif sunxi-fw info "$img" | grep -i -q "PhoenixSuite image file"
then
echo "Allwinner PhoenixSute Image Format Detected.."
is_allwinner=1
cp "$img" "$update_img_tmp_dir/update.img"
imgrepacker /skip "$update_img_tmp_dir/update.img"
rm -f "$update_img_tmp_dir/update.img"
super_file="$update_img_tmp_dir/update.img.dump/super.fex"
super_file_ext4="$update_img_tmp_dir/update.img.dump/super.fex.ext4"
if file "$super_file" | grep "Android sparse image"
then
simg2img "$super_file" "$super_file_ext4"
lpunpack "$super_file_ext4" "$super_img_tmp_dir"
else
lpunpack "$super_file" "$super_img_tmp_dir"
fi
systemfile="$super_img_tmp_dir/system_a.img"
systemfile_ext4="$super_img_tmp_dir/system_a.img.ext4"
if file "$systemfile" | grep "Android sparse image"
then
resize_system_image "$systemfile_ext4"
else
resize_system_image "$systemfile"
fi
else
local update_img="${build_dir}/$(basename "$img")-update.img"
local update_img_tmp_dir="$build_dir/img_dir"
is_amlogic=0
img_unpack "$img" "$update_img"
mkdir -p "$update_img_tmp_dir"
# fix: afptool 只能用相对路径创建Image目录
pushd "$build_dir"
afptool -unpack "$update_img" "./img_dir"
......@@ -103,7 +167,7 @@ unpack_and_mount_image() {
losetup -d "$loopdev"
}
build_image() {
install_dianxin() {
local img="$1"
local android_sdk
......@@ -204,7 +268,22 @@ pack_image() {
outfile_path="${packge_dir}/${CHANNELID}-$(basename "$img")"
if [[ "$is_amlogic" == "1" ]]
then
echo "Amlogic Image Format Detected.."
aml_image_v2_packer -r "/$build_dir/image.cfg" "$build_dir" "$outfile_path"
elif [[ "$is_allwinner" == "1" ]]
then
echo "Allwinner PhoenixSute Image Format Detected.."
if [[ -f "$super_file_ext4" ]]
then
lpadd --readonly --replace "$super_file_ext4" system_a "$(get_group_name "$super_file_ext4")" "$systemfile"
rm -rf "$super_file"
img2simg "$super_file_ext4" "$super_file"
rm -rf "$super_file_ext4"
else
lpadd --readonly --replace "$super_file" system_a "$(get_group_name "$super_file")" "$systemfile"
fi
imgrepacker "$update_img_tmp_dir/update.img.dump"
mv "$update_img_tmp_dir/update.img" "$outfile_path"
else
local update_img_tmp_dir="$build_dir/img_dir"
find "$update_img_tmp_dir/Image/" -name parameter.txt -exec cp {} "$update_img_tmp_dir/parameter" \;
......@@ -292,5 +371,5 @@ IMAGE_FILE="/baseimages/$VENDOR-$ORGCODE.img"
[[ ! -f "$IMAGE_FILE" ]] && IMAGE_FILE="CH-A03.img"
generate_vendor_confg
update_hugepall_zipfile
build_image "$IMAGE_FILE"
install_dianxin "$IMAGE_FILE"
upload
File added
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment