From b7daf4e4e3fa19502f4595cce994705afd08cf02 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 19 Jul 2023 12:08:33 +0600 Subject: [PATCH] Minor fixes --- Makefile | 51 ++++++++++---------------------- source/ubl-settings-usergroups.h | 2 +- source/ubl-utils.c | 2 +- source/ubl-utils.h | 1 + 4 files changed, 18 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 07ba802..120e355 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,11 @@ MAKEFILE_PATH := $(dir $(MAKEFILE_FILEPATH)) CMAKE_COMMAND = cmake CMAKE_SOURCE_DIR = $(MAKEFILE_PATH)source CMAKE_BUILD_DIR = $(MAKEFILE_PATH)compile -#CMAKE_SOURCE_DIR = ./source -#CMAKE_BUILD_DIR = ./compile DEPENDS = /bin/cmake -PREFIX ?= /usr +PREFIX ?= /usr/local PKGNAME = $(MAKEFILE_DIR) -#PKGNAME = ubl-settings-manager -LATEST_TAG= +FILE_VER = source/${PKGNAME}.h + default_target: all .PHONY: all init depend debug prepare check build uninstall install clean help @@ -24,11 +22,11 @@ all: init build init: @echo "Initialize ..."; \ if [ -d ".git" ]; then \ - LATEST_TAG=$$(git describe --tags | sed 's/^v//'|grep -oE "^[0-9]{1,}.[0-9]{1,}"); \ + LATEST_TAG=$$(git describe --abbrev=0 --tags | sed 's/^v//'); \ else \ - LATEST_TAG="0.0"; \ + LATEST_TAG="Development"; \ fi; \ - sed -r "s/^(string version_application).*/\1=\"$${LATEST_TAG}\";/" -i source/${PKGNAME}.h; \ + sed -r "s/^(string version_application).*/\1 = \"$${LATEST_TAG}\";/" -i ${FILE_VER}; \ echo "-- Build path: ${CMAKE_BUILD_DIR}" depend: @@ -39,16 +37,14 @@ depend: exit 1; \ fi; \ done; \ + $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B${CMAKE_BUILD_DIR} --check-build-system CMakeFiles/Makefile.cmake 1 || exit 1; \ echo "Check depends: OK" -# $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -debug: init build - @echo "Debug ..."; \ +debug: + @echo "Debug ..." if [ ! -d ${CMAKE_BUILD_DIR} ]; then \ $(CMAKE_COMMAND) -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \ fi; \ - echo "${CMAKE_BUILD_DIR}/${PKGNAME}"; \ - cp ${CMAKE_BUILD_DIR}/${PKGNAME} ./; \ echo "Debug: OK" prepare: @@ -69,7 +65,8 @@ check: build: depend prepare @echo "Build ..."; \ - make --directory=${CMAKE_BUILD_DIR}; \ + $(MAKE_COMMAND) --directory=${CMAKE_BUILD_DIR}; \ + sed -r "s/^(string version_application).*/\1;/" -i ${FILE_VER}; \ echo "Build: OK" uninstall: @@ -92,9 +89,7 @@ uninstall: @$(RM) "${DESTDIR}${PREFIX}/bin/${PKGNAME}" @$(RM) "${DESTDIR}${PREFIX}/share/applications/${PKGNAME}.desktop" @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.svg" - @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.checked.svg" - @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.warning.svg" - @$(RM) "${DESTDIR}${PREFIX}/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy" + @$(RM) "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy" @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ @@ -104,9 +99,6 @@ uninstall: install: check uninstall @echo "Install ..." -#################################################### УДАЛИТЬ ПЕРЕД КОММИТОМ ################################################################################ - @gcc source/ubl-cmake.h compile/resources.c compile/ubl-cmake.h source/ubl-settings-usergroups.c source/ubl-settings-usergroups.h source/ubl-strings.h source/ubl-utils.c source/ubl-utils.h -o ubl-settings-usergroups `pkg-config --cflags --libs gtk+-3.0 vte-2.91 webkit2gtk-4.0 webkit2gtk-web-extension-4.0` -g -#################################################### УДАЛИТЬ ПЕРЕД КОММИТОМ ################################################################################ @for FILE_PO in $(wildcard *.po); do \ LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \ install -dm755 "${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES"; \ @@ -119,23 +111,19 @@ install: check uninstall install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \ rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ done - @install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" - @install -dm755 "${DESTDIR}${PREFIX}/share/polkit-1/actions" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/polkit-1/actions/" "com.ublinux.${PKGNAME}.policy" + @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "com.ublinux.${PKGNAME}.policy" @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" - @install -dm755 "${DESTDIR}/etc/xdg" - @install -dm755 "${DESTDIR}${PREFIX}/share/applications" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" + @sed -e 's+/usr/bin+${PREFIX}/bin+g' -i ${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ [ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \ fi @echo "Install: OK" - @sed -r "s/^(string version_application=\"*\").*/string version_application;/" -i source/${PKGNAME}.h; \ clean: @echo "Clean ..." @@ -146,14 +134,6 @@ clean: echo "Clean: OK"; \ fi -up_ver: - @CURRENT=$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2); \ - MAJOR=$$(cut -d. -f1 <<< $${CURRENT}); \ - MINOR=$$(cut -d. -f2 <<< $${CURRENT}); \ - VER="$${MAJOR}.$$(($${MINOR}+1))"; \ - sed "s/VERSION *[[:digit:]]*.*/VERSION $${VER}/" -i ${FILE_VERSION}; \ - echo "Updated version to VERSION.md: $${CURRENT} to $${VER}" - help: @echo "The following are some of the valid targets for this Makefile:"; \ echo "... all (the default if no target is provided)"; \ @@ -163,5 +143,4 @@ help: echo "... compile"; \ echo "... install"; \ echo "... uninstall"; \ - echo "... clean"; \ - echo "... up_ver" + echo "... clean" \ No newline at end of file diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index c3ce036..c13f3c0 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -30,7 +30,7 @@ #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-usergroups" typedef char* string; -string version_application=""; +string version_application; char *local; diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 1f80016..7358272 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -739,7 +739,7 @@ char *yon_ubl_root_user_get(){ if (user&&strcmp(user,"")!=0){ return user; }else { - FILE *file = popen("getent passwd $PKEXEC_UID | cut -d: -f1","r"); + FILE *file = popen(get_pkexec_user_command,"r"); user=g_malloc0(4096); fgets(user,4096,file); user=yon_char_divide_search(user,"\n",-1); diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 4eb6137..01281cd 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -24,6 +24,7 @@ #define new(type) malloc(sizeof(type)) #define new_arr(type,size) malloc(sizeof(type)*size) +#define get_pkexec_user_command "getent passwd $PKEXEC_UID | cut -d: -f1" typedef enum {