diff --git a/licensing/Dockerfile b/licensing/Dockerfile new file mode 100644 index 000000000..6c3a6ff04 --- /dev/null +++ b/licensing/Dockerfile @@ -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 diff --git a/licensing/README.md b/licensing/README.md new file mode 100644 index 000000000..9061f5093 --- /dev/null +++ b/licensing/README.md @@ -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. diff --git a/licensing/gpl.lua b/licensing/gpl.lua new file mode 100755 index 000000000..b2a045964 --- /dev/null +++ b/licensing/gpl.lua @@ -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 diff --git a/licensing/license.sh b/licensing/license.sh new file mode 100755 index 000000000..51ea21e22 --- /dev/null +++ b/licensing/license.sh @@ -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