Skip to content

Commit e57423f

Browse files
rpm_works
1 parent 285ff54 commit e57423f

5 files changed

Lines changed: 138 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ if(GPGFRONTEND_BUILD_TYPE_ONLY_APPLICATION)
163163
set(STABLE_BUILD_ONLY_APPLICATION 1)
164164
endif()
165165

166+
# Fallback for BUILD_APPLICATION if not set by any build type
167+
if(NOT DEFINED BUILD_APPLICATION)
168+
if(GPGFRONTEND_GENERATE_LINUX_INSTALL_SOFTWARE OR GPGFRONTEND_BUILD_TYPE_STABLE OR GPGFRONTEND_BUILD_TYPE_ONLY_APPLICATION)
169+
set(BUILD_APPLICATION 1)
170+
message(STATUS "Setting BUILD_APPLICATION=1 as fallback based on build configuration")
171+
endif()
172+
endif()
173+
166174
if(GPGFRONTEND_BUILD_APP_IMAGE)
167175
set(BUILD_APP_IMAGE 1)
168176
endif()
@@ -474,12 +482,90 @@ set(CPACK_PACKAGE_NAME "GpgFrontend")
474482
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
475483
set(CPACK_PACKAGE_RELEASE "1")
476484
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
485+
set(CPACK_PACKAGE_CONTACT "eric@bktus.com")
477486
set(CPACK_RPM_PACKAGE_LICENSE "GPLv3")
478487
set(CPACK_RPM_PACKAGE_GROUP "Applications/System")
479-
set(CPACK_RPM_PACKAGE_REQUIRES "libassuan >= 2.5.0, gpgme >= 1.12.0, qt6-qtbase >= 6.0.0")
488+
set(CPACK_RPM_PACKAGE_REQUIRES "libassuan >= 2.5.0, gpgme >= 1.12.0, qt6-qtbase >= 6.0.0, gtk-update-icon-cache")
480489
set(CPACK_RPM_PACKAGE_URL "https://gpgfrontend.bktus.com")
481490
set(CPACK_RPM_PACKAGE_DESCRIPTION "GpgFrontend is a free, open-source, robust yet user-friendly, compact and cross-platform tool for OpenPGP encryption.")
482491

492+
# Configure RPM scripts
493+
configure_file(
494+
"${CMAKE_SOURCE_DIR}/cmake/rpm/post-install.sh"
495+
"${CMAKE_BINARY_DIR}/rpm-post-install.sh"
496+
@ONLY
497+
)
498+
configure_file(
499+
"${CMAKE_SOURCE_DIR}/cmake/rpm/post-uninstall.sh"
500+
"${CMAKE_BINARY_DIR}/rpm-post-uninstall.sh"
501+
@ONLY
502+
)
503+
504+
# Set RPM scripts
505+
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_BINARY_DIR}/rpm-post-install.sh")
506+
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_BINARY_DIR}/rpm-post-uninstall.sh")
507+
508+
# Make the scripts executable
509+
file(CHMOD ${CMAKE_BINARY_DIR}/rpm-post-install.sh
510+
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
511+
file(CHMOD ${CMAKE_BINARY_DIR}/rpm-post-uninstall.sh
512+
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
513+
514+
# Documentation handling
515+
set(CPACK_RPM_PACKAGE_LICENSE_FILE "${CMAKE_SOURCE_DIR}/COPYING")
516+
set(CPACK_RPM_PACKAGE_DOCUMENTATION "${CMAKE_SOURCE_DIR}/README.md")
517+
518+
# Install license and documentation
519+
install(FILES "${CMAKE_SOURCE_DIR}/COPYING"
520+
DESTINATION "share/licenses/${CPACK_PACKAGE_NAME}"
521+
COMPONENT runtime)
522+
install(FILES "${CMAKE_SOURCE_DIR}/README.md"
523+
DESTINATION "share/doc/${CPACK_PACKAGE_NAME}"
524+
COMPONENT runtime)
525+
526+
# Install icons for all resolutions
527+
foreach(size IN ITEMS 32 48 64 128 256 512)
528+
install(FILES "${CMAKE_SOURCE_DIR}/resource/lfs/hicolor/${size}x${size}/apps/com.bktus.gpgfrontend.png"
529+
DESTINATION "share/icons/hicolor/${size}x${size}/apps"
530+
RENAME "gpgfrontend.png"
531+
COMPONENT runtime)
532+
# Also install with the full name for .desktop file compatibility
533+
install(FILES "${CMAKE_SOURCE_DIR}/resource/lfs/hicolor/${size}x${size}/apps/com.bktus.gpgfrontend.png"
534+
DESTINATION "share/icons/hicolor/${size}x${size}/apps"
535+
COMPONENT runtime)
536+
endforeach()
537+
538+
# Install desktop file
539+
install(FILES "${CMAKE_SOURCE_DIR}/resource/appstream/com.bktus.gpgfrontend.desktop"
540+
DESTINATION "share/applications"
541+
COMPONENT runtime)
542+
543+
# Install metainfo/appdata
544+
install(FILES "${CMAKE_SOURCE_DIR}/resource/appstream/com.bktus.gpgfrontend.metainfo.xml"
545+
DESTINATION "share/metainfo"
546+
COMPONENT runtime)
547+
548+
# Exclude files from auto-detection of dependencies
549+
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
550+
"/usr/share/doc"
551+
"/usr/share/licenses"
552+
"/usr/share/applications"
553+
"/usr/share/metainfo"
554+
"/usr/share/icons"
555+
"/usr/share/icons/hicolor"
556+
"/usr/share/icons/hicolor/128x128"
557+
"/usr/share/icons/hicolor/256x256"
558+
"/usr/share/icons/hicolor/32x32"
559+
"/usr/share/icons/hicolor/48x48"
560+
"/usr/share/icons/hicolor/512x512"
561+
"/usr/share/icons/hicolor/64x64"
562+
"/usr/share/icons/hicolor/128x128/apps"
563+
"/usr/share/icons/hicolor/256x256/apps"
564+
"/usr/share/icons/hicolor/32x32/apps"
565+
"/usr/share/icons/hicolor/48x48/apps"
566+
"/usr/share/icons/hicolor/512x512/apps"
567+
"/usr/share/icons/hicolor/64x64/apps")
568+
483569
# Include CPack to enable packaging support
484570
include(CPack)
485571

cmake/rpm/post-install.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
3+
# Update icon cache
4+
if [ -x /usr/bin/gtk-update-icon-cache ]; then
5+
/usr/bin/gtk-update-icon-cache -f -t /usr/share/icons/hicolor || :
6+
fi
7+
8+
# Update desktop database
9+
if [ -x /usr/bin/update-desktop-database ]; then
10+
/usr/bin/update-desktop-database -q /usr/share/applications || :
11+
fi
12+
13+
# Update mime database
14+
if [ -x /usr/bin/update-mime-database ]; then
15+
/usr/bin/update-mime-database /usr/share/mime || :
16+
fi
17+
18+
# Try XDG icon cache update if available
19+
if [ -x /usr/bin/xdg-icon-resource ]; then
20+
/usr/bin/xdg-icon-resource forceupdate --theme hicolor || :
21+
fi
22+
23+
# Clear icon cache for current user if logged in
24+
if [ ! -z "$SUDO_USER" ]; then
25+
su "$SUDO_USER" -c 'gtk-update-icon-cache -f -t ~/.local/share/icons/hicolor 2>/dev/null || :'
26+
fi

cmake/rpm/post-uninstall.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
# Update icon cache after removal
4+
if [ -x /usr/bin/gtk-update-icon-cache ]; then
5+
/usr/bin/gtk-update-icon-cache -f -t /usr/share/icons/hicolor || :
6+
fi
7+
8+
# Update desktop database after removal
9+
if [ -x /usr/bin/update-desktop-database ]; then
10+
/usr/bin/update-desktop-database -q /usr/share/applications || :
11+
fi
12+
13+
# Update mime database after removal
14+
if [ -x /usr/bin/update-mime-database ]; then
15+
/usr/bin/update-mime-database /usr/share/mime || :
16+
fi
17+
18+
# Try XDG icon cache update if available
19+
if [ -x /usr/bin/xdg-icon-resource ]; then
20+
/usr/bin/xdg-icon-resource forceupdate --theme hicolor || :
21+
fi

src/core/function/gpg/GpgSmartCardManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ auto PercentDataEscape(const QByteArray& data, bool plus_escape = false,
204204
} else if (plus_escape && ch == ' ') {
205205
result += '+';
206206
} else if (plus_escape && (ch < 0x20 || ch == '+')) {
207-
result += QString("%%%1").arg(ch, 2, 16, QLatin1Char('0')).toUpper();
207+
result += QString("%%%1").arg(static_cast<int>(static_cast<unsigned char>(ch)), 2, 16, QLatin1Char('0')).toUpper();
208208
} else {
209209
result += QLatin1Char(ch);
210210
}

src/ui/GpgFrontendApplication.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ namespace GpgFrontend::UI {
3535
GpgFrontendApplication::GpgFrontendApplication(int &argc, char *argv[])
3636
: QApplication(argc, argv) {
3737
#if !(defined(__APPLE__) && defined(__MACH__))
38-
GpgFrontend::UI::GpgFrontendApplication::setWindowIcon(
39-
QIcon(":/icons/gpgfrontend.png"));
38+
// Try system theme icon first, fall back to resource
39+
QIcon appIcon = QIcon::fromTheme("gpgfrontend", QIcon(":/icons/gpgfrontend.png"));
40+
GpgFrontend::UI::GpgFrontendApplication::setWindowIcon(appIcon);
4041
#endif
4142

4243
QString application_display_name = GetProjectName();

0 commit comments

Comments
 (0)