Commit fc6b0a53 authored by fuyanbin's avatar fuyanbin
Browse files

删除旧的pack.sh

parent f575cdd8
Pipeline #49892 passed with stages
in 44 seconds
#!/bin/bash
usage() {
echo "Usage: $0 -V | --vendor <vendor id>
-t | --type <pipe type>
-i | --image <image file>
--chroot-type <pack type>
--orgcode <organization code>
--channelid <channel id>
--packtype <pack type>
--help"
exit 1
}
VENDOR=""
PIPE_TYPE="small"
CHROOT_TYPE="androidrom"
DEPLOY="elf"
ORGCODE=""
CHANNELID=""
IMAGE_FILE=""
PACK_TYPE="other"
# new append
NOUPLOAD="false"
LOCAL="false"
export PATH=${PATH}:$(pwd)/tools/
PARSED_ARUGMENTS=$(getopt -a -n "$0" -o V:t:i: --long help,vendor:,type:,image:,chroot-type:,orgcode:,channelid:,packtype: -- "$@")
eval set -- "${PARSED_ARUGMENTS}"
while :
do
case "$1" in
-V | --vendor) VENDOR="$2"; shift 2 ;;
-t | --type) PIPE_TYPE="$2"; shift 2 ;;
-i | --image) IMAGE_FILE="$2"; shift 2 ;;
--chroot-type) CHROOT_TYPE="$2"; shift 2 ;;
--orgcode) ORGCODE="$2"; shift 2;;
--channelid) CHANNELID="$2"; shift 2;;
--packtype) PACK_TYPE="$2"; shift 2;;
--help) usage ;;
--) shift; break;;
*) usage ;;
esac
done
build_dir=$(mktemp -d /build/tmp.XXXXX)
packge_dir=$(mktemp -d /build/tmp.XXXXX)
boot_dir=$(mktemp -d /build/tmp.XXXXX)
build_image() {
local img="$1"
local android_sdk
local system_mount_point
local system_path
systemfile="$build_dir/system.PARTITION"
systemfile_ext4="$build_dir/system.PARTITION.ext4"
aml_image_v2_packer -d "$img" "$build_dir"
if file "$systemfile" | grep "Android sparse image"
then
simg2img "$systemfile" "$systemfile_ext4"
loopdev=$(losetup -P -f --show "$systemfile_ext4")
else
loopdev=$(losetup -P -f --show "$systemfile")
fi
system_mount_point="$build_dir/system"
mkdir "$system_mount_point"
mount "$loopdev" "$system_mount_point"
if [[ -d "$system_mount_point/system" ]]
then
system_path="$system_mount_point/system"
else
system_path="$system_mount_point"
fi
touch "$system_path/.androidrom"
rm -f "$system_path/hugep-all.zip"
rm -f "$system_path/bin/hugep-all.zip"
android_sdk="$(grep "build\.version\.sdk" "$system_path"/build.prop | awk -F'=' '{print $2}')"
android_sdk="${android_sdk//$'\r'}"
android_sdk="${android_sdk//$'\n'}"
if [[ "$android_sdk" -ge 28 ]]
then
find ./services/ -type f -name "*.rc" -exec install -t "$system_path"/etc/init/ {} \;
else
pushd "$boot_dir"
abootimg -x "$build_dir/boot.PARTITION" ramdisk
mkdir initrd_dir
pushd initrd_dir
gunzip -c ../initrd.img | cpio -i
popd
cp initrd_dir/init.rc .
rm -rf initrd_dir
popd
cp "$boot_dir"/init.rc "$packge_dir"/init.rc
rm -rf "$boot_dir"
if ! find_autostart -script_name preinstall.sh -initrc "$packge_dir"/init.rc -root_path "$build_dir" > "$packge_dir"/find_autostart.log 2>/dev/null
then
find_autostart -script_name recovery.sh -initrc "$packge_dir"/init.rc -root_path "$build_dir" > "$packge_dir"/find_autostart.log 2>/dev/null
fi
local auto_start_script
auto_start_script="$(cat "$packge_dir"/find_autostart.log)"
if [[ -z "$auto_start_script" ]] && [[ -f "$system_path"/bin/startsoftdetector.sh ]]
then
# TODO: startsoftdetector.sh 会阻塞在某一步,要把 starthugep.sh 加在中间部分
auto_start_script="/system/bin/startsoftdetector.sh"
fi
# NOTE: 返回的脚本路径里一定以 /system/ 开头, 所以下边拼路径时没有加上 /system
if [[ -n "$auto_start_script" ]]
then
local _script_path
_script_path="$system_path/$(echo "$auto_start_script" | sed '|^/system||')"
if ! grep -q "#!/system/bin/sh" "$_script_path"
then
echo "#!/system/bin/sh" >> "$_script_path"
fi
echo " " >> "$_script_path"
echo "/system/bin/starthugep.sh > /dev/null 2>&1 &" >> "$_script_path"
chmod 0755 "$_script_path"
chcon u:object_r:drmserver_exec:s0 "$_script_path"
fi
fi
cp -f "$build_dir/hugep-all.zip" "$system_path"/bin/hugep-all.zip
find ./services/ -type f ! -name "*.rc" ! -name "*.zip" -exec install -m 0777 -t "$system_path"/bin/ {} \;
cp -f services/manager_bin_file.zip "$system_path"/bin/manager_bin_file.zip
for file in $(find ./services/ -type f ! -name "*.rc" ! -name "*.zip")
do
chcon u:object_r:drmserver_exec:s0 "$system_path/bin/$(basename "$file")"
done
umount "$loopdev"
losetup -d "$loopdev"
rm -rf "$system_mount_point"
sync
if [[ -f "$systemfile_ext4" ]]
then
rm -f "$systemfile"
img2simg "$systemfile_ext4" "$systemfile"
rm -f "$systemfile_ext4"
fi
aml_image_v2_packer -r "/$build_dir/image.cfg" "$build_dir" "${packge_dir}/$(basename "$img")"
rm -rf "$build_dir"
}
generate_vendor_confg() {
local yaml_file_src
local yaml_file
yaml_file="$build_dir"/vendor.yaml
yaml_file_src="$build_dir"/vendor.yaml.src
cp vendor.yaml.src "$yaml_file_src"
sed -i'' "s#__VENDOR__#$VENDOR#g" "$yaml_file_src"
sed -i'' "s#__ORGCODE__#$ORGCODE#g" "$yaml_file_src"
sed -i'' "s#__CHROOT_TYPE__#$CHROOT_TYPE#g" "$yaml_file_src"
sed -i'' "s#__DEPLOY__#$DEPLOY#g" "$yaml_file_src"
sed -i'' "s#__CHANNEL_ID__#$CHANNELID#g" "$yaml_file_src"
sed -i'' "s#__PACK_TYPE__#$PACK_TYPE#g" "$yaml_file_src"
aio -m enc -i "$yaml_file_src" -o "$yaml_file"
}
update_hugepall_zipfile() {
local yaml_file
local hugep_zip_file
local hugep_zip_file_origin
yaml_file="$build_dir"/vendor.yaml
hugep_zip_file="$build_dir/hugep-all.zip"
hugep_zip_file_origin="./services/hugep-all.zip"
cp "$hugep_zip_file_origin" "$hugep_zip_file"
zip -u -j "$hugep_zip_file" "$yaml_file"
}
upload() {
local date_i
local outfile
local outfile_gz
local MD5SUM
local uri
outfile="${packge_dir}/$(basename "$IMAGE_FILE")"
outfile_gz="${outfile}.gz"
date_i="$(date +%Y-%m-%d-%s)"
MD5SUM=$(md5sum "$outfile" | awk '{print $1}' )
zstd --ultra --format=gzip "$outfile" -o "$outfile_gz"
uri="product/terminal/chroot_androidrom/""$ORGCODE/$date_i/$(basename "$outfile_gz")"
obsutil cp "$outfile_gz" obs://fae-cdn.linkfog.cn/"$uri"
IMG_URL="https://fae-cdn.linkfog.cn/""$uri"
echo "RESULT: ${VENDOR} ${IMG_URL} ${MD5SUM} ${TITLE}"
rm -f "$outfile" "$outfile_gz"
rm -rf "$packge_dir"
}
export PATH="$PATH:$(pwd)"/tools/
generate_vendor_confg
update_hugepall_zipfile
build_image "$IMAGE_FILE"
upload
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