-
Notifications
You must be signed in to change notification settings - Fork 235
/
makeimg2.sh
executable file
·59 lines (44 loc) · 1.71 KB
/
makeimg2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# Copyright (C) 2020 Xiaoxindada <2245062854@qq.com>
source ./bin.sh
LOCALDIR=`cd "$( dirname ${BASH_SOURCE[0]} )" && pwd`
cd $LOCALDIR
rm -rf ./images
echo ""
read -p "请输入要打包的分区(别带.img): " species
echo "
开始打包
当前img大小为:
_________________
`du -sh ./out/$species | awk '{print $1}'`
`du -sm ./out/$species | awk '{print $1}' | sed 's/$/&M/'`
`du -sb ./out/$species | awk '{print $1}' | sed 's/$/&B/'`
_________________
使用G为单位打包时必须带单位且为整数
使用B为单位打包时无需带单位且在自动识别的大小添加一定大小
推荐用M为单位大小进行打包需带单位且在自动识别的大小添加至少130M大小
"
read -p "请输入要打包的数值: " size
M="$(echo "$size" | sed 's/M//g')"
G="$(echo "$size" | sed 's/G//g')"
if [ $(echo "$size" | grep 'M') ];then
ssize=$(($M*1024*1024))
elif [ $(echo "$size" | grep 'G') ];then
ssize=$(($G*1024*1024*1024))
else
ssize=$size
fi
if [ $species = "system" ];then
$bin/mkuserimg_mke2fs.sh "./out/$species/" "./out/${species}.img" "ext4" "/$species" "$ssize" -j "0" -T "1230768000" -C "./out/config/${species}_fs_config" -L "$species" -I "256" -M "/$species" -m "0" "./out/config/${species}_file_contexts"
else
$bin/mkuserimg_mke2fs.sh "./out/$species/" "./out/${species}.img" "ext4" "/$species" "$ssize" -j "0" -T "1230768000" -C "./out/config/${species}_fs_config" -L "$species" -I "256" -M "/$species" -m "0" "./out/config/${species}_file_contexts"
fi
if [ -s ./out/$species.img ];then
echo "打包完成"
echo "输出至images文件夹"
mkdir -p ./images
mv -f ./out/$species.img ./images
chmod 777 -R ./images
else
echo "打包失败,错误日志如上"
fi