Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Github CI build

on:
push:
tags:
- '*'
pull_request:
branches:
- master
- patchmanager3

env:
RELEASE: 4.0.1.45

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Prepare
run: mkdir output

- name: Build armv7hl
run: docker run --rm --privileged -v $PWD:/share coderus/sailfishos-platform-sdk:$RELEASE /bin/bash -c "
mkdir -p build ;
cd build ;
cp -r /share/* . ;
mb2 -t SailfishOS-$RELEASE-armv7hl build ;
sudo cp -r RPMS/*.rpm /share/output"

- name: Build i486
run: docker run --rm --privileged -v $PWD:/share coderus/sailfishos-platform-sdk:$RELEASE /bin/bash -c "
mkdir -p build ;
cd build ;
cp -r /share/* . ;
mb2 -t SailfishOS-$RELEASE-i486 build ;
sudo cp -r RPMS/*.rpm /share/output"

- name: Upload build result
uses: actions/upload-artifact@v2
with:
name: output-rpms
path: output

- name: Create release
if: contains(github.ref, 'release')
run: |
set -x
assets=()
for asset in output/*.rpm; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release create "${assets[@]}" -m "$tag_name" "$tag_name"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@ build/
src/bin/patchmanager-daemon/adaptor.*

*.rpm
*.so*
Makefile
*.o
moc_*
*.moc
patchmanager_interface.*
patchmanager_adaptor.*
patchmanager-dialog

.build*
38 changes: 14 additions & 24 deletions rpm/patchmanager.spec
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
%define theme sailfish-default

%{!?qtc_qmake:%define qtc_qmake %qmake}
%{!?qtc_qmake5:%define qtc_qmake5 %qmake5}
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}

Name: patchmanager

Expand All @@ -16,12 +14,6 @@ URL: https://github.com/sailfishos-patches/patchmanager
Source0: %{name}-%{version}.tar.bz2
Requires: unzip
Requires: patch
Conflicts: jolla-settings-%{name}
Obsoletes: jolla-settings-%{name}
Conflicts: %{name}-ui
Obsoletes: %{name}-ui
Conflicts: prepatch
Obsoletes: prepatch
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(Qt5Qml)
Expand All @@ -31,7 +23,8 @@ BuildRequires: pkgconfig(sailfishapp) >= 0.0.10
BuildRequires: sailfish-svg2png >= 0.1.5
BuildRequires: pkgconfig(nemonotifications-qt5)
BuildRequires: qt5-qtdeclarative-devel-tools
BuildRequires: pkgconfig(libsystemd-journal)
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(libshadowutils)
BuildRequires: qt5-qttools-linguist
BuildRequires: pkgconfig(rpm)
BuildRequires: pkgconfig(popt)
Expand All @@ -56,11 +49,11 @@ rm -rf %{buildroot}
/usr/lib/qt5/bin/qmlplugindump -v -noinstantiate -nonrelocatable org.SfietKonstantin.patchmanager 2.0 %{buildroot}%{_libdir}/qt5/qml > %{buildroot}%{_libdir}/qt5/qml/org/SfietKonstantin/%{name}/plugin.qmltypes |:
sed -i 's#%{buildroot}##g' %{buildroot}%{_libdir}/qt5/qml/org/SfietKonstantin/%{name}/plugin.qmltypes

mkdir -p %{buildroot}/lib/systemd/system/multi-user.target.wants/
ln -s ../dbus-org.SfietKonstantin.patchmanager.service %{buildroot}/lib/systemd/system/multi-user.target.wants/
mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants/
ln -s ../dbus-org.SfietKonstantin.patchmanager.service %{buildroot}%{_unitdir}/multi-user.target.wants/

mkdir -p %{buildroot}/lib/systemd/system/timers.target.wants/
ln -s ../checkForUpdates-org.SfietKonstantin.patchmanager.timer %{buildroot}/lib/systemd/system/timers.target.wants/
mkdir -p %{buildroot}%{_unitdir}/timers.target.wants/
ln -s ../checkForUpdates-org.SfietKonstantin.patchmanager.timer %{buildroot}%{_unitdir}/timers.target.wants/

mkdir -p %{buildroot}/usr/lib/systemd/user/lipstick.service.wants/
ln -s ../lipstick-patchmanager.service %{buildroot}/usr/lib/systemd/user/lipstick.service.wants/
Expand Down Expand Up @@ -156,17 +149,15 @@ systemctl-user daemon-reload
%{_datadir}/%{name}/tools
%{_datadir}/dbus-1/
%{_sysconfdir}/dbus-1/system.d/
/lib/systemd/system/dbus-org.SfietKonstantin.patchmanager.service
/lib/systemd/system/multi-user.target.wants/dbus-org.SfietKonstantin.patchmanager.service
/lib/systemd/system/checkForUpdates-org.SfietKonstantin.patchmanager.service
/lib/systemd/system/checkForUpdates-org.SfietKonstantin.patchmanager.timer
/lib/systemd/system/timers.target.wants/checkForUpdates-org.SfietKonstantin.patchmanager.timer
%{_unitdir}/dbus-org.SfietKonstantin.patchmanager.service
%{_unitdir}/multi-user.target.wants/dbus-org.SfietKonstantin.patchmanager.service
%{_unitdir}/checkForUpdates-org.SfietKonstantin.patchmanager.service
%{_unitdir}/checkForUpdates-org.SfietKonstantin.patchmanager.timer
%{_unitdir}/timers.target.wants/checkForUpdates-org.SfietKonstantin.patchmanager.timer
%{_sharedstatedir}/environment/patchmanager/10-dbus.conf
#%{_datadir}/patchmanager/patches/sailfishos-patchmanager-unapplyall/patch.json
#%{_datadir}/patchmanager/patches/sailfishos-patchmanager-unapplyall/unified_diff.patch
%{_libdir}/systemd/user/dbus-org.SfietKonstantin.patchmanager.service
%{_libdir}/systemd/user/lipstick-patchmanager.service
%{_libdir}/systemd/user/lipstick.service.wants/lipstick-patchmanager.service
%{_userunitdir}/dbus-org.SfietKonstantin.patchmanager.service
%{_userunitdir}/lipstick-patchmanager.service
%{_userunitdir}/lipstick.service.wants/lipstick-patchmanager.service
%{_libdir}/libpreload%{name}.so

%attr(0755,root,root-) %{_libexecdir}/pm_apply
Expand All @@ -178,7 +169,6 @@ systemctl-user daemon-reload
%{_datadir}/jolla-settings/pages/%{name}
%{_datadir}/jolla-settings/entries/%{name}.json
%{_datadir}/%{name}/icons/icon-m-patchmanager.png
%attr(644,nemo,nemo) %ghost /home/nemo/.config/patchmanager2.conf

%{_datadir}/themes/%{theme}/meegotouch/z1.0/icons/*.png
%{_datadir}/themes/%{theme}/meegotouch/z1.25/icons/*.png
Expand Down
25 changes: 1 addition & 24 deletions src/bin/dialog/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,6 @@
#include <QDBusReply>
#include <QTimer>

QString getLang()
{
QString lang = QStringLiteral("en_US.utf8");

QFile localeConfig(QStringLiteral("/var/lib/environment/nemo/locale.conf"));

if (!localeConfig.exists() || !localeConfig.open(QFile::ReadOnly)) {
return lang;
}

while (!localeConfig.atEnd()) {
QString line = localeConfig.readLine().trimmed();
if (line.startsWith(QStringLiteral("LANG="))) {
lang = line.mid(5);
break;
}
}

qDebug() << Q_FUNC_INFO << lang;

return lang;
}

int main(int argc, char *argv[])
{
qputenv("NO_PM_PRELOAD", "1");
Expand All @@ -47,7 +24,7 @@ int main(int argc, char *argv[])
QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));

QTranslator translator;
bool success = translator.load(QLocale(getLang()),
bool success = translator.load(QLocale(),
QStringLiteral("settings-patchmanager"),
QStringLiteral("-"),
QStringLiteral("/usr/share/translations/"),
Expand Down
5 changes: 2 additions & 3 deletions src/bin/patchmanager-daemon/patchmanager-daemon.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ TARGET = patchmanager
QT = core dbus network
CONFIG += link_pkgconfig
PKGCONFIG += nemonotifications-qt5
PKGCONFIG += libsystemd-journal
PKGCONFIG += libsystemd
PKGCONFIG += rpm
PKGCONFIG += popt

INCLUDEPATH += /usr/include
INCLUDEPATH += /usr/include/rpm

isEmpty(PROJECT_PACKAGE_VERSION) {
Expand Down Expand Up @@ -55,7 +54,7 @@ systemd.files = \
systemd/dbus-org.SfietKonstantin.patchmanager.service \
systemd/checkForUpdates-org.SfietKonstantin.patchmanager.service \
systemd/checkForUpdates-org.SfietKonstantin.patchmanager.timer
systemd.path = /lib/systemd/system/
systemd.path = /usr/lib/systemd/system/
INSTALLS += systemd

env.files = environment/10-dbus.conf
Expand Down
26 changes: 16 additions & 10 deletions src/bin/patchmanager-daemon/patchmanagerobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,23 @@ QString getLang()
{
QString lang = QStringLiteral("en_US.utf8");

QFile localeConfig(QStringLiteral("/var/lib/environment/nemo/locale.conf"));

if (!localeConfig.exists() || !localeConfig.open(QFile::ReadOnly)) {
return lang;
}
QStringList locales = {
QStringLiteral("/etc/locale.conf"),
QStringLiteral("/var/lib/environment/nemo/locale.conf"),
};
for (const QString &localePath : locales) {
QFile localeConfig(localePath);

if (!localeConfig.exists() || !localeConfig.open(QFile::ReadOnly)) {
continue;
}

while (!localeConfig.atEnd()) {
QString line = localeConfig.readLine().trimmed();
if (line.startsWith(QStringLiteral("LANG="))) {
lang = line.mid(5);
break;
while (!localeConfig.atEnd()) {
QString line = localeConfig.readLine().trimmed();
if (line.startsWith(QStringLiteral("LANG="))) {
lang = line.mid(5);
break;
}
}
}

Expand Down
27 changes: 26 additions & 1 deletion src/icons/icons.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
TEMPLATE = aux
# Configures svg to png
THEMENAME=sailfish-default
CONFIG += sailfish-svg2png

load(sailfish-svg2png-sizes)

theme.path = /usr/share/themes/$${THEMENAME}/
themeDirectory.path = /usr/share/themes/$${THEMENAME}/meegotouch
themeDirectory.files += $${OUT_PWD}/icons

for(profile, SAILFISH_SVG2PNG.profiles) {
# a work-around for installing directories that do not exist yet
system(mkdir -p $${OUT_PWD}/z$${profile})

exists( $${OUT_PWD}/symlinks ): svg2png.commands += cp -r symlinks/icons z$${profile} &&

svg2png.commands += /usr/bin/sailfish_svg2png \
-z $$eval(SAILFISH_SVG2PNG.scales.$${profile}) \
$$eval(SAILFISH_SVG2PNG.extra.$${profile}) \
$${_PRO_FILE_PWD_}/svgs \
z$${profile}/icons &&

svg2png.files += $${OUT_PWD}/z$${profile}
}

svg2png.commands += true
svg2png.path = $${themeDirectory.path}

INSTALLS += svg2png theme themeDirectory
3 changes: 3 additions & 0 deletions src/preload/preload.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
TEMPLATE = lib
QT =
CONFIG += plugin
CONFIG += link_pkgconfig
PKGCONFIG += libshadowutils
INCLUDEPATH += /usr/include/libshadowutils
QMAKE_CFLAGS += -std=c11

LIBS = -ldl
Expand Down
16 changes: 4 additions & 12 deletions src/preload/src/preloadpatchmanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static orig_open_f_type orig_open64 = NULL;
#include <limits.h>
#include <libgen.h>

#include <getdef.h>
#include <pwd.h>

#define SERVER_PATH "/tmp/patchmanager-socket"
Expand Down Expand Up @@ -95,26 +96,17 @@ static void pm_name(char new_name[]) {
close(sockfd);
}

static uid_t nemo_uid()
static uid_t user_uid()
{
static struct passwd *nemo_pwd;

if (!nemo_pwd) {
nemo_pwd = getpwnam("nemo");
if (!nemo_pwd) {
return 100000;
}
}

return nemo_pwd->pw_uid;
return getdef_num("UID_MIN", 100000);
}

static int pm_validate_uid(uid_t uid)
{
#ifdef ALLOW_ALL_USERS
return 1;
#else // #ifdef ALLOW_ALL_USERS
return uid == nemo_uid();
return uid >= user_uid();
#endif // #ifdef ALLOW_ALL_USERS
}

Expand Down