diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-09-30 23:35:07 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-09-30 23:35:07 -0400 |
commit | 031bc1627fdc38d1c178707c86dd267224b94693 (patch) | |
tree | 9e44e7bfd24da233e0b950892f48932bdde37618 | |
download | spm-031bc1627fdc38d1c178707c86dd267224b94693.tar.gz |
Initial commit
33 files changed, 1454 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..54ddeaf --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +pkgs/ +tmp/ +*/*/buildroot +*/*/root +*/*/runtime diff --git a/include/9999-template.sh b/include/9999-template.sh new file mode 100644 index 0000000..9577ee7 --- /dev/null +++ b/include/9999-template.sh @@ -0,0 +1,20 @@ +#!/bin/bash +name= +version= +revision=0 +sources=() +depends=() + +function prepare() { + : +} + +function build() { + : +} + +function package() { + : +} + + diff --git a/scripts/autoconf/build.sh b/scripts/autoconf/build.sh new file mode 100644 index 0000000..09c4f72 --- /dev/null +++ b/scripts/autoconf/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash +name=autoconf +version=2.69 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.xz" +) +depends=( + "m4-1.4.18-0.tar.gz" +) + + +function prepare() { + tar xf ${name}-${version}.tar.xz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/automake/build.sh b/scripts/automake/build.sh new file mode 100644 index 0000000..9fe23b7 --- /dev/null +++ b/scripts/automake/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash +name=automake +version=1.16 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.xz" +) +depends=( + "autoconf-2.69-0.tar.gz" +) + + +function prepare() { + tar xf ${name}-${version}.tar.xz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/base/build.sh b/scripts/base/build.sh new file mode 100644 index 0000000..02306da --- /dev/null +++ b/scripts/base/build.sh @@ -0,0 +1,68 @@ +#!/bin/bash +name=base +version=1.0.0 +revision=0 +sources=() +depends=( + # development tools + "autoconf" + "automake" + "m4" + # file manipulation + "diffutils" + "findutils" + "grep" + "sed" + # archivers + "tar" + # compression + "bzip2" + "gzip" + "xz" + "zlib" + # terminal + "ncurses" + "readline" + # web + "curl" +) + +function prepare() { + : +} + +function build() { + : +} + +function package() { + dest="${destdir}/${prefix}" + schema=( + bin + etc + lib + libexec + sbin + tmp + var/cache + var/db + var/empty + var/games + var/local + var/log + var/lock + var/lib + var/opt + var/run + var/tmp + ) + mkdir -p "${dest}" + pushd "${dest}" + for d in "${schema[@]}"; do + mkdir -p "${d}" + chmod 0755 "${d}" + done + ln -sf lib lib64 + popd + +} diff --git a/scripts/bison/build.sh b/scripts/bison/build.sh new file mode 100644 index 0000000..115374e --- /dev/null +++ b/scripts/bison/build.sh @@ -0,0 +1,24 @@ +#!/bin/bash +name=bison +version=3.4.2 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.xz" +) +depends=( + "m4" +) + +function prepare() { + tar xf ${name}-${version}.tar.xz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/build.order b/scripts/build.order new file mode 100644 index 0000000..3b101e0 --- /dev/null +++ b/scripts/build.order @@ -0,0 +1,26 @@ +m4 +autoconf +automake +grep +sed +bzip2 +xz +zlib +gzip +tar +pcre +diffutils +findutils +bison +gdbm +libffi +ncurses +readline +openssl +curl +sqlite +tcl +tk +python +python-setuptools +python-pip diff --git a/scripts/bzip2/build.sh b/scripts/bzip2/build.sh new file mode 100644 index 0000000..6ee43c3 --- /dev/null +++ b/scripts/bzip2/build.sh @@ -0,0 +1,38 @@ +#!/bin/bash +name=bzip2 +version=1.0.8 +revision=0 +sources=( + https://sourceware.org/pub/bzip2/${name}-${version}.tar.gz +) +depends=() + + +function prepare() { + tar xf ${name}-${version}.tar.gz + cd ${name}-${version} +} + +function build() { + make -f Makefile-libbz2_so CC="gcc $CFLAGS $LDFLAGS" + make bzip2 bzip2recover CC="gcc $CFLAGS $LDFLAGS" +} + +function package() { + mkdir -p "$destdir" + install -dm755 "$destdir"/{bin,lib,include,share/man/man1} + install -m755 bzip2-shared "$destdir"/bin/bzip2 + install -m755 bzip2recover bzdiff bzgrep bzmore "$destdir"/bin + ln -sf bzip2 "$destdir"/bin/bunzip2 + ln -sf bzip2 "$destdir"/bin/bzcat + cp -a libbz2.so* "$destdir"/lib + ln -s libbz2.so.${version} "$destdir"/lib/libbz2.so + ln -s libbz2.so.${version} "$destdir"/lib/libbz2.so.1 + install -m644 bzlib.h "$destdir"/include + install -m644 bzip2.1 "$destdir"/share/man/man1 + ln -sf bzip2.1 "$destdir"/share/man/man1/bunzip2.1 + ln -sf bzip2.1 "$destdir"/share/man/man1/bzcat.1 + ln -sf bzip2.1 "$destdir"/share/man/man1/bzip2recover.1 +} + + diff --git a/scripts/curl/build.sh b/scripts/curl/build.sh new file mode 100644 index 0000000..91ef02f --- /dev/null +++ b/scripts/curl/build.sh @@ -0,0 +1,26 @@ +#!/bin/bash +name=curl +version=7.66.0 +revision=0 +sources=( + "https://curl.haxx.se/download/${name}-${version}.tar.xz" +) +depends=( + "libffi-3.2.1-0.tar.gz" + "openssl-1.1.1d-0.tar.gz" +) + + +function prepare() { + tar xf ${name}-${version}.tar.xz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/diffutils/build.sh b/scripts/diffutils/build.sh new file mode 100644 index 0000000..de85ab9 --- /dev/null +++ b/scripts/diffutils/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash +name=diffutils +version=3.7 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.xz" +) +depends=() + + +function prepare() { + tar xf ${name}-${version}.tar.xz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/findutils/build.sh b/scripts/findutils/build.sh new file mode 100644 index 0000000..5429b88 --- /dev/null +++ b/scripts/findutils/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash +name=findutils +version=4.7.0 +revision=0 +sources=( + "https://ftp.gnu.org/gnu/${name}/${name}-${version}.tar.xz" +) +depends=() + + +function prepare() { + tar xf ${name}-${version}.tar.xz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} + + diff --git a/scripts/gdbm/build.sh b/scripts/gdbm/build.sh new file mode 100644 index 0000000..30f65e4 --- /dev/null +++ b/scripts/gdbm/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash +name=gdbm +version=1.18.1 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.gz" +) +depends=() + + +function prepare() { + tar xf ${name}-${version}.tar.gz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix --enable-libgdbm-compat + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/grep/build.sh b/scripts/grep/build.sh new file mode 100644 index 0000000..7d396d9 --- /dev/null +++ b/scripts/grep/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash +name=grep +version=3.3 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.xz" +) +depends=() + + +function prepare() { + tar xf ${name}-${version}.tar.xz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/gzip/build.sh b/scripts/gzip/build.sh new file mode 100644 index 0000000..686ac5f --- /dev/null +++ b/scripts/gzip/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash +name=gzip +version=1.10 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.xz" +) +depends=( + "grep-3.3-0.tar.gz" + "sed-4.7-0.tar.gz" +) + +function prepare() { + tar xf ${name}-${version}.tar.xz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/libffi/build.sh b/scripts/libffi/build.sh new file mode 100644 index 0000000..7ac8bfa --- /dev/null +++ b/scripts/libffi/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash +name=libffi +version=3.2.1 +revision=0 +sources=( + ftp://sourceware.org/pub/libffi/${name}-${version}.tar.gz +) +depends=() + + +function prepare() { + tar xf ${name}-${version}.tar.gz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix --enable-pax_emutramp + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/libuuid/build.sh b/scripts/libuuid/build.sh new file mode 100644 index 0000000..dea7aaf --- /dev/null +++ b/scripts/libuuid/build.sh @@ -0,0 +1,29 @@ +#!/bin/bash +name=libuuid +version=2.34 +revision=0 +sources=( + "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.34/util-linux-2.34.tar.xz" + "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v${version}/util-linux-${version}.tar.xz" +) +depends=() + + +function prepare() { + tar xf util-linux-${version}.tar.xz + cd util-linux-${version} +} + +function build() { + ./configure --prefix=$prefix \ + --disable-all-programs \ + --enable-libuuid \ + --without-systemd \ + --without-btrf + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" + rm -r "${destdir}/${prefix}/sbin" +} diff --git a/scripts/m4/build.sh b/scripts/m4/build.sh new file mode 100644 index 0000000..c5a5388 --- /dev/null +++ b/scripts/m4/build.sh @@ -0,0 +1,24 @@ +#!/bin/bash +name=m4 +version=1.4.18 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.xz" +) +depends=( +) + +function prepare() { + tar xf ${name}-${version}.tar.xz + cd ${name}-${version} + patch -p1 -i ${build_script_root}/"m4-1.4.18-glibc-change-work-around.patch" +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/m4/m4-1.4.18-glibc-change-work-around.patch b/scripts/m4/m4-1.4.18-glibc-change-work-around.patch new file mode 100644 index 0000000..582ae9b --- /dev/null +++ b/scripts/m4/m4-1.4.18-glibc-change-work-around.patch @@ -0,0 +1,115 @@ +diff -up m4-1.4.18/lib/fflush.c.orig m4-1.4.18/lib/fflush.c +--- m4-1.4.18/lib/fflush.c.orig 2018-05-02 12:35:59.536851666 +0200 ++++ m4-1.4.18/lib/fflush.c 2018-05-02 12:37:02.768958606 +0200 +@@ -33,7 +33,7 @@ + #undef fflush + + +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + + /* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */ + static void +@@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp) + + #endif + +-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */) ++#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */) + + # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */ +@@ -148,7 +148,7 @@ rpl_fflush (FILE *stream) + if (stream == NULL || ! freading (stream)) + return fflush (stream); + +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + + clear_ungetc_buffer_preserving_position (stream); + +diff -up m4-1.4.18/lib/fpending.c.orig m4-1.4.18/lib/fpending.c +--- m4-1.4.18/lib/fpending.c.orig 2018-05-02 12:35:32.305806774 +0200 ++++ m4-1.4.18/lib/fpending.c 2018-05-02 12:35:44.944827347 +0200 +@@ -32,7 +32,7 @@ __fpending (FILE *fp) + /* Most systems provide FILE as a struct and the necessary bitmask in + <stdio.h>, because they need it for implementing getc() and putc() as + fast macros. */ +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + return fp->_IO_write_ptr - fp->_IO_write_base; + #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */ +diff -up m4-1.4.18/lib/fpurge.c.orig m4-1.4.18/lib/fpurge.c +--- m4-1.4.18/lib/fpurge.c.orig 2018-05-02 12:38:13.586078669 +0200 ++++ m4-1.4.18/lib/fpurge.c 2018-05-02 12:38:38.785121867 +0200 +@@ -62,7 +62,7 @@ fpurge (FILE *fp) + /* Most systems provide FILE as a struct and the necessary bitmask in + <stdio.h>, because they need it for implementing getc() and putc() as + fast macros. */ +-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + fp->_IO_read_end = fp->_IO_read_ptr; + fp->_IO_write_ptr = fp->_IO_write_base; + /* Avoid memory leak when there is an active ungetc buffer. */ +diff -up m4-1.4.18/lib/freadahead.c.orig m4-1.4.18/lib/freadahead.c +--- m4-1.4.18/lib/freadahead.c.orig 2016-12-31 14:54:41.000000000 +0100 ++++ m4-1.4.18/lib/freadahead.c 2018-05-02 11:43:19.570336724 +0200 +@@ -25,7 +25,7 @@ + size_t + freadahead (FILE *fp) + { +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + if (fp->_IO_write_ptr > fp->_IO_write_base) + return 0; + return (fp->_IO_read_end - fp->_IO_read_ptr) +diff -up m4-1.4.18/lib/freading.c.orig m4-1.4.18/lib/freading.c +--- m4-1.4.18/lib/freading.c.orig 2018-05-02 12:37:33.970011368 +0200 ++++ m4-1.4.18/lib/freading.c 2018-05-02 12:37:59.393054359 +0200 +@@ -31,7 +31,7 @@ freading (FILE *fp) + /* Most systems provide FILE as a struct and the necessary bitmask in + <stdio.h>, because they need it for implementing getc() and putc() as + fast macros. */ +-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + return ((fp->_flags & _IO_NO_WRITES) != 0 + || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0 + && fp->_IO_read_base != NULL)); +diff -up m4-1.4.18/lib/fseeko.c.orig m4-1.4.18/lib/fseeko.c +--- m4-1.4.18/lib/fseeko.c.orig 2018-05-02 11:44:17.947460233 +0200 ++++ m4-1.4.18/lib/fseeko.c 2018-05-02 12:39:49.537216897 +0200 +@@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int when + #endif + + /* These tests are based on fpurge.c. */ +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + if (fp->_IO_read_end == fp->_IO_read_ptr + && fp->_IO_write_ptr == fp->_IO_write_base + && fp->_IO_save_base == NULL) +@@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int when + return -1; + } + +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + fp->_flags &= ~_IO_EOF_SEEN; + fp->_offset = pos; + #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ +diff -up m4-1.4.18/lib/stdio-impl.h.orig m4-1.4.18/lib/stdio-impl.h +--- m4-1.4.18/lib/stdio-impl.h.orig 2016-12-31 14:54:42.000000000 +0100 ++++ m4-1.4.18/lib/stdio-impl.h 2018-05-02 11:43:19.570336724 +0200 +@@ -18,6 +18,12 @@ + the same implementation of stdio extension API, except that some fields + have different naming conventions, or their access requires some casts. */ + ++/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this ++ problem by defining it ourselves. FIXME: Do not rely on glibc ++ internals. */ ++#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN ++# define _IO_IN_BACKUP 0x100 ++#endif + + /* BSD stdio derived implementations. */ + diff --git a/scripts/ncurses/build.sh b/scripts/ncurses/build.sh new file mode 100644 index 0000000..e4b6a55 --- /dev/null +++ b/scripts/ncurses/build.sh @@ -0,0 +1,32 @@ +#!/bin/bash +name=ncurses +version=6.1 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.gz" +) +depends=() + + +function prepare() { + tar xf ${name}-${version}.tar.gz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix \ + --with-shared \ + --with-normal \ + --without-debug \ + --without-ada \ + --enable-widec \ + --enable-pc-files \ + --with-cxx-bindings \ + --with-cxx-shared \ + --with-manpage-format=normal + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/openssl/build.sh b/scripts/openssl/build.sh new file mode 100644 index 0000000..a996f1e --- /dev/null +++ b/scripts/openssl/build.sh @@ -0,0 +1,41 @@ +#!/bin/bash +name=openssl +version=1.1.1d +revision=0 +sources=( + "https://www.openssl.org/source/${name}-${version}.tar.gz" +) +depends=( + "zlib-1.2.11-0.tar.gz" +) + + +function prepare() { + tar xf ${name}-${version}.tar.gz + cd ${name}-${version} +} + +function build() { + export KERNEL_BITS=64 + export TARGET=linux-x86_64 + #mkdir -p ${build_runtime}/lib + ./Configure \ + --prefix="$prefix" \ + --openssldir="$prefix/etc/ssl" \ + shared \ + threads \ + zlib-dynamic \ + no-ssl3-method \ + ${TARGET} + + #mkdir -p ${prefix}/{bin,lib,share} + make -j${maxjobs} +} + +function package() { + make \ + DESTDIR="${destdir}" \ + MANDIR=${prefix}/share/man \ + MANSUFFIX=ssl \ + install +} diff --git a/scripts/pcre/build.sh b/scripts/pcre/build.sh new file mode 100644 index 0000000..92f2a37 --- /dev/null +++ b/scripts/pcre/build.sh @@ -0,0 +1,34 @@ +#!/bin/bash +name=pcre +version=8.43 +revision=0 +sources=( + "https://ftp.pcre.org/pub/${name}/${name}-${version}.tar.gz" +) +depends=( + "bzip2" + "readline" + "zlib" +) + +function prepare() { + tar xf ${name}-${version}.tar.gz + cd ${name}-${version} +} + +function build() { + ./configure \ + --prefix=${prefix} \ + --enable-unicode-properties \ + --enable-pcre16 \ + --enable-pcre32 \ + --enable-jit \ + --enable-pcregrep-libz \ + --enable-pcregrep-libbz2 \ + --enable-pcretest-readline + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/python-pip/build.sh b/scripts/python-pip/build.sh new file mode 100644 index 0000000..e2ba34c --- /dev/null +++ b/scripts/python-pip/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash +name=python-pip +version=19.2.3 +revision=0 +sources=(https://github.com/pypa/${name/python-/}/archive/${version}.tar.gz) +depends=( + 'python-3' + 'python-setuptools' +) + +function prepare() { + tar xf ${version}.tar.gz + cd ${name/python-/}-${version} +} + +function package() { + python setup.py install --root="${destdir}" --prefix="${prefix}" + #find ${destdir} -type f | xargs sed -i -e "s|${build_runtime}|${prefix}|g" +} diff --git a/scripts/python-setuptools/build.sh b/scripts/python-setuptools/build.sh new file mode 100644 index 0000000..cc903a7 --- /dev/null +++ b/scripts/python-setuptools/build.sh @@ -0,0 +1,17 @@ +#!/bin/bash +name=python-setuptools +version=41.2.0 +revision=0 +sources=(https://github.com/pypa/setuptools/archive/v${version}.tar.gz) +depends=('python-3') + +function prepare() { + tar xf v${version}.tar.gz + cd ${name/python-/}-${version} +} + +function package() { + python bootstrap.py + python setup.py install --root="${destdir}" --prefix="${prefix}" + #find ${destdir} -type f | xargs -I'{}' sed -i -e "s|${build_runtime}|${prefix}|g" '{}' +} diff --git a/scripts/python/build.sh b/scripts/python/build.sh new file mode 100644 index 0000000..7bc3b37 --- /dev/null +++ b/scripts/python/build.sh @@ -0,0 +1,60 @@ +#!/bin/bash +name=python +version=3.7.4 +_basever=${version%.*} +revision=0 +sources=( + "https://www.python.org/ftp/python/${version}/Python-${version}.tar.xz" +) +depends=( + "tar-1.32-0.tar.gz" + "openssl-1.1.1d-0.tar.gz" + "libffi-3.2.1-0.tar.gz" + "grep-3.3-0.tar.gz" + "sed-4.7-0.tar.gz" + "sqlite-3.29.0-0.tar.gz" + "zlib-1.2.11-0.tar.gz" + "tcl-8.6.9-0.tar.gz" + "tk-8.6.9-0.tar.gz" +) + + +function prepare() { + tar xf Python-${version}.tar.xz + cd Python-${version} +} + +function build() { + + zlib="zlib zlibmodule.c ${CFLAGS} ${LDFLAGS} -lz" + echo "${zlib/=/ } >> Modules/Setup" + + ./configure \ + --prefix="${prefix}" \ + --enable-ipv6 \ + --enable-loadable-sqlite-extensions \ + --enable-shared \ + --with-computed-gotos \ + --with-lto \ + --with-dbmliborder=gdbm:ndbm \ + --with-pymalloc \ + --with-system-expat \ + --with-system-ffi \ + --without-ensurepip + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" + echo "Removing __pycache__ directories..." + find "${destdir}" -name "__pycache__" | xargs rm -rf + + ln -s python3 "${destdir}/${prefix}"/bin/python + ln -s python3-config "${destdir}/${prefix}"/bin/python-config + ln -s idle3 "${destdir}/${prefix}"/bin/idle + ln -s pydoc3 "${destdir}/${prefix}"/bin/pydoc + ln -s python${_basever}.1 "${destdir}/${prefix}"/share/man/man1/python.1 + chmod 755 "${destdir}/${prefix}"/lib/libpython${_basever}m.so +} + + diff --git a/scripts/readline/build.sh b/scripts/readline/build.sh new file mode 100644 index 0000000..45db38e --- /dev/null +++ b/scripts/readline/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash +name=readline +version=8.0 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.gz" +) +depends=() + + +function prepare() { + tar xf ${name}-${version}.tar.gz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} SHLIB_LIBS=-lncurses +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/sed/build.sh b/scripts/sed/build.sh new file mode 100644 index 0000000..5042713 --- /dev/null +++ b/scripts/sed/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash +name=sed +version=4.7 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.xz" +) +depends=("grep-3.3-0.tar.gz") + + +function prepare() { + tar xf ${name}-${version}.tar.xz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/sqlite/build.sh b/scripts/sqlite/build.sh new file mode 100644 index 0000000..3683f0f --- /dev/null +++ b/scripts/sqlite/build.sh @@ -0,0 +1,24 @@ +#!/bin/bash +name=sqlite +version=3.29.0 +_v=3290000 +revision=0 +sources=( + "https://sqlite.org/2019/${name}-autoconf-${_v}.tar.gz" +) +depends=() + + +function prepare() { + tar xf ${name}-autoconf-${_v}.tar.gz + cd ${name}-autoconf-${_v} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} diff --git a/scripts/tar/build.sh b/scripts/tar/build.sh new file mode 100644 index 0000000..12cd3e6 --- /dev/null +++ b/scripts/tar/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash +name=tar +version=1.32 +revision=0 +sources=( + "http://mirror.rit.edu/gnu/${name}/${name}-${version}.tar.xz" +) +depends=() + + +function prepare() { + tar xf ${name}-${version}.tar.xz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} + + diff --git a/scripts/tcl/build.sh b/scripts/tcl/build.sh new file mode 100644 index 0000000..6fa40c2 --- /dev/null +++ b/scripts/tcl/build.sh @@ -0,0 +1,30 @@ +#!/bin/bash +name=tcl +version=8.6.9 +revision=0 +sources=( + "https://prdownloads.sourceforge.net/${name}/${name}${version}-src.tar.gz" +) +depends=( + "bzip2-1.0.8-0.tar.gz" + "grep-3.3-0.tar.gz" + "sed-4.7-0.tar.gz" + "pcre-8.43-0.tar.gz" + "zlib-1.2.11-0.tar.gz" +) + +function prepare() { + tar xf ${name}${version}-src.tar.gz + cd ${name}${version} +} + +function build() { + cd unix + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" + chmod 755 "${destdir}/${prefix}"/lib/*.so +} diff --git a/scripts/tk/build.sh b/scripts/tk/build.sh new file mode 100644 index 0000000..9515c27 --- /dev/null +++ b/scripts/tk/build.sh @@ -0,0 +1,30 @@ +#!/bin/bash +name=tk +version=8.6.9 +version_full="${version}.1" +revision=0 +sources=( + "https://prdownloads.sourceforge.net/tcl/${name}${version_full}-src.tar.gz" +) +depends=( + "grep-3.3-0.tar.gz" + "sed-4.7-0.tar.gz" + "zlib-1.2.11-0.tar.gz" + "tcl-${version}-0.tar.gz" +) + +function prepare() { + tar xf ${name}${version_full}-src.tar.gz + cd ${name}${version} +} + +function build() { + cd unix + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" + chmod 755 "${destdir}/${prefix}"/lib/*.so +} diff --git a/scripts/xz/build.sh b/scripts/xz/build.sh new file mode 100644 index 0000000..ea31bdc --- /dev/null +++ b/scripts/xz/build.sh @@ -0,0 +1,28 @@ +#!/bin/bash +name=xz +version=5.2.4 +revision=0 +sources=( + "https://tukaani.org/xz/${name}-${version}.tar.gz" +) +depends=( + "sed-4.7-0.tar.gz" + "grep-3.3-0.tar.gz" +) + + +function prepare() { + tar xf ${name}-${version}.tar.gz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} + + diff --git a/scripts/zlib/build.sh b/scripts/zlib/build.sh new file mode 100644 index 0000000..fd46e1f --- /dev/null +++ b/scripts/zlib/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash +name=zlib +version=1.2.11 +revision=0 +sources=( + "http://zlib.net/${name}-${version}.tar.gz" +) +depends=() + + +function prepare() { + tar xf ${name}-${version}.tar.gz + cd ${name}-${version} +} + +function build() { + ./configure --prefix=$prefix + make -j${maxjobs} +} + +function package() { + make install DESTDIR="${destdir}" +} + + @@ -0,0 +1,476 @@ +#!/bin/bash +TMPDIR=${TMPDIR:-/tmp} + +default_script=build.sh +build_order=scripts/build.order + +build_scripts=$(cat ${build_order}) + +# TODO: Make this part of MKTC +SPM_PROG_RELOC=$HOME/Documents/work/reloc/reloc +SPM_PREFIX_BIN=.SPM_PREFIX_BIN +SPM_PREFIX_TEXT=.SPM_PREFIX_TEXT +SPM_DEPENDS=.SPM_DEPENDS +SPM_VERBOSE=0 + +export prefix_placeholder=_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_ +export prefix="/${prefix_placeholder}" +export maxjobs=7 +export pkgdir=$(pwd)/pkgs +mkdir -p ${pkgdir} +source include/9999-template.sh + + +function spm_abspath() { + local filename="${1}" + local start="$(dirname ${filename})" + + pushd "${start}" &>/dev/null + end="$(pwd)" + popd &>/dev/null + + if [[ -f ${filename} ]]; then + end="${end}/$(basename ${filename})" + fi + + echo "${end}" +} + + +function spm_rpath_nearest() { + local cwd="$(pwd)" + local start=$(dirname $(spm_abspath ${1})) + local result= + + # Jump to location of file + cd "$(dirname ${start})" + + # Scan upward until we find a "lib" directory + # OR when: + # - Top of filesystem is reached (pretty much total failure [missing local dep]) + # - Top of active environment is reached (post installation) + # - Top of default installation prefix is reached (during packaging) + while [[ $(pwd) != / ]] + do + result+="../" + if [[ -d lib ]] || [[ $(pwd) == ${SPM_ENV} ]] || [[ $(pwd) == *${prefix} ]]; then + result+="lib" + break + fi + cd .. + done + + # Sanitize: removing double-slashes (if any) + result=${result/\/\//\/} + + # Return to where we were instantiated + cd "${cwd}" + + echo "${result}" +} + +function spm_gen_package_rpath() { + local rpath_orig + local rpath_new + + # Assimilate all file paths that contain an RPATH + for path in $(find . -type f -not -name '.SPM-*') + do + readelf -d "${path}" 2>/dev/null | grep RPATH &>/dev/null + if (( $? )); then + continue + fi + rpath_orig="$(readelf -d "${path}" | grep RPATH | awk -F'[][]' '{ print $2 }')" + rpath_new='$ORIGIN/'"$(spm_rpath_nearest ${path})" + echo "${path}: ${rpath_orig} -> ${rpath_new}" + patchelf --set-rpath "${rpath_new}" "${path}" + done +} + +function spm_gen_package_prefixes() { + echo "Generating build prefix manifest" + # Create record files + >${SPM_PREFIX_BIN} + >${SPM_PREFIX_TEXT} + + # Assimilate file path for anything containing our prefix + local count_text=0 + local count_bin=0 + local count_total=0 + local prefixes=( + ${prefix} + ${build_runtime} + ${build_root} + ${destdir} + ) + + for pkg_prefix in "${prefixes[@]}"; do + for path in $(find . -type f -not -name ".SPM_*"); do + # Check for prefix + grep -l "${pkg_prefix}" "${path}" &>/dev/null + + # Prefix present? (0: yes, 1: no) + if (( $? )); then + continue + fi + + # Get file type + local mimetype="$(file -i ${path} | awk -F': ' '{ print $2 }')" + local outfile + + # Record prefix data + if [[ ${mimetype} = *text/* ]]; then + outfile=${SPM_PREFIX_TEXT} + (( count_text++ )) + else + outfile=${SPM_PREFIX_BIN} + (( count_bin++ )) + fi + + echo "#${prefix}" >> "${outfile}" + echo "${path}" >> "${outfile}" + + done + done + + count_total=$(( count_text + count_bin )) + if (( ${count_total} )); then + echo "Text: ${count_text}" + echo "Binary: ${count_bin}" + echo "Total: ${count_total}" + else + echo "No prefixes detected" + fi +} + + +function spm_gen_package_depends() { + echo "Generating dependency manifest" + local outfile="${SPM_DEPENDS}" + >${outfile} + + for dep in "${depends[@]}"; do + echo "${dep}" >> "${outfile}" + done +} + + +_spm_install_depends=() +_spm_install_seen=() +function spm_install() { + local pkg="$(pkg_match $1)" + if [[ ! -f ${pkg} ]]; then + echo "Package not found: ${pkg}" >&2 + exit 1 + fi + + local destroot="$2" + if [[ -z ${destroot} ]]; then + echo "destination root undefined" >&2 + exit 1 + elif [[ ! -d ${destroot} ]]; then + mkdir -p "${destroot}" + fi + + # extract package into temp directory + local pkgtmp=$(mktemp -d ${TMPDIR}/spm.XXXX) + pushd "${pkgtmp}" &>/dev/null + echo "Unpacking: ${pkg}" + tar xf "${pkg}" + + local prefix_base + + # relocate binaries + if [[ -f ${SPM_PREFIX_BIN} ]]; then + while read path; do + if [[ -z $path ]]; then + continue + elif [[ $path =~ ^# ]]; then + if [[ -z $path ]]; then + continue; + fi + prefix_base="${path#\#}" + continue + fi + + if [[ ! -f $path ]]; then + echo "WARNING: ${path} does not exist!" >&2 + continue + fi + + if (( $SPM_VERBOSE )); then + if [[ $path =~ .pyc$ ]]; then + continue + fi + echo "Relocating binary paths: ${path}" + fi + ${SPM_PROG_RELOC} "${prefix_base}" "${destroot}" "${path}" 1>/dev/null + done <<< $(cat "${SPM_PREFIX_BIN}") + rm -f ${SPM_PREFIX_BIN} + fi + prefix_base="" + + # relocate text + if [[ -f ${SPM_PREFIX_TEXT} ]]; then + while read path; do + if [[ -z $path ]]; then + continue + elif [[ $path =~ ^# ]]; then + if [[ -z $path ]]; then + continue; + fi + prefix_base="${path#\#}" + continue + fi + + if [[ ! -f $path ]]; then + echo "WARNING: ${path} does not exist!" >&2 + continue + fi + if (( $SPM_VERBOSE )); then + if [[ $path =~ .pyc$ ]]; then + continue + fi + echo "Relocating text paths: ${path}" + fi + sed -i -e "s|${prefix_base}|${destroot}|g" "${path}" + done <<< $(cat "${SPM_PREFIX_TEXT}") + rm -f ${SPM_PREFIX_TEXT} + fi + + # service package dependencies + if [[ -f ${SPM_DEPENDS} ]]; then + if [[ -z ${_spm_install_depends} ]]; then + _spm_install_depends=($(cat ${SPM_DEPENDS})) + else + _spm_install_depends+=($(cat ${SPM_DEPENDS})) + fi + + for dep in "${_spm_install_depends[@]}"; do + # Track dependencies we have already processed to avoid infinite recursion + if [[ "${_spm_install_seen[@]}" =~ "$dep" ]]; then + # Pop dependency and do nothing + _spm_install_depends=("${_spm_install_depends[@]:1}") + continue + fi + + # Pop dependency and process it + _spm_install_depends=("${_spm_install_depends[@]:1}") + + # Stop processing when the array is totally empty + if (( ${#_spm_install_depends[@]} < 0 )); then + break + fi + + _spm_install_seen+=("${dep}") + spm_install "${dep}" "${destroot}" + done + rm -f "${SPM_DEPENDS}" + fi + + # install package + echo "Installing: ${pkg}" + rsync -a ./ "${destroot}" + + popd &>/dev/null + if [[ -d $pkgtmp ]]; then + rm -rf "${pkgtmp}" + fi +} + + +function builder() { + for build_script in ${build_scripts}; do + build_script=$(readlink -f scripts/$build_script/build.sh) + build_script_root=$(dirname ${build_script}) + export build_root="${build_script_root}/buildroot" + export build_runtime="${build_script_root}/runtime" + export destdir="${build_script_root}/root" + + export CC=gcc + export CXX=g++ + export LD_LIBRARY_PATH="${build_runtime}/lib" + export CFLAGS="-I${build_runtime}/include" + export CPPFLAGS="${CFLAGS}" + export LDFLAGS="-L${build_runtime}/lib -Wl,-rpath="'\$$ORIGIN'"/../lib" + + echo "Building: ${build_script}" + + if [[ ! -f ${build_script} ]]; then + echo "${build_script} does not exist, check ${build_order}" >&2 + exit 1 + fi + + if [[ -d ${build_root} ]]; then + rm -rf ${build_root} + fi + mkdir -p ${build_root} + + if [[ -d ${build_runtime} ]]; then + rm -rf ${build_runtime} + fi + mkdir -p ${build_runtime} + + if [[ -d ${destdir} ]]; then + rm -rf ${destdir} + fi + mkdir -p ${destdir} + + export PATH="${build_runtime}/bin:${build_runtime}/sbin:$PATH" + export PKG_CONFIG_PATH="${build_runtime}/lib/pkgconfig" + + pushd ${build_root} &>/dev/null + source ${build_script} + for url in "${sources[@]}"; do + if [[ -f $(basename $url) ]]; then + continue + fi + echo "Downloading source: ${url}" + curl -LO $url + done + + for dep in "${depends[@]}"; do + echo "Depends on: ${dep}" + pkg=$(basename $(pkg_match "${dep}")) + spm_install "${pkg}" "${build_runtime}" + done + hash -r + + set -e + prepare + build + package + set +e + + if [[ -d ${destdir} ]]; then + pushd ${destdir} &>/dev/null + if [[ -d ${destdir}/${prefix} ]]; then + pushd ${destdir}/${prefix} &>/dev/null + fi + spm_gen_package_rpath + spm_gen_package_prefixes + spm_gen_package_depends + + pkg="${pkgdir}/${name}-${version}-${revision}.tar.gz" + echo "Creating package: ${pkg}" + pwd + ls -la + tar cfz "${pkg}" .SPM_* . + + if [[ -d ${destdir}/${prefix} ]]; then + popd &>/dev/null + fi + popd &>/dev/null + fi + popd &>/dev/null + done +} + +function pkg_match() { + if [[ -z $1 ]]; then + echo "pkg_match: missing argument, package" >&2 + exit 1 + fi + match=$(find "${pkgdir}" -type f -regex ".*/${1}\-?[0-9]+?.*" 2>/dev/null | sort | head -n 1) + echo "${match}" +} + +function installer() { + local root="" + local packages=() + + while [[ $# != 0 ]]; do + case "$1" in + --verbose|-v) + SPM_VERBOSE=1 + ;; + --root|-r) + root="$2" + shift + ;; + -*|--*) + echo "installer: unknown argument: $1" >&2 + exit 1 + ;; + *) + # "Most-likely" match the requested package by name + p=$(basename $(pkg_match "${1}")) + packages+=("$p") + ;; + esac + shift + done + + if [[ -z $root ]]; then + echo "missing required argument: --root {destination}" >&2 + exit 1 + fi + + export PATH="${root}/bin:${PATH}" + for pkg in "${packages[@]}"; do + spm_install "${pkg}" "${root}" + done +} + +function usage() { +echo "Usage: $0 [build|install] {package} + +Options: + --help (-h) this message + --verbose (-v) increase verbosity + +Commands: + build build a package + install install a package + +Positional arguments: + package package to interact with + +" +} + + +if [[ $# < 2 ]]; then + usage + exit 1 +fi + +fn= +args= +while [[ $# != 0 ]]; do + case "$1" in + --verbose|-v) + SPM_VERBOSE=1 + ;; + --help|-h) + usage + exit 0 + ;; + build) + fn=builder + if [[ $2 != "all" ]]; then + build_scripts="$2" + if [[ $build_scripts =~ .*/build.sh ]]; then + build_scripts=$(dirname ${build_scripts}) + fi + fi + shift 2 + break + ;; + + install) + fn=installer + shift + args=("$@") + break + ;; + + *) + echo "unknown argument: $1" + exit 1 + ;; + esac + shift +done + +$fn "${args[@]}" |