Since I'm running postmarketOS on my phone I had to find a way to sync my music collection to my phone. There's a lot of solutions to do that.

But since I have a full package-managed Linux distro on my phone, and it's very easy to create repositories, I decided to just package my music.

Upsides:

  • Music collection gets neatly synced to all my devices
  • Music collection updates together with my system updates

Downsides:

  • Need to run a repository
  • This is not really efficient

Since I already have a local repository on my server and my music collection is not terribly large, I just ignored the downsides and did it anyway.

The software

I made a python script that scans through the music directory on my server and generates the required APKBUILD package definitions for Alpine Linux. Since I manually make sure that the directory structure and metadata is perfect I just don't deal with that at all in the script and always assume music is in $dir/$artist/$album/$track. It also packages every file in the album directory even if it's not related to the music.

You can find the python script here

The script takes 2 arguments, one is the directory the music is stored in, the other is a directory where it will create the package definitions, the music files will be symlinked between those.

$ python3 musicrepo.py /mnt/music /mnt/files/pmaports/custom-music
$ pmbootstrap build musicdir-all

I already have pmbootstrap on my server for building my custom packages I use on various devices, in this case there's just an apache vhost that reads the packages from the pmbootstrap builddir and this repository is added on my postmarketOS phones and Alpine desktop machines.

The only thing I need to do now is installing the musicdir-all package on my devices to get all the music synced or add the musicdir-$artist package to get a subset.

On a phone

As you've probably seen on the top image, the updates for the music collection just show up as software updates. Sadly it only shows that there's an update for the meta package for the artist and not that it will pull in a new album as dependency. But the important part is that it works.

The music in these packages are stored inside /usr/share/music after installing. In Lollypop I just added that path as additional directory in the collection so I can both have music in my homedir and in the system packages. After that and restarting Lollypop a few times it will show the music

So not very CPU efficient to compress the music into archives and unpack them again, and I have the music stored twice now on the server. But aside from that it works great :D