Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
付燕斌
android-image-pack-tool
Commits
bd8b5bcc
Commit
bd8b5bcc
authored
Aug 12, 2024
by
fuyanbin
Browse files
allwiner打包兼容分区变大
parent
e3214841
Changes
2
Show whitespace changes
Inline
Side-by-side
pack-ci.sh
View file @
bd8b5bcc
...
@@ -57,20 +57,63 @@ super_file_ext4=""
...
@@ -57,20 +57,63 @@ super_file_ext4=""
update_img_tmp_dir
=
"
$build_dir
/img_dir"
update_img_tmp_dir
=
"
$build_dir
/img_dir"
super_img_tmp_dir
=
"
$build_dir
/img_dir/super"
super_img_tmp_dir
=
"
$build_dir
/img_dir/super"
ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
=
"system_a"
is_amlogic
=
0
is_amlogic
=
0
is_allwinner
=
0
is_allwinner
=
0
outfile_path
=
""
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
()
{
get_group_name
()
{
local
group_name
local
group_name
local
partition_info_dump
local
partition_info_dump
local
c_super_file
=
"
$1
"
local
c_super_file
=
"
$1
"
local
parttion_name
=
"
$2
"
partition_info_dump
=
$(
lpdump
-j
"
$c_super_file
"
| jq
-c
-r
'.partitions[]'
)
partition_info_dump
=
$(
lpdump
-j
"
$c_super_file
"
| jq
-c
-r
'.partitions[]'
)
for
item
in
$partition_info_dump
for
item
in
$partition_info_dump
do
do
if
[[
"
$(
echo
"
$item
"
| jq
-r
'.name'
)
"
==
"
system_a
"
]]
if
[[
"
$(
echo
"
$item
"
| jq
-r
'.name'
)
"
==
"
$parttion_name
"
]]
then
then
group_name
=
$(
echo
"
$item
"
| jq
-r
'.group_name'
)
group_name
=
$(
echo
"
$item
"
| jq
-r
'.group_name'
)
fi
fi
...
@@ -126,8 +169,8 @@ unpack_and_mount_image() {
...
@@ -126,8 +169,8 @@ unpack_and_mount_image() {
else
else
lpunpack
"
$super_file
"
"
$super_img_tmp_dir
"
lpunpack
"
$super_file
"
"
$super_img_tmp_dir
"
fi
fi
systemfile
=
"
$super_img_tmp_dir
/
system_a
.img"
systemfile
=
"
$super_img_tmp_dir
/
${
ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
}
.img"
systemfile_ext4
=
"
$super_img_tmp_dir
/
system_a
.img.ext4"
systemfile_ext4
=
"
$super_img_tmp_dir
/
${
ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
}
.img.ext4"
if
file
"
$systemfile
"
|
grep
"Android sparse image"
if
file
"
$systemfile
"
|
grep
"Android sparse image"
then
then
resize_system_image
"
$systemfile_ext4
"
resize_system_image
"
$systemfile_ext4
"
...
@@ -273,14 +316,32 @@ pack_image() {
...
@@ -273,14 +316,32 @@ pack_image() {
elif
[[
"
$is_allwinner
"
==
"1"
]]
elif
[[
"
$is_allwinner
"
==
"1"
]]
then
then
echo
"Allwinner PhoenixSute Image Format Detected.."
echo
"Allwinner PhoenixSute Image Format Detected.."
local
c_super_file
=
if
[[
-f
"
$super_file_ext4
"
]]
then
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
"
]]
if
[[
-f
"
$super_file_ext4
"
]]
then
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
"
img2simg
"
$super_file_ext4
"
"
$super_file
"
rm
-rf
"
$super_file_ext4
"
rm
-rf
"
$super_file_ext4
"
fi
else
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
fi
imgrepacker
"
$update_img_tmp_dir
/update.img.dump"
imgrepacker
"
$update_img_tmp_dir
/update.img.dump"
mv
"
$update_img_tmp_dir
/update.img"
"
$outfile_path
"
mv
"
$update_img_tmp_dir
/update.img"
"
$outfile_path
"
...
...
tools/android-tools/repack.sh
0 → 100644
View file @
bd8b5bcc
#!/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
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment