Skip to content
This repository has been archived by the owner on Mar 6, 2018. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jprjr committed Nov 2, 2017
0 parents commit c2b927e
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/builds
/chroots
/dist
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: c
compiler: gcc
sudo: required
dist: trusty


install:
- wget -nv -O github-release.amd64.tar.bz2 https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2
- tar xf github-release.amd64.tar.bz2 --strip-components=3
- sudo apt-get update && sudo apt-get install -y qemu-user-static && sudo apt-get install -y binfmt-support

script:
- bash build

after_success:
- bash upload
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#socklog-static

This is just a convenience repo to have a statically-compiled
version of [socklog](http://smarden.org/socklog/) available for
download.

Compiled using a chroot from https://github.com/just-containers/busybox-chroots
88 changes: 88 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env bash
set -e

#assumes you already have
#binfmt-support and
#qemu-user-static installed

BUSYBOX_CHROOT_RELEASE=v1.0.0
BUSYBOX_CHROOT_SRC="https://github.com/just-containers/busybox-chroots/releases/download/${BUSYBOX_CHROOT_RELEASE}"

CHROOTDIR=$(pwd)/chroots
BUILDDIR=$(pwd)/builds
PACKAGEDIR=$(pwd)/pkg
DISTDIR=$(pwd)/dist

mkdir -p "$BUILDDIR"
mkdir -p "$PACKAGEDIR"
mkdir -p "$DISTDIR"
mkdir -p "$CHROOTDIR"

declare -A qemu_targets
qemu_targets[x86_64-linux-musl]=qemu-x86_64-static
qemu_targets[arm-linux-musleabihf]=qemu-arm-static
qemu_targets[arm-linux-musleabi]=qemu-arm-static
qemu_targets[i486-linux-musl]=qemu-i386-static
qemu_targets[aarch64-linux-musl]=qemu-aarch64-static

# target platforms + simplified
# platform
declare -A targets
targets[arm-linux-musleabi]=arm
targets[arm-linux-musleabihf]=armhf
targets[aarch64-linux-musl]=aarch64
targets[x86_64-linux-musl]=amd64
targets[i486-linux-musl]=x86

# software versions
declare -A versions
versions[socklog]=2.1.0

cd "$BUILDDIR"
curl -R -L -O http://smarden.org/socklog/socklog-${versions[socklog]}.tar.gz

for target in "${!targets[@]}"; do
echo "Building socklog for $target..."
mkdir -p "$CHROOTDIR/$target"

curl -R -L -o "$CHROOTDIR/chroot-${targets[$target]}.tar.gz" \
"$BUSYBOX_CHROOT_SRC/chroot-${targets[$target]}.tar.gz"
tar xf "$CHROOTDIR/chroot-${targets[$target]}.tar.gz" -C "$CHROOTDIR/$target"

mkdir -p "$CHROOTDIR/$target/src"
tar xf "$BUILDDIR/socklog-${versions[socklog]}.tar.gz" -C "$CHROOTDIR/$target/src"

echo "/usr/bin/gcc -Wall -Wextra -fPIC -D_GNU_SOURCE -g0 -Os" > "$CHROOTDIR/$target/src/admin/socklog-${versions[socklog]}/src/conf-cc"
echo "/usr/bin/gcc -static -s" > "$CHROOTDIR/$target/src/admin/socklog-${versions[socklog]}/src/conf-ld"
echo "#!/bin/sh" > "$CHROOTDIR/$target/src/compile"
echo "cd /src/admin/socklog-${versions[socklog]} && ./package/compile" >> $CHROOTDIR/$target/src/compile
chmod +x $CHROOTDIR/$target/src/compile

sudo mount -t proc proc $CHROOTDIR/${target}/proc/
sudo mount --rbind /sys $CHROOTDIR/${target}/sys/
sudo mount --rbind /dev $CHROOTDIR/${target}/dev/

cp /usr/bin/${qemu_targets[$target]} $CHROOTDIR/${target}/usr/bin/

sudo env -i /usr/sbin/chroot $CHROOTDIR/${target} /src/compile

mkdir -p $BUILDDIR/${target}/socklog-${versions[socklog]}/usr/bin
mkdir -p $BUILDDIR/${target}/socklog-${versions[socklog]}/usr/share/doc/socklog-${versions[socklog]}

mkdir -p $BUILDDIR/${target}/socklog-${versions[socklog]}/usr/share/man/man8
mkdir -p $BUILDDIR/${target}/socklog-${versions[socklog]}/usr/share/man/man1

cp $CHROOTDIR/${target}/src/admin/socklog-${versions[socklog]}/command/* $BUILDDIR/${target}/socklog-${versions[socklog]}/usr/bin
cp $CHROOTDIR/${target}/src/admin/socklog-${versions[socklog]}/doc/* $BUILDDIR/${target}/socklog-${versions[socklog]}/usr/share/doc/socklog-${versions[socklog]}/
cp $CHROOTDIR/${target}/src/admin/socklog-${versions[socklog]}/man/*.8 $BUILDDIR/${target}/socklog-${versions[socklog]}/usr/share/man/man8/
cp $CHROOTDIR/${target}/src/admin/socklog-${versions[socklog]}/man/*.1 $BUILDDIR/${target}/socklog-${versions[socklog]}/usr/share/man/man1/
cp $CHROOTDIR/${target}/src/admin/socklog-${versions[socklog]}/package/COPYING $BUILDDIR/${target}/socklog-${versions[socklog]}/usr/share/doc/socklog-${versions[socklog]}/

tar -cvzf $DISTDIR/socklog-${versions[socklog]}-linux-${targets[${target}]}.tar.gz \
--owner 0 \
--group 0 \
-C $BUILDDIR/${target}/socklog-${versions[socklog]} .


done

32 changes: 32 additions & 0 deletions upload
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -x

# don't loop if files don't exist
shopt -s nullglob

# exit if TRAVIS_TAG is empty, no need to release anything
if [ -z "${TRAVIS_TAG}" ]; then
exit 0
fi

# get user and repo names
USERNAME=$(echo ${TRAVIS_REPO_SLUG} | cut -d"/" -f1)
REPONAME=$(echo ${TRAVIS_REPO_SLUG} | cut -d"/" -f2)

# release
./github-release release \
--user "${USERNAME}" \
--repo "${REPONAME}" \
--tag "${TRAVIS_TAG}" \
--name "${TRAVIS_TAG}"

# binaries
for i in dist/*.tar.gz; do
name=$(basename ${i})
./github-release upload \
--user "${USERNAME}" \
--repo "${REPONAME}" \
--tag "${TRAVIS_TAG}" \
--name "${name}" \
--file "${i}"
done

0 comments on commit c2b927e

Please sign in to comment.