Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitf3ab982835fd995711ca5fda2c441d1fb1ef4666 (patch)
Author
 Syndamia <kamen@syndamia.com>
2026-07-20 21:20:17 +0300
Committer
 Syndamia <kamen@syndamia.com>
2026-07-20 21:20:17 +0300
Filesae47adce60bda40074280514a3720a6d4c305fcd
uniconfx-f3ab982835fd995711ca5fda2c441d1fb1ef4666.tar
uniconfx-f3ab982835fd995711ca5fda2c441d1fb1ef4666.tar.gz
uniconfx-f3ab982835fd995711ca5fda2c441d1fb1ef4666.zip
Parentd516a98eba3e9bf180beeda00148a86c4297b2ed (diff)
wip: Initial idea
5 files changed, 192 insertions, 0 deletions
-rwxr-xr-xUniConfX.sh140
-rwxr-xr-xXpath15
-rw-r--r--std/builder/builder.ucx25
-rw-r--r--std/builder/builder_rust.ucx6
-rw-r--r--test.ucx6
diff --git a/UniConfX.sh b/UniConfX.sh
new file mode 100755
index 0000000..0ccb9d0
--- /dev/null
+++ b/UniConfX.sh
@@ -0,0 +1,140 @@
+#!/bin/sh
+
+: ${UCX_PATH:=$(pwd)/std}
+export UCX_PATH
+
+case "$1" in
+ (help)
+ echo "UniConfX.sh ACTION FILE"
+ exit 0
+esac
+
+UCX_FILE="$(realpath $2)"
+
+# 0) Prepare work directory
+WORKDIR="/tmp/ucx_$$"
+mkdir -p "$WORKDIR/execution/usr/share/bin"
+cp Xpath "$WORKDIR/execution/usr/share/bin"
+export PATH="$PATH:$WORKDIR/execution/usr/share/bin"
+cd "$WORKDIR/execution"
+
+# cp -L /bin/sh /usr/bin/env $(command -v find) $(command -v awk) ./bin
+# cp -L $(command -v git) $(command -v git-receive-pack) $(command -v git-shell) $(command -v git-upload-archive) $(command -v git-upload-pack) $(command -v git-http-backend) ./bin
+# cp -rL /lib /lib64 .
+#
+# if command -v ldd >/dev/null 2>&1
+# then
+# while read -r f
+# do
+# deps="$(ldd "./$f" 2>/dev/null | awk '$3~/\/lib\//{print$3}')"
+# [ -n "$deps" ] && cp -Lf $deps ./lib
+# deps="$(ldd "./$f" 2>/dev/null | awk '$3~/\/lib64\//{print$3}')"
+# [ -n "$deps" ] && cp -Lf $deps ./lib64
+# done <<LIBS
+# $(find . -type f)
+# LIBS
+# fi
+# if command -v patchelf >/dev/null 2>&1
+# then
+# while read -r f
+# do
+# chmod +w $f
+# patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 "$f" 2>/dev/null || continue
+# patchelf --set-rpath /lib:/lib64 "$f" 2>/dev/null || continue
+# done <<LIBS
+# $(find ./bin ./lib -type f)
+# LIBS
+# fi
+if command -v mount >/dev/null 2>&1
+then
+ mkdir bin
+ sudo mount --bind /run/current-system/sw/bin ./bin
+ mkdir lib
+ sudo mount --bind /lib ./lib
+ mkdir lib64
+ sudo mount --bind /lib64 ./lib64
+ mkdir dev
+ sudo mount --bind /dev ./dev
+fi
+
+cd "$WORKDIR"
+echo $WORKDIR
+
+safe_exit() {
+ chmod -R +w ./execution/bin
+ rm -rf "$WORKDIR"
+ exit "$1"
+}
+
+REG_NAME='/^[ \t\v]*name[ \t\v]*:=[ \t\v]*/'
+REG_IMPORT='/^[ \t\v]*import[ \t\v]*:=[ \t\v]*/'
+
+# 0) Get name
+export SELF=$(awk '
+ match($0, '"$REG_NAME"') {
+ name = substr($0, RSTART + RLENGTH)
+ }
+ END {
+ print name
+ }
+' "$UCX_FILE")
+
+# 1) Emplace includes
+cp "$UCX_FILE" "$SELF.ucx"
+until awk '
+ BEGIN {
+ status = 0
+ while ((getline < ARGV[1]) > 0) {
+ if (match($0, '"$REG_IMPORT"')) {
+ status = 1
+ "Xpath " substr($0, RSTART + RLENGTH) | getline imf
+ while ((getline < imf) > 0) {
+ if ($0 !~ '"$REG_NAME"')
+ print
+ }
+ close(imf)
+ }
+ else
+ print
+ }
+ close(ARGV[1])
+ exit status
+ }
+ ' "$SELF.ucx" > temp.ucx
+do
+ mv temp.ucx "$SELF.ucx"
+done
+rm temp.ucx
+
+# 3) Hash
+UCX_HASH="$(cksum "$SELF.ucx" | awk '{print$1}')"
+
+case "$1" in
+ (hash)
+ echo "$UCX_HASH"
+ safe_exit 0
+ ;;
+esac
+
+# 3) Split into components
+mkdir -p ./execution/sections/
+awk '
+ /^#-- / {
+ section = substr($0, 5)
+ if (outf != "")
+ close(outf)
+ outf = "./execution/sections/" ENVIRON["SELF"] "_" section ".ucxs"
+ next
+ }
+ outf != "" {
+ print > outf
+ }
+' "$SELF.ucx"
+
+# 4) Execute
+sudo chroot ./execution /bin/env -i PATH="$PATH:/usr/share/bin" SELF="$SELF" /bin/sh "/sections/${SELF}_do.ucxs" || exit 1
+echo $?
+
+# 5) Install
+
+safe_exit 0
diff --git a/Xpath b/Xpath
new file mode 100755
index 0000000..ee349f4
--- /dev/null
+++ b/Xpath
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+case "$1" in
+ (*.*)
+ f="$(find / -type f -name "$(echo "$1.ucxs" | awk '{sub(/\./,"_");print}')")"
+ [ -f "$f" ] && echo "$f"
+ ;;
+ (*)
+ while read -r dir
+ do
+ find "$dir" -type f -name "$1.ucx" && break
+ done <<PATH
+$(echo "$UCX_PATH" | awk '{gsub(/:/,ORS);print}')
+PATH
+esac
diff --git a/std/builder/builder.ucx b/std/builder/builder.ucx
new file mode 100644
index 0000000..b5e00b0
--- /dev/null
+++ b/std/builder/builder.ucx
@@ -0,0 +1,25 @@
+name := builder
+#-- do
+if [ -f "$(Xpath $SELF.src)" ]
+then
+ while read -r src
+ do
+ case "$src" in
+ (*.git|git:*) git clone $src ;;
+ (*) wget $src
+ esac
+ done <"$(Xpath $SELF.src)"
+fi
+if [ -f "$(Xpath $SELF.build)" ]
+then
+ /bin/sh $(Xpath $SELF.build)
+else
+ make
+fi
+if [ -f "$(Xpath $SELF.install)" ]
+then
+ /bin/sh $(Xpath $SELF.install)
+else
+ mkdir /out
+ PREFIX=/out make install
+fi
diff --git a/std/builder/builder_rust.ucx b/std/builder/builder_rust.ucx
new file mode 100644
index 0000000..3cc5f76
--- /dev/null
+++ b/std/builder/builder_rust.ucx
@@ -0,0 +1,6 @@
+name := builder_rust
+import := builder
+#-- build
+cargo build
+#-- install
+cargo install
diff --git a/test.ucx b/test.ucx
new file mode 100644
index 0000000..bef85aa
--- /dev/null
+++ b/test.ucx
@@ -0,0 +1,6 @@
+name := b
+import := builder_rust
+#-- src
+https://github.com/meta-rust/rust-hello-world.git
+#-- patch
+changes.patch