1

Why I want to know this:

Currently I use apt-get source to get the source code for all packages within my Debian based docker images to comply with the GPL when I distribute the docker images.

Now there are e few docker images where I would like to use the alpine based docker image but I don't know how to get the source code used to build the packages within these docker images.

What I found out so far:

If there where an equivalent for apt-get source for alpine linux this wouldn't be a problem (the documentation does not mention a source option for apk)

The Github page only contains the scripts and patches but not the exact source code, but then the build scripts just seem to get the source code from upstream.

They have to provide the source code somewhere since they are surely distributing some GPL licensed binaries within there docker images.

How to get (exactly) the source code used to build the packages of an alpine docker image?

0

Alpines package manager APK does not support a command like dpkg with apt-get source <PACKAGE_NAME>.

To get the exact source code matching the installed packages on alpine linux you can use a combination of apk and alpine-sdk commands.

Steps to get the exact source code of the installed packages on alpine linux:

  1. Get a list of all installed packages:

    apk info
    
  2. Install the alpine-sdk (and set it up) as described in the alpine wiki.

  3. Clone your current apline version from aports:

            git clone --single-branch --branch YOUR_VERSION-stable https://git.alpinelinux.org/aports
    
  4. Loop over the installed packages and find the correct folder within the aports folder (beware the package version that you can get with apk version <PACKAGE_NAME> is equal to <PACKAGE_NAME>-<PACKAGE_BUILD_VERSION>-<PACKGAE_RELEASE_VERSION>).

  5. Within each folder run

    abuild fetch
    

    to get the source code.

  6. Not every package has its own folder within aports, because sometimes a package listed by apk info will be a sub package of another package.

    In this case you have to fetch the source code for the package referenced in the origin variable within the .PKGINFO file which you can obtain by using the apt fetch <sub-packagename> command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.