commit 3714ba6
hovercats
·
2025-05-20 23:06:02 +0000 UTC
parent 3714ba6
init
A
LICENSE
+21,
-0
1@@ -0,0 +1,21 @@
2+MIT License
3+
4+Copyright (c) 2025 Cats that hovers
5+
6+Permission is hereby granted, free of charge, to any person obtaining a copy
7+of this software and associated documentation files (the "Software"), to deal
8+in the Software without restriction, including without limitation the rights
9+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+copies of the Software, and to permit persons to whom the Software is
11+furnished to do so, subject to the following conditions:
12+
13+The above copyright notice and this permission notice shall be included in all
14+copies or substantial portions of the Software.
15+
16+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+SOFTWARE.
A
README
+34,
-0
1@@ -0,0 +1,34 @@
2+rcpm
3+----
4+
5+A simple package manager written in plan9's rc[1] shell.
6+
7+Taking notes from kiss'[1] ease of packaging, and some of Oasis'[3] git
8+features we landed here.
9+
10+Its designed to work in conjunction with Oasis, thus packages built is supposed
11+to be merged into /, similarly to Oasis.
12+However, there should be nothing agaist using this outside of this aswell.
13+
14+Still very much WIP, so use at your own risk.
15+
16+Layout
17+------
18+$pkg/
19+ build
20+ src (if using submodule)
21+ sha256 (not present if using submodule)
22+ url (not if using submodule)
23+ ver
24+
25+Requirements
26+------------
27+- rc (Most implementations should work)
28+- POSIX utilities
29+- git
30+- pax
31+
32+
33+[1] http://doc.cat-v.org/plan_9/2nd_edition/papers/rc
34+[2] https://github.com/dylanaraps/kiss
35+[3] https://github.com/oasislinux/oasis
A
rcpm
+130,
-0
1@@ -0,0 +1,130 @@
2+#!/bin/rc
3+
4+flag e +
5+
6+# This will eventually get removed
7+RCPM_PATH=$PWD/repo
8+RCPM_CACHE=$HOME/var/rcpm/bin
9+RCPM_DB=/var/db/rcpm
10+ROOTFS_REPO=/tmp/fs
11+
12+if (~ $#RCPM_PATH 0) {
13+ printf 'RCPM_PATH is not set\n'
14+ exit 1
15+}
16+
17+fn rcpm_help {
18+ printf 'Usage: rcpm b|c|d|h|s\n'
19+}
20+
21+fn dl_pkg {
22+ cd $RCPM_PATH/$pkg
23+ curl -LK url -O
24+}
25+
26+fn chksum_pkg {
27+ cd $RCPM_PATH/$pkg
28+ if (! sha256sum -c sha256) dl_pkg
29+ sha256sum -c sha256
30+}
31+
32+fn unpack_pkg {
33+ for (archive in `{awk '{print $2}' sha256}) {
34+ switch($archive) {
35+ case *.gz
36+ tool=gzip
37+ case *.xz
38+ tool=xz
39+ case *.bz2
40+ tool=bz2
41+ case *
42+ exit 1
43+ }
44+ $tool -dc $archive | pax -r -s ',^[^/]*,src,'
45+ }
46+}
47+
48+fn get_ver {
49+ version=`{cat ../ver}
50+ ver=$version(1)
51+ rev=$version(2)
52+
53+}
54+fn packup_pkg {
55+ test -d $RCPM_CACHE || mkdir -p $RCPM_CACHE
56+ pax -w . | gzip > $RCPM_CACHE/$pkg@$ver-$rev.tar.gz
57+}
58+
59+fn create_worktree {
60+ if (test ! -d $ROOTFS_REPO/.git/worktrees/$pkg) {
61+ test -d $RCPM_DB || doas mkdir -p $RCPM_DB
62+ doas git -C $ROOTFS_REPO worktree add --orphan $RCPM_DB/$pkg
63+ doas git -C $RCPM_DB/$pkg symbolic-ref HEAD refs/heads/$pkg
64+ doas git -C $ROOTFS_REPO config --add branch.master.merge $pkg
65+ }
66+ if not {printf 'Worktree exists\n'}
67+}
68+
69+fn merge_pkg {
70+ doas git -C $ROOTFS_REPO config --add branch.master.merge $pkg
71+ doas git -C $ROOTFS_REPO merge $pkg --allow-unrelated --no-edit
72+}
73+
74+fn check_pkgbuilt {
75+ if (test ! -f $RCPM_DB/$pkg@$ver-$rev.tar.gz) {
76+ printf %s $pkg is not built\n
77+ exit 1
78+ }
79+}
80+
81+fn pkg_install {
82+ create_worktree
83+ cd $RCPM_DB/$pkg
84+ gzip -dc $RCPM_CACHE/$pkg@$ver-$rev.tar.gz | doas pax -r
85+ doas git add .
86+ echo $pkg@$ver-$rev | doas git commit '--file=-'
87+ merge_pkg
88+
89+}
90+
91+fn pkg_build {
92+ for (pkg) {
93+ cd $RCPM_PATH/$pkg
94+ if (test ! -f url) git submodule update --init --checkout src
95+ if not {
96+ chksum_pkg $pkg
97+ rm -rf src
98+ unpack_pkg $archive
99+ }
100+ cd src
101+ destdir=/tmp/$pid/$pkg
102+ ../build
103+ get_ver
104+ cd $destdir
105+ packup_pkg
106+ pkg_install
107+ }
108+}
109+
110+switch($1) {
111+ case b
112+ shift
113+ pkg_build $*
114+ case c
115+ shift
116+ for (pkg) chksum_pkg $pkg
117+ case d
118+ shift
119+ for (pkg) dl_pkg $pkg
120+ case h
121+ rcpm_help
122+ exit 0
123+ case i
124+ exit 0
125+ case s
126+ shift
127+ for (pkg in $*) find $RCPM_PATH -type d -name $pkg
128+ case *
129+ printf 'Error!\n'
130+ exit 1
131+}