initial program to extract GPL source from running Moby for #45

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack 2016-03-18 15:19:56 +00:00
parent cbd7af5e1d
commit 3907ec30b1
4 changed files with 82 additions and 0 deletions

9
licensing/Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM alpine:3.3
RUN apk update && apk add lua git
RUN git clone https://github.com/alpinelinux/aports.git
ADD license.sh gpl.lua /usr/bin/
CMD license.sh

12
licensing/README.md Normal file
View File

@ -0,0 +1,12 @@
Extract GPL source from Moby
WORK IN PROGRESS SOME ISSUES STILL
This container runs on a Pinata system and dumps out the GPL code it is running
```
docker build -t license .
docker run -it -v /etc:/etc -v /lib:/lib -v $PWD/output:/output license
```
TODO add kernel to this, there is now a patch to get the metadata in.

18
licensing/gpl.lua Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/lua
p = {}
f = io.open("/lib/apk/db/installed")
for line in f:lines() do
if line == "" then
if p.L:match("[Gg][Pg][Ll]") then
print(p.P, p.L, p.c)
end
p = {}
else
k, v = line:match("(%a):(.*)")
if k then
p[k] = v
end
end
end

43
licensing/license.sh Executable file
View File

@ -0,0 +1,43 @@
#!/bin/sh
set -x
cat /etc/issue | grep -q Moby || ( printf "You must run this script with -v /etc:/etc -v /lib:/lib\n" && exit 1 )
apk info | grep fuse || ( printf "You must run this script with -v /etc:/etc -v /lib:/lib\n" && exit 1 )
# [ -f /etc/kernel-version-info ] || ( printf "Missing kernel version info\n" && exit 1 )
# . /etc/kernel-version-info
# APORTS=https://github.com/alpinelinux/aports.git
# git clone ${APORTS}
mkdir -p /output
cd /output
gpl.lua | while read l
do
echo $l
APORT_PACKAGE=$(echo $l | sed 's/ .*//')
APORT_COMMIT=$(echo $l | sed 's/^.* //')
(
cd /aports
[ ! -d main/${APORT_PACKAGE} ] && ( printf "Cannot find package ${APORT_PACKAGE} in aports\n" && exit 1 )
git checkout ${APORT_COMMIT} || ( printf "Cannot find commit ${APORT_COMMIT} for ${APORT_PACKAGE} in aports\n" && exit 1 )
export srcdir=/output
cd main/${APORT_PACKAGE}
. ./APKBUILD
mkdir -p "$srcdir"/$pkgname-$pkgver
for f in $source
do
if [ -f $f ]
then
cp -a $f "$srcdir"/$pkgname-$pkgver/
else
( cd "$srcdir"/$pkgname-$pkgver && \
wget $f || ( printf "Cannot retrieve $f\n" && exit )
)
fi
done
)
done