ports: Add a port system
The only port right now is bc, which works... kind of. It compiles, and runs, but is really janky. At least it runs!!
This commit is contained in:
parent
865018e7f8
commit
1a82bbb234
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,3 +11,6 @@ tests/**/bin/**
|
||||
base/usr/include/**
|
||||
base/usr/lib/**
|
||||
**/*.a
|
||||
ports/**/workdir/**
|
||||
ports/ports.list
|
||||
**/*.pkg.tar.xz
|
1
Makefile
1
Makefile
@ -23,3 +23,4 @@ install:
|
||||
@$(MAKE) -C kernel install
|
||||
@$(MAKE) -C libs install
|
||||
@$(MAKE) -C apps install
|
||||
@tools/install-built-ports.sh
|
96
ports/add-port.sh
Executable file
96
ports/add-port.sh
Executable file
@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
source tools/env.sh
|
||||
|
||||
cd ports
|
||||
|
||||
export DESTDIR=${DESTDIR:-"$LUNA_ROOT/initrd"}
|
||||
|
||||
export listdir=$PWD
|
||||
|
||||
if [ -z $1 ]
|
||||
then
|
||||
echo "Usage: add-port.sh <port-name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d $1 ]
|
||||
then
|
||||
pkgscript=$1/package.sh
|
||||
elif [ -f $1 ]
|
||||
then
|
||||
pkgscript=$1
|
||||
else
|
||||
echo "Unrecognized argument: $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export portdir=$(realpath $(dirname $pkgscript))
|
||||
export workdir=$portdir/workdir
|
||||
mkdir -p $workdir
|
||||
|
||||
source $pkgscript
|
||||
|
||||
echo "Building $pkgname version $pkgver..."
|
||||
|
||||
cd $workdir
|
||||
|
||||
if ! [ -d $srcdir ]
|
||||
then
|
||||
mkdir -p $setupdir
|
||||
cd $setupdir
|
||||
|
||||
echo "Downloading $pkgname version $pkgver..."
|
||||
|
||||
case $pkgmode in
|
||||
"web") wget $pkgurl;;
|
||||
"git") git clone $pkgurl;;
|
||||
*) echo "Don't know how to download package mode '$pkgmode'"; exit 1;;
|
||||
esac
|
||||
|
||||
command -v port_unpack >/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
echo "Unpacking $pkgname version $pkgver..."
|
||||
port_unpack
|
||||
fi
|
||||
|
||||
command -v port_patch >/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
echo "Patching $pkgname version $pkgver..."
|
||||
port_patch
|
||||
fi
|
||||
fi
|
||||
|
||||
cd $workdir
|
||||
|
||||
mkdir -p $builddir
|
||||
cd $builddir
|
||||
|
||||
command -v port_configure >/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
echo "Configuring $pkgname version $pkgver..."
|
||||
port_configure
|
||||
fi
|
||||
|
||||
echo "Making $pkgname version $pkgver..."
|
||||
port_build # this one is required
|
||||
|
||||
cd $workdir
|
||||
|
||||
mkdir -p $installdir
|
||||
cd $installdir
|
||||
|
||||
echo "Installing $pkgname version $pkgver..."
|
||||
port_install
|
||||
|
||||
echo "$pkgname" >> $listdir/ports.list
|
||||
cat $listdir/ports.list | sort | uniq | tee $listdir/ports.list >/dev/null # avoid duplicates
|
||||
|
||||
echo "Success! Registered port: $pkgname version $pkgver."
|
69
ports/bc/bc.patch
Normal file
69
ports/bc/bc.patch
Normal file
@ -0,0 +1,69 @@
|
||||
diff --color -rN -u bc-vanilla/include/library.h bc-6.0.4/include/library.h
|
||||
--- a/bc-6.0.4/include/library.h 2022-09-26 19:34:34.000000000 +0200
|
||||
+++ b/bc-6.0.4/include/library.h 2022-10-15 14:59:11.413415573 +0200
|
||||
@@ -36,7 +36,7 @@
|
||||
#ifndef LIBBC_PRIVATE_H
|
||||
#define LIBBC_PRIVATE_H
|
||||
|
||||
-#ifndef _WIN32
|
||||
+#if !defined(_WIN32) && !defined(__luna__)
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -236,13 +236,17 @@
|
||||
BcVm*
|
||||
bcl_getspecific(void);
|
||||
|
||||
-#ifndef _WIN32
|
||||
+#if !defined(_WIN32) && !defined(__luna__)
|
||||
|
||||
typedef pthread_key_t BclTls;
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
+#ifdef __luna__
|
||||
+typedef int BclTls;
|
||||
+#else
|
||||
typedef DWORD BclTls;
|
||||
+#endif
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
diff --color -rN -u bc-vanilla/src/vm.c bc-6.0.4/src/vm.c
|
||||
--- a/bc-6.0.4/src/vm.c 2022-09-26 19:34:35.000000000 +0200
|
||||
+++ b/bc-6.0.4/src/vm.c 2022-10-21 17:29:13.511229371 +0200
|
||||
@@ -49,7 +49,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
-#else // _WIN32
|
||||
+#else
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
@@ -193,7 +193,7 @@
|
||||
static void
|
||||
bc_vm_sigaction(void)
|
||||
{
|
||||
-#ifndef _WIN32
|
||||
+#if !defined(_WIN32) && !defined(__luna__)
|
||||
|
||||
struct sigaction sa;
|
||||
|
||||
@@ -223,11 +223,15 @@
|
||||
if (BC_TTY) sigaction(SIGHUP, &sa, NULL);
|
||||
#endif // BC_ENABLE_HISTORY
|
||||
|
||||
-#else // _WIN32
|
||||
+#else
|
||||
+
|
||||
+#ifndef __luna__
|
||||
|
||||
signal(SIGTERM, bc_vm_sig);
|
||||
signal(SIGINT, bc_vm_sig);
|
||||
|
||||
+#endif
|
||||
+
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
40
ports/bc/package.sh
Normal file
40
ports/bc/package.sh
Normal file
@ -0,0 +1,40 @@
|
||||
pkgname="bc"
|
||||
pkgver="6.0.4"
|
||||
pkgurl="https://github.com/gavinhoward/bc/releases/download/$pkgver/bc-$pkgver.tar.gz"
|
||||
|
||||
pkgmode="web"
|
||||
|
||||
setupdir="$workdir"
|
||||
builddir="$workdir/build"
|
||||
installdir="$workdir/build"
|
||||
srcdir="$workdir/bc-$pkgver"
|
||||
|
||||
port_unpack()
|
||||
{
|
||||
tar xvf bc-$pkgver.tar.gz
|
||||
}
|
||||
|
||||
port_patch()
|
||||
{
|
||||
patch -u -i $portdir/bc.patch -p 1 -d $workdir
|
||||
}
|
||||
|
||||
port_configure()
|
||||
{
|
||||
HOSTCC=gcc PREFIX=${PREFIX:-""} $workdir/bc-$pkgver/configure --disable-nls --bc-only --disable-history --disable-man-pages
|
||||
}
|
||||
|
||||
port_build()
|
||||
{
|
||||
make
|
||||
}
|
||||
|
||||
port_install()
|
||||
{
|
||||
make install
|
||||
}
|
||||
|
||||
port_uninstall()
|
||||
{
|
||||
make uninstall
|
||||
}
|
23
ports/make-package.sh
Executable file
23
ports/make-package.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
source $(dirname $0)/../tools/env.sh
|
||||
|
||||
source $LUNA_ROOT/ports/$1/package.sh
|
||||
|
||||
mkdir $PWD/pkgroot
|
||||
|
||||
DESTDIR=$PWD/pkgroot $LUNA_ROOT/ports/add-port.sh $pkgname
|
||||
|
||||
cd pkgroot
|
||||
|
||||
tar cJf ../$pkgname-$pkgver.pkg.tar.xz *
|
||||
|
||||
cd ..
|
||||
|
||||
DESTDIR=$PWD/pkgroot $LUNA_ROOT/ports/remove-port.sh $pkgname
|
||||
|
||||
rm -rf $PWD/pkgroot
|
||||
|
||||
echo "Built package $pkgname-$pkgver.pkg.tar.xz"
|
44
ports/remove-port.sh
Executable file
44
ports/remove-port.sh
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
source tools/env.sh
|
||||
|
||||
cd ports
|
||||
|
||||
export listdir=$PWD
|
||||
|
||||
if [ -z $1 ]
|
||||
then
|
||||
echo "Usage: remove-port.sh <port-name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d $1 ]
|
||||
then
|
||||
pkgscript=$1/package.sh
|
||||
elif [ -f $1 ]
|
||||
then
|
||||
pkgscript=$1
|
||||
else
|
||||
echo "Unrecognized argument: $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export portdir=$(realpath $(dirname $pkgscript))
|
||||
export workdir=$portdir/workdir
|
||||
mkdir -p $workdir
|
||||
|
||||
source $pkgscript
|
||||
|
||||
echo "Removing $pkgname version $pkgver..."
|
||||
|
||||
cd $installdir
|
||||
port_uninstall
|
||||
|
||||
rm -rf $workdir
|
||||
cat $listdir/ports.list | sort | uniq | grep -v $pkgname | tee $listdir/ports.list >/dev/null
|
||||
|
||||
echo "Success! Removed port: $pkgname version $pkgver."
|
27
tools/install-built-ports.sh
Executable file
27
tools/install-built-ports.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
source $(dirname $0)/env.sh
|
||||
|
||||
cd $LUNA_ROOT/ports
|
||||
|
||||
if ! [ -f ./ports.list ]
|
||||
then
|
||||
echo "No ports built."
|
||||
fi
|
||||
|
||||
install_port()
|
||||
{
|
||||
export portdir=$PWD/$1
|
||||
export workdir=$portdir/workdir
|
||||
source $portdir/package.sh
|
||||
echo "installing port: $pkgname version $pkgver"
|
||||
mkdir -p $installdir
|
||||
cd $installdir
|
||||
port_install
|
||||
}
|
||||
|
||||
while read package; do
|
||||
install_port $package
|
||||
done < ./ports.list
|
Loading…
Reference in New Issue
Block a user