Amazon MP3 Downloader on 64bit Gentoo Linux
Update 2010/12/04: A commenter recommended clamz instead. I’ve installed it but not yet tried it, but it’s certainly easier than installing another OS in a chroot.
(This is going to be a bit of a narrative. If you’re impatient, scroll to the “How-To” section at the bottom of the post.)
Today I decided to download an MP3 album from Amazon. I actually wanted all the songs on the particular album, and noted that you save a couple bucks by downloading the whole album vs. downloading each individual song. So click through, and find that it requires the Amazon Download Manager thingo.
Lame, I think. I click the download link, and it actually gives me some buttons to choose from that have to do with Linux. Huh. Nice work. However, I assume it’s closed-source proprietary crap. But hey, why not give it a try.
My choices are two .deb files, one for Ubuntu Jaunty, and one for Debian 5, or two .rpm files, one for Fedora 11, and one for OpenSuse somethingorother.
So I grab the Ubuntu one. I’m on Gentoo, so I “emerge dpkg”, and then run “dpkg -x amazonmp3.deb .” in an empty directory. I look in usr/bin that it created, and find a binary. But it’s a 32bit binary.
Crap.
I run ‘ldd’ on it, and of course it needs gtk and a bunch of other stuff that I don’t have 32bit libraries for. Like boost.
So I think, ok, I can install a 32bit chroot. So I download the stage3 Gentoo i686 tarball and unpack it in /opt/gentoo32. I also “emerge schroot” in my regular system, and set that up. I recently found schroot while using Ubuntu at work. It’s awesome. Eventually the stage3 tarball finishes up, so I schroot into my new 32bit environment and “emerge libboost”. After it’s finished, I note a problem. Amazon’s binary is expecting some weird version of boost that has “gcc42” in the filename. Also, I just installed boost 1.35, and it wants 1.34. Out of desperation, I try to make symlinks to the correct file names, assuming it probably won’t work. I was right: it doesn’t work. Balls.
Then I think… well, why not install a chroot of 32bit Ubuntu Jaunty? I “emerge debootstrap” and pray… yep, it’s in portage, excellent. I install it, schroot into it, and apt-get a bunch of the libboost packages, and… holy crap, it works.
How-To
Here’s a step-by-step. This is for Gentoo, but it should work equally well on any system where you can install debootstrap and chroot. The following instructions assume you’ve installed them already.
As root on the “main” system:
# mkdir -p /opt/ubuntu-jaunty-32 # debootstrap --arch i386 jaunty /opt/ubuntu-jaunty-32 http://archive.ubuntu.com/ubuntu/ # cat >/etc/schroot/chroot.d/jaunty32.conf [ubuntu-jaunty-32] type=directory description=Ubuntu Jaunty (32-bit) location=/opt/ubuntu-jaunty-32 priority=3 users=$USER groups=$USER,root root-users=root,$USER root-groups=root,wheel personality=linux32 run-setup-scripts=true run-exec-scripts=true aliases=jaunty [hit ctrl+d] # cat >/etc/schroot/mount-defaults /proc/procnonerw,bind 00 /proc/bus/usb/proc/bus/usbnonerw,bind00 /sys/sysnone rw,bind00 /dev/devnonerw,bind00 /dev/pts/dev/ptsnonerw,bind00 /dev/shm/dev/shmnonerw,bind00 /home/homenonerw,bind00 /tmp/tmpnonerw,bind00 /var/run/dbus/var/run/dbusnonerw,bind00 /usr/portage/usr/portagenonerw,bind00 [hit ctrl+d] # schroot -c jaunty (32bit)# groupadd -r staff (32bit)# apt-get update (32bit)# apt-get install sudo curl libglademm-2.4-1c2a xdg-utils libboost-date-time1.34.1 libboost-filesystem1.34.1 libboost-iostreams1.34.1 libboost-regex1.34.1 libboost-signals1.34.1 libboost-thread1.34.1 (32bit)# dpkg -i $DOWNLOAD_DIR/amazonmp3.deb
Note that I didn’t just type all this verbatim… this was just my memory of what I did. So if something’s missing, please leave a note in the comments and I’ll update this.
Next you can try running “amazonmp3” to test it. If that works, you can go back out to your “real” system (just type “exit” in that shell), and do this:
# mkdir -p /usr/local/bin # cat >/usr/local/bin/amazonmp3 #!/bin/bash schroot -c jaunty -p /usr/bin/amazonmp3 -- "$@" [hit ctrl+d] # chmod +x amazonmp3
This creates a script in your “real” system that will chain to the 32bit amazonmp3 binary in your Jaunty chroot. You can set up your browser of choice to automatically launch this script when you download .amz files. At this point you can try running “amazonmp3” from your “real” system (outside the chroot) and see if that works.
There are also a few other things:
-
If you are running a system that uses GDM to log in, you may need to add /var/run/gdm to the bind mounts in the mount-defaults file or else apps started in your chroot won’t be able to connect to your X server.
-
If you’re using non-default gtk2 theme engines on your “real” desktop”, you’ll need to install them in the chroot (via apt-get) as well. Well, ok, you don’t have to, but if you don’t, the Amazon app will look uglier than it should.
-
Remember to always pass the “-p” option to schroot. If you don’t, the environment in the chroot will get reset, which means you’ll lose your DISPLAY env var, and you won’t be able to connect to the X server without manually setting it.
-
When I first ran the apt-get command in the chroot, I got some weird errors at the end of the process about some packages not being configured because another package (gtk, I think) that it depended on hadn’t been configured yet. Just running the same apt-get command a couple times fixed it, strangely.
-
Make sure your “real” system has /usr/local/bin in the PATH.
Anyhow, that’s it. Works like a charm.
Amazon MP3 Downloader on 64bit Gentoo Linux
Update 2010/12/04: A commenter recommended clamz instead. I've installed it but not yet tried it, but it's certainly easier than installing another OS in a chroot.
(This is going to be a bit of a narrative. If you're impatient, scroll to the "How-To" section at the bottom of the post.)
Today I decided to download an MP3 album from Amazon. I actually wanted all the songs on the particular album, and noted that you save a couple bucks by downloading the whole album vs. downloading each individual song. So click through, and find that it requires the Amazon Download Manager thingo.
Lame, I think. I click the download link, and it actually gives me some buttons to choose from that have to do with Linux. Huh. Nice work. However, I assume it's closed-source proprietary crap. But hey, why not give it a try.
My choices are two .deb files, one for Ubuntu Jaunty, and one for Debian 5, or two .rpm files, one for Fedora 11, and one for OpenSuse somethingorother.
So I grab the Ubuntu one. I'm on Gentoo, so I "emerge dpkg", and then run "dpkg -x amazonmp3.deb ." in an empty directory. I look in usr/bin that it created, and find a binary. But it's a 32bit binary.
Crap.
I run 'ldd' on it, and of course it needs gtk and a bunch of other stuff that I don't have 32bit libraries for. Like boost.
So I think, ok, I can install a 32bit chroot. So I download the stage3 Gentoo i686 tarball and unpack it in /opt/gentoo32. I also "emerge schroot" in my regular system, and set that up. I recently found schroot while using Ubuntu at work. It's awesome. Eventually the stage3 tarball finishes up, so I schroot into my new 32bit environment and "emerge libboost". After it's finished, I note a problem. Amazon's binary is expecting some weird version of boost that has "gcc42" in the filename. Also, I just installed boost 1.35, and it wants 1.34. Out of desperation, I try to make symlinks to the correct file names, assuming it probably won't work. I was right: it doesn't work. Balls.
Then I think... well, why not install a chroot of 32bit Ubuntu Jaunty? I "emerge debootstrap" and pray... yep, it's in portage, excellent. I install it, schroot into it, and apt-get a bunch of the libboost packages, and... holy crap, it works.
How-To
Here's a step-by-step. This is for Gentoo, but it should work equally well on any system where you can install debootstrap and chroot. The following instructions assume you've installed them already.
As root on the "main" system:
# mkdir -p /opt/ubuntu-jaunty-32 # debootstrap --arch i386 jaunty /opt/ubuntu-jaunty-32 http://archive.ubuntu.com/ubuntu/ # cat >/etc/schroot/chroot.d/jaunty32.conf [ubuntu-jaunty-32] type=directory description=Ubuntu Jaunty (32-bit) location=/opt/ubuntu-jaunty-32 priority=3 users=$USER groups=$USER,root root-users=root,$USER root-groups=root,wheel personality=linux32 run-setup-scripts=true run-exec-scripts=true aliases=jaunty [hit ctrl+d] # cat >/etc/schroot/mount-defaults /proc/procnonerw,bind 00 /proc/bus/usb/proc/bus/usbnonerw,bind00 /sys/sysnone rw,bind00 /dev/devnonerw,bind00 /dev/pts/dev/ptsnonerw,bind00 /dev/shm/dev/shmnonerw,bind00 /home/homenonerw,bind00 /tmp/tmpnonerw,bind00 /var/run/dbus/var/run/dbusnonerw,bind00 /usr/portage/usr/portagenonerw,bind00 [hit ctrl+d] # schroot -c jaunty (32bit)# groupadd -r staff (32bit)# apt-get update (32bit)# apt-get install sudo curl libglademm-2.4-1c2a xdg-utils libboost-date-time1.34.1 libboost-filesystem1.34.1 libboost-iostreams1.34.1 libboost-regex1.34.1 libboost-signals1.34.1 libboost-thread1.34.1 (32bit)# dpkg -i $DOWNLOAD_DIR/amazonmp3.deb
Note that I didn't just type all this verbatim... this was just my memory of what I did. So if something's missing, please leave a note in the comments and I'll update this.
Next you can try running "amazonmp3" to test it. If that works, you can go back out to your "real" system (just type "exit" in that shell), and do this:
# mkdir -p /usr/local/bin # cat >/usr/local/bin/amazonmp3 #!/bin/bash schroot -c jaunty -p /usr/bin/amazonmp3 -- "$@" [hit ctrl+d] # chmod +x amazonmp3
This creates a script in your "real" system that will chain to the 32bit amazonmp3 binary in your Jaunty chroot. You can set up your browser of choice to automatically launch this script when you download .amz files. At this point you can try running "amazonmp3" from your "real" system (outside the chroot) and see if that works.
There are also a few other things: 1. If you are running a system that uses GDM to log in, you may need to add /var/run/gdm to the bind mounts in the mount-defaults file or else apps started in your chroot won't be able to connect to your X server.
If you're using non-default gtk2 theme engines on your "real" desktop", you'll need to install them in the chroot (via apt-get) as well. Well, ok, you don't have to, but if you don't, the Amazon app will look uglier than it should.
Remember to always pass the "-p" option to schroot. If you don't, the environment in the chroot will get reset, which means you'll lose your DISPLAY env var, and you won't be able to connect to the X server without manually setting it.
When I first ran the apt-get command in the chroot, I got some weird errors at the end of the process about some packages not being configured because another package (gtk, I think) that it depended on hadn't been configured yet. Just running the same apt-get command a couple times fixed it, strangely.
Make sure your "real" system has /usr/local/bin in the PATH.
Anyhow, that's it. Works like a charm.
Amazon MP3 Downloader on 64bit Gentoo Linux
(This is going to be a bit of a narrative. If you’re impatient, scroll to the “How-To” section at the bottom of the post.)
Today I decided to download an MP3 album from Amazon. I actually wanted all the songs on the particular album, and noted that you save a couple bucks by downloading the whole album vs. downloading each individual song. So click through, and find that it requires the Amazon Download Manager thingo.
Lame, I think. I click the download link, and it actually gives me some buttons to choose from that have to do with Linux. Huh. Nice work. However, I assume it’s closed-source proprietary crap. But hey, why not give it a try.
My choices are two .deb files, one for Ubuntu Jaunty, and one for Debian 5, or two .rpm files, one for Fedora 11, and one for OpenSuse somethingorother.
So I grab the Ubuntu one. I’m on Gentoo, so I “emerge dpkg”, and then run “dpkg -x amazonmp3.deb .” in an empty directory. I look in usr/bin that it created, and find a binary. But it’s a 32bit binary.
Crap.
I run ‘ldd’ on it, and of course it needs gtk and a bunch of other stuff that I don’t have 32bit libraries for. Like boost.
So I think, ok, I can install a 32bit chroot. So I download the stage3 Gentoo i686 tarball and unpack it in /opt/gentoo32. I also “emerge schroot” in my regular system, and set that up. I recently found schroot while using Ubuntu at work. It’s awesome. Eventually the stage3 tarball finishes up, so I schroot into my new 32bit environment and “emerge libboost”. After it’s finished, I note a problem. Amazon’s binary is expecting some weird version of boost that has “gcc42″ in the filename. Also, I just installed boost 1.35, and it wants 1.34. Out of desperation, I try to make symlinks to the correct file names, assuming it probably won’t work. I was right: it doesn’t work. Balls.
Then I think… well, why not install a chroot of 32bit Ubuntu Jaunty? I “emerge debootstrap” and pray… yep, it’s in portage, excellent. I install it, schroot into it, and apt-get a bunch of the libboost packages, and… holy crap, it works.
How-To
Here’s a step-by-step. This is for Gentoo, but it should work equally well on any system where you can install debootstrap and chroot. The following instructions assume you’ve installed them already.
As root on the “main” system:
# mkdir -p /opt/ubuntu-jaunty-32 # debootstrap --arch i386 jaunty /opt/ubuntu-jaunty-32 http://archive.ubuntu.com/ubuntu/ # cat >/etc/schroot/chroot.d/jaunty32.conf [ubuntu-jaunty-32] type=directory description=Ubuntu Jaunty (32-bit) location=/opt/ubuntu-jaunty-32 priority=3 users=$USER groups=$USER,root root-users=root,$USER root-groups=root,wheel personality=linux32 run-setup-scripts=true run-exec-scripts=true aliases=jaunty [hit ctrl+d] # cat >/etc/schroot/mount-defaults /proc /proc none rw,bind 0 0 /proc/bus/usb /proc/bus/usb none rw,bind 0 0 /sys /sys none rw,bind 0 0 /dev /dev none rw,bind 0 0 /dev/pts /dev/pts none rw,bind 0 0 /dev/shm /dev/shm none rw,bind 0 0 /home /home none rw,bind 0 0 /tmp /tmp none rw,bind 0 0 /var/run/dbus /var/run/dbus none rw,bind 0 0 /usr/portage /usr/portage none rw,bind 0 0 [hit ctrl+d] # schroot -c jaunty (32bit)# groupadd -r staff (32bit)# apt-get update (32bit)# apt-get install sudo curl libglademm-2.4-1c2a xdg-utils libboost-date-time1.34.1 libboost-filesystem1.34.1 libboost-iostreams1.34.1 libboost-regex1.34.1 libboost-signals1.34.1 libboost-thread1.34.1 (32bit)# dpkg -i $DOWNLOAD_DIR/amazonmp3.deb
Note that I didn’t just type all this verbatim… this was just my memory of what I did. So if something’s missing, please leave a note in the comments and I’ll update this.
Next you can try running “amazonmp3″ to test it. If that works, you can go back out to your “real” system (just type “exit” in that shell), and do this:
# mkdir -p /usr/local/bin # cat >/usr/local/bin/amazonmp3 #!/bin/bash schroot -c jaunty -p /usr/bin/amazonmp3 -- "$@" [hit ctrl+d] # chmod +x amazonmp3
This creates a script in your “real” system that will chain to the 32bit amazonmp3 binary in your Jaunty chroot. You can set up your browser of choice to automatically launch this script when you download .amz files. At this point you can try running “amazonmp3″ from your “real” system (outside the chroot) and see if that works.
There are also a few other things:
- If you are running a system that uses GDM to log in, you may need to add /var/run/gdm to the bind mounts in the mount-defaults file or else apps started in your chroot won’t be able to connect to your X server.
- If you’re using non-default gtk2 theme engines on your “real” desktop”, you’ll need to install them in the chroot (via apt-get) as well. Well, ok, you don’t have to, but if you don’t, the Amazon app will look uglier than it should.
- Remember to always pass the “-p” option to schroot. If you don’t, the environment in the chroot will get reset, which means you’ll lose your DISPLAY env var, and you won’t be able to connect to the X server without manually setting it.
- When I first ran the apt-get command in the chroot, I got some weird errors at the end of the process about some packages not being configured because another package (gtk, I think) that it depended on hadn’t been configured yet. Just running the same apt-get command a couple times fixed it, strangely.
- Make sure your “real” system has /usr/local/bin in the PATH.
Anyhow, that’s it. Works like a charm.
Messing up with Vala (again)
First some good news. I didn't look close enough into the possibilities offered by Automake 1.11 when I first wrote the post about building Vala projects. Automake 1.11 is all about making releases without the end-users having to compile Vala! Just like it is written in the Automake documentation. From now on I will always apply this wherever it is possible.I updated the Xfce4 Vala bindings with libraries from the 4.7 stack. In there I have updated the panel plugin example, and as you can see the Automake file is extremely short. When there is a SOURCES defined with a Vala file, Automake will create targets for each compiled program or library with Vala compilation, and generate one vala.stamp file per target. This has its pros and cons. In the case of the Notes plugin, this disallowed me to have a mix of only C written software and Vala inside the same directory. In reality I used to have a single main file for the panel plugin to compile to C either for the 4.7 version or prior. Automake makes the Vala specific targets visible outside the scope of the "if PANEL47 ... else ... end" block. I ended up with self-compiled Vala for each target in maintainer mode only, as previously, which is a small overhead for the specific targets.
Other nice thing about Vala is that bindings are just files. I compiled the Notes plugin for the Xfce 4.6 panel on my netbook just to verify everything is alright but unfortunately there were some problems. I bumped the required version of Vala to 0.7.8 which has GTK+ bindings for 2.18 already while I only have GTK+ 2.16 available. The simple thing to do was to download the GTK+ bindings from the version of Vala I used previously and copy them into a location of the project (or system wide). As long as the Vala compiler knows where to pick them up (with "--vapidir=") it will choose them and not the ones provided by default. This makes it awesomely easy to provide customized bindings for example.
Vala can always be very time consuming, but I still like it! Just like git merge by the way.
Xfce4 Settings hacking
I started to hack a bit on Xfce4 Settings: I have a branch ready for review implementing a clipboard manager and started a branch to improve Xfce4 Settings Editor.
The clipboard manager allows the system to have a persistent clipboard. When you copy some text or an image and close the application where you copied it, the contents of the clipboard is no longer lost. I was able to add this functionality quickly thanks to the amazing work of Mike Massonnet in Xfce4 Clipman Plugin.
The settings editor is now able to edit existing properties, to rename them, to reset them to their default value or to remove them if there is no default value. It also monitors the channels to detect property changes and to update the view automatically and remembers the window geometry so that you don't have to resize the windows and the columns every time. I still need to work on adding new properties and improving the channel stuff: adding, removing or renaming channels should be possible in the future.
Amazon MP3 Downloader on 64bit Gentoo Linux
(This is going to be a bit of a narrative. If you’re impatient, scroll to the “How-To” section at the bottom of the post.) Today I decided to download an MP3 album from Amazon. I actually wanted all the songs on the particular album, and noted that you save a couple bucks by downloading the [...]It’s a boy!
Last wednesday I became father for the second time. It’s a boy and his name is Guido. Me, his mom and his big sister Leonie are the happiest people in the world right now.
Here’s a screenshot, err, a picture of him just having found his own thumb:
Don’t expect anything Xfce-related from me any time soon…
Donations, FOSDEM
It’s been a while that I used PayPal for anything, so it came as a nice surprise that when I logged in yesterday I was presented with 60€ worth of donations for Thunar and Xfce as a whole. Thanks to Michael Gstettenbauer, James Wallen and Alin Anton (I hope the names are correct), you guys rock!
Edit: Of course this money will be used for Xfce activities and stuff exclusively, not for my own private expenses. ;)
Another interesting piece of information I noticed last night is that despite our inactivity with regards to FOSDEM, there is a developer room reserved for cross desktop talks at next year’s event. I haven’t talked to anyone yet but since they excplicitely mention Xfce as possible participants, I guess there still is a chance for one or two presentations related to Xfce. Anything you’d like us to talk about?