ClanStat/scripts/make-appimage.sh

78 lines
2.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# Импортирует скрипт с определениями цветов
source ../3rdparty/colors.sh/colors.sh
APPDIR="../AppDir"
GIT_HASH=$(git rev-parse --short HEAD)
# Скачивает x86_64 AppImageTool
download_appimage_tool() {
echo -e "${CYAN}Загрузка AppImageTool...${NC}"
wget -q --show-progress https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x appimagetool-x86_64.AppImage
}
# Скачивает March Any Linux Python
download_python() {
wget -q --show-progress https://github.com/niess/python-appimage/releases/download/python3.13/python3.13.3-cp313-cp313-manylinux2014_x86_64.AppImage
chmod +x python3.13.3-cp313-cp313-manylinux2014_x86_64.AppImage
mv python3.13.3-cp313-cp313-manylinux2014_x86_64.AppImage python3.13
mkdir -p ${APPDIR}/usr/bin/
cp ./python3.13 ${APPDIR}/usr/bin/python3.13
}
# Загружает Python зависимости проекта
get_requirements() {
./python3.13 -m pip install --target=$(pwd)/packages -r ../requirements.txt > /dev/null 2>&1
}
# Копирует записимости в AppDir
copy_requirements() {
mkdir -p ${APPDIR}/usr/lib/python3.13/site-packages/
cp -r packages/* ${APPDIR}/usr/lib/python3.13/site-packages/
}
# Копирует приложение в AppDir
copy_app_files() {
echo -e "${GREEN}Копирование файлов ...${NC}"
rm -rf ${APPDIR}/usr/lib/python3.13/site-packages/ClanStat
cp -r ../ClanStat ${APPDIR}/usr/lib/python3.13/site-packages/ClanStat
rm -rf ${APPDIR}/usr/lib/python3.13/site-packages/ClanStat/__pycache__
}
# Выполянет сборку AppImage
make_appimage() {
echo -e "${GREEN}Сборка AppImage...${NC}"
./appimagetool-x86_64.AppImage ${APPDIR} > /dev/null 2>&1
mv ./ClanStat-x86_64.AppImage ./ClanStat-${GIT_HASH}-x86_64.AppImage
echo -e "${RED}Сборка AppImage заверщена${NC}"
}
# Основная функция
main() {
clear
echo -e "${YELLOW}Подготовка к сборке AppImage...${NC}"
if [ ! -f "appimagetool-x86_64.AppImage" ]; then
download_appimage_tool
fi
if [ ! -f "python3.13" ]; then
download_python
get_requirements
copy_requirements
fi
copy_app_files
make_appimage
}
# Запускает основную функцию
main