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
Guru
Guru


Joined: 14 Jul 2012
Posts: 499

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:
http://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.
_________________
Intel Core i3-2120 / 4Gb RAM / 250Gb HDD / NVidia GeForce-550Ti


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
Advocate
Advocate


Joined: 20 Apr 2005
Posts: 3998

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
Guru
Guru


Joined: 14 Jul 2012
Posts: 499

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.
_________________
Intel Core i3-2120 / 4Gb RAM / 250Gb HDD / NVidia GeForce-550Ti
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2391
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
Advocate
Advocate


Joined: 20 Apr 2005
Posts: 3998

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
Guru
Guru


Joined: 14 Jul 2012
Posts: 499

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
_________________
Intel Core i3-2120 / 4Gb RAM / 250Gb HDD / NVidia GeForce-550Ti
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2391
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
Guru
Guru


Joined: 14 Jul 2012
Posts: 499

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.
_________________
Intel Core i3-2120 / 4Gb RAM / 250Gb HDD / NVidia GeForce-550Ti
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