2
0
mirror of https://gitlab.com/Nanolx/NanoDroid synced 2024-10-31 09:20:23 +00:00
NanoDroid/data/build-package.common

270 lines
6.7 KiB
Plaintext
Raw Normal View History

2018-01-23 20:11:52 +00:00
#!/bin/bash
nanodroid_missing_files=0
nanodroid_broken_files=0
2018-01-23 20:11:52 +00:00
missing_database=""
debug_message () {
2020-08-19 18:37:02 +00:00
[ "${BP_DEBUG}" != '1' ] && return 0
case "$1" in
normal)
echo "$3$(tput setaf 3)$2$(tput sgr 0)"
;;
newline)
echo -e "$3$(tput setaf 3)$2$(tput sgr 0)"
;;
esac
}
2018-01-23 20:11:52 +00:00
check_nanodroid () {
for file in ${file_database[@]}; do
2018-01-23 20:11:52 +00:00
if [[ ! -f ${CWD}/${file} ]]; then
nanodroid_missing_files=1
missing_database=(${missing_database[@]} ${file})
else
case ${file} in
*.gz )
mimetype=$(file -b --mime-type ${CWD}/${file})
mimetype_int=$(gzip -dc ${CWD}/${file} | file -b --mime-type - )
;;
*.so* )
mimetype=$(file -b --mime-type ${CWD}/${file})
mimetype_int=""
;;
esac
case ${mimetype} in
application/x-sharedlib )
# library
;;
2019-07-08 18:54:17 +00:00
application/gzip )
# APK
;;
* )
2020-08-19 16:55:29 +00:00
debug_message newline "${file} has non-supported mimetype ${mimetype}"
nanodroid_broken_files=1
broken_database=(${broken_database[@]} ${file})
2020-08-19 18:10:34 +00:00
[ "${BP_DEBUG}" != '1' ] && rm -f ${CWD}/${file}
;;
esac
case ${mimetype_int} in
"" )
# library
;;
application/java-archive | application/zip )
# APK
;;
* )
2020-08-19 16:55:29 +00:00
debug_message newline "compressed ${file} has non-supported mimetype ${mimetype_int}"
nanodroid_broken_files=1
broken_database=(${broken_database[@]} ${file})
2020-08-19 18:10:34 +00:00
[ "${BP_DEBUG}" != '1' ] && rm -f ${CWD}/${file}
;;
esac
2018-01-23 20:11:52 +00:00
fi
done
if [[ ${nanodroid_missing_files} -ne 0 ]]; then
2018-01-23 20:11:52 +00:00
echo -e "\nThe following files are missing:\n"
printf '%s\n' ${missing_database[@]} | uniq | sort
fi
if [[ ${nanodroid_broken_files} -ne 0 && "${BP_DEBUG}" -ne 1 ]]; then
echo -e "\nThe following files are broken (and will be removed):\n"
printf '%s\n' ${broken_database[@]} | uniq | sort
elif [[ ${nanodroid_broken_files} -ne 0 && "${BP_DEBUG}" -eq 1 ]]; then
echo -e "\nThe following files are broken (and are kept because BP_DEBUG is set):\n"
printf '%s\n' ${broken_database[@]} | uniq | sort
fi
if [[ ${nanodroid_missing_files} -eq 0 && ${nanodroid_broken_files} -eq 0 ]]; then
2018-09-14 16:57:52 +00:00
echo -e "\nNanoDroid correctly populated\n"
return 0
else return 1
2018-01-23 20:11:52 +00:00
fi
}
2019-03-01 13:23:44 +00:00
update_patches () {
grab_patches sigspoof-core/services.jar.dex core_services.jar.dex
grab_patches sigspoof-hook-4.1-6.0/services.jar.dex hook_4.1-6.0_services.jar.dex
grab_patches sigspoof-hook-7.0-9.0/services.jar.dex hook_7.0-9.0_services.jar.dex
}
2018-01-23 20:11:52 +00:00
progress () {
sleep 0.5
while [ -d "/proc/${1}" ];do
echo -ne '/\x08' ; sleep 0.05
echo -ne '-\x08' ; sleep 0.05
echo -ne '\\\x08' ; sleep 0.05
echo -ne '|\x08' ; sleep 0.05
done
echo "Done"
}
zip_add () {
local file_path="${CWD}/${1}"
local file_mask="${2}"
local zip_path="${CWD}/${ZIP}"
cd "${file_path}"
if [ -z "${file_mask}" ]; then
zip -qr "${zip_path}" . || exit 1
elif [ -d "${file_mask}" ]; then
zip -qr "${zip_path}" "${file_mask}" || exit 1
else
zip -q "${zip_path}" ${file_mask} || exit 1
fi
cd "${CWD}"
2018-01-23 20:11:52 +00:00
}
zip_add_setup () {
2019-07-28 19:06:12 +00:00
cd "${CWD}/doc"
local zip_path="${CWD}/${ZIP}"
case ${1} in
0 )
sed -e 's/nanodroid_overlay=1/nanodroid_overlay=0/' -i .nanodroid-setup
zip -q "${zip_path}" .nanodroid-setup || exit 1
sed -e 's/nanodroid_overlay=0/nanodroid_overlay=1/' -i .nanodroid-setup
;;
1 )
zip -q "${zip_path}" .nanodroid-setup || exit 1
;;
esac
cd "${CWD}"
}
increase_version_number () {
if [ -z ${2} ]; then
date=99999999
else date=${2}
2018-01-23 20:11:52 +00:00
fi
[ -z ${1} ] && error "no new version number given (current: ${version_code})"
2019-08-11 20:41:24 +00:00
for file in "CommonAddon" "CommonInstaller" \
"systest/SysTest" "patcher/CommonPatcher" \
2019-08-11 20:41:24 +00:00
"SetupWizard/nanodroid-setup" \
"uninstaller/META-INF/com/google/android/update-binary"; do
sed -e "s/^VERSION=.*/VERSION=${1}.${date}/" -i "${CWD}/${file}"
done
2018-01-23 20:11:52 +00:00
2019-10-08 18:59:08 +00:00
sed -e "s/^version_code.*/version_code=${1}/g" -i "${CWD}/build-package"
sed -e "s/^version_date.*/version_date=${date}/g" -i "${CWD}/build-package"
2019-08-11 20:41:24 +00:00
for module in Full microG FDroid BromiteWebView OsmAnd Google; do
sed -e "s/version=.*/version=v${1}.${date}/" -i \
2018-01-23 20:11:52 +00:00
"${CWD}/${module}/module.prop"
done
sed -e "s/rom_version\",.*/rom_version\", \"${1}\")\;/" -i \
2019-07-21 19:33:28 +00:00
"${CWD}/SetupWizard/META-INF/com/google/android/aroma-config"
sed -e "s/rom_date\",.*/rom_date\", \"${date}\")\;/" -i \
2019-07-21 19:33:28 +00:00
"${CWD}/SetupWizard/META-INF/com/google/android/aroma-config"
2018-01-23 20:11:52 +00:00
}
increase_module_version () {
for module in Full microG FDroid BromiteWebView OsmAnd Google; do
eval $(grep versionCode "${CWD}/${module}/module.prop")
local versionCode=$((versionCode+1))
2018-01-23 20:11:52 +00:00
sed -e "s/versionCode.*/versionCode=${versionCode}/" \
-i "${CWD}/${module}/module.prop"
done
}
dalvikize_jar () {
[ -z "${ANDROID_HOME}" ] && error "ANDROID_HOME is not set!"
[ ! -f "${ANDROID_HOME}/build-tools/28.0.3/dx" ] && error "can't find 'dx' binary in \"${ANDROID_HOME}/build-tools/28.0.3\"!"
[ ! -z "${2}" ] && local dx_extra_arg="--min-sdk-version=${2}"
if [ -f "${1}" ]; then
${ANDROID_HOME}/build-tools/28.0.3/dx --dex \
2018-01-23 20:11:52 +00:00
--output="$(basename "${1}" .jar).dex" \
${dx_extra_arg} "${1}"
else
error "can't find input file \"${1}\""
2018-01-23 20:11:52 +00:00
fi
}
show_help () {
echo -e "
** NanoDroid ${VERSION} helper script **
usage: build-package [opt] [arg]
setup NanoDroid [! do this first !]:
pull | download all required apks for NanoDroid
update contents:
u-microg | update microG and companions
u-fdroid | update F-Droid and Extension
u-bromite | update Bromite System WebView
2018-11-23 22:51:10 +00:00
u-osmand | update OsmAnd and Plugins
2018-01-23 20:11:52 +00:00
u-apps | update applications
u-swipe | update swipe libraries
u-gsync | update Google Sync Adapters
u-patch | download Haystack patches
2018-01-23 20:11:52 +00:00
create zip files:
2019-07-21 19:33:28 +00:00
full | create Full package zip from repo
2018-01-23 20:11:52 +00:00
microg | create microG package zip from repo
2019-07-21 19:33:28 +00:00
fdroid | create FDroid package zip from repo
2018-01-23 20:11:52 +00:00
patcher | create framework patcher zip from repo
uninstaller | create uninstaller zip from repo
2019-07-21 19:33:28 +00:00
setupwizard | create SetupWizard zip from repo
2018-11-08 17:27:34 +00:00
bromitewebview | create Bromite WebView zip from repo
osmand | create OsmAnd package zip from repo
google | create Google package zip from repo
2018-01-23 20:11:52 +00:00
all | create all zips from repo
misc. stuff:
check | check if all files were properly downloaded
clean | remove any untracked files from the repo
report | create package report (work-in-progress)
dalvik [jar] [:minsdk] | prepare a jar file for dalvikvm usage
ver [ver] [:date] | bump version accross whole project
bump | increment Magisk Module versionCodes by 1
2018-01-23 20:11:52 +00:00
"
exit 0
}
print_package () {
echo "
Creating Package
Type ${1}
Name ${ZIP}
Directory ${CWD}
2018-01-23 20:11:52 +00:00
"
rm -f "${CWD}/${ZIP}"*
2018-01-23 20:11:52 +00:00
}
error () {
echo -e "${@}"
exit 1
}
sum_sign_package () {
2019-06-26 17:55:36 +00:00
cd "${CWD}"
cd "$(dirname "${1}")"
2020-08-11 19:38:33 +00:00
${sumsha256} "$(basename "${1}")" > "${1}.sha256"
cd "${CWD}"
gpg --sign --detach-sign "${1}.sha256"
}