Skip to content

Commit

Permalink
feat: initial implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Rynhard <[email protected]>
  • Loading branch information
andrewrynhard committed Jul 12, 2019
1 parent e2983a4 commit b4e3778
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 1 deletion.
80 changes: 80 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
kind: pipeline
name: default

services:
- name: docker
image: docker:19.03.0-rc3-dind
privileged: true
command:
- --dns=8.8.8.8
- --dns=8.8.4.4
- --mtu=1440
volumes:
- name: docker-socket
path: /var/run

steps:
- name: build-pull-request
image: autonomy/build-container:latest
pull: always
commands:
- docker buildx create --driver docker-container --platform linux/amd64 --name local --use
- bldr pack --progress=plain -o autonomy -f pkg.yaml
when:
event:
include:
- pull_request
volumes:
- name: docker-socket
path: /var/run

- name: build-and-publish
image: autonomy/build-container:latest
pull: always
environment:
DOCKER_USERNAME:
from_secret: docker_username
DOCKER_PASSWORD:
from_secret: docker_password
commands:
- docker buildx create --driver docker-container --platform linux/amd64 --name local --use
- docker login --username "$${DOCKER_USERNAME}" --password "$${DOCKER_PASSWORD}"
- bldr pack --progress=plain -o autonomy -f pkg.yaml --push=true --cache-to=autonomy/tools:cache --cache-from=autonomy/tools:cache
when:
event:
exclude:
- pull_request
volumes:
- name: docker-socket
path: /var/run

volumes:
- name: docker-socket
temp: {}
---
kind: pipeline
name: notify

clone:
disable: true

steps:
- name: slack
image: plugins/slack
settings:
webhook:
from_secret: slack_webhook
channel: proj-talos-maint
when:
status:
- success
- failure

trigger:
status:
- success
- failure

depends_on:
- default
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# tools
# tools

This repository produces a set of binaries suitable for building a target Linux distribution.
All binaries are produced with a search path of `/toolchain/lib`, allowing for an independent set of build dependencies.
We recommend using these tools with an adjusted toolchain (produces binaries with standard search paths).

## Resources

- https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html
- https://wiki.osdev.org/Target_Triplet
34 changes: 34 additions & 0 deletions files/adjust.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/toolchain/bin/bash

set -eoux pipefail

export ARCH=$(uname -m)

mv -v /toolchain/bin/{ld,ld-old}
mv -v /toolchain/${ARCH}-linux-musl/bin/{ld,ld-old}
mv -v /toolchain/bin/{ld-new,ld}
ln -sv /toolchain/bin/ld /toolchain/${ARCH}-linux-musl/bin/ld

gcc -dumpspecs | sed -e "s@/toolchain@@g" \
-e '/\*startfile_prefix_spec:/{n;s@.*@/lib/ @}' \
-e '/\*cpp:/{n;s@$@ -isystem /include@}' > `dirname $(gcc --print-libgcc-file-name)`/specs

echo 'int main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib'
grep -o '/lib.*/crt[1in].*succeeded' dummy.log
grep -B1 '^ /include' dummy.log
grep 'SEARCH.*/lib' dummy.log | sed 's|; |\n|g'
grep "/lib/libc.so succeeded" dummy.log
rm -v dummy.c a.out dummy.log

# # Ensure that `make menuconfig` works for the kernel build.

# mkdir -p /usr/lib/pkgconfig
# ln -s /toolchain/include /usr/include

# for lib in ncurses form panel menu ; do
# rm -vf /lib/lib${lib}.so
# echo "INPUT(-l${lib}w)" > /lib/lib${lib}.so
# ln -sfv ${lib}w.pc /lib/pkgconfig/${lib}.pc
# done
31 changes: 31 additions & 0 deletions files/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/toolchain/bin/bash

function remove_symlinks() {
set +e
for l in $(find ${PREFIX} -type l); do
readlink $l | grep -q /toolchain
if [ $? == 0 ]; then
echo "Unlinking $l"
unlink $l
fi
done
set -e
}

PREFIX="${1}"

remove_symlinks
find ${PREFIX} -type f -name \*.a -print0 | xargs -0 rm -rf || true
find ${PREFIX} -type f -name \*.la -print0 | xargs -0 rm -rf || true
find ${PREFIX}/lib ${PREFIX}/usr/lib -type f \( -name \*.so* -a ! -name \*dbg \) -exec strip --strip-unneeded {} ';' || true
find ${PREFIX}/{bin,sbin} -type f -exec strip --strip-all {} ';' || true

rm -rvf \
${PREFIX}/lib/gconv/ \
${PREFIX}/lib/pkgconfig/ \
${PREFIX}/include/* \
${PREFIX}/share/* \
${PREFIX}/usr/include/* \
${PREFIX}/usr/share/* \
${PREFIX}/usr/libexec/getconf \
${PREFIX}/var/db
15 changes: 15 additions & 0 deletions files/symlink.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

PREFIX="${1}"

mkdir -p ${PREFIX}/usr/share
mkdir -p ${PREFIX}/usr/local/share

paths=( /etc/pki /usr/share/ca-certificates /usr/local/share/ca-certificates /etc/ca-certificates )
for d in "${paths[@]}"; do
ln -sv /etc/ssl/certs ${PREFIX}$d
done

mkdir -p ${PREFIX}/usr/libexec
mkdir -p ${PREFIX}/var/libexec/kubernetes
ln -sv ../../var/libexec/kubernetes ${PREFIX}/usr/libexec/kubernetes
60 changes: 60 additions & 0 deletions pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: tools
dependencies:
- image: docker.io/autonomy/toolchain:d1f6110
- image: docker.io/autonomy/argp-standalone:d99eb22
- image: docker.io/autonomy/autoconf:1d0a25e
- image: docker.io/autonomy/automake:5295745
- image: docker.io/autonomy/bash:48e85fc
- image: docker.io/autonomy/bc:1b24e89
- image: docker.io/autonomy/bison:f20f464
- image: docker.io/autonomy/bzip2:33106f0
- image: docker.io/autonomy/ca-certificates:c6fe138
- image: docker.io/autonomy/coreutils:2352c24
- image: docker.io/autonomy/cpio:08e31a9
- image: docker.io/autonomy/curl:014afb9
- image: docker.io/autonomy/dejagnu:9fc0ca4
- image: docker.io/autonomy/diffutils:766467f
- image: docker.io/autonomy/dtc:e29b7d2
- image: docker.io/autonomy/elfutils:0cd38dd
- image: docker.io/autonomy/expect:ca819e8
- image: docker.io/autonomy/file:8f37283
- image: docker.io/autonomy/findutils:be63c60
- image: docker.io/autonomy/flex:801265d
- image: docker.io/autonomy/gawk:23f4cfd
- image: docker.io/autonomy/gettext:156b4b0
- image: docker.io/autonomy/git:6495ae8
- image: docker.io/autonomy/golang:1221a45
- image: docker.io/autonomy/gperf:d1539d2
- image: docker.io/autonomy/grep:b4a238a
- image: docker.io/autonomy/gzip:3c4f1fd
- image: docker.io/autonomy/kmod:c16f871
- image: docker.io/autonomy/libressl:3db5cb9
- image: docker.io/autonomy/libtool:79f0104
- image: docker.io/autonomy/m4:c53d3d8
- image: docker.io/autonomy/make:1604c6a
- image: docker.io/autonomy/musl-fts:d02ec7a
- image: docker.io/autonomy/musl-obstack:36661cd
- image: docker.io/autonomy/ncurses:5f50a89
- image: docker.io/autonomy/patch:6756342
- image: docker.io/autonomy/pcre:e1b790f
- image: docker.io/autonomy/perl:9f0dd58
- image: docker.io/autonomy/pkg-config:60373d8
- image: docker.io/autonomy/protobuf:80c22ab
- image: docker.io/autonomy/protoc-gen-go:93b480c
- image: docker.io/autonomy/python2:98564e5
- image: docker.io/autonomy/sed:662ead7
- image: docker.io/autonomy/swig:35efcf9
- image: docker.io/autonomy/tar:0791718
- image: docker.io/autonomy/tcl:648e1d6
- image: docker.io/autonomy/texinfo:8a099b2
- image: docker.io/autonomy/util-linux:59112f5
- image: docker.io/autonomy/xz:9e880b7
- image: docker.io/autonomy/zlib:4e1cd1f
finalize:
- from: /toolchain
to: /toolchain
variant: scratch
shell: /toolchain/bin/bash
steps:
- prepare: |
cp /pkg/files/adjust.sh ${TOOLCHAIN}/bin

0 comments on commit b4e3778

Please sign in to comment.