Commit bd8b5bcc authored by fuyanbin's avatar fuyanbin
Browse files

allwiner打包兼容分区变大

parent e3214841
......@@ -57,20 +57,63 @@ super_file_ext4=""
update_img_tmp_dir="$build_dir/img_dir"
super_img_tmp_dir="$build_dir/img_dir/super"
ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME="system_a"
is_amlogic=0
is_allwinner=0
outfile_path=""
validate_partition_size_change() {
local group_name
local size
local total_size
local group_maxinum_size
local c_super_file="$1"
local parttion_name="$2"
local partition_info_dump
local group_info_dump
group_name=$(get_group_name "$c_super_file" "$parttion_name")
partition_info_dump=$(lpdump -j "$c_super_file" | jq -c -r '.partitions[]')
for item in $partition_info_dump
do
if [[ "$(echo "$item" | jq -r '.group_name')" == "$group_name" ]]
then
size=$(echo "$item" | jq -r '.size')
total_size=$((total_size+size))
fi
done
total_size=$((total_size+(210*1024*1024)))
group_info_dump=$(lpdump -j "$c_super_file" | jq -c -r '.groups[]')
for item in $group_info_dump
do
if [[ "$(echo "$item" | jq -r '.name')" == "$group_name" ]]
then
group_maxinum_size=$(echo "$item" | jq r '.maximum_size')
break
fi
done
if [[ -n "$group_maxinum_size" ]] && [[ "$group_maxinum_size" -lt "$total_size" ]]
then
return 1
fi
return 0
}
get_group_name() {
local group_name
local partition_info_dump
local c_super_file="$1"
local parttion_name="$2"
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" ]]
if [[ "$(echo "$item" | jq -r '.name')" == "$parttion_name" ]]
then
group_name=$(echo "$item" | jq -r '.group_name')
fi
......@@ -126,8 +169,8 @@ unpack_and_mount_image() {
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"
systemfile="$super_img_tmp_dir/${ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME}.img"
systemfile_ext4="$super_img_tmp_dir/${ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME}.img.ext4"
if file "$systemfile" | grep "Android sparse image"
then
resize_system_image "$systemfile_ext4"
......@@ -273,14 +316,32 @@ pack_image() {
elif [[ "$is_allwinner" == "1" ]]
then
echo "Allwinner PhoenixSute Image Format Detected.."
local c_super_file=
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"
c_super_file="$super_file_ext4"
else
c_super_file="$super_file"
fi
local c_group_name
c_group_name="$(get_group_name "$c_super_file" "$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME")"
if validate_partition_size_change "$c_super_file" "$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME"
then
lpadd --readonly \
--replace \
"$c_super_file" \
"$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME" \
"$c_group_name" \
"$systemfile"
if [[ -f "$super_file_ext4" ]]
then
img2simg "$super_file_ext4" "$super_file"
rm -rf "$super_file_ext4"
fi
else
lpadd --readonly --replace "$super_file" system_a "$(get_group_name "$super_file")" "$systemfile"
repack.sh "$c_super_file" "$c_group_name" "$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME" "$systemfile"
mv "$(dirname "$c_super_file")/super.new.img" "$c_super_file"
fi
imgrepacker "$update_img_tmp_dir/update.img.dump"
mv "$update_img_tmp_dir/update.img" "$outfile_path"
......
#!/bin/bash
set -e
c_super_file="$1"
n_super_file="$(dirname "$c_super_file")/super.new.img"
group_name="$2"
c_system_file="$3"
c_system_partion_name="$4"
args=""
super_block_device_size=0
blockdevice_info_dump=$(lpdump -j "$c_super_file" | jq -c -r '.block_devices[]')
for item in $blockdevice_info_dump
do
if [[ "$(echo "$item" | jq -r '.name')" == "super" ]]
then
super_block_device_size="$(echo "$item" | jq -r '.size')"
break
fi
done
if [[ "$super_block_device_size" == "0" ]]
then
exit 1
fi
group_maxinum_size=0
group_info_dump=$(lpdump -j "$c_super_file" | jq -c -r '.groups[]')
for item in $group_info_dump
do
if [[ "$(echo "$item" | jq -r '.name')" == "$group_name" ]]
then
group_maxinum_size=$(echo "$item" | jq -r '.maximum_size')
break
fi
done
if [[ "$group_maxinum_size" == "0" ]]
then
exit 2
fi
temp_super_dir="$(dirname "$c_super_file")/super/"
total_size=0
partition_info_dump=$(lpdump -j "$c_super_file" | jq -c -r '.partitions[]')
for item in $partition_info_dump
do
echo $item
if [[ "$(echo "$item" | jq -r '.group_name')" == "$group_name" ]]
then
name=$(echo "$item" | jq -r '.name')
size=$(echo "$item" | jq -r '.size')
if [[ "$name" == "$c_system_partion_name" ]]
then
size="$(stat -c "%s" "$c_system_file")"
fi
args="$args --partition ${name}:readonly:${size}:${group_name} --image ${name}=${temp_super_dir}/${name}.img"
total_size=$((total_size + size))
fi
done
if [[ -z "$args" ]]
then
exit 3
fi
mkdir -p "$temp_super_dir"
lpunpack "$c_super_file" "$temp_super_dir"
mv "$c_system_file" "$temp_super_dir"
if [[ "$group_maxinum_size" -lt "$total_size" ]]
then
if [[ "$super_block_device_size" -lt "$total_size" ]]
then
space_needed=$((total_size-group_maxinum_size))
super_block_device_size=$((super_block_device_size + space_needed))
fi
group_maxinum_size="$total_size"
fi
lpmake \
--metadata-size 65536 \
--super-name super \
--metadata-slots 2 \
--device super:"$super_block_device_size" \
--group "$group_name":"$group_maxinum_size" \
--sparse \
--output "$n_super_file" \
$args
rm -rf "$temp_super_dir"
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