4000th COMMIT: Add a package manager, xbps

Now you don't have to wait painstakingly long for ports to compile!
This commit is contained in:
2026-08-25 23:51:27 +03:00
parent 59077f0f72
commit 1433657697
8 changed files with 153 additions and 13 deletions
+22 -10
View File
@@ -9,7 +9,7 @@ This is my hobby operating system written in C++. Currently supports x86\_64 and
You can find a live demo [here](https://bananymous.com/banan-os)
If you want to try out DOOM, you should first enter the GUI environment using the `start-gui` command. Then you can run `doom` in the GUI terminal.
![screenshot from qemu running banan-os](assets/banan-os.png)
### Features
@@ -18,6 +18,8 @@ If you want to try out DOOM, you should first enter the GUI environment using th
- [x] SMP (multiprocessing)
- [x] Linear framebuffer (VESA and GOP)
- [x] Network stack
- [x] USB stack
- [x] Audio support
- [x] ELF executable loading
- [x] AML interpreter (partial)
- [x] Basic graphical environment
@@ -27,16 +29,14 @@ If you want to try out DOOM, you should first enter the GUI environment using th
- [ ] Some nice apps
- [x] ELF dynamic linking
- [x] copy-on-write memory
- [x] file mappings
- [ ] anonymous mappings
#### Drivers
- [x] NVMe disks
- [x] ATA (IDE, SATA) disks
- [x] E1000 and E1000E NICs
- [x] RTL8111/8168/8211/8411 NICs
- [x] PS2 keyboard (all scancode sets)
- [x] PS2 mouse
- [x] AC97 and iHDA audio cards
- [x] PS2 keyboard and mouse
- [x] USB
- [x] xHCI
- [ ] EHCI
@@ -46,7 +46,8 @@ If you want to try out DOOM, you should first enter the GUI environment using th
- [x] Mouse
- [x] Mass storage
- [x] Hubs
- [ ] ...
- [ ] Network
- [ ] Audio
- [ ] virtio devices (network, storage)
#### Network
@@ -54,7 +55,7 @@ If you want to try out DOOM, you should first enter the GUI environment using th
- [x] ICMP
- [x] IPv4
- [x] UDP
- [x] TCP (partial and buggy)
- [x] TCP
- [x] Unix domain sockets
- [ ] SSL
@@ -65,7 +66,6 @@ If you want to try out DOOM, you should first enter the GUI environment using th
- [x] Dev
- [x] Ram
- [x] Proc
- [ ] Sys
- [ ] 9P
#### Bootloader support
@@ -73,8 +73,6 @@ If you want to try out DOOM, you should first enter the GUI environment using th
- [x] Custom BIOS bootloader
- [ ] Custom UEFI bootloader
![screenshot from qemu running banan-os](assets/banan-os.png)
## Code structure
Each major component and library has its own subdirectory (kernel, userspace, libc, ...). Each directory contains directory *include*, which has **all** of the header files of the component. Every header is included by its absolute path.
@@ -125,8 +123,22 @@ If you have corrupted your disk image or want to create new one, you can either
./bos image-full
```
To test on real hardware, I have a script to generate a compressed ISO. The ISO can be copied directly to an USB drive with for example `dd`. The file is created at build/banan-os.iso and can be generated with
```sh
./bos iso
```
I have also created shell completion script for zsh. You can either copy the file in _script/shell-completion/zsh/\_bos_ to _/usr/share/zsh/site-functions/_ or add the _script/shell-completion/zsh_ to your fpath in _.zshrc_.
### Package Manager
banan-os uses xbps as its package manager for ports. All upstream ports are packaged into xbps packages hosted on a [repository on my server](https://packages.bananymous.com/banan-os). You can manage sysroot's xbps packages with `./bos` wrapper. You can use `xbps-install`, `xbps-remove` and `xbps-query` with repository and sysroot set to the correct values. For example to install xbps that can be used inside banan-os you can use
```sh
./bos xbps-install -S xbps
```
For xbps usage see [their documentation](https://docs.voidlinux.org/xbps/index.html).
## Contributing
As the upstream is hosted on my server https://git.bananymous.com/Bananymous/banan-os, merging contributions is not as trivial as it would be on GitHub. You can still send PRs in GitHub in which case I should be able to download the diff and apply it manually. If you want, I can also provide you an account to my git server. In this case please contact me ([email](mailto:[email protected]), [discord](https://discord.gg/ehjGySwYdK)).
+2 -2
View File
@@ -301,6 +301,6 @@ if (( $PACKAGE )); then
mkdir -p "$PACKAGE_REPO"
cd "$PACKAGE_REPO"
xbps-create -A "$BANAN_ARCH" -n "${version_string%.*}" -s "$DESCRIPTION" -D "$dependencies" "$package_dir"
xbps-rindex -af "$version_string.xbps"
run_xbps xbps-create -A "$BANAN_ARCH" -n "${version_string%.*}" -s "$DESCRIPTION" -D "$dependencies" "$package_dir"
run_xbps xbps-rindex -af "$version_string.xbps"
fi
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash ../install.sh
NAME='xbps'
VERSION='0.60.7'
DOWNLOAD_URL="https://github.com/void-linux/xbps/archive/refs/tags/$VERSION.tar.gz#ec8c2e4d595863b5748c10d9ada1d51ac1da6f910a9d31682acd1a477310c64e"
DEPENDENCIES=('libarchive' 'openssl')
@@ -0,0 +1,46 @@
diff -ruN xbps-0.60.7/lib/fetch/common.c xbps-0.60.7-banan_os/lib/fetch/common.c
--- xbps-0.60.7/lib/fetch/common.c 2026-02-09 22:23:08.000000000 +0200
+++ xbps-0.60.7-banan_os/lib/fetch/common.c 2026-04-18 14:03:30.521070264 +0300
@@ -163,7 +163,9 @@
fetchLastErrCode = FETCH_TIMEOUT;
break;
case ECONNREFUSED:
+#ifdef EHOSTDOWN
case EHOSTDOWN:
+#endif
fetchLastErrCode = FETCH_DOWN;
break;
default:
diff -ruN xbps-0.60.7/lib/fetch/ftp.c xbps-0.60.7-banan_os/lib/fetch/ftp.c
--- xbps-0.60.7/lib/fetch/ftp.c 2026-02-09 22:23:08.000000000 +0200
+++ xbps-0.60.7-banan_os/lib/fetch/ftp.c 2026-04-18 14:04:26.685837239 +0300
@@ -138,7 +138,7 @@
sin4->sin_port = port;
sin4->sin_family = AF_INET;
*len = sizeof(struct sockaddr_in);
-#ifndef __linux__
+#if !defined(__linux__) && !defined(__banan_os__)
sin4->sin_len = sizeof(struct sockaddr_in);
#endif
}
@@ -508,7 +508,7 @@
tm.tm_mon--;
tm.tm_year = year - 1900;
tm.tm_isdst = -1;
- t = timegm(&tm);
+ t = mktime(&tm);
if (t == (time_t)-1)
t = time(NULL);
us->mtime = t;
diff -ruN xbps-0.60.7/lib/fetch/http.c xbps-0.60.7-banan_os/lib/fetch/http.c
--- xbps-0.60.7/lib/fetch/http.c 2026-02-09 22:23:08.000000000 +0200
+++ xbps-0.60.7-banan_os/lib/fetch/http.c 2026-04-18 14:03:46.645405420 +0300
@@ -525,7 +525,7 @@
setlocale(LC_TIME, locale);
if (r == NULL)
return (-1);
- *mtime = timegm(&tm);
+ *mtime = mktime(&tm);
return (0);
}
@@ -0,0 +1,6 @@
diff -ruN xbps-0.60.7/data/repod-main.conf xbps-0.60.7-banan_os/data/repod-main.conf
--- xbps-0.60.7/data/repod-main.conf 2026-02-09 22:23:08.000000000 +0200
+++ xbps-0.60.7-banan_os/data/repod-main.conf 2026-04-18 14:07:59.005131620 +0300
@@ -1 +1 @@
-repository=https://repo-default.voidlinux.org/current
+repository=https://packages.bananymous.com/banan-os
+24 -1
View File
@@ -35,7 +35,7 @@ build_target () {
echo "No target provided"
exit 1
fi
run_fakeroot $BANAN_CMAKE --build $BANAN_BUILD_DIR -- -j$(nproc) $1
run_fakeroot $BANAN_CMAKE --build $BANAN_BUILD_DIR -- -j$(nproc) "$1"
}
build_toolchain () {
@@ -138,6 +138,29 @@ case $1 in
rm -rf $BANAN_BUILD_DIR
find $BANAN_ROOT_DIR/ports -name '.compile_hash' -exec rm {} +
;;
xbps-*)
command="$1"
shift
build_target all
build_target install
xbps_args=()
case "$command" in
xbps-install|xbps-remove|xbps-query)
xbps_args+=(--rootdir "$BANAN_SYSROOT")
;;
esac
case "$command" in
xbps-install|xbps-query)
xbps_args+=(--repository "$BANAN_XBPS_REPO")
;;
esac
run_xbps "$command" "${xbps_args[@]}" "$@"
;;
*)
build_target $1
;;
+6
View File
@@ -41,3 +41,9 @@ if [[ -z $BANAN_BOOTLOADER ]]; then
fi
export BANAN_CMAKE="$BANAN_TOOLCHAIN_PREFIX/bin/cmake"
run_xbps() {
PATH="$BANAN_TOOLCHAIN_PREFIX/bin:$PATH" LD_LIBRARY_PATH="$BANAN_TOOLCHAIN_PREFIX/lib" "$@"
}
export -f run_xbps
export BANAN_XBPS_REPO='https://packages.bananymous.com/banan-os'
+41
View File
@@ -21,6 +21,10 @@ MESON_VERSION="meson-1.10.0"
MESON_TAR="$MESON_VERSION.tar.gz"
MESON_URL="https://github.com/mesonbuild/meson/releases/download/1.10.0/$MESON_TAR"
XBPS_VERSION="0.60.7"
XBPS_TAR="$XBPS_VERSION.tar.gz"
XBPS_URL="https://github.com/void-linux/xbps/archive/refs/tags/$XBPS_TAR"
if [[ -z $BANAN_SYSROOT ]]; then
echo "You must set the BANAN_SYSROOT environment variable" >&2
exit 1
@@ -230,6 +234,30 @@ build_meson() {
./packaging/create_zipapp.py --outfile "$BANAN_TOOLCHAIN_PREFIX/bin/meson" --interpreter '/usr/bin/env python3'
}
build_xbps() {
cd "$BANAN_BUILD_DIR/toolchain"
if [ ! -d "xbps-$XBPS_VERSION" ]; then
if [ ! -f "$XBPS_TAR" ]; then
echo "Downloading xbps-$XBPS_TAR"
wget "$XBPS_URL"
fi
echo "Unpacking ${XBPS_TAR}"
tar xvf "$XBPS_TAR"
fi
cd "xbps-$XBPS_VERSION"
echo "Building xbps-$XBPS_VERSION"
CFLAGS=-Wno-discarded-qualifiers \
./configure \
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
--dbdir="$BANAN_TOOLCHAIN_PREFIX/db"
make $MAKE_JOBS
make install
}
BUILD_BINUTILS=1
if [[ -f $BANAN_TOOLCHAIN_PREFIX/bin/$BANAN_TOOLCHAIN_TRIPLE-ld ]]; then
echo "You already seem to have a binutils installed."
@@ -283,6 +311,15 @@ if [[ -f $BANAN_TOOLCHAIN_PREFIX/bin/meson ]]; then
fi
fi
BUILD_XBPS=1
if [[ -f $BANAN_TOOLCHAIN_PREFIX/bin/xbps-install ]]; then
echo "You already seem to have a xbps installed."
read -e -p "Do you want to rebuild it [y/N]? " choice
if ! [[ "$choice" == [Yy]* ]]; then
BUILD_XBPS=0
fi
fi
# delete everything but toolchain
mkdir -p $BANAN_BUILD_DIR
find $BANAN_BUILD_DIR -mindepth 1 -maxdepth 1 ! -name toolchain -exec rm -r {} +
@@ -314,6 +351,10 @@ if (($BUILD_MESON)); then
build_meson
fi
if (($BUILD_XBPS)); then
build_xbps
fi
if (($BUILD_LIBSTDCPP)); then
# delete sysroot and install libc
rm -r $BANAN_SYSROOT