nemrod.se Various guides and experiments

Install RPM packages on Arch Linux


I recently found myself wanting to upload music to Google Music from my computer with Arch Linux but found that they only had RPM and APT (.deb) packages available for download. It’s fairly straightforward to install an RPM on Arch:

  1. Download the RPM for your architecture (64- or 32-bit)
  2. Install rpmextract for extracting the RPM and any dependencies the program has (libidn for Google Music Manager for example) with pacman
  3. Now create a new folder, move the RPM file to it and go there
  4. Run rpmextract.sh and you’ll get a directory structure based on the root (/) in the current directory
  5. Copy the files to where they belong in your own file hierarchy

There are some downsides to this, though. For example you won’t be able to easily uninstall the program, nor will it warn you if you remove any of the dependencies. That’s why I thought it would be a better idea to create an Arch package out of it.

To create an Arch package basically all you need is to create a PKGBUILD file which contains all of the information about the package you’re about to create. Here are their own instructions (which contains a lot more information but also takes longer to figure out if all you want to do is convert an RPM package) and here’s a reference for the different variables you can use in a PKGBUILD file.

This is what my PKGBUILD file ended up like:

# Maintainer: Anders Mårtensson <anders@nemrod.se>
pkgname=google-musicmanager-beta
pkgver=current
pkgrel=2
pkgdesc="A program necessary to upload audio files to your Google Music library."
arch=('x86_64')
url="https://music.google.com/"
license=('unknown')
depends=('libidn')
makedepends=('rpmextract')
options=('emptydirs')
source=("http://dl.google.com/linux/direct/google-musicmanager-beta_current_x86_64.rpm")
md5sums=('6c05f087f9cd77563b7d001584e3b2d8')

build() {
  cd "$pkgdir"
  rpmextract.sh ../google-musicmanager-beta_current_x86_64.rpm
}

As you can see it’s pretty straight-forward:

  • Name of the program (lowercase, no spaces, etc.)
  • Version (Google says “current” and I couldn’t bother figuring out the actual version number so I went with it)
  • An internal version number that should increment by one for every change to the package
  • A short description (less than about 80 characters)
  • The architecture (i686, x86_64, both or any)
  • A URL to the official site of the package (optional)
  • License (GPL, BSD, unknown, etc.)
  • Any dependencies the program might have (separated by space, no comma)
  • Dependencies only required to build but not run the program
  • Any options (in this case there were some empty directories after extraction which I found unnecessary so I used the emptydirs option)
  • A list of source files (these will be downloaded when installing if they’re URLs, but you can also provide local files putting them in the same folder as the PKGBUILD file)
  • A list of md5sums for the files (you can get these by running “makepkg -g” in the folder with the files).
  • Finally there’s the build script which does the extracting

Once you’ve created the PKGBUILD file run “makepkg” in the folder and watch it create the .pkg.tar.xz file for use with pacman! Install it with pacman -U and you’re done. It will complain if you are missing dependencies and you can remove the package with pacman -R just like when installing with pacman -S. Simple, huh?

How a session of doing this might look:

mkdir package # might want a more descriptive folder ;)
cd package
cp /usr/share/pacman/PKGBUILD.proto PKGBUILD # it's a prototype file to save a lot of keypresses
vim PKGBUILD # modify it to fit your package
makepkg -g # will download any files specified and spit back an md5sum line, copy it
vim PKGBUILD # paste in the md5sums returned from the previous command
makepkg # you may get complaints about dependencies you don't have installed, install them and run until it goes till the end
pacman -U *.pkg.tar.xz # and it's installed!

Posted in Guides | 6 Comments

6 Responses to “Install RPM packages on Arch Linux”

  1. Sean says:

    Thank you for such a great howto :) Could you update these instructions with respect to the requirements of pacman 4.1?

  2. satanselbow says:

    18 months later BUT! – Thanks for this pointed me in the right direction when I was tying myself up in knots following the wiki :D

  3. Taras says:

    It’s helped. Thank you!

  4. Claus Conrad says:

    Thanks for the tutorial!

  5. David Ford says:

    Great tutorial, I’ve built the package, however it does not install the packages in the required directories. It says it has installed the package with 0.00MiB Total Installed Size. I copied the files manually to the required directories and was able to get the package working, however, I am going to play around with the PKGBUILD and makepkg for a bit and see if I can get it install correctly. I am running Linux arch 3.13.6-1. I’ll let you know how this goes…

  6. David Ford says:

    I added this to the end of my PKGBUILD file and it seemed to build correctly as it built an empty file without it. I installed with pacman -U and everything works!

    package() {
    cd $srcdir
    rsync -ruDq $srcdir $pkgdir
    }

Leave a Reply