summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-09-02 21:21:29 +0200
committerSuren A. Chilingaryan <csa@suren.me>2019-09-02 21:21:29 +0200
commit9ee658cba222c4141d90f868a45ac3718d655852 (patch)
treeeed31c493fe9bc9a69d4895bd72d5a5aa8956c71
downloadgentoo-builder-9ee658cba222c4141d90f868a45ac3718d655852.tar.gz
gentoo-builder-9ee658cba222c4141d90f868a45ac3718d655852.tar.bz2
gentoo-builder-9ee658cba222c4141d90f868a45ac3718d655852.tar.xz
gentoo-builder-9ee658cba222c4141d90f868a45ac3718d655852.zip
Proof of concept
-rw-r--r--Makefile79
-rw-r--r--README32
-rw-r--r--bootstrap/Dockerfile49
-rw-r--r--builder/Dockerfile9
4 files changed, 169 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..afa4bcc
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,79 @@
+all: build
+install: push
+
+.PHONY: rebuild builder update bash connect start stop restart bash logs debug cancel bootstrap reinit check
+
+
+
+# This is bootstrap image
+bootstrap: bootstrap/Dockerfile
+ docker build --tag chsa/gbootstrap:latest bootstrap
+
+reinit: bootstrap/Dockerfile
+ docker build --no-cache --tag chsa/gbootstrap:latest bootstrap
+
+check: bootstrap/Dockerfile
+ if [ `docker ps -a | grep chsa/gbootstrap | wc -l` -gt 0 ]; then \
+ docker rm gbootstrap ;\
+ fi ;\
+ docker run -v /home/docker/volumes/binpkgs:/var/cache/binpkgs --name gbootstrap -it chsa/gbootstrap:latest /bin/bash
+
+
+# This is builder itself
+builder: bootstrap bootstrap/Dockerfile
+ docker build --tag chsa/gbuilder:latest builder
+
+update: builder/Dockerfile
+ docker build --no-cache --tag chsa/gbuilder:latest builder
+
+bash:
+ if [ `docker ps | grep chsa/gbuilder:latest | wc -l` -eq 0 ]; then \
+ if [ `docker ps -a | grep gbuilder:latest | wc -l` -gt 0 ]; then \
+ echo "Stalled copy... Remove to continue..." ;\
+ echo "docker rm gbuilder" ;\
+ exit 1 ;\
+ fi ;\
+ docker run -v /home/docker/volumes/binpkgs:/var/cache/binpkgs --name gbuilder -it chsa/gbuilder:latest /bin/bash ;\
+ else \
+ echo "Already running..." ;\
+ fi
+
+build:
+ if [ `docker ps | grep chsa/gbuilder:latest | wc -l` -eq 0 ]; then \
+ if [ `docker ps -a | grep gbuilder:latest | wc -l` -gt 0 ]; then \
+ echo "Stalled copy... Remove to continue..." ;\
+ echo "docker rm gbuilder" ;\
+ exit 1 ;\
+ fi ;\
+ docker run -v /home/docker/volumes/binpkgs:/var/cache/binpkgs --name gbuilder -t -d chsa/gbuilder:latest ;\
+ else \
+ echo "Already running..." ;\
+ fi
+
+stop:
+ @if [ `docker ps | grep gbuilder | wc -l` -gt 0 ]; then \
+ docker stop gbuilder ;\
+ fi
+
+cancel:
+ @if [ `docker ps -a | grep gbuilder | wc -l` -gt 0 ]; then \
+ docker stop gbuilder ;\
+ docker rm -f gbuilder ;\
+ fi
+
+restart:
+ make cancel
+ make build
+
+# Control
+logs:
+ docker logs -f gbuilder
+
+connect:
+ docker exec -it gbuilder /bin/bash
+
+# Slow & big, avoid if possible
+debug: stop
+ echo "Generating image from container. Thats slow!" ; \
+ docker commit gbuilder gbuilder-debug ;\
+ docker run -v /home/docker/volumes/binpkgs:/var/cache/binpkgs --name gbuilder-debug -ti bash
diff --git a/README b/README
new file mode 100644
index 0000000..2f9e115
--- /dev/null
+++ b/README
@@ -0,0 +1,32 @@
+Proof of concept remote builder of clean Gentoo tree to provide on demand binary packages to desktop and
+laptop comptuers.
+
+ - This will not work with presence of any significant unstable packet.
+ * For instance, unstable firefox depends on unstable "nss-3.45". After update it is replaced in portage
+ with "nss-3.46". Either full "nss-3.*" branch should be unmasked (which may bring its own problems or the
+ manual intervention is required)
+ - Even with stable tree, there are pereodically circular dependencies (always during the bootstrap phase)
+
+
+Idea:
+ - Create 'Bootstrap' image, i.e. Gentoo image with all configuration. Solved circular dependencies ready to build
+ make bootstrap
+ make check
+
+ - Instantiate 'Builder', i.e. synced configs and portage tree
+ make builder
+ make bash
+
+ - Update builder to integrate latest configuration/portage changes
+ make update
+ make bash
+
+ - Start building
+ make build
+ make logs
+
+
+ It will build packages and put it on the attached volume. If crashed and restarted, he will first re-use already
+ built binaries and, then, will continue compilling. This requires fast storage and will not play well with overlayfs.
+ I guess lvm based stuff is necessety.
+
diff --git a/bootstrap/Dockerfile b/bootstrap/Dockerfile
new file mode 100644
index 0000000..08d0447
--- /dev/null
+++ b/bootstrap/Dockerfile
@@ -0,0 +1,49 @@
+FROM gentoo/stage3-amd64:20190829
+
+VOLUME /var/cache/binpkgs
+
+RUN emerge --sync && \
+ emerge -1 portage
+
+#Pre-build configuration could be here
+#RUN touch /etc/init.d/functions.sh && \
+# echo 'PYTHON_TARGETS="${PYTHON_TARGETS} python3_6"' >> /etc/portage/make.conf && \
+# echo 'PYTHON_SINGLE_TARGET="python3_6"' >> /etc/portage/make.conf
+
+# Install mandatory packages
+RUN emerge -1 -U =gcc-8.3.0* distcc dev-vcs/git dev-vcs/bzr app-portage/layman app-portage/gentoolkit app-portage/eix app-misc/mc dev-libs/libxml2 && \
+ eix-sync
+
+# Adapt configuration
+RUN \
+ mkdir /darklin && \
+ cd /darklin && \
+ git clone http://darksoft.org/git/csa/devops/darkconf/gentoo.git && \
+ git clone http://darksoft.org/git/csa/devops/darkconf/darklin4.git && \
+ \
+ # Configuring paths
+ rm -rf /etc/portage && rm -f /etc/make.conf && \
+ ln -s /darklin/gentoo /etc/portage && \
+ ln -s /etc/portage/extraconf/remote.conf /etc/make.conf && \
+ mkdir -p /Image/My/DarkLin/ && \
+ ln -s /darklin/darklin4 /Image/My/DarkLin/portage && \
+ ln -s /var/db/repos/gentoo /usr/portage && \
+ ln -s /var/cache/distfiles /usr/portage/distfiles && \
+ \
+ # Fixing layman and local portage
+ rm -f /var/lib/layman/installed.xml && \
+ mkdir -p /usr/local/portage/profiles && \
+ mkdir -p /usr/local/portage/metadata && \
+ echo "masters = gentoo" > /usr/local/portage/metadata/layout.conf && \
+ echo "local" > /usr/local/portage/profiles/repo_name && \
+ bash /etc/portage/scripts/bootstrap/layman_reinit.sh && \
+ \
+ # Adjusting for legacy packets
+ rm -f /etc/portage/sets/legacy && \
+ rm -f /etc/portage/package.keywords/skip.keywords && \
+ rm -f /etc/portage/package.keywords/xdeps-perl* && \
+ rm -f /etc/portage/package.keywords/xdeps-firefox* && \
+ bash /etc/portage/scripts/gen-world-sets && \
+ bash /etc/portage/scripts/bootstrap/fix_deps.sh
+
+CMD ["bash"]
diff --git a/builder/Dockerfile b/builder/Dockerfile
new file mode 100644
index 0000000..898cfd3
--- /dev/null
+++ b/builder/Dockerfile
@@ -0,0 +1,9 @@
+FROM chsa/gbootstrap
+
+RUN \
+ cd /darklin/gentoo && git pull && \
+ cd /darklin/darklin4 && git pull && \
+ emerge --sync && eix-sync && \
+ emerge -1 portage
+
+CMD ["/bin/bash", "/etc/portage/scripts/bootstrap/builder.sh"]