Broken postinst on Ubuntu 12.04 #13

Closed
mma8x opened this Issue Jul 11, 2012 · 6 comments

Projects

None yet

3 participants

mma8x commented Jul 11, 2012

Running Ubuntu 12.04; sorry, can't figure out how to format code here...

  • Using ppas for install fails at configuration.
The following NEW packages will be installed:
  schwinn810
0 upgraded, 1 newly installed, 0 to remove and 295 not upgraded.
Need to get 0 B/12.1 kB of archives.
After this operation, 139 kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package schwinn810.
(Reading database ... 231708 files and directories currently installed.)
Unpacking schwinn810 (from .../schwinn810_0.1-1_all.deb) ...
Setting up schwinn810 (0.1-1) ...
/var/lib/dpkg/info/schwinn810.postinst: 14: /var/lib/dpkg/info/schwinn810.postinst: [[: not found
/var/lib/dpkg/info/schwinn810.postinst: 27: /var/lib/dpkg/info/schwinn810.postinst: [[: not found
/var/lib/dpkg/info/schwinn810.postinst: 38: /var/lib/dpkg/info/schwinn810.postinst: Bad substitution
dpkg: error processing schwinn810 (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 schwinn810
E: Sub-process /usr/bin/dpkg returned an error code (1)

Seems that all files except schwinn.conf are installed though.

  • Importing a kml file (I wasn't able to use babelize.cmd directly because of the lack of a schwinn.conf file, but used the command from that file) into google maps doesn't generate one track. Instead, it imports and displays every data point as a way point.

The gpx file that's generated works well with uTrack, though the speeds are off (pretty sure I wasn't averaging 82 mph on my bike). Thanks for the effort on this!

Owner
mlt commented Jul 11, 2012

I knew that udev stuff is broken. But this is new to me. The package installs okay locally for me without ppa. I'll try ppa.

because of the lack of a schwinn.conf file

Here is the content of mine /etc/schwinn810.conf

# use dpkg-reconfigure -plow schwinn810
AUTO=true
PORT=/dev/schwinn810
DIR=/var/lib/schwinn810
NOTIFY=true
HOOK=/usr/share/schwinn810/babelize.sh
OFFSET=5
DEBUG=

Note that either port must be changed to /dev/ttyUSB0 and you should be in dialout group, or udev rule needs to be fixed for wider permissions and port alias.

[[: not found

What does sh --version return? bash (and probably zsh I never used) should interpret it as a logical command and not try to call that as a program.

mlt@nb:~$ sudo sh -e /var/lib/dpkg/info/schwinn810.postinst configure
custom logging function 0x205eb008 registered
selinux=0
runtime dir '/run/udev'
calling: control

google maps doesn't generate one track. Instead, it imports and displays every data point as a way point

Lookup gpsbabel manual. You can create your own "babelize-mine.sh". It is likely you are looking for -x transform,trk=wpt,del option. This will ask gpsbabel to convert your waypoints into track data and get rid of waypoints.

the speeds are off

Did you do any watch stops on the way? If you open gpx file, you'll see that there are no speed data in it. I don't know why it happens yet. IIRC though watch reports speed in km/h, gpsbabel should respect speed field and pass it to gpx format. Perhaps I need to convert km/h into m/s used by gpsbabel.

It is likely that uTrack is trying to recalculate your speed based on location and time.

@mlt mlt added a commit that referenced this issue Jul 21, 2012
@mlt mlt Cleanup
* Less bashisms may help with #13
25af418

On Ubuntu 12.04 here as well. Your previous comment is correct that bashisms are the root of the issue. By default, sh on Ubuntu (12.04, at least) is just a symlink to the 'dash' shell, which does not support the double-bracket test construct. I've confirmed that temporarily changing sh to link to bash fixes the issue (both for the dpkg postinst step and for actually running the schwinn810 program).

I'm not sure if the fix would be as simple as changing the shebang line to ask explicitly for bash...but losing the [[ ]] tests would definitely do it.

Great work with this!

Owner
mlt commented Aug 1, 2012

By default, sh on Ubuntu (12.04, at least) is just a symlink to the 'dash' shell

I keep upgrading from 9.04 or so. I guess at some point I changed it to bash and forgot.

I'm not sure if the fix would be as simple as changing the shebang line to ask explicitly for bash

I would prefer to be as flexible as possible in case someone feels strong against bash or something.

losing the [[ ]] tests would definitely do it

Have you tried version tagged as 0.1.1 ? I removed [[ replacing either with test or with single bracket. I believe package should be based on corresponding version tagged as 0.1.1 in git.

Great work with this!

Thank you!

buck2202 commented Aug 7, 2012

Ok, I think that the bashism problems are fixed, but it seems like there may be files missing from the repo now. With the current ppa (0.2), executing schwinn810 fails with

Traceback (most recent call last):
File "/usr/share/schwinn810/download.py", line 65, in
main()
File "/usr/share/schwinn810/download.py", line 50, in main
p = GtkProgress()
File "/usr/share/schwinn810/core/progress_gtk.py", line 11, in init
builder.add_from_file("{:s}/progress.glade".format(dir))
File "/usr/lib/python2.7/dist-packages/gi/types.py", line 43, in function
return info.invoke(_args, *_kwargs)
gi._glib.GError: Failed to open file '/usr/share/schwinn810/core/progress.glade': No such file or directory

I'm not seeing a glade layout in the repository anywhere...is it something that's supposed to be dumped from a script during install?

I was able to successfully build a .deb package from your tagged 0.1.1 version, and it works as expected without having to change from dash to bash. The only issue (which doesn't seem to affect data extraction) is that I get this error
unicsv: Invalid parameter value $[-OFF] for option utc
printed once for each track that's extracted from the device

Owner
mlt commented Aug 7, 2012

Thank you for testing!

I'm not seeing a glade layout in the repository anywhere

It is here but apparently I forgot to include it in packaging. I fixed that.

unicsv: Invalid parameter value $[-OFF] for option utc

Check the content of /etc/schwinn810.conf there should be a simple timezone shift. I feel like $[-OFF] from postinst was interpreted literary. Another bashism?

buck2202 commented Aug 7, 2012

Oh, sorry...not sure how I didn't see the glade file sitting right there.

But yeah, the conf file does contain the text $[-OFF]. Seems that dash doesn't support that. (I'm not actually familiar with that notation either, so this is just a guess based on what bash does when I hand-enter the commands from postinst)

If you're just trying to strip off the leading hyphen, dash's supported prefix removal expansion is just ${var:substr}. So
OFF="${OFF#-}"
?

@mlt mlt closed this in d2526e0 Aug 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment