Initial commit

This commit is contained in:
Mark Vainomaa 2018-11-10 00:42:27 +02:00
commit 3baa648f45
Signed by: mikroskeem
GPG Key ID: 1B3F9523B542D315
18 changed files with 478 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
root/
*.pkg.tar.xz
*-src.*

50
pkgs/build-all.sh Executable file
View File

@ -0,0 +1,50 @@
#!/bin/bash
set -e
TARGET="${1}"
if [ -z "${TARGET}" ]; then
echo "You must specify rootfs where packages should be unpacked"
fi
TARGET="$(realpath "${TARGET}")"
source ./prepare-musl.sh
build_and_install () {
local pkg="${1}"
local ver="$(grep ^pkgver < "${pkg}/build.sh" | sed 's/pkgver="\(.*\)"/\1/')"
pushd "${pkg}" > /dev/null
local pkgfile="$(realpath "./${pkg}-${ver}.pkg.tar.xz")"
if [ ! -f "${pkgfile}" ]; then
echo ">>> Building '${pkg}'"
./build.sh
fi
tar -C "${TARGET}" -xf "${pkgfile}"
popd > /dev/null
}
b () {
build_and_install "${@}"
return "${?}"
}
# Absulutely needed
b filesystem
b musl-libc
b libexecinfo
b mksh
# Networking
b zlib
b libressl
b curl
# Init
b sabotage-kernel-headers
b runit
b eudev

49
pkgs/common.sh Normal file
View File

@ -0,0 +1,49 @@
set -e
check_function () {
if [ ! "$(type -t "${1}")" = "function" ]; then
echo ">>> Function '${1}' is not defined!"
return 1
fi
return 0
}
do_prepare () {
prepare
cd "${wd}"
}
do_build () {
build
cd "${wd}"
}
do_package () {
package
cd "${wd}"
fakeroot tar -C "${pkgdir}" -cf - . | \
xz -9 -T 0 -vvv \
> "${pkgname}-${pkgver}.pkg.tar.xz"
}
[ -z "${pkgname}" ] && ( echo ">>> pkgname is not defined"; exit 1 );
[ -z "${pkgver}" ] && ( echo ">>> pkgver is not defined"; exit 1 );
check_function prepare || exit 1
check_function build || exit 1
check_function package || exit 1
wd="$(pwd)"
srcdir="$(mktemp -d /tmp/buildpkg-src.XXXXXXX)"
pkgdir="$(mktemp -d /tmp/buildpkg-bin.XXXXXXX)"
do_prepare
do_build
do_package
rm -rf "${srcdir}"
rm -rf "${pkgdir}"

38
pkgs/curl/build.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
pkgname="curl"
pkgver="7.62.0"
src="https://curl.haxx.se/download/curl-${pkgver}.tar.gz"
prepare () {
[ -f "${pkgname}-src.tar.gz" ] || curl -o "${pkgname}-src.tar.gz" "${src}"
tar -C "${srcdir}" -xvf "${pkgname}-src.tar.gz"
}
build () {
cd "${srcdir}/curl-${pkgver}"
mkdir build && cd build
../configure \
--prefix=/usr \
--mandir=/usr/share/man \
--with-random=/dev/urandom \
--with-ssl \
--with-zlib \
--enable-versioned-symbols \
--enable-threaded-resolver \
--disable-ldap \
--disable-ldaps
make
}
package () {
cd "${srcdir}/curl-${pkgver}/build"
make DESTDIR="${pkgdir}" install
make DESTDIR="${pkgdir}" install -C scripts
}
. ../common.sh

47
pkgs/eudev/build.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
pkgname="eudev"
pkgver="3.2.7"
src="https://github.com/gentoo/eudev/archive/v${pkgver}.tar.gz"
prepare () {
[ -f "${pkgname}-src.tar.gz" ] || curl -L -o "${pkgname}-src.tar.gz" "${src}"
tar -C "${srcdir}" -xvf "${pkgname}-src.tar.gz"
}
build () {
cd "${srcdir}/eudev-${pkgver}"
./autogen.sh
# Patch defs which aren't in 3.12.6 kernel headers
sed -i 's/KEY_ALS_TOGGLE/0x230/g' src/udev/udev-builtin-input_id.c
mkdir build && cd build
../configure \
--prefix=/usr \
--sysconfdir=/etc \
--disable-blkid \
--disable-mtd_probe \
--disable-kmod \
--disable-selinux
make
}
package () {
cd "${srcdir}/eudev-${pkgver}/build"
make DESTDIR="${pkgdir}" install
# Also bundle runit services
install -d -m 755 "${pkgdir}"/etc
install -d -m 755 "${pkgdir}"/etc/sv
for svc in "${wd}"/sv-service/*; do
cp -p -r "${svc}" "${pkgdir}"/etc/sv/
done
}
. ../common.sh

View File

@ -0,0 +1,2 @@
#!/bin/sh -eu
exec udevadm settle

View File

@ -0,0 +1,5 @@
#!/bin/sh -eu
sv start udevd
/sbin/udevadm trigger --type=subsystems --action=add
/sbin/udevadm trigger --type=devices --action=add
exec sv once .

View File

@ -0,0 +1,2 @@
#!/bin/sh -eu
exec udevadm settle

View File

@ -0,0 +1,2 @@
#!/bin/sh -eu
exec /sbin/udevd

32
pkgs/filesystem/build.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
pkgname="filesystem"
pkgver="0.0.1"
prepare () {
true
}
build () {
true
}
package () {
install -d "${pkgdir}"/dev
install -d "${pkgdir}"/proc
install -d "${pkgdir}"/sys
install -d "${pkgdir}"/etc
install -d "${pkgdir}"/usr
install -d "${pkgdir}"/usr/bin
install -d "${pkgdir}"/usr/sbin
install -d "${pkgdir}"/usr/lib
ln -s /usr/bin "${pkgdir}"/bin
ln -s /usr/bin "${pkgdir}"/sbin
ln -s /usr/bin "${pkgdir}"/usr/sbin
ln -s /usr/lib "${pkgdir}"/lib
}
. ../common.sh

28
pkgs/libexecinfo/build.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
pkgname="libexecinfo"
pkgver="1.1-2"
src="https://github.com/mikroskeem/${pkgname}/archive/1.1-2.tar.gz"
prepare () {
[ -f "${pkgname}-src.tar.gz" ] || curl -L -o "${pkgname}-src.tar.gz" "${src}"
tar -C "${srcdir}" -xvf "${pkgname}-src.tar.gz"
}
build () {
cd "${srcdir}/${pkgname}-${pkgver}"
make \
CC="${CC:-cc}" \
CFLAGS="${CFLAGS} -fno-omit-frame-pointer" \
all
}
package () {
cd "${srcdir}/${pkgname}-${pkgver}"
make DESTDIR="${pkgdir}/usr" install
}
. ../common.sh

29
pkgs/libressl/build.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
pkgname="libressl"
pkgver="2.8.2"
src="https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${pkgver}.tar.gz"
prepare () {
[ -f "${pkgname}-src.tar.gz" ] || curl -o "${pkgname}-src.tar.gz" "${src}"
tar -C "${srcdir}" -xvf "${pkgname}-src.tar.gz"
}
build () {
cd "${srcdir}/libressl-${pkgver}"
mkdir build && cd build
../configure \
--prefix=/usr \
--with-openssldir=/etc/ssl
make
}
package () {
cd "${srcdir}/libressl-${pkgver}/build"
make DESTDIR="${pkgdir}" install
}
. ../common.sh

47
pkgs/mksh/build.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
pkgname="mksh"
pkgver="R56c"
src="http://www.mirbsd.org/MirOS/dist/mir/mksh/${pkgname}-${pkgver}.tgz"
prepare () {
[ -f "${pkgname}-src.tar.gz" ] || curl -o "${pkgname}-src.tar.gz" "${src}"
tar -C "${srcdir}" -xvf "${pkgname}-src.tar.gz"
}
build () {
cd "${srcdir}/mksh"
sh ./Build.sh -j
}
package () {
cd "${srcdir}/mksh"
strip --strip-all mksh
local PREFIX
PREFIX="/usr"
# Create directory structure
install -d "${pkgdir}${PREFIX}"/bin
install -d "${pkgdir}"/usr/share/man/cat1/
install -d "${pkgdir}"/usr/share/man/man1/
install -d "${pkgdir}"/usr/share/doc/mksh/examples/
# Copy files
install -s -m 555 mksh "${pkgdir}${PREFIX}"/bin/mksh
install -m 444 dot.mkshrc "${pkgdir}"/usr/share/doc/mksh/examples/
install -m 444 lksh.cat1 "${pkgdir}"/usr/share/man/cat1/lksh.0
install -m 444 mksh.cat1 "${pkgdir}"/usr/share/man/cat1/mksh.0
install -m 444 lksh.1 "${pkgdir}"/usr/share/man/man1/lksh.1
install -m 444 mksh.1 "${pkgdir}"/usr/share/man/man1/mksh.1
# Symlink /usr/bin/sh to /usr/bin/mksh
ln -s "${PREFIX}"/bin/mksh "${pkgdir}${PREFIX}"/bin/sh
#grep -x "${PREFIX}"/bin/mksh "${pkgdir}"/etc/shells > /dev/null || \
# echo "${PREFIX}"/bin/mksh >> "${pkgdir}"/etc/shells
}
. ../common.sh

32
pkgs/musl-libc/build.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
pkgname="musl-libc"
pkgver="1.1.20"
src="https://www.musl-libc.org/releases/musl-${pkgver}.tar.gz"
prepare () {
[ -f "${pkgname}-src.tar.gz" ] || curl -o "${pkgname}-src.tar.gz" "${src}"
tar -C "${srcdir}" -xvf "${pkgname}-src.tar.gz"
}
build () {
cd "${srcdir}/musl-${pkgver}"
mkdir build && cd build
../configure \
--prefix=/usr
make
}
package () {
cd "${srcdir}/musl-${pkgver}/build"
make DESTDIR="${pkgdir}" install
# Fix mislocated ld-musl-*.so
mv "${pkgdir}"/lib/ld-musl*.so* "${pkgdir}"/usr/lib
rmdir "${pkgdir}"/lib
}
. ../common.sh

3
pkgs/prepare-musl.sh Normal file
View File

@ -0,0 +1,3 @@
export MAKEFLAGS="-j$(grep -c ^processor /proc/cpuinfo)"
export CC="musl-gcc -L\"${TARGET}/usr/lib\" -I\"${TARGET}/usr/include\""
export LDFLAGS="-L\"${TARGET}/usr/lib\""

57
pkgs/runit/build.sh Executable file
View File

@ -0,0 +1,57 @@
#!/bin/bash
pkgname="runit"
pkgver="2.1.2"
src="http://smarden.org/runit/runit-${pkgver}.tar.gz"
prepare () {
[ -f "${pkgname}-src.tar.gz" ] || curl -o "${pkgname}-src.tar.gz" "${src}"
tar -C "${srcdir}" -xvf "${pkgname}-src.tar.gz"
}
build () {
cd "${srcdir}/admin/runit-${pkgver}"
echo "${CC:-gcc} $CFLAGS" > src/conf-cc
echo "${CC:-gcc -s} $LDFLAGS" > src/conf-ld
# Fix quirks
sed -i 's/ -static//g' src/Makefile
sed -i 's#/service#/var&#g' src/sv.c
sed -i 's#/service#/var&#g' etc/debian/3
make -C src
make -C src check
}
package () {
cd "${srcdir}/admin/runit-${pkgver}"
# Oh boy...
install -d -m 755 "${pkgdir}"/etc/runit/runsvdir/pkg-default
install -d -m 755 "${pkgdir}"/etc/runit/runsvdir/all
install -d -m 755 "${pkgdir}"/var
install -m 755 etc/debian/{1,2,3} "${pkgdir}"/etc/runit/
install -m 755 etc/debian/ctrlaltdel "${pkgdir}"/etc/runit/
ln -s ../etc/runit/runsvdir/current "${pkgdir}"/var/service
# Install binaries
install -d -m 755 "${pkgdir}"/usr/bin
for f in $(<package/commands); do
install -s -m 755 "src/${f}" "${pkgdir}"/usr/bin
done
# Symlink runit to /sbin/init
ln -s /usr/bin/runit-init "${pkgdir}"/usr/bin/init
# Manual pages
install -d -m 755 "${pkgdir}"/usr/share/man/man8
install -m 644 man/* "${pkgdir}"/usr/share/man/man8
# Documentation
install -d -m 755 "${pkgdir}"/usr/share/doc/runit
install -m 644 doc/*.html "${pkgdir}"/usr/share/doc/runit
}
. ../common.sh

View File

@ -0,0 +1,23 @@
#!/bin/bash
pkgname="sabotage-kernel-headers"
pkgver="3.12.6-6"
src="https://github.com/sabotage-linux/kernel-headers/archive/v${pkgver}.tar.gz"
prepare () {
[ -f "${pkgname}-src.tar.gz" ] || curl -L -o "${pkgname}-src.tar.gz" "${src}"
tar -C "${srcdir}" -xvf "${pkgname}-src.tar.gz"
}
build () {
cd "${srcdir}/kernel-headers-${pkgver}"
}
package () {
cd "${srcdir}/kernel-headers-${pkgver}"
make ARCH=x86_64 prefix=/usr DESTDIR="${pkgdir}" install
}
. ../common.sh

29
pkgs/zlib/build.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
pkgname="zlib"
pkgver="1.2.11"
src="https://zlib.net/zlib-${pkgver}.tar.gz"
prepare () {
[ -f "${pkgname}-src.tar.gz" ] || curl -o "${pkgname}-src.tar.gz" "${src}"
tar -C "${srcdir}" -xvf "${pkgname}-src.tar.gz"
}
build () {
cd "${srcdir}/${pkgname}-${pkgver}"
mkdir build && cd build
../configure \
--prefix=/usr
make
}
package () {
cd "${srcdir}/${pkgname}-${pkgver}/build"
make DESTDIR="${pkgdir}" install
}
. ../common.sh