修复打包器生成的 deb 包在非 Deepin 系统无法正常在启动器显示快捷方式的问题

This commit is contained in:
gfdgd xi 2024-01-14 22:25:53 +08:00
parent 0ae06f118c
commit 4669c756c4
3 changed files with 11 additions and 2 deletions

View File

@ -566,6 +566,7 @@ class RunThread(QtCore.QThread):
debDesktop = ReplaceText(desktopFile, replaceMap)
########### 写入文件
WriteTxt(f"{debBuildPath}/opt/apps/{debPackageName}/entries/applications/{debPackageName}.desktop", debDesktop)
WriteTxt(f"{debBuildPath}/opt/usr/share/applications/{debPackageName}.desktop", debDesktop)
WriteTxt(f"{debBuildPath}/opt/apps/{debPackageName}/files/run.sh", debRunSh)
WriteTxt(f"{debBuildPath}/opt/apps/{debPackageName}/info", debInfo)
WriteTxt(f"{debBuildPath}/DEBIAN/control", debControl)
@ -575,6 +576,7 @@ class RunThread(QtCore.QThread):
self.RunCommand(f"chmod -Rv 0755 '{debBuildPath}/DEBIAN'")
self.RunCommand(f"chmod -Rv 755 '{debBuildPath}/opt/apps/{debPackageName}/files/'*.sh")
self.RunCommand(f"chmod -Rv 755 '{debBuildPath}/opt/apps/{debPackageName}/entries/applications/'*.desktop")
self.RunCommand(f"chmod -Rv 755 '{debBuildPath}/usr/share/applications/'*.desktop")
########### 打包 deb
print(debPackageVersion)
self.RunCommand(f"dpkg-deb -Z xz -b '{debBuildPath}' '{desktopPath}/{debPackageName}_{debPackageVersion}_all.deb'")

View File

@ -1384,6 +1384,7 @@ fi
if debArch.currentIndex() != 2:
# Deepin Wine 包目录结构
os.makedirs("{}/opt/apps/{}/entries/applications".format(debPackagePath, e1_text.text()))
os.makedirs("{}/usr/share/applications".format(debPackagePath))
os.makedirs("{}/opt/apps/{}/entries/icons/hicolor/scalable/apps".format(debPackagePath, e1_text.text()))
os.makedirs("{}/opt/apps/{}/files".format(debPackagePath, e1_text.text()))
else:
@ -1519,6 +1520,7 @@ Description: {e3_text.text()}
]
line = "\\"
if desktopIconTab.count() <= 1 and debArch.currentIndex() != 2:
write_txt("{}/usr/share/applications/{}.desktop".format(debPackagePath, e1_text.text()), '#!/usr/bin/env xdg-open\n[Desktop Entry]\nEncoding=UTF-8\nType=Application\nX-Created-By={}\nCategories={};\nIcon={}\nExec="/opt/apps/{}/files/run.sh" --uri {}\nName={}\nComment={}\nMimeType={}\nGenericName={}\nTerminal=false\nStartupNotify=false\n'.format(e4_text.text(), option1_text.currentText(), a, e1_text.text(), e15_text.text(), e8_text.text(), e3_text.text(), e10_text.text(), e1_text.text()))
write_txt("{}/opt/apps/{}/entries/applications/{}.desktop".format(debPackagePath, e1_text.text(), e1_text.text()), '#!/usr/bin/env xdg-open\n[Desktop Entry]\nEncoding=UTF-8\nType=Application\nX-Created-By={}\nCategories={};\nIcon={}\nExec="/opt/apps/{}/files/run.sh" --uri {}\nName={}\nComment={}\nMimeType={}\nGenericName={}\nTerminal=false\nStartupNotify=false\n'.format(e4_text.text(), option1_text.currentText(), a, e1_text.text(), e15_text.text(), e8_text.text(), e3_text.text(), e10_text.text(), e1_text.text()))
elif debArch.currentIndex() == 2:
# 直接跳过 .desktop 文件生成
@ -1529,7 +1531,7 @@ Description: {e3_text.text()}
command = f"--uri {iconUiList[i][2].text()}"
else:
command = iconUiList[i][2].text()
write_txt("{}/opt/apps/{}/entries/applications/{}-{}.desktop".format(debPackagePath, e1_text.text(), e1_text.text(), os.path.splitext(os.path.basename(iconUiList[i][0].text().replace("\\", "/")))[0]), f'''#!/usr/bin/env xdg-open
desktopFile = f'''#!/usr/bin/env xdg-open
[Desktop Entry]
Encoding=UTF-8
Type=Application
@ -1543,7 +1545,9 @@ MimeType={iconUiList[i][5].text()}
GenericName={e1_text.text()}
Terminal=false
StartupNotify=false
''')
'''
write_txt("{}/opt/apps/{}/entries/applications/{}-{}.desktop".format(debPackagePath, e1_text.text(), e1_text.text(), os.path.splitext(os.path.basename(iconUiList[i][0].text().replace("\\", "/")))[0]), desktopFile)
write_txt("{}/usr/share/applications/{}-{}.desktop".format(debPackagePath, e1_text.text(), os.path.splitext(os.path.basename(iconUiList[i][0].text().replace("\\", "/")))[0]), desktopFile)
# 要开始分类讨论了
if debArch.currentIndex() == 0 or debArch.currentIndex() == 1 and debArch.currentIndex() != 2:
if desktopIconTab.count() <= 1:
@ -1601,6 +1605,7 @@ StartupNotify=false
#self.run_command("chmod -Rv 755 {}/opt/apps/{}/files/*_with_box86.sh".format(debPackagePath, e1_text.text()))
#self.run_command("chmod -Rv 755 {}/opt/apps/{}/files/*_with_exagear.sh".format(debPackagePath, e1_text.text()))
self.run_command("chmod -Rv 755 {}/opt/apps/{}/entries/applications/*.desktop".format(debPackagePath, e1_text.text(), e1_text.text()))
self.run_command("chmod -Rv 755 {}/usr/share/applications/*.desktop".format(debPackagePath, e1_text.text()))
################
# 构建 deb 包
################

View File

@ -307,7 +307,9 @@ TranslateTemplateFileUos "$outdir/info"
#if no desktop_file_categories, don't create desktop
if [ -n "$desktop_file_categories" ]; then
mkdir -p "$outentries/applications"
mkdir -p "$dstdir/usr/share/applications"
cp "$curdir/template/target.desktop" "$outentries/applications/$deb_package_name.desktop"
cp "$curdir/template/target.desktop" "$dstdir/usr/share/applications/$deb_package_name.desktop"
TranslateTemplateFileUos "$outentries/applications/$deb_package_name.desktop"
# TODO: We should generate icons from main program automatically.