Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Device mounter for *-kit free KDE
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
creaker
l33t
l33t


Joined: 14 Jul 2012
Posts: 651

PostPosted: Wed Oct 16, 2013 11:17 am    Post subject: Device mounter for *-kit free KDE Reply with quote

How to build consolekit-free and policykit-free kde was described here:
https://forums.gentoo.org/viewtopic-t-938680-highlight-.html
pmount-gui tool was suggested as device notifier replacement. Unfortunately this tool refuses to work for me (shows only one device and doesn't responds on mouse click events) and looks ugly under kde because it uses gtk.

I wrote my own device mounter app. Maybe this application will be useful for someone else, so I decided to share it here.

It is a QT app and have a native kde appearance. App enumerates available devices and can mount, unmount them and open their contents in Dolphin.

App shows partition size, label (if label was set), UUID, device type (harddrive or usb-stick)
Default mount point - /mnt/<partition UUID>. If partition mounted under other directory, app can handle it as well (unmounting and opening the content).

Root partition (/) and swap are excluded from devices list.

App requires passwordless sudo privileges because launches "blkid" and "fdisk -l" commands to collect devices properties. It can be set in /etc/sudoers. May be it is possible to restrict it and pass password to blkid with piping by modifying source code.

Screenshot and zip archive are available here:
http://sourceforge.net/projects/devmount/

For instructions on compiling and installing see README file.

update:
Added Samba shares mounting/unmounting functionality.

update:
Added auto-launch functionality. Application window pops up when you connect a new usb device (hard drive or usb stick).
Auto-launch works regardless have you udisks installed or not.
Project was renamed to devmount-suite, because now it consists of two apps:
mounting tool and devices monitoring tool.
Auto-launch will be activated on next system boot after installation automatically.


Last edited by creaker on Wed Oct 23, 2013 11:13 pm; edited 3 times in total
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Wed Oct 16, 2013 6:08 pm    Post subject: Reply with quote

I was just trying to prepare an ebuild for trying (and maybe later releasing), but there are some problems:
  1. What is the license?
  2. Please, release only tarballs (or zips) with version numbers in the name [and do not change them, once released] - otherwise the checksum of ebuilds will break.
  3. Is it intentional that the tarball (zipfile) contains *.o and executable (If yes, you should recommend "make maintainer-clean" first...)?
  4. The install section in the Makefile (even if generated) is empty; not a severe issue, since "dobin" can be used, but maybe you want to fix it.
  5. Main point: I do not understnd how to use it. Is it supposed to be called by some udev rule? Maybe you can give an example for such a rule in the README or provide an udev file?
Back to top
View user's profile Send private message
creaker
l33t
l33t


Joined: 14 Jul 2012
Posts: 651

PostPosted: Wed Oct 16, 2013 7:33 pm    Post subject: Reply with quote

1. I am not experienced in all these licences. You can use these sources on your own.
2. I do not expecting that someone will create ebuild for this tool, OK, I'll append version number to archive's name.
3. 8O What "make maintainer-clean" is ? I just uploaded my app with sources for sharing. :roll: I have no any idea why this archive can't contain ready-to-use binary? If you care about what app does, you can check sources and rebuild it.
4. Do you mean that the install section should contain some info about where executable should be placed? If yes, you can put it anywhere. It's a standalone application and uses only system-wide known tools: sudo, blkid, fdisk, df, udevadm. All of them can be invoked from any location. The only limitation: "images" folder should be placed in the same place as the executable. Otherwise you will get buttons without icons.
5. How to use: you can add this app to main panel, as well as any other launcher (look at screenshot, it sits at the left side of panel, immediately after firefox icon). Unlock widgets and drug executable (devmount) to panel. Once it will be added, just click icon and you will get app window opened. No need to close it, window will be closed automatically on focus lost event. If you want just to try, app can be launched by mouse click on executable (devmount).
Right now app does not reacts to devices plugging events. I thought about udev integration, but can't get it lanched by adding rule. It is a thing to be done.



P.S.
I forgot to assign an icon to executable. Will be added.
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Wed Oct 16, 2013 9:11 pm    Post subject: Reply with quote

This is excellent creaker: it's good to see you diving in and coding up what you need.
creaker wrote:
1. I am not experienced in all these licences. You can use these sources on your own.

No, you have to pick a license from /usr/portage/licenses. If you're not sure, use GPL3+, or alternatively LGPL3+, MIT or BSD-2. In any event, include it (with your name and year etc) as COPYING.
Quote:
3. What "make maintainer-clean" is ? I just uploaded my app with sources for sharing. :roll: I have no any idea why this archive can't contain ready-to-use binary? If you care about what app does, you can check sources and rebuild it.

That's no good sorry: source archives should just be sources, that the distribution can build.
make clean typically removes object files and other "intermediates"; make maintainer-clean would depend on clean, and further remove programs and libs that the user would install. Both would be .PHONY targets as below.
Quote:
4. Do you mean that the install section should contain some info about where executable should be placed? If yes, you can put it anywhere. It's a standalone application and uses only system-wide known tools: sudo, blkid, fdisk, df, udevadm. All of them can be invoked from any location. The only limitation: "images" folder should be placed in the same place as the executable. Otherwise you will get buttons without icons.

That's fine, but include at minimum this (assuming just one prog):
Code:
INSTALL = install
DESTDIR =
BINDIR = /bin

.PHONY: install
install:
   $(INSTALL) someprog $(DESTDIR)$(BINDIR)

If you have something more complex, tell us. The distro/user can then override with make DESTDIR=/path/to/ROOT install
Quote:
5. How to use: you can add this app to main panel, as well as any other launcher (look at screenshot, it sits at the left side of panel, immediately after firefox icon). Unlock widgets and drug executable (devmount) to panel. Once it will be added, just click icon and you will get app window opened. No need to close it, window will be closed automatically on focus lost event. If you want just to try, app can be launched by mouse click on executable (devmount).

Is there a README that explains all this?
Quote:
Right now app does not reacts to devices plugging events. I thought about udev integration, but can't get it lanched by adding rule. It is a thing to be done.

Hmm how does pmount-gui do it? I'm guessing you'll need a dependency on uam.

Anyhow, it's a great start: well done! :-)
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Thu Oct 17, 2013 8:17 am    Post subject: Reply with quote

creaker wrote:
1. I am not experienced in all these licences. You can use these sources on your own.

For an ebuild, one has to choose a license. What you say is perhaps LICENSE=public-domain, but I guess this would mean that it is even ok if e.g. somebody would erase your name. Perhaps you want some BSD-type license instead which excludes this (This is why I use the BSD license if possible). However, maybe using qmake disallows you to make your project public domain or BSD...
Quote:
What "make maintainer-clean" is?

Sorry, I meant "make distclean". Every autogenerated makefile support it: It removes all files which are usually not in the distributed source tarball (binary, *.o, in your case even Makefile).
Quote:
I have no any idea why this archive can't contain ready-to-use binary?

I can, of course, but it is unusual for a tarball (for gentoo users, it means downloading and storing data which will be removed anyway). If one follows your instructions for rebuilding, nothing will be reubuild. Note that rebuilding is almost certainly necessary if somebody does not use exactly your version of qt.
Quote:
Do you mean that the install section should contain some info about where executable should be placed? [...] "images" folder folder should be placed in the same place as the executable[...]

I am not familiar with qmake, but probably you can specify there where the binary and "images" folder should go. There is no compatible way from a running program to find the path by which it is invoked, so usually it is preferrable to hardcode the path. Moreover, having subdirectories of /usr/bin with data does not correspond to FHS; usually they should be place into /usr/share/...
Certainly, qmake has a way how the image path can be used inside the C code and how this can be changed easily by an option if necessary.
Just in case you are interested: Here is the preliminary ebuild (which currently does not install the images directory...)
Code:
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="5"
RESTRICT=mirror

inherit eutils readme.gentoo qt4-r2

DESCRIPTION="devicemounter without udisks and polkit"
HOMEPAGE="http://sourceforge.net/projects/devmount/"
SRC_URI="mirror://sourceforge/${PN}/${PN}.zip"

LICENSE="public-domain"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

BOTHDEPEND="dev-qt/qt-core"
DEPEND="${BOTHDEPEND}
app-arch/unzip"
RDEPEND="${BOTHDEPEND}
app-admin/sudo
sys-apps/util-linux
virtual/udev"
S="${WORKDIR}/${PN}"

DOC_CONTENTS="To use devmount, add it to the main panel of KDE.
You will need appropriate permissions in sudo, see README"

src_prepare() {
   ! test -r Makefile || make distclean
   epatch_user
   qt4-r2_src_prepare
}

src_install() {
   readme.gentoo_create_doc
   dobin "${PN}"
   insinto /usr/bin
   doins -r "images"
   dodoc README
}

once the version is in the archive, the second ${PN} in SRC_URI should be changed to ${P} (and perhaps the S=... can be removed). I am not sure wheter the dependencies are complete; at least, some dev-qt/qt-...[useflags(+)] are probably stiill missing. If there is a proper "install" section in your Makefile then most parts of the install section can be replaced by "readme.gentoo_src_install".
A more professional ebuild would perhaps add already an appropriate file to /etc/sudoers.d (or you might already want to provide some such file in the tarball).
Back to top
View user's profile Send private message
creaker
l33t
l33t


Joined: 14 Jul 2012
Posts: 651

PostPosted: Thu Oct 17, 2013 10:43 pm    Post subject: Reply with quote

Guys, you pull me into the swamp :roll:
I did not plan to create installer, write ebuilds and so on. It was just a simplest qt project...
OK, I did the following:

1. Install section was added
2. README was rewritten to be more detailed.
3. Added application icon.
4. Created devmount.desktop file for using it as launcher.
5. Added ability to manage samba shares.

Further improvements and fixes are possible, if people are interested
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Fri Oct 18, 2013 1:36 pm    Post subject: Reply with quote

creaker wrote:
Guys, you pull me into the swamp :roll:
I did not plan to create installer, write ebuilds and so on. It was just a simplest qt project...

What did you expect? Ebuilds are how we distribute build recipes for Gentoo.

And yes, we expect you to provide sources and only sources that can be used by an ebuild well: after all you're coming from Gentoo.

Further, we expect them to be in such shape that they can be used by any other distro as well: a makefile with the standard setup, or qmake or w/e. Again, you're coming from Gentoo, so we require you to represent us well: to the best of your ability.
Quote:
Further improvements and fixes are possible, if people are interested

OFC we are: why else do you think we're spending time on it? ;-)
Back to top
View user's profile Send private message
creaker
l33t
l33t


Joined: 14 Jul 2012
Posts: 651

PostPosted: Wed Oct 23, 2013 11:32 pm    Post subject: Reply with quote

mv wrote:
Is it supposed to be called by some udev rule?


Now devmounter will be called automatically on new device plug-in event. It doesn't use udev rule. It was implemented by watching on "/dev/disk/by-id" directory changes. I did it this way because I have no udisks installed and can't use udev rules. For this goal I have added second tool - devwatcher, so now I renamed a project to devmount-suite (devices mounter and devices watcher). No need to build them separately. To build and install both tools at once unpack archive, navigate to top level directory (devmount-suite) and run following commands:
Code:
qmake
make
sudo make install
make clean (or make distclean) # for cleanup

Auto-launch will be enabled on next boot. To start it immediately (without reboot):
Code:
$ cd /opt/devmount/
$ ./devwatcher


P.S.
First post was updated.
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 3509

PostPosted: Sun Jan 11, 2015 5:13 pm    Post subject: Reply with quote

With this thread languishing for over a year later, SteveL pointed me here from the pmount thread.

This looks like just what I want/need.

As this thread died down back in the fall of 2013 it looked like people were putting together an ebuild, but I never saw a link to one, or to an overlay. Is there an ebuild, or has that effort died out? I can always start from source, I generally prefer ebuilds. I guess I should be ready to offer help too, if it's needed. I've never actually written an ebuild, though I have made minor tweaks.
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
l33tmmx
Tux's lil' helper
Tux's lil' helper


Joined: 12 Mar 2005
Posts: 111
Location: Pirkkala, Finland

PostPosted: Mon Jan 26, 2015 4:53 pm    Post subject: Reply with quote

I'm also one of those people who are completely fed up with the whole Consolekit-Policykit-Udisks2 crap (not to even mention systemd and pulseaudio). Consequently, I recently recompiled my system with
Code:
USE="-consolekit -policykit -udisks"
the only minus-side being the lost usb/hard drive detection functionality in Dolphin. And while searching for alternatives I stumbled on this thread. One word: EXCELLENT!

I don't like installing source-based software outside portage, so I started hacking an ebuild for the devmount-suite version 0.3.1. Here you are, a sys-apps/devmount-suite-0.3.1.ebuild:

Code:
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="5"
inherit eutils qt4-r2

DESCRIPTION="Device mounter GUI for hard drives, usb sticks and samba shares - *without* udisks/polkit."
HOMEPAGE="http://sourceforge.net/projects/devmount/"
SRC_URI="mirror://sourceforge/devmount/${P}.zip"
RESTRICT="mirror"

LICENSE="GPL-2"
KEYWORDS="~amd64 ~x86"
SLOT="0"
IUSE=""

DEPEND="dev-qt/qtgui:4
   app-arch/unzip"

RDEPEND="${DEPEND}
   app-admin/sudo
   sys-apps/util-linux
   virtual/udev"

S="${WORKDIR}/${PN}"
DOCS="README"

src_prepare() {
   ebegin "Correcting install paths & stuff..."
   mv devmount/devmount.conf devmount/devmount.conf.sample
   sed -i "s@settings.path = \$\$(HOME)/.devmount/@settings.path = /etc/devmount/@" devmount/devmount.pro
   sed -i "s@settings.files += devmount.conf@settings.files += devmount.conf.sample@" devmount/devmount.pro
   sed -i "s@desktop.path = \$\$(HOME)/.kde4/share/autostart@desktop.path = /usr/share/applications/@" devwatcher/devwatcher.pro
   eend
}

src_install() {
   qt4-r2_src_install
   make_wrapper devmount /opt/devmount/devmount
   make_wrapper devwatcher /opt/devmount/devwatcher
}

pkg_postinst() {
   ewarn "This program requires passwordless sudo privileges for running"
   ewarn "\"blkid\", \"fdisk -l\", \"mount\" and \"umount\" commands."
   ewarn "Please set these privileges in /etc/sudoers."
   elog
   elog "Copy the /etc/devmount/devmount.conf.sample file to ~/.devmount/devmount.conf"
   elog "and edit it to suit your needs. Please consult README for further"
   elog "instructions of use."
}


I had to patch the install script, because ebuilds aren't supposed to even try to install anything to user's home directory, EVER :?

There's just one hitch: I don't know whether it is due to some misconfiguration at the Sourceforge end, some error of the devmount-suite developer, or a bug in my ebuild (not likely 8) ), but the SRC_URI above fetches a corrupted version of the zip file, which is only about half the size it should be. Also, wget gets the corrupted version. But, if you download the source zip file manually from http://sourceforge.net/projects/devmount/, you get the correct version. So I suggest that you manually download it and place it in /distfiles before emerging the package, until I'm able to figure out what's wrong there.
_________________
"Trust me, I know what I'm doing!"
- Sledge Hammer
Back to top
View user's profile Send private message
l33tmmx
Tux's lil' helper
Tux's lil' helper


Joined: 12 Mar 2005
Posts: 111
Location: Pirkkala, Finland

PostPosted: Wed Jan 28, 2015 12:58 pm    Post subject: Reply with quote

Oh crap, devmount is segfaulting 8O ... devwatcher works as expected, but devmount keeps segfaulting... More to follow, when I have time to debug.
_________________
"Trust me, I know what I'm doing!"
- Sledge Hammer
Back to top
View user's profile Send private message
l33tmmx
Tux's lil' helper
Tux's lil' helper


Joined: 12 Mar 2005
Posts: 111
Location: Pirkkala, Finland

PostPosted: Sun Feb 01, 2015 1:11 pm    Post subject: Reply with quote

Ok, finally got time to do a proper debugging session. I rebuilt the devmount-suite with all the possible debug options (as per Bugzilla HOWTO). Here's the (shortened) output of gdb:
Code:
madmax@wintermute ~ $ gdb /opt/devmount/devmount
GNU gdb (Gentoo 7.8.1 vanilla) 7.8.1
- - -
Reading symbols from /opt/devmount/devmount...done.
(gdb) run
Starting program: /opt/devmount/devmount
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffe83c5700 (LWP 6324)]
Salasana:
Program received signal SIGSEGV, Segmentation fault.
QString (other=..., this=0x7fffffffd780)
    at /usr/include/qt4/QtCore/qstring.h:726
726     { Q_ASSERT(&other != this); d->ref.ref(); }
(gdb) bt
#0  QString (other=..., this=0x7fffffffd780)
    at /usr/include/qt4/QtCore/qstring.h:726
#1  Mounter::refreshList (this=this@entry=0x7fffffffda80)
    at src/devmount.cpp:246
#2  0x000000000040ae75 in Mounter::Mounter (this=0x7fffffffda80,
    parent=<optimized out>) at src/devmount.cpp:46
#3  0x0000000000404524 in main (argc=1, argv=<optimized out>) at src/main.cpp:29
(gdb) quit
A debugging session is active.

        Inferior 1 [process 6323] will be killed.

Quit anyway? (y or n) y


In the kernel log I have the following, either
Code:
[  604.928212] traps: devmount[4180] general protection ip:407f39 sp:7fff0ffc5540 error:0 in devmount[400000+f000]

or
Code:
[ 1627.460632] devmount[5289]: segfault at 0 ip 0000000000407f39 sp 00007fff635f8240 error 6 in devmount[400000+f000]

It seems to be somewhat random which one I get.

I could post the output of strace, too, if you want, but it is quite a big file.

I played around with the /etc/sudoers file, too. If I disable the passwordless sudo settings, the devmount GUI starts, but of course does not do anything. If I give either fdisk or blkid permissions, devmount segfaults... Current /etc/sudoers is as follows (only the devmount-relevant section):
Code:
## devmount
madmax ALL=(root) NOPASSWD: /sbin/fdisk
madmax ALL=(root) NOPASSWD: /sbin/blkid
madmax ALL=(root) NOPASSWD: /bin/mount
madmax ALL=(root) NOPASSWD: /bin/umount

But, as you can notice from the gdb output above, it still asks for password ("Salasana"="Password") at some point, just before the segfault :?. Is there still something more in the code which needs sudo permissions?
Also, Ive been examining the sources; but my knowledge of C and C++ is very minimal, I don't really understand what the code does, not to mention fix it...

Just a thought, how does devmount handle RAID arrays? My sdb and sdc disks forms a RAID 1-array (i.e. md0, md1 etc.)
_________________
"Trust me, I know what I'm doing!"
- Sledge Hammer
Back to top
View user's profile Send private message
l33tmmx
Tux's lil' helper
Tux's lil' helper


Joined: 12 Mar 2005
Posts: 111
Location: Pirkkala, Finland

PostPosted: Sun Feb 01, 2015 1:13 pm    Post subject: Reply with quote

creaker, are you still following your own thread :) ?
_________________
"Trust me, I know what I'm doing!"
- Sledge Hammer
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Sun Feb 01, 2015 3:03 pm    Post subject: Reply with quote

Hmm creaker seems to have dropped out; no posts since last October.

Don't suppose anyone does C++?
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Fri May 01, 2015 12:19 pm    Post subject: Reply with quote

Hmm src/devmount.cpp:246 triggering an assert, looks like it's trying to make a string from itself.

Though I don't like that the Mounter has the same address as the string passed to QString.

When I get updated (yes i know..) I'll try installing it, and take a closer look.

Feel free to show us the code, or paste a link to it, if you have it on your machine.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum