[SOLVED] Package mentioned in index not found (try 'apk update')

2 posts / 0 new
Last post
#1 Fri, 2015-12-04 11:11
giminni
  • giminni's picture
  • Offline
  • Last seen: 2 years 3 months ago
  • Joined: 2015-12-04

I am using Alpine Linux with docker and my idea is to
build a local repository under an Apache web server reducing bandwith & delays.

So far so good, I created a docker image with an external
volume called cache under /vol/cache.
This is internal linked to a docker directory named /etc/apk/cache

After running the docker container I enter the shell making a cache update after
installation with
"apk update -vU --allow-untrusted"

Resulting in populating the directory with all the installed packages as apk files.

alpine-base-3.2.3-r0.6210c243.apk      
alpine-baselayout-2.3.2-r0.f9c0e2cc.apk
alpine-conf-3.2.1-r6.571324ae.apk      
alpine-keys-1.1-r0.0403eb8d.apk                       
...

Then I made an APKINDEX.tar.gz with
apk index -vU --allow-untrusted -o /etc/apk/cache/APKINDEX.tar.gz /etc/apk/cache/*.apk

Here the final result:

alpine-base-3.2.3-r0.6210c243.apk      
alpine-baselayout-2.3.2-r0.f9c0e2cc.apk
alpine-conf-3.2.1-r6.571324ae.apk      
alpine-keys-1.1-r0.0403eb8d.apk                       
APKINDEX.tar.gz                        
...

I linked the volume called cache to an EXTERNAL to docker apache subdirectory named x86_64 with
(Next step would be an internal mini_httpd with localhost link)

"ln -s /vol/cache /var/www/html/cache/x86_64"

Here how it looks like:

/var/www/html                                         
|-- cache                                             
|   `-- x86_64 -> /vol/cache
|-- icons -> /usr/share/apache2/icons/                
`-- index.html                                        

Next I changed the /etc/apk/repositories adding one line
"http://172.17.0.1/cache"

My dockerfile contains at some place

"... apk add -U --allow-untrusted --repository "http://172.17.0.1/cache" ..."

The result is

fetch "http://172.17.0.1/cache/x86_64/APKINDEX.tar.gz"                                    
(1/10) Installing ncurses-terminfo-base (6.0-r2)                                           
ERROR: ncurses-terminfo-base-6.0-r2: package mentioned in index not found (try 'apk update'
...

Apparently I am doing something wrong, the documentation how to build a local
apk repository is thin or not available.

Can someone enlight me how to accomplish this?

TIA
giminni

Mon, 2015-12-07 23:31
giminni
  • giminni's picture
  • Offline
  • Last seen: 2 years 3 months ago
  • Joined: 2015-12-04

I found myself the solution:

downloaded file in a cache directory has alway x.y.z
for x=filename&ver, y=unique_key and z=.apk suffix

using the same directory for downloaded files from mainstream an own repo file there is a difference
own repo must have only x.z and therefore i made a one liner to remove y (unique key) and make a
relative symlink to the downloaded files. This guarantees the external access via web browser and the
internal access from a docker container :-)

#!/bin/bash
for f in $( cd /etc/apk/cache && ls *.apk ); do g=$(echo ${f:0:-13}.apk); cd /etc/apk/cache; ln -s $f $g; done

Looking now

alpine-base-3.2.3-r0.apk -> alpine-base-3.2.3-r0.6210c243.apk      
alpine-base-3.2.3-r0.6210c243.apk      
alpine-baselayout-2.3.2-r0.apk -> alpine-baselayout-2.3.2-r0.f9c0e2cc.apk
alpine-baselayout-2.3.2-r0.f9c0e2cc.apk
alpine-conf-3.2.1-r6.apk -> alpine-conf-3.2.1-r6.571324ae.apk      
alpine-conf-3.2.1-r6.571324ae.apk      
alpine-keys-1.1-r0.apk -> alpine-keys-1.1-r0.0403eb8d.apk                       
alpine-keys-1.1-r0.0403eb8d.apk                       
APKINDEX.tar.gz         

Resulting in

fetch "http://172.17.0.1/cache/x86_64/APKINDEX.tar.gz"
(1/10) Installing ncurses-terminfo-base (6.0-r2)  
...     

Apache is happy logging:

...
"GET /cache/x86_64/APKINDEX.tar.gz HTTP/1.1" 200 6910 "-" "libfetch/2.0"
"GET /cache/x86_64/ncurses-terminfo-base-6.0-r2.apk HTTP/1.1" 200 25882 "-" "libfetch/2.0"
...

At the end rebuilding a docker container is very fast using a local persistent docker data volume.
Another benefit is the possibility to add packages from the container itself.

Log in or register to post comments