raelgc / ubuntu_xboxdrv

Ubuntu xboxdrv Integration
https://launchpad.net/~rael-gc/+archive/ubuntu-xboxdrv
GNU General Public License v3.0
165 stars 16 forks source link

Latest package is broken for Ubuntu 15.04 #39

Closed melo0187 closed 9 years ago

melo0187 commented 9 years ago

Hey there!

I was not sure whether this is related to the issues about Systemd or not, so I am submitting a new issue. Feel free to mark it as duplicate...

Since updating to Ubuntu 15.04 I am not able to install ubuntu-xboxdrv anymore. I get this error:

Failed to start xboxdrv.service: Unit xboxdrv.service failed to load: No such file or directory.
dpkg: error processing package ubuntu-xboxdrv (--configure):
 subprocess installed post-installation script returned error exit status 6
Setting up evtest (1:1.32-1) ...
Setting up joystick (1:1.4.7-2) ...
Processing triggers for libc-bin (2.21-0ubuntu4) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for dbus (1.8.12-1ubuntu5) ...
Errors were encountered while processing:
 ubuntu-xboxdrv
E: Sub-process /usr/bin/dpkg returned an error code (1)

Please let me know if I can provide anything else to help solve this. I am a big fan of ubuntu-xboxdrv and it has become essential for my gaming self =)

Thanks in advance for any feedback.

melo0187 commented 9 years ago

I just found a post on the Ubuntu forums with someone pointing out how he managed to get it to run: http://ubuntuforums.org/showthread.php?t=2275219&p=13284158#post13284158

He got got it working by creating a new file /etc/systemd/system/xboxdrv.service:

[Unit]
Description=Load the XBoxDrv controller driver
Documentation=man:xboxdrv(1)

[Service]
Type=forking
EnvironmentFile=-/etc/default/xboxdrv
ExecStartPre=/bin/rm -f /dev/input/js*
ExecStart=/usr/bin/xboxdrv --daemon --detach --pid-file /var/run/xboxdrv.pid --silent --dbus disabled $XBOXDRV_OPTIONS $PAD_OPTIONS $CONTROLLER0_OPTIONS

[Install]
WantedBy=multi-user.target

He claims that with that file in place he can start the service by using

sudo systemctl start xboxdrv.service
raelgc commented 9 years ago

Well, what we need is basically port the /etc/init/xboxdrv.conf file to systemd.

The above file appears to works (I didn't test it), but only for one joystick.

melo0187 commented 9 years ago

Let me know how I can help. I have a system running Ubuntu 15.04 and a wireless receiver with one XBox 360 Wireless Controller and I should be able to borrow a second wireless and another cable version of the XBox controller and I am willing to help and test things.

melo0187 commented 9 years ago

@raelgc Just out of ignorance, one question: Could the following idea work?

Simply remove the line where you call the xboxdrv command from xboxdrv.conf and reformat the rest of the file to be an executable script with the purpose to build the $XBOXDRV_OPTIONS, $PAD_OPTIONS, $CONTROLLER[0-3]_OPTIONS arguments. The pre-start part of the old script would also be removed and supplied as ExecStartPre, while the rest of the remaining script that builds the arguments could be called as EnvironmentFile and the line where you call the xboxdrv command in the current version of xboxdrv.conf would be used as ExecStart in the new xboxdrv.service (with the syntax change ${var} instead of $var), which for the rest would look quite similar to the version I found in the ubuntuforums. Could this work? Hope I explained it in a comprehensible way.

Can I try it myself somehow to test it?

melo0187 commented 9 years ago

Ok, I just went ahead and tried it and I managed to got my wirless controller working.

Here is what I did. Created /etc/systemd/system/xboxdrv.service:

[Unit]
Description=Load the Ubuntu XBoxDrv
Documentation=man:xboxdrv(1)

[Service]
Type=forking
EnvironmentFile=/usr/lib/ubuntu-xboxdrv/argbuilder.sh
ExecStartPre=/bin/rm -f /dev/input/js*
ExecStart=/usr/bin/xboxdrv --daemon --detach --pid-file /var/run/xboxdrv.pid --silent ${XBOXDRV_OPTIONS} ${PAD_OPTIONS} ${CONTROLLER0_OPTIONS} --next-controller ${PAD_OPTIONS} ${CONTROLLER1_OPTIONS} --next-controller ${PAD_OPTIONS} ${CONTROLLER2_OPTIONS}--next-controller ${PAD_OPTIONS} ${CONTROLLER3_OPTIONS}

[Install]
WantedBy=multi-user.target

Created /usr/lib/ubuntu-xboxdrv/argbuilder.sh and made it executable:

!#/bin/sh

# Edit /etc/default/xboxdrv to change these options
FORCE_FEEDBACK=false
MIMIC_XPAD=true
TRIGGER_AS_BUTTON=true
XBOXDRV_OPTIONS=""
CONTROLLER0_OPTIONS=""
CONTROLLER1_OPTIONS=""
CONTROLLER2_OPTIONS=""
CONTROLLER3_OPTIONS=""
# Read configuration variable file if it is present
if [ -f /etc/default/xboxdrv ] ; then
. /etc/default/xboxdrv
fi
# This will store all pad options from /etc/default/xboxdrv
PAD_OPTIONS=""
# Checking if user has enabled forcefeedback
if [ "$FORCE_FEEDBACK" = true ] ; then
PAD_OPTIONS="$PAD_OPTIONS --force-feedback"
fi
# Checking if user has enabled mimic_xpad
if [ "$MIMIC_XPAD" = true ] ; then
PAD_OPTIONS="$PAD_OPTIONS --mimic-xpad --mimic-xpad-wireless"
fi
# Checking if user is using trigger as buttons instead of zaxis
if [ "$TRIGGER_AS_BUTTON" = true ] ; then
PAD_OPTIONS="$PAD_OPTIONS --trigger-as-button"
fi
# Adding --detache-kernel-driver
PAD_OPTIONS="$PAD_OPTIONS --detach-kernel-driver"

I then went ahead and installed from your ppa with sudo apt-get install ubuntu-xboxdrv Only thing not working is run on startup. I don't know how to configure the service to autostart. Also I am not sure whether ${PAD_OPTIONS} or $PAD_OPTIONS is the correct syntax. I activated force-feedback in /etc/default/xboxdrv, but could not manage to get force-feedback in several games I tried but I can't be sure that it is my service file's fault and not the games themselves. I also can't tell if this is working for more than one controller, since I have only one atm.

mainmachine commented 9 years ago

@melo0187 - according systemd folks, it's not a good idea to take existing bash scripts (which works in upstart) and run them as is with systemd. The way quotes are handled is different with systemd, and there are probably other differences which can break things or make them buggy.

mainmachine commented 9 years ago

I have a working port to systemd, but I could use some more testing. I've forked the project just to make it easier to submit pull requests: https://github.com/mainmachine/ubuntu_xboxdrv

I hope it's not bad form to link like that - I'm new to github, so please forgive me! :D

raelgc commented 9 years ago

@mainmachine This is exactly how you should do: create a fork then submit a Pull Request :)

mainmachine commented 9 years ago

Awesome. :)

melo0187 commented 9 years ago

@mainmachine That is very good to know, thank you for your feedback! I will have a look at your fork both to learn a little more about systemd and to test your approach. Do I just get your xboxdrv.service, xboxdrv-pre and uxvars on my system before I install from the PPA or is their another way to test?

You also mentioned that

it's not a good idea to take existing bash scripts (which works in upstart) and run them as is with systemd.

Where exactly does your implementation differ from what I have done? Your xboxdrv-pre script looks pretty much like my argbuilder.sh with only the use of uxvars added. Can you explain what was wrong with my approach and what yours makes different?

Thank you in advance!

mainmachine commented 9 years ago

@melo0187 Yes, we took basically the same approach, the key difference I learned regarding Upstart > systemd migration is that systemd is a little more rigid in terms of structure. With Upstart your startup script can just have shell script, whereas with systemd the *.service file is very limited syntax. You can call scripts to prepare for the service itself to launch, gather variables, build arguments, etc. , but you're not running a shell script, so you can't pass on variables as you would if the ExecStart line was a child of your initialization script. In other words, the vars can't be inherited.

The systemd approach is to stick those vars in a file, so instead of building your arguments, then running the service directly, your ExecStartPre scripts build the file that contains the variables.

Other than that, yes we basically did the same thing. :)

We should add your "Documentation=man:xboxdrv(1)" line to the *.service file - it's a nice touch.

melo0187 commented 9 years ago

@mainmachine ah, now I get. That is good to know and makes sense to me. Thanks for clarifying =)

mainmachine commented 9 years ago

@melo0187 I don't know if you've seen these, but this is where I learned enough to get this working, and both are helpful:

https://wiki.ubuntu.com/SystemdForUpstartUsers#Example_Services

http://patrakov.blogspot.com/2011/01/writing-systemd-service-files.html

melo0187 commented 9 years ago

@mainmachine Thanks for providing the resources =) The second link is new to me.

Based on the first resource on the Ubuntu wiki I was wondering if the correct syntax to access variables from your environment file in the ExecStart line was ${varname} instead of $varname. You used the latter in your .service file.

raelgc commented 9 years ago

Package for vivid uploaded to the PPA. SystemD version is now the current branch. The previous (upstart) was archived in a released version.

Please, update and upgrade. Let us know the issues.

mhalano commented 9 years ago

I Have the same bug. Please see the log: marcos@GLaDOS ~/Downloads % LANGUAGE=en_US sudo dpkg -i ubuntu-xboxdrv_20150520-1_all.deb (Reading database ... 217975 files and directories currently installed.) Preparing to unpack ubuntu-xboxdrv_20150520-1_all.deb ... stop: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused Unpacking ubuntu-xboxdrv (20150520-1) over (20150520-1) ... /usr/bin/update-desktop-database Setting up ubuntu-xboxdrv (20150520-1) ... /usr/bin/update-desktop-database Failed to start xboxdrv.service: Unit xboxdrv.service failed to load: No such file or directory. dpkg: error processing package ubuntu-xboxdrv (--install): subprocess installed post-installation script returned error exit status 6 Processing triggers for dbus (1.8.12-1ubuntu5) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for gnome-menus (3.10.1-0ubuntu5) ... Processing triggers for desktop-file-utils (0.22-1ubuntu3) ... Processing triggers for bamfdaemon (0.5.1+15.04.20150202-0ubuntu1) ... Rebuilding /usr/share/applications/bamf-2.index... Processing triggers for mime-support (3.58ubuntu1) ... Errors were encountered while processing: ubuntu-xboxdrv

mainmachine commented 9 years ago

@melo0187 Just a guess, but that example uses a variable defined in an "Environment=" call, rather than an "EnvironmentFile=" call, so maybe that makes the difference? Either way it is working as is, so I can't speak to why the Ubuntu wiki page uses that syntax. The second link I posted shows an example near the end of the post that uses no brackets, and is sourcing vars from an EnvironmentFile call - this was the model I used to make the port.

mainmachine commented 9 years ago

@raelgc I've purged ubuntu-xboxdrv, removed your ppa then re-added it, then apt-get update && apt-get install ubuntu-xboxdrv and I am seeing the same thing.

The new systemd components aren't getting installed...?

raelgc commented 9 years ago

The package for Vivid was published 1 hour ago, as you can see in the Launchpad: https://launchpad.net/~rael-gc/+archive/ubuntu/ubuntu-xboxdrv

On Wed, May 20, 2015 at 11:01 AM, David Martinka notifications@github.com wrote:

@raelgc https://github.com/raelgc I've purged ubuntu-xboxdrv, removed your ppa then re-added it, then apt-get update && apt-get install ubuntu-xboxdrv and I am seeing the same thing.

The new systemd components aren't getting installed...?

— Reply to this email directly or view it on GitHub https://github.com/raelgc/ubuntu_xboxdrv/issues/39#issuecomment-103897601 .

mhalano commented 9 years ago

@raelgc I downloaded and inspect the package and can't find Systemd related files. :/

raelgc commented 9 years ago

@mhalano Thank you for inspect the package and report. I checked now and the PR missed to correct the file list in /debian/install. I'll fix it and publish again.

mainmachine commented 9 years ago

@raelgc Thanks for moving this forward quickly! I know we all have work to do besides this. :)

mhalano commented 9 years ago

@raelgc Did you see? The latest package can't finish compilation with the error:

cp: cannot stat 'debian/tmp/src/lib/systemd/system/xboxdrv.service': No such file or directory dh_install: cp -a debian/tmp/src/lib/systemd/system/xboxdrv.service debian/ubuntu-xboxdrv/src/lib/systemd/system/ returned exit code 1 debian/rules:7: recipe for target 'binary' failed

2015-05-20 11:47 GMT-03:00 David Martinka notifications@github.com:

@raelgc https://github.com/raelgc Thanks for moving this forward quickly! I know we all have work to do besides this. :)

— Reply to this email directly or view it on GitHub https://github.com/raelgc/ubuntu_xboxdrv/issues/39#issuecomment-103912577 .

Marcos Alano

P: Por que este email é tão curto?

R: http://five.sentenc.es

raelgc commented 9 years ago

@mhalano Yeap, already locally fixed. Tomorrow I'll try again with the fixes. Anyway, thanks for sharing this. Any useful info is always appreciated! :)

raelgc commented 9 years ago

Just uploaded. Let me know if it works.

mhalano commented 9 years ago

@raelgc I found a bug but a found the workaround too. Service can't start, but if you grant execute permission for the file /usr/share/ubuntu-xboxdrv/xboxdrv-pre the Systemd integration works as well.

2015-05-21 8:32 GMT-03:00 Rael Gugelmin Cunha notifications@github.com:

Just uploaded. Let me know if it works.

— Reply to this email directly or view it on GitHub https://github.com/raelgc/ubuntu_xboxdrv/issues/39#issuecomment-104235823 .

Marcos Alano

P: Por que este email é tão curto?

R: http://five.sentenc.es

mainmachine commented 9 years ago

@mhalano Yes, that seems to be the only bug ATM.

@raelgc Is there anything I can do to help, or is this just an issue of packaging?

raelgc commented 9 years ago

I've added the x permission to the file and uploaded again. Please, re-test :)

mhalano commented 9 years ago

@raelgc Still didn't work. :(

2015-05-21 11:34 GMT-03:00 Rael Gugelmin Cunha notifications@github.com:

I've added the x permission to the file and uploaded again. Please, re-test :)

— Reply to this email directly or view it on GitHub https://github.com/raelgc/ubuntu_xboxdrv/issues/39#issuecomment-104299453 .

Marcos Alano

P: Por que este email é tão curto?

R: http://five.sentenc.es

mainmachine commented 9 years ago

confirmed. Is there a way to script a chmod +x during package install?

mhalano commented 9 years ago

I think you need to change the .orig.tar.gz file.

2015-05-21 12:14 GMT-03:00 David Martinka notifications@github.com:

confirmed. Is there a way to script a chmod +x during package install?

— Reply to this email directly or view it on GitHub https://github.com/raelgc/ubuntu_xboxdrv/issues/39#issuecomment-104314724 .

Marcos Alano

P: Por que este email é tão curto?

R: http://five.sentenc.es

melo0187 commented 9 years ago

I just installed from the ppa which states the latest build is 19 hours ago. It was still required to chmod +x the xboxdrv-pre.

There is also another bug in the xboxdrv.service file. There is a missing space before the last --next-controller argument, which causes only 3 instead of 4 js devices to be created.

melo0187 commented 9 years ago

One last thing. For the driver to be started on boot I need to do the following: sudo systemctl enable xboxdrv.service

raelgc commented 9 years ago

New package with fixes uploaded.

mainmachine commented 9 years ago

@melo0187 Good bug hunting! Updated my fork to reflect the controller space typo.

@raelgc Would it have helped if I included a script to make these changes during install of the package, or is that handled during packaging in some different way?

mhalano commented 9 years ago

@mainmachine I think we need to change the source tar.gz in the most of the cases and avoid scripts related changes. Normally if you don't have access to change the source so easily, we need to create post-install scripts, etc. but in this particular project we can change the source.

raelgc commented 9 years ago

@mainmachine Like said by @mhalano, usually a .deb package respect the file attributes.

But, in the case you need to change anything, you can use the postinst script in the debian folder.

For now, I changed the file attribute in the package, so it should be working.

mainmachine commented 9 years ago

Confirmed - all is working correctly after an aptitude purge and install. :D

raelgc commented 9 years ago

Thanks to all of you guys, specially @mainmachine for the PR, @melo0187 to draft the code in comments and @mhalano to debug and point the issues in the package.

melo0187 commented 9 years ago

@raelgc @mainmachine @mhalano It really changes my perspective on the world every time I get in touch with people on GitHub. Everyone is so friendly and willing to help. It was my pleasure to help out to fix this with all these amazing people. Keep up the good work and stay great =)