├── .gitattributes ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── makefile ├── ports ├── convenience │ ├── README.txt │ ├── kdiskmark │ │ ├── pkgfile │ │ └── sources │ ├── teamviewer │ │ ├── pkgfile │ │ └── sources │ └── wootility │ │ ├── pkgfile │ │ └── sources ├── dev │ ├── neovim │ │ ├── pkgfile │ │ └── sources │ └── shellcheck │ │ ├── pkgfile │ │ └── sources ├── fonts │ ├── fonts-cozette │ │ ├── pkgfile │ │ └── sources │ ├── fonts-cursed │ │ ├── pkgfile │ │ └── sources │ └── fonts-uushi │ │ ├── pkgfile │ │ └── sources ├── media │ ├── apple-music-desktop │ │ ├── pkgfile │ │ ├── res │ │ │ ├── apple-music-desktop.desktop │ │ │ └── apple-music-desktop.png │ │ └── sources │ ├── deezer-desktop │ │ ├── pkgfile │ │ └── sources │ ├── dzr │ │ ├── pkgfile │ │ └── sources │ ├── feishin │ │ ├── pkgfile │ │ └── sources │ ├── spotify-tui │ │ ├── pkgfile │ │ └── sources │ └── spotifyd │ │ ├── pkgfile │ │ └── sources ├── meta │ └── @cfg │ │ ├── cfg │ │ ├── autotools.cfg │ │ └── build.cfg │ │ ├── pkgfile │ │ └── sources ├── misc │ ├── exa │ │ ├── pkgfile │ │ └── sources │ ├── fff │ │ ├── pkgfile │ │ └── sources │ ├── tree │ │ ├── pkgfile │ │ └── sources │ └── unzip │ │ ├── pkgfile │ │ └── sources ├── network │ └── sshpass │ │ ├── pkgfile │ │ └── sources ├── rice │ ├── lolcat │ │ ├── pkgfile │ │ └── sources │ ├── neofetch │ │ ├── pkgfile │ │ └── sources │ ├── pfetch │ │ ├── pkgfile │ │ └── sources │ └── skroll │ │ ├── pkgfile │ │ └── sources ├── security │ └── pash │ │ ├── pkgfile │ │ └── sources ├── system │ ├── balena │ │ ├── pkgfile │ │ └── sources │ ├── gotop │ │ ├── pkgfile │ │ └── sources │ └── oksh │ │ ├── pkgfile │ │ └── sources └── xorg │ ├── bdftopcf │ ├── pkgfile │ └── sources │ ├── color │ ├── pkgfile │ └── sources │ └── xdimmer │ ├── pkgfile │ └── sources └── src ├── add ├── build ├── del ├── link ├── main ├── ports └── util /.gitattributes: -------------------------------------------------------------------------------- 1 | ports/*/*/*.pkgfile linguist-language=shell 2 | src/* linguist-language=shell 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bonsai.db 2 | bonsai.rc 3 | bonsai 4 | 5 | test 6 | testing 7 | 8 | a.out 9 | *~* 10 | *bkup* 11 | *.bk 12 | 13 | *rootfs.gz 14 | *isolinux.bin 15 | *isolinux.cfg 16 | 17 | musl-ports 18 | broken 19 | BROKEN 20 | tmp 21 | wip 22 | WIP 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # ----- all: 2 | # SC1090: file sourcing - shellcheck is unaware of sourced pkgfiles 3 | # SC2154: undeclared vars - shellcheck is unaware vars inside pkgfiles 4 | # SC2120: unused arguments - shellcheck is unaware of pkgfile function calls 5 | # SC2295: Expansions with '#' - shellcheck thinks "#" which we are using as 6 | # package version delimiter isn't taken literally 7 | # ----- portfiles only: 8 | # SC2034: unused variables - shellcheck is unaware of pkgfile vars use 9 | # SC2016: expressions in single quotes don't expand - often in sed calls within pkgfiles (intentional) 10 | # SC2086: word splitting - this is used often, intentionally, in pkgfiles 11 | # SC2209: shellcheck thinks "deps=sed" for example is a misuse of command output. 12 | # SC2164: 'use || exit in case cd fails' -- only used when will never fail 13 | script: 14 | - make 15 | - shellcheck -s sh -e 1090 -e 2154 -e 2120 -e 2295 bonsai 16 | - shellcheck -s sh -e 1090 -e 2154 -e 2034 -e 2016 -e 2086 -e 2209 -e 2164 ports/*/*/pkgfile 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 Mitch Weaver 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bonsai 2 | 3 | ``` 4 | # -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/- # 5 | # # 6 | # ,####, # 7 | # #######, ,#####, # 8 | # #####',# '###### # 9 | # ''###'';,,,'###' # 10 | # ,; '''' # 11 | # ;;; ,#####, # 12 | # ;;;' ,,;;;### # 13 | # ';;;;'''####' # 14 | # ;;; # 15 | # ,.;;';'',,, # 16 | # # ' ' # 17 | # # O # 18 | # ##, ,##,',##, ,## ,#, , # 19 | # # # # # #''# #,, # # # # 20 | # '#' '##' # # ,,# '##;, # # 21 | # # 22 | # # 23 | # http://github.com/mitchweaver/bonsai # 24 | # # 25 | # * NOTICE * # 26 | # # 27 | # In early development. Not intended for use. # 28 | # # 29 | # -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/- # 30 | ``` 31 | 32 | ## Bonsai 33 | 34 | Originally the package manager of a now extinct hobby Linux distribution, 35 | `bonsai` is small package manager meant to be cross-platform and extremely 36 | simple to use. Written in POSIX shell with only basic UNIX utilities 37 | as dependencies, it's meant to be able to be pulled down on any machine 38 | to quickly get access to the programs you need, root access not required. 39 | 40 | Nowadays I personally use it for miscellaneous things not commonly 41 | found in distros. Not meant for public use. 42 | 43 | Maybe it will be helpful to you too. 44 | Feel free to open github issues/PR as needed. 45 | 46 | \- Mitch 47 | 48 | --- 49 | 50 | ## Installation 51 | 52 | ``` 53 | git clone https://github.com/mitchweaver/bonsai 54 | cd bonsai 55 | make 56 | make install 57 | ``` 58 | 59 | ## Environment 60 | 61 | ``` 62 | cat >> ~/.profile <bonsai 6 | for i in src/* ; do cat $$i ; echo ; done >>bonsai 7 | echo 'main "$$@"' >>bonsai 8 | 9 | install: 10 | @if [ ! -f bonsai ] ; then >&2 echo "Use 'make' first to build the program." ; exit 1 ; fi 11 | mkdir -p ${BONSAI_ROOT}/src 12 | cp -rf ports ${BONSAI_ROOT}/src/ 13 | install -D -m 0755 bonsai ${PREFIX}/bin/bonsai 14 | install -D -m 0755 bonsai ${BONSAI_ROOT}/bin/bonsai 15 | ln -sf bonsai ${PREFIX}/bin/bs 16 | ln -sf bonsai ${BONSAI_ROOT}/bin/bs 17 | 18 | clean: 19 | rm bonsai 20 | 21 | uninstall: 22 | rm ${PREFIX}/bin/bonsai 23 | unlink ${PREFIX}/bin/bs 24 | 25 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 26 | # SC1090: file sourcing - shellcheck is unaware of sourced pkgfiles 27 | # SC2154: undeclared vars - shellcheck is unaware vars inside pkgfiles 28 | # SC2120: unused arguments - shellcheck is unaware of pkgfile function calls 29 | # SC2295: Expansions with '#' - shellcheck thinks "#" which we are using as 30 | # package version delimiter isn't taken literally 31 | SHELLCHECK = shellcheck -s sh --norc -e 1090 -e 2154 -e 2120 -e 2295 32 | 33 | test: 34 | ${SHELLCHECK} bonsai 35 | @# SC2034: unused variables 36 | @# shellcheck is unaware of how vars in pkgfiles are used 37 | @# SC2016: expressions in single quotes don't expand 38 | @# this is used often in sed calls within pkgfiles 39 | @# SC2086: word splitting 40 | @# this is used often, intentionally, in pkgfiles 41 | @# SC2209: shellcheck thinks "deps=sed" for example is a misuse 42 | @# of command output. False positive. 43 | @# SC2164: 'use || exit in case cd fails' -- only used when will never fail 44 | ${SHELLCHECK} -e 2034 -e 2016 -e 2086 -e 2209 -e 2164 ports/*/*/pkgfile 45 | @# count lines of code, excluding comments and blank lines: 46 | @echo SLOC: $$(sed '/^\s*#/d;/^\s*$$/d' bonsai | wc -l) 47 | -------------------------------------------------------------------------------- /ports/convenience/README.txt: -------------------------------------------------------------------------------- 1 | # ports/convenience 2 | 3 | These are ports that are not easily buildable or have a lot of 4 | dependencies. 5 | 6 | They aren't really in the "spirit" of bonsai but because its so 7 | convenient for me I'm adding them just for use with my personal 8 | machine. 9 | -------------------------------------------------------------------------------- /ports/convenience/kdiskmark/pkgfile: -------------------------------------------------------------------------------- 1 | info='crystaldiskmark Linux alternative' 2 | ver=3.1.2 3 | build() { 4 | install -D -m 0755 "KDiskMark-$ver-fio-3.32-x86_64.AppImage" "$pkg/bin/$name" 5 | } 6 | -------------------------------------------------------------------------------- /ports/convenience/kdiskmark/sources: -------------------------------------------------------------------------------- 1 | https://github.com/JonMagon/KDiskMark/releases/download/3.1.2/KDiskMark-3.1.2-fio-3.32-x86_64.AppImage 0ee060409637a9f31f0da0a4f86657f79294a3e5738f3c0e9205d3fffa9aa51e6a0bb5c07ad1eddf1250cdaa08a19b4be927407420e2d27004763ea786c105f8 2 | -------------------------------------------------------------------------------- /ports/convenience/teamviewer/pkgfile: -------------------------------------------------------------------------------- 1 | info='proprietary remote access software' 2 | ver=unknown 3 | build() { 4 | mkdir -p "$pkg/opt" "$pkg/bin" 5 | mv tv_bin "$name"/ 6 | mv doc "$name"/ 7 | mv "$name" "$pkg/opt" 8 | } 9 | postbuild() { 10 | cat > "$pkg/bin/$name" <unsigned conversion. 136 | ##### CFLAGS="$CFLAGS -Wconversion -Wsign-conversion" 137 | 138 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 139 | # 4. Finishing up 140 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 141 | # Use same flags for C++ as for C 142 | CXXFLAGS="$CFLAGS" 143 | 144 | # Number of jobs to be passed to make. 145 | NPROC="${NPROC:-$(nproc 2>/dev/null)}" 146 | NPROC="${NPROC:-1}" 147 | JOBS=$((NPROC + 1)) 148 | 149 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 150 | # 5. Path variables - edit at your own risk 151 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 152 | LIBRARY_PATH="$BONSAI_ROOT/lib:$BONSAI_ROOT/libexec" # .: 153 | LD_LIBRARY_PATH="$LIBRARY_PATH" 154 | 155 | # force the use of our linker, note if we're bootstrapping 156 | # (but check if it exists, we may be bootstrapping) 157 | # [ -e "$BONSAI_ROOT"/lib/ld-musl-x86_64.so.1 ] && 158 | # CFLAGS="$CFLAGS -Wl,-dynamic-linker=$BONSAI_ROOT/lib/ld-musl-x86_64.so.1" 159 | 160 | CPATH="$BONSAI_ROOT/include" # .: 161 | PKG_CONFIG_PATH="$BONSAI_ROOT/lib/pkgconfig:$BONSAI_ROOT/share/pkgconfig" 162 | BINDIR="$PREFIX"/bin 163 | LIBDIR="$PREFIX"/lib 164 | MANDIR="$PREFIX"/share/man 165 | SBINDIR="$BINDIR" 166 | LIBEXECDIR="$LIBDIR" 167 | 168 | # vim:ft=config 169 | -------------------------------------------------------------------------------- /ports/meta/@cfg/pkgfile: -------------------------------------------------------------------------------- 1 | info='bonsai global configuration files' 2 | build() { 3 | install -D -m 0644 cfg/*.cfg "$CONFIG"/ 4 | } 5 | -------------------------------------------------------------------------------- /ports/meta/@cfg/sources: -------------------------------------------------------------------------------- 1 | cfg/build.cfg c405685dba6fafea131b591da48164feb4651b5ea622fbbea6c14006bab6916b43ac3e3c1f037e9aa18f5102007ea2953e4ffa920407cde1c3faefab70dabad1 2 | cfg/autotools.cfg f10392f3bfa8a0ce4c75f536e1f6d24ea9ee4ee85e90f7b8dd11f8b66206be53a208819aa72b80dd32a3d0c12a6b176b2397ba612d5982fbc591b1ac64523321 3 | -------------------------------------------------------------------------------- /ports/misc/exa/pkgfile: -------------------------------------------------------------------------------- 1 | info='a modern replacement for ls' 2 | ver=0.10.1 3 | deps=unzip 4 | postbuild() { 5 | ln -svf exa "$pkg/bin/ls" 6 | } 7 | -------------------------------------------------------------------------------- /ports/misc/exa/sources: -------------------------------------------------------------------------------- 1 | https://github.com/ogham/exa/releases/download/v0.10.1/exa-linux-x86_64-v0.10.1.zip 6897aae29da9f6aa4a16ce14d8d7a00c9c292cef447b0d1c973465533f144d43b259b907c152637b0835f74b7c421650c23e3321579bb703b0a1a33979e46faa 2 | -------------------------------------------------------------------------------- /ports/misc/fff/pkgfile: -------------------------------------------------------------------------------- 1 | info='fucking fast file manager' 2 | ver=2.2 3 | build() { 4 | bsinstall 5 | } 6 | -------------------------------------------------------------------------------- /ports/misc/fff/sources: -------------------------------------------------------------------------------- 1 | https://github.com/dylanaraps/fff/archive/refs/tags/2.2.tar.gz 364fef67b69aa28fc9448eb4b11c4d7152f11191fd4313f728b1bb00fbc80682dd2d3b4d65884aa3d70b82d319e2ca8e19bf7a06c04b250e49c3577caa5fe2cf 2 | -------------------------------------------------------------------------------- /ports/misc/tree/pkgfile: -------------------------------------------------------------------------------- 1 | info='recursive directory listing command that produces a depth indented listing of files' 2 | ver=2.0.4 3 | -------------------------------------------------------------------------------- /ports/misc/tree/sources: -------------------------------------------------------------------------------- 1 | https://mama.indstate.edu/users/ice/tree aaba0a8e28f0b1dbb6d23ac45c32f721cac8efdf384d4178444bf736887ce964e94787a55e600833e542085df1ec203017df0071c4d5845731fabd2684b1fb53 2 | -------------------------------------------------------------------------------- /ports/misc/unzip/pkgfile: -------------------------------------------------------------------------------- 1 | info='UnZip is an extraction utility for archives compressed in .zip format' 2 | ver=6.0 3 | build() { 4 | make -f unix/Makefile linux_noasm 5 | make -f unix/Makefile prefix="$DESTDIR" install 6 | } 7 | -------------------------------------------------------------------------------- /ports/misc/unzip/sources: -------------------------------------------------------------------------------- 1 | https://downloads.sourceforge.net/infozip/unzip60.tar.gz 0694e403ebc57b37218e00ec1a406cae5cc9c5b52b6798e0d4590840b6cdbf9ddc0d9471f67af783e960f8fa2e620394d51384257dca23d06bcd90224a80ce5d 2 | -------------------------------------------------------------------------------- /ports/network/sshpass/pkgfile: -------------------------------------------------------------------------------- 1 | info='sshpass is a tool for non-interactivly performing password authentication with SSH' 2 | ver=1.0.8 3 | -------------------------------------------------------------------------------- /ports/network/sshpass/sources: -------------------------------------------------------------------------------- 1 | https://versaweb.dl.sourceforge.net/project/sshpass/sshpass/1.08/sshpass-1.08.tar.gz 615c6b05c07a87b7be390dc99820adfd5ac392e29b82657cd9dd4c76dfdd71b326825b3ea056221e759fbdbc99f1d790eeb1493af31b3512248b00a747da7d88 2 | -------------------------------------------------------------------------------- /ports/rice/lolcat/pkgfile: -------------------------------------------------------------------------------- 1 | info='High-performance implementation of https://github.com/busyloop/lolcat' 2 | ver='v1.4' 3 | build() { 4 | bsmk 5 | install -D -m 0755 lolcat "$pkg"/bin/lolcat 6 | } 7 | -------------------------------------------------------------------------------- /ports/rice/lolcat/sources: -------------------------------------------------------------------------------- 1 | https://github.com/jaseg/lolcat/archive/refs/tags/v1.4.tar.gz 8f73121ef372383f5ff1d444f69a6255f5ff65abfbb4f103197480f957dcc440375c7c01be5c33247ce920ff39e34519702f7550b9b8ada2f18190d0ae948024 2 | -------------------------------------------------------------------------------- /ports/rice/neofetch/pkgfile: -------------------------------------------------------------------------------- 1 | info='A command-line system information tool written in bash 3.2+' 2 | ver=7.1.0 3 | build() { 4 | bsinstall 5 | } 6 | -------------------------------------------------------------------------------- /ports/rice/neofetch/sources: -------------------------------------------------------------------------------- 1 | https://github.com/dylanaraps/neofetch/archive/refs/tags/7.1.0.tar.gz fe1013fb54585c15ba556054478a2c8c503120387e81bd16bfdfbb6f3a188ed4124585540abf43da9209cbbe0d7fb90d50914cd6620137d00f013cfb6954a042 2 | -------------------------------------------------------------------------------- /ports/rice/pfetch/pkgfile: -------------------------------------------------------------------------------- 1 | info='A pretty system information tool written in POSIX sh' 2 | ver=0.6.0 3 | -------------------------------------------------------------------------------- /ports/rice/pfetch/sources: -------------------------------------------------------------------------------- 1 | https://github.com/dylanaraps/pfetch/archive/refs/tags/0.6.0.tar.gz 868901bec6ae8999ad40fcb94bdf804969a3dfd724dc554d62f59982daf48d359094764b2e45d4816983d4f46e38de30f0bcb646ecd95bf3263ba128b87a1ddf 2 | -------------------------------------------------------------------------------- /ports/rice/skroll/pkgfile: -------------------------------------------------------------------------------- 1 | info='read text on stdin and make it scroll on stdout' 2 | ver=0.6 3 | -------------------------------------------------------------------------------- /ports/rice/skroll/sources: -------------------------------------------------------------------------------- 1 | http://dl.z3bra.org/releases/skroll-0.6.tar.bz2 0a0e52f395dd86d02fe5f543233b7420703a69741e75063696ff43730e5d9941525ba13fd59f446782d362396cfe70b6fc82916d72c30d01508a4adc0d7c3ffc 2 | -------------------------------------------------------------------------------- /ports/security/pash/pkgfile: -------------------------------------------------------------------------------- 1 | info='pass clone written in shell' 2 | ver=2.3.0 3 | -------------------------------------------------------------------------------- /ports/security/pash/sources: -------------------------------------------------------------------------------- 1 | https://github.com/dylanaraps/pash/archive/2.3.0.tar.gz 389dace794913492ea84345e920187d33c456551b7cfaea7a71810be21fa05b33b8cee5aacbcf4b17fa84b20399c41607c49988de7ecf263569be33aea1118ea 2 | -------------------------------------------------------------------------------- /ports/system/balena/pkgfile: -------------------------------------------------------------------------------- 1 | info='Flash OS images to SD cards & USB drives, safely and easily' 2 | ver=1.7.9 3 | build() { 4 | mv "balenaEtcher-$ver-x64.AppImage" "$name" 5 | bsinstall 6 | } 7 | -------------------------------------------------------------------------------- /ports/system/balena/sources: -------------------------------------------------------------------------------- 1 | https://github.com/balena-io/etcher/releases/download/v1.7.9/balena-etcher-electron-1.7.9-linux-x64.zip d892e5b587eaab770355a2dcf6150254f135c1765177c7d52efa4e71d3d6a3bf45cdb3971d1443721c633389746deed3ac222417937503731e0eca89896de58e 2 | -------------------------------------------------------------------------------- /ports/system/gotop/pkgfile: -------------------------------------------------------------------------------- 1 | info='A terminal based graphical activity monitor inspired by gtop and vtop' 2 | ver=4.2.0 3 | build() { 4 | bsinstall 5 | } 6 | -------------------------------------------------------------------------------- /ports/system/gotop/sources: -------------------------------------------------------------------------------- 1 | https://github.com/xxxserxxx/gotop/releases/download/v4.2.0/gotop_v4.2.0_linux_amd64.tgz 7e1ff74defd7bee051ab8d0dc213733c9d03a055c4d376acf9e94589723623c63521bcd1c7a3d9da4c06f9b286a94a46ddf8a54ba23c849d0e1cf269f8dcf720 2 | -------------------------------------------------------------------------------- /ports/system/oksh/pkgfile: -------------------------------------------------------------------------------- 1 | info='Portable OpenBSD ksh, from Ibara' 2 | ver=7.2 3 | build() { 4 | bscfg 5 | bsmk 6 | rm Makefile 7 | bsinstall 8 | } 9 | -------------------------------------------------------------------------------- /ports/system/oksh/sources: -------------------------------------------------------------------------------- 1 | https://github.com/ibara/oksh/releases/download/oksh-7.2/oksh-7.2.tar.gz 1b412ebbae58bdb1ccf9b9e0b64bab233cd5e184a02bc67db9b4ba82fce0749b8166dd688c24fd890d22a111d7f6ba859c47e3175f28675fca9c6def8c416a08 2 | -------------------------------------------------------------------------------- /ports/xorg/bdftopcf/pkgfile: -------------------------------------------------------------------------------- 1 | info='xorg tool to convert bdf to pcf font files' 2 | ver=1.1.1 3 | -------------------------------------------------------------------------------- /ports/xorg/bdftopcf/sources: -------------------------------------------------------------------------------- 1 | https://gitlab.freedesktop.org/xorg/util/bdftopcf/-/archive/bdftopcf-1.1.1/bdftopcf-bdftopcf-1.1.1.tar.bz2 f5d1a51819ccab6add5c97257729b1b7f84fc22ec63a7322f11c64b6e65b3e814b937c5cf89af46df2f587d5a4791e00a50b28984267e9e86912fee600c88348 2 | -------------------------------------------------------------------------------- /ports/xorg/color/pkgfile: -------------------------------------------------------------------------------- 1 | info='dead simple X11 color picker' 2 | ver=1.0 3 | build() { 4 | bsmk 5 | rm makefile 6 | bsinstall 7 | } 8 | -------------------------------------------------------------------------------- /ports/xorg/color/sources: -------------------------------------------------------------------------------- 1 | https://github.com/mitchweaver/color/archive/refs/tags/1.0.tar.gz 238da4f8761e13f3110025901ac81d8146006700193b0249bfd43297479351e58e12c7e7796cff27dbc6e62655991570aa9278fa4ea1b1dd4a4861ae68bc58d2 2 | -------------------------------------------------------------------------------- /ports/xorg/xdimmer/pkgfile: -------------------------------------------------------------------------------- 1 | info='lightweight X11 utility to dim the screen and/or keyboard backlight when idle' 2 | # Oct 25, 2021 3 | ver=a65ae357615f3dc3b3f4dd15891c96e6ee8f043c 4 | libs=libbsd 5 | build() { 6 | bsmk 7 | rm Makefile 8 | bsinstall 9 | } 10 | -------------------------------------------------------------------------------- /ports/xorg/xdimmer/sources: -------------------------------------------------------------------------------- 1 | https://github.com/jcs/xdimmer/archive/a65ae357615f3dc3b3f4dd15891c96e6ee8f043c.tar.gz 12a821a134d0611adef3f2e7b53f79b7199f915e612f54ecb1e58a4ab4c9dcae897aa6e2ed65cb9af8951481f9029fe4f3f694349841c86a63849d533944515a 2 | -------------------------------------------------------------------------------- /src/add: -------------------------------------------------------------------------------- 1 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 2 | # Package Installation http://github.com/bonsai-linux/bonsai 3 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 4 | 5 | add() { 6 | if [ "$1" = -f ] ; then 7 | FORCE=true 8 | shift 9 | fi 10 | 11 | # packages we have been asked to add 12 | mainpkgs=$* 13 | 14 | # clear the array, we will use it to build the list 15 | set -- 16 | 17 | for p in $mainpkgs ; do 18 | # grab initial package variables 19 | loadpkgfile "$p" 20 | 21 | # search for dependencies, the value is stored in $pkgdeps 22 | pkgdeps "$p" 23 | 24 | # add deps to list, before the main package 25 | case $pkgdeps in 26 | ""|"* *") 27 | # if unset or empty string, there are no deps 28 | ;; 29 | *) 30 | for dep in $pkgdeps ; do 31 | # if dep is not installed, schedule it to be added 32 | if ! isinst "$dep" ; then 33 | contains "$*" " $dep " || set -- "$* $dep" 34 | fi 35 | done 36 | esac 37 | 38 | # once all dependencies have been calculated, append the main package 39 | set -- "$* $p" 40 | 41 | # remove variables from the environment 42 | unloadpkgfile 43 | done 44 | 45 | # now that we have the correct dependency-tree calculated, 46 | # add all of the arguments 47 | # 48 | # splitting on '$@' is intentional for the loop 49 | # shellcheck disable=SC2068 50 | for p in $@ ; do 51 | # start back at $WORK directory as $workdir may get deleted 52 | cd "$WORK" || die "couldn't cd to $WORK" 53 | 54 | # try to remove an empty dir in "$pkgs" should it exist 55 | rmdir "$pkgs/$p" 2>/dev/null ||: 56 | 57 | # warn if package is being reinstalled 58 | [ "$FORCE" != true ] && isinst "$p" && die "$p is already installed" 59 | 60 | # load package variables into the environment 61 | loadpkgfile "$p" 62 | 63 | # check if we have required libs to build 64 | if [ "$libs" ] ; then 65 | haslib "$libs" || die "missing required libraries to build" 66 | fi 67 | 68 | # clear old working directory should it exist 69 | rm -rf -- "$workdir" 2>/dev/null ||: 70 | mkdir -p "$workdir" 71 | 72 | # download sources and copy to $workdir 73 | # sc bug: 74 | # shellcheck disable=SC2119 75 | [ -f "$portdir"/sources ] && get 76 | 77 | # build 78 | run_build || exit 1 79 | 80 | # after successful build, create the symlinks in the root 81 | linkpkg 82 | 83 | # remove our build dir 84 | rm -rf -- "$workdir" 85 | 86 | msg "$name installed" 87 | 88 | # remove package variables from the environment 89 | unloadpkgfile 90 | done 91 | } 92 | 93 | # 1. downloads all remote files to $SOURCES/$pkgstring if needed 94 | # 2. copies files, both local and remote, as specified to $workdir 95 | get() { 96 | while read -r file sum ; do 97 | case $file in 98 | *'://'*) 99 | # must be a remote file 100 | msg "downloading ${file##*/}" 101 | 102 | # curl cannot handle '#' in file paths and I cannot figure 103 | # out how to fix this without patching it. 104 | # 105 | # as a shitty workaround use '-' as the delimitor for $SOURCES dirs 106 | IFS='#' read -r ppath pver </dev/null 2>&1 ; then 17 | prebuild || die "prebuild failed for $name" 18 | else 19 | bspatch 20 | fi 21 | 22 | msg "building $name" 23 | 24 | # create pkg dir 25 | # bonsai uses this directory as its pkg "database" 26 | mkdir -p "$pkg" 27 | 28 | # if pkgfile has a build() function, execute it 29 | if type build >/dev/null 2>&1 ; then 30 | build || die "build failed for $name" 31 | else 32 | generic_build || die "generic build failed for $name" 33 | bsinstall || die "generic install failed for $name" 34 | fi 35 | 36 | # run postbuild(), if defined 37 | if type postbuild >/dev/null 2>&1 ; then 38 | postbuild || die "postbuild failed for $name" 39 | fi 40 | 41 | # remove all suckage that gets put here. (ex: docs) 42 | rm -r "${pkg:-?}"/sucks 2>/dev/null ||: 43 | } 44 | 45 | # Exports flags into the environment to be read by makefiles. 46 | getflags() { 47 | # Import user's flags and export them. 48 | # shellcheck disable=SC1091 49 | isinst @cfg >/dev/null && . "$CONFIG"/build.cfg 50 | 51 | # Only use slibtool/pkgconf if we aren't bootstrapping. 52 | # [ -x "$BONSAI_ROOT"/bin/slibtool ] && LIBTOOL="$BONSAI_ROOT"/bin/slibtool 53 | [ -x "$BONSAI_ROOT"/bin/pkgconf ] && PKG_CONFIG="$BONSAI_ROOT"/bin/pkgconf 54 | 55 | # User flags 56 | export JOBS="${JOBS:-1}" CFLAGS LDFLAGS CPPFLAGS CXXFLAGS \ 57 | LIBRARY_PATH LD_LIBRARY_PATH CPATH PKG_CONFIG_PATH \ 58 | BINDIR LIBDIR SBINDIR LIBEXECDIR MANDIR 59 | 60 | # use our musl wrapper if its installed 61 | [ -x "$BONSAI_ROOT/bin/musl-gcc" ] && export CC="$BONSAI_ROOT/bin/musl-gcc" 62 | 63 | # add necessary libraries if specified 64 | if [ "$libs" ] ; then 65 | # shellcheck disable=2155,2086 66 | export LIBS="$LIBS $(${PKG_CONFIG:-pkg-config} --libs $libs)" 67 | export LDFLAGS="$LDFLAGS $LIBS" 68 | fi 69 | 70 | # Makefiles have a problem which goes mostly unrecognized. 71 | # There is no standard forcing authors to use CFLAGS, CPPFLAGS, etc. 72 | # 73 | # This leads to packages that compile correctly, but do not include the 74 | # security mitigations / performance enhancements we want. 75 | # 76 | # One way of getting around this is to rewrite or patch all makefiles 77 | # by hand. This is too much of a burden and is almost impossible 78 | # for large-scale packages using autotools. 79 | # 80 | # While discouraged, *because you should be writing makefiles correctly!*, 81 | # the lesser of evils is to pack our build flags into $CC variable. 82 | # 83 | # This forces all package makefiles to use them as at the very least 84 | # they should use $CC or $cc instead of hardcoding 'gcc', even if they 85 | # do not properly include CFLAGS and friends. 86 | # 87 | # This also prevents overwriting of packages' internal flags should 88 | # they be ignorantly overwriting the external $CFLAGS variable 89 | # instead of using an internally created one such as $CCFLAGS. 90 | # 91 | # If you disagree with this, please do suggest a better solution. 92 | export CC="${CC:-gcc} $CFLAGS $CPPFLAGS" CXX="${CXX:-g++} $CFLAGS $CPPFLAGS" 93 | # export CC="${CC:-gcc}" CXX="${CXX:-g++}" 94 | 95 | # System flags 96 | export LIBTOOL="${LIBTOOL:-libtool}" PKG_CONFIG="${PKG_CONFIG:-pkg-config}" \ 97 | cc="$CC" DESTDIR="$pkg" PREFIX=/ prefix=/ MAKEINFO=false 98 | } 99 | 100 | # thanks GNU 101 | autotools_sucks() { 102 | # commonly needed variables for whatever reason 103 | export SHELL=/bin/sh GREP=grep FGREP=fgrep EGREP=egrep \ 104 | SED=sed AWK=awk MKDIR_P='mkdir -p' 105 | 106 | # create dummy files to make autoconf happy 107 | [ -f INSTALL ] || :>INSTALL 108 | [ -f depcomp ] || :>depcomp 109 | [ -f compile ] || :>compile 110 | # [ ! -f missing ] || :>missing 111 | [ ! -f build-aux/missing ] || :>build-aux/missing 112 | } 113 | 114 | # Try to automagically build/install if a pkgfile doesn't 115 | # define a custom build(). Works for most packages. 116 | # 117 | # sc bug, thinks we're using arguments yet we aren't passing any 118 | # shellcheck disable=SC2119 119 | generic_build() { 120 | if [ -f configure ] ; then 121 | bscfg || return 1 122 | elif [ -f autogen.sh ] ; then 123 | sh autogen.sh || return 1 124 | bscfg || return 1 125 | fi 126 | 127 | if [ -f Makefile ] || [ -f makefile ] ; then 128 | bsmk || return 1 129 | else 130 | msg "No makefile found. Assuming binary..." 131 | fi 132 | } 133 | 134 | # bonsai make function 135 | bsmk() { 136 | # * arguments supplied override vars within makefiles should they exist 137 | # * to enable verbose build output, you can set the $VERBOSE env var 138 | # * while non-standard, some makefiles use lowercase vars 139 | # * $MAKE variable is needed to enforce use of our $LIBTOOL 140 | # because autotools doesn't play nice 141 | make -j"$JOBS" ${VERBOSE:+V=1} CC="$CC" CXX="$CXX" cc="$CC" cxx="$CXX" \ 142 | LIBTOOL="$LIBTOOL" MAKE="make LIBTOOL='$LIBTOOL'" \ 143 | PKG_CONFIG="$PKG_CONFIG" DESTDIR="$DESTDIR" PREFIX="$PREFIX" \ 144 | BINDIR="$BINDIR" SBINDIR="$BINDIR" LIBDIR="$LIBDIR" \ 145 | LIBEXECDIR="$LIBEXECDIR" DOCDIR="$DOCDIR" \ 146 | destdir="$DESTDIR" prefix="$PREFIX" bindir="$BINDIR" \ 147 | sbindir="$BINDIR" libdir="$LIBDIR" libexecdir="$LIBEXECDIR" \ 148 | MAKEINFO=false "$@" || die "make $* failed for $name" 149 | } 150 | 151 | bsinstall() { 152 | msg "installing $name" 153 | 154 | if [ -f Makefile ] || [ -f makefile ] ; then 155 | bsmk install 156 | else 157 | # see if a specific bin name was set in the pkgfile 158 | # otherwise install as the package name 159 | if [ ! "$bin" ] ; then 160 | bin=$name 161 | fi 162 | if [ -f "$bin" ] ; then 163 | install -D -m 0755 "$bin" "$pkg/bin/$bin" 164 | elif [ -f "bin/$bin" ] ; then 165 | install -D -m 0755 "bin/$bin" "$pkg/bin/$bin" 166 | fi 167 | if [ -f "$bin.1" ] ; then 168 | install -D -m 0644 "$bin.1" "$pkg/share/man/man1/$bin.1" 169 | elif [ -f "share/man/man1/$bin.1" ] ; then 170 | install -D -m 0644 "share/man/man1/$bin.1" "$pkg/share/man/man1/$bin.1" 171 | fi 172 | fi 173 | } 174 | 175 | bscfg() { 176 | # Try to enable as many of user's autotools.cfg options as possible. 177 | 178 | # 1. grab --help output from the configure script 179 | cfghelp=$(sh ./configure --help) 180 | 181 | YES() { 182 | case $cfghelp in 183 | *" --enable-$1"*|*" --disable-$1"*) 184 | cfgflags="$cfgflags --enable-$1 " 185 | msg "adding flag: --enable-$1 " 186 | ;; 187 | *" --with-$1"*|*" --without-$1"*) 188 | cfgflags="$cfgflags --with-$1 " 189 | msg "adding flag: --with-$1 " 190 | esac 191 | } 192 | NO() { 193 | case $cfghelp in 194 | *" --disable-$1"*|*" --enable-$1"*) 195 | cfgflags="$cfgflags --disable-$1 " 196 | msg "adding flag: --disable-$1 " 197 | ;; 198 | *" --without-$1"*|*" --with-$1"*) 199 | cfgflags="$cfgflags --without-$1 " 200 | msg "adding flag: --without-$1 " 201 | esac 202 | } 203 | SET() { 204 | # set the literal '$pkg' to $pkg, 205 | # while avoiding use of eval 206 | # shellcheck disable=SC2016 207 | case $2 in 208 | '"$pkg"'/*) 209 | set -- "$1" "$pkg/${2#\"$pkg\"}" 210 | esac 211 | case $cfghelp in 212 | *" --$1="*) 213 | cfgflags="$cfgflags --$1=$2 " 214 | msg "adding flag: --$1=$2 " 215 | ;; 216 | *" --$1 "*) 217 | cfgflags="$cfgflags --$1 " 218 | msg "adding flag: --$1 " 219 | esac 220 | } 221 | 222 | # 2. Parse the user's autotools.cfg, using our helper funtions 223 | # to build up the configure script arguments. 224 | [ -f "$CONFIG"/autotools.cfg ] && 225 | while read -r func flag arg ; do 226 | case $func in 227 | SET) SET "$flag" "$arg" ;; 228 | YES) YES "$flag" ;; 229 | NO) NO "$flag" ;; 230 | esac 231 | done <"$CONFIG"/autotools.cfg 232 | 233 | # 3. Store flags used to a file for convenience. 234 | for flag in $cfgflags ; do 235 | printf '%s\n' "$flag" >>"$workdir"/cfgflags 236 | done 237 | for flag in "$@" ; do 238 | msg "adding flag: $flag" 239 | printf '%s\n' "$flag" >>"$workdir"/cfgflags 240 | done 241 | 242 | # 4. Run the script with our argument chain. 243 | # 244 | # Disable sc warning for word splitting, this is intentional. 245 | # shellcheck disable=SC2086 246 | sh ./configure $cfgflags || die "configure failed for $name" 247 | } 248 | 249 | # convenience function, automatically finds and apply all 250 | # *.patch or *.diff from a pkg's $portdir 251 | bspatch() { 252 | find . -type f -prune -name '*.patch' -o -name '*.diff' | sort | \ 253 | while read -r patch ; do 254 | msg "applying patch: ${patch##*/}" 255 | patch -f -l -p0 <"$patch" >/dev/null || die "$patch failed" 256 | done 257 | } 258 | -------------------------------------------------------------------------------- /src/del: -------------------------------------------------------------------------------- 1 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 2 | # Package Removal http://github.com/bonsai-linux/bonsai 3 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 4 | 5 | # uninstalls a given $name and removes its symlinks 6 | del() { 7 | isinst "$1" || die "$1 is not installed" 8 | 9 | # prompt user for confirmation before continuing 10 | warn "these packages will be deleted:" 11 | printf '\n %s\n\n' "$*" 12 | confirm 13 | 14 | # delete the packages, one at a time 15 | while [ "$1" ] ; do 16 | # skip if package is not installed / already uninstalled 17 | if ! isinst "$1" ; then 18 | warn "$1 is not installed" 19 | shift 20 | continue 21 | fi 22 | 23 | # load pkg vars into environment to retrieve $pkg name 24 | loadpkgfile "$1" 25 | 26 | cd "$BONSAI_ROOT" || die "unable to cd to $BONSAI_ROOT" 27 | 28 | if [ -d "$pkg" ] ; then 29 | # go through $PKGS/$pkg, deleting files as we go 30 | # afterwards, remove its symlink in the root 31 | find "$pkg" -type f -o -type l | \ 32 | while read -r file ; do 33 | rm -f "$file" 2>/dev/null ||: 34 | unlink "$BONSAI_ROOT/${file#$pkg}" 2>/dev/null ||: 35 | done 36 | # recurse through dirs in reverse, removing empty dirs as we go 37 | # afterwards, remove its equivalent dir in the $BONSAI_ROOT, if empty 38 | # 39 | # note: sed here is to emulte 'tac', which is not portable 40 | find "$pkg" -type d | sed '1!G;h;$!d' | \ 41 | while read -r dir ; do 42 | rmdir "$dir" 2>/dev/null ||: 43 | rmdir "$BONSAI_ROOT/${dir#$pkg}" 2>/dev/null ||: 44 | done 45 | fi 46 | 47 | msg "$pkgstring deleted" 48 | shift 49 | done 50 | } 51 | -------------------------------------------------------------------------------- /src/link: -------------------------------------------------------------------------------- 1 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 2 | # Package Linking http://github.com/bonsai-linux/bonsai 3 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 4 | 5 | # create symlinks for an installed package 6 | linkpkg() { 7 | # if link=false is specified in the pkgfile, return 8 | [ "$link" = false ] && return 9 | 10 | # if given a specific $PKGS to link against, use this 11 | # (this is done during relink_world) 12 | if [ "$2" ] ; then 13 | LINK_PKGS=$2/src/pkgs 14 | # remove doubled leading slash if given $BONSAI_ROOT was '/' 15 | LINK_PKGS=/${LINK_PKGS#//} 16 | else 17 | # otherwise use $PKGS from the environment as normal 18 | LINK_PKGS=$PKGS 19 | fi 20 | 21 | # do not attempt to link if pkg is not installed 22 | isinst "$name" || die "$name is not installed" 23 | 24 | cd "$BONSAI_ROOT" || die "could not cd to $BONSAI_ROOT" 25 | 26 | msg "creating symlinks for $name" 27 | 28 | for dir in bin sbin share include etc lib libexec ; do 29 | if [ -d "$PKGS/$pkgstring/$dir" ] ; then 30 | # recursively create pkg subdirectories in 31 | # equivalent $BONSAI_ROOT subdirectories 32 | # example: $PKGS/$pkgstring/lib/pkgconfig -> $BONSAI_ROOT/lib/pkgconfig 33 | find "$PKGS/$pkgstring/$dir" ! -path "*$dir" \ 34 | -type d 2>/dev/null | while read -r subdir ; do 35 | mkdir -p "${subdir#$PKGS/$pkgstring/}" 36 | done 37 | 38 | # recursively link all files 39 | # example: $PKGS/$pkgstring/include/asm/*.h -> $BONSAI_ROOT/include/asm/*.h 40 | find "$PKGS/$pkgstring/$dir" ! -path "*share/*man*" \ 41 | -type f -o -type l 2>/dev/null | while read -r file ; do 42 | file="${file#$PKGS/$pkgstring/}" 43 | ln -sf "$LINK_PKGS/$pkgstring/$file" "$file" 2>/dev/null 44 | done 45 | fi 46 | done 47 | 48 | # do the same for all possibly existing manpage directories 49 | for manX in man1 man2 man3 man4 man5 man6 man7 man8 ; do 50 | if [ -d "$PKGS/$pkgstring/share/man/$manX" ] ; then 51 | find "$PKGS/$pkgstring/share/man/$manX" ! -path "*/$manX" 2>/dev/null | \ 52 | while read -r man ; do 53 | ln -sf "$LINK_PKGS/$pkgstring/share/man/$manX/${man##*/}" \ 54 | "${man#$PKGS/$pkgstring/}" 2>/dev/null 55 | done 56 | fi 57 | done 58 | 59 | # return whence we were 60 | cd - >/dev/null 61 | } 62 | 63 | # relink a package or list of packages 64 | relink() { 65 | for name in "$@" ; do 66 | loadpkgfile "$name" 67 | linkpkg "$name" 68 | unloadpkgfile 69 | done 70 | } 71 | 72 | # relink the world against a given $BONSAI_ROOT location 73 | # (used to convert a stage0 into a chrooted environment) 74 | relink_world() { 75 | [ -d "$1" ] || die "no such directory $1" 76 | 77 | msg "relinking world with \$BONSAI_ROOT=$1..." 78 | for name in $(listpkgs) ; do 79 | loadpkgfile "$name" 80 | linkpkg "$name" "$1" 81 | unloadpkgfile 82 | done 83 | } 84 | 85 | # # * relinks every package installed, used to fix broken / inconsistent symlinks 86 | # # * also used to bootstrap systems under a different $BONSAI_ROOT 87 | # # params: [--chroot] 88 | # relink_world() { 89 | # # if no args, use the $PKGS variable from the bonsai.rc 90 | # case "$1" in 91 | # --chroot) relink_pkgs=/src/pkgs ;; 92 | # *) relink_pkgs="$PKGS" 93 | # esac 94 | # msg "relinking world with \$PKGS=$relink_pkgs..." 95 | # echo 96 | 97 | # listpkgs | while read -r pkgid ; do 98 | # pkg="$(pkgid2pkg "$pkgid")" 99 | # if ! grep '^nolink=true$' "$(getpkgfile $pkg)" >/dev/null ; then 100 | # # if its a metapkg, only link if it has a pkgdir 101 | # ismetapkg "$pkg" && [ ! -d "$PKGS/$pkg" ] && continue 102 | # linkpkg "$pkg" "$relink_pkgs" 103 | # fi 104 | # done || die "relink_world(): linking failed" 105 | 106 | # echo 107 | # msg 'done!' 108 | # } 109 | -------------------------------------------------------------------------------- /src/main: -------------------------------------------------------------------------------- 1 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 2 | # Variables http://github.com/bonsai-linux/bonsai 3 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 4 | : "${BONSAI_ROOT:=${HOME}/.bonsai}" 5 | : "${PORTS:=$BONSAI_ROOT/src/ports}" 6 | : "${PKGS:=$BONSAI_ROOT/src/pkgs}" 7 | : "${SOURCES:=$BONSAI_ROOT/src/sources}" 8 | : "${WORK:=$BONSAI_ROOT/src/work}" 9 | : "${CONFIG:=$BONSAI_ROOT/src/cfg}" 10 | : "${TOOLS:=$BONSAI_ROOT/src/tools}" 11 | : "${PROMPT:=→}" 12 | : "${CONFIRM_PROMPT:=(y\n): }" 13 | 14 | # prepend bonsai paths to the running environment's paths 15 | # programs and libraries inside the chroot will be preferred 16 | export PATH="$BONSAI_ROOT/bin:$PATH" 17 | export LD_LIBRARY_PATH="$BONSAI_ROOT/lib:$BONSAI_ROOT/libexec:$LD_LIBRARY_PATH:/lib:/usr/lib" 18 | 19 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 20 | # Main 21 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 22 | init() { 23 | mkdir -p "$PKGS" "$PORTS" "$SOURCES" "$WORK" "$CONFIG" 24 | for dir in bin share include etc lib libexec ; do 25 | mkdir -p "$BONSAI_ROOT/$dir" 26 | done 27 | rmdir "$PKGS"/* 2>/dev/null ||: 28 | } 29 | 30 | usage() { 31 | >&2 cat <<"EOF" 32 | 33 | # 34 | # O 35 | ##, ,##,',##, ,## ,#, , 36 | # # # # #''# #,, # # # 37 | '#' '##' # # ,,# '##;, # 38 | 39 | [a] - add 40 | [d] - del 41 | [r] - relink 42 | [l] - list 43 | [c] - count 44 | [i] - isinst 45 | [s] - search 46 | [h] - usage 47 | 48 | EOF 49 | exit 1 50 | } 51 | 52 | main() { 53 | init 54 | [ "$1" ] || usage 55 | 56 | flag=${1#-} 57 | shift 58 | 59 | # validate syntax 60 | case $flag in 61 | a|d|i|r|*d) 62 | [ "$1" ] || die 'no argument provided' 63 | esac 64 | 65 | case $flag in 66 | a) add "$@" ;; 67 | d) del "$@" ;; 68 | r) relink "$@" ;; 69 | l) listpkgs ;; 70 | c) printf '%s\n' "$PKGS"/*/ | wc -l ;; 71 | i) isinst "$1" || die "$1 is not installed" && msg "$1 is installed" ;; 72 | s) searchpkg "$1" ;; 73 | mksum) mksum ;; 74 | cat) getpkgfile "$1" ; cat "$pkgfile" ;; 75 | deps) pkgdeps "$1" ; printf '%s\n' "$pkgdeps" ;; 76 | *relink-world) relink_world "$1" ;; 77 | h) usage 78 | esac 79 | } 80 | -------------------------------------------------------------------------------- /src/ports: -------------------------------------------------------------------------------- 1 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 2 | # Portfile Handling http://github.com/bonsai-linux/bonsai 3 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 4 | 5 | getportdir() { 6 | while read -r dir ; do 7 | if [ -d "$dir$1" ] ; then 8 | portdir=$dir$1 9 | return 10 | fi 11 | done <<-EOF 12 | $(printf '%s\n' "$PORTS"/*/) 13 | EOF 14 | die "unable to find portdir for '$1'" 15 | } 16 | 17 | getpkgfile() { 18 | [ "$portdir" ] || getportdir "$1" 19 | [ -f "$portdir"/pkgfile ] || die "unable to find pkgfile for '$1'" 20 | pkgfile=$portdir/pkgfile 21 | } 22 | 23 | # desc: loads $pkgfile variables into environment 24 | # arg: $name or $pkgstring of package 25 | loadpkgfile() { 26 | name=${1%%\#*} 27 | getportdir "$name" 28 | getpkgfile "$name" 29 | . "$pkgfile" 30 | 31 | # helper variables 32 | pkgstring=$name${ver:+\#}$ver 33 | 34 | # dir where port will be built and files copied 35 | workdir=${WORK:-?}/$name 36 | # dir the package will be installed to 37 | pkg=$PKGS/$pkgstring 38 | } 39 | 40 | unloadpkgfile() { 41 | unset bin name portdir pkgfile pkgstring pkg workdir 42 | unset info url ver deps link libs 43 | unset LIBS 44 | unset -f build prebuild postbuild 45 | } 46 | 47 | # checks whether $name is installed 48 | isinst() { 49 | # prefixed '@' denotes metapkgs, which do not have versions 50 | case $1 in 51 | @*) 52 | [ -d "$PKGS/$1" ] 53 | ;; 54 | *) 55 | # we use a case statement as globs do not work with test 56 | printf '%s\n' "$PKGS"/*/ | \ 57 | while read -r dir ; do 58 | case $dir in */"$1"\#*) break ; esac 59 | false 60 | done 61 | esac 62 | return $? 63 | } 64 | 65 | haslib() { 66 | msg "checking for required libraries: $*" 67 | for lib in "$@" ; do 68 | pkg-config --libs "$lib" >/dev/null || \ 69 | die "missing library: $lib" 70 | done 71 | } 72 | 73 | # list packages installed 74 | listpkgs() { 75 | printf '%s\n' "$PKGS"/* | \ 76 | while read -r pkg ; do 77 | printf '%s\n' "${pkg#$PKGS/}" 78 | done 79 | } 80 | 81 | # search for a packaged named $1 82 | searchpkg() { 83 | printf '%s\n' "$PORTS"/*/* | \ 84 | while read -r dir ; do 85 | if [ -d "$dir" ] ; then 86 | case $dir in 87 | *"$1"*) 88 | loadpkgfile "${dir##*/}" 89 | printf '%s %s\n' "$name" "$info" 90 | esac 91 | fi 92 | done | sort | column -t -l 2 -o ' ' 93 | } 94 | 95 | # calculates dependencies of a $name and stores 96 | # them in $pkgdeps in the correct installation order 97 | # 98 | # wordsplitting is used intentionally, ignore: 99 | # shellcheck disable=2086,2068 100 | pkgdeps() { 101 | master=$1 102 | 103 | # recursively go through the dependency tree appending 104 | # unique deps to $pkdeps as we go 105 | dep_recurse() { 106 | 107 | # clear deps from previous file 108 | unset deps 109 | 110 | # load in deps of package 111 | loadpkgfile "$1" 112 | 113 | # save the name of the package being checked 114 | # we must use the arg array for this otherwise 115 | # it will get overwritten on next recurse 116 | set -- $name 117 | 118 | # recurse for each dep that exists 119 | for dep in $deps ; do 120 | contains "$pkgdeps" " $dep " || dep_recurse $dep 121 | done 122 | 123 | # When we reach the bottom-most child of a dependency 124 | # tree, we add it to the list. Then the recursions 125 | # complete appending each of their parents to the list. 126 | if [ "$master" != "$1" ] ; then 127 | pkgdeps="$pkgdeps $1" 128 | fi 129 | } 130 | 131 | # start recursion 132 | dep_recurse "$1" 133 | 134 | # trim whitespace and clear duplicates 135 | # note: '${var:+string}' returns 'string' if 'var' is defined 136 | set -- $pkgdeps 137 | pkgdeps= 138 | for dep in $@ ; do 139 | contains "$pkgdeps" "$dep" || 140 | pkgdeps="$pkgdeps${pkgdeps:+ }$dep" 141 | done 142 | } 143 | 144 | # # show what packages depend on given port 145 | # # params: $name 146 | # rdeps() { 147 | # # echo all packages that list $1 in their $deps 148 | # depends() { 149 | # find "$PORTS" -name pkgfile | while read -r _pkgfile ; do 150 | # deps="" 151 | # . "$_pkgfile" 152 | # for dep in $deps ; do 153 | # [ "$dep" = "$1" ] && echo "$_pkgfile" 154 | # done 155 | # done 156 | # } 157 | # deps="$(depends "$1")" 158 | 159 | # for dep in $deps ; do 160 | # deps="$deps $(depends "$dep")" 161 | # done 162 | 163 | # # 1. remove duplicates and white space 164 | # # 2. convert $BONSAI_ROOT/src/ports/$name/pkgfile -> $name 165 | # set -- $(\ 166 | # for dep in $deps ; do 167 | # printf '%s\n' $(basename $(dirname $dep)) $@ 168 | # done | sort -u \ 169 | # ) 170 | # msg "$*" 171 | # unset deps dep 172 | # } 173 | -------------------------------------------------------------------------------- /src/util: -------------------------------------------------------------------------------- 1 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 2 | # Utility Functions http://github.com/bonsai-linux/bonsai 3 | # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 4 | 5 | msg() { 6 | printf "\033[32;1m%s\033[m %s\n" "$PROMPT" "$*" 7 | } 8 | 9 | warn() { 10 | >&2 printf "\033[33;1m%s \033[mwarning: %s\n" "$PROMPT" "$*" 11 | } 12 | 13 | die() { 14 | >&2 printf "\033[31;1m%s \033[merror: %s\n" "$PROMPT" "$*" 15 | exit 1 16 | } 17 | 18 | confirm() { 19 | >&2 printf "\033[33;1m%s \033[mconfirm? %s" "$PROMPT" "$CONFIRM_PROMPT" 20 | read -r ans 21 | if [ "$ans" != y ] ; then 22 | >&2 printf '%s\n' 'Exiting.' 23 | exit 24 | fi 25 | } 26 | 27 | # params: [full_string] [partial_string] 28 | contains() { [ "${1#*$2}" != "$1" ] || return 1 ; } 29 | 30 | # args: [file] [sum] 31 | chksum() { 32 | msg "comparing checksums for ${1##*/}" 33 | sum=$(sha512sum "$1") 34 | [ "$2" = "${sum%% *}" ] || return 1 35 | } 36 | 37 | # args: [compressed_file] [output_dir] 38 | extract() { 39 | case $1 in 40 | *tar.*|*.tgz|*.txz|*.tbz) 41 | decompress "$1" | tar -C "$2" -xf - 42 | 43 | # Ensure extracted tar files are in the top level of $2. 44 | # 45 | # note: Ee must use a loop here as glob will match '.' 46 | # in some shells even when not in the directory, 47 | # which will cause 'mv' to prematurely error. 48 | for dot in "$2"/*/.* ; do 49 | mv "$dot" "$2"/ 2>/dev/null ||: 50 | done 51 | mv "$2"/*/* "$2"/ 2>/dev/null ||: 52 | 53 | # remove any empty dirs we may have created 54 | rmdir "$2"/* 2>/dev/null ||: 55 | ;; 56 | *.xz|*.gz|*.bz2) 57 | out=${1##*/} 58 | decompress "$1" >"$2/${out%.*}" 59 | ;; 60 | *.zip) 61 | unzip -q "$1" -d "$2" 62 | ;; 63 | *) 64 | # not compressed 65 | cp -f "$1" "$2"/ 66 | esac 67 | } 68 | 69 | # args: [compressed_file] 70 | decompress() { 71 | case ${1##*.} in 72 | gz|tgz) 73 | if command -v gunzip >/dev/null ; then 74 | gunzip -qdc "$1" 75 | else 76 | tgunzip "$1" /dev/stdout 77 | fi 78 | ;; 79 | xz|txz) 80 | if command -v xz >/dev/null ; then 81 | xz -qdcT 0 "$1" 82 | else 83 | xzminidec <"$1" 84 | fi 85 | ;; 86 | bz2|tbz) 87 | bunzip2 -qdc "$1" 88 | esac 89 | } 90 | 91 | # Helper utility to create "sources" files for packages. 92 | # shellcheck disable=SC2094 93 | mksum() { 94 | if [ ! -f sources ] ; then 95 | >&2 printf '%s\n' "no sources file found in \$PWD" 96 | exit 1 97 | fi 98 | :>sums 99 | trap 'rm sums 2>/dev/null' INT 100 | 101 | # file syntax: 102 | # 103 | # $url $checksum 104 | # $url2 $checksum2 105 | # $url3 $checksum3 106 | # ... 107 | while read -r line ; do 108 | case $line in 109 | //*|\#*) continue ;; # comment 110 | esac 111 | 112 | url=${line% *} 113 | # trim leading slash, if exists 114 | url=${url%/} 115 | 116 | # if file exists, it is a local file (not an actual url) 117 | [ -e "$url" ] && continue 118 | 119 | # make temp dir to download file 120 | dl=/tmp/mksum-${url##*/} 121 | mkdir -p "$dl" 122 | 123 | # download and checksum, appending to temp file 124 | printf 'downloading %s\n' "$url" 125 | curl -qL#C - --url "$url" -o "$dl/${url##*/}" || exit 1 126 | 127 | read -r sum _ <<-EOF 128 | $(sha512sum "$dl/${url##*/}") 129 | EOF 130 | 131 | printf '%s %s\n' "$url" "$sum" >>sums 132 | 133 | # remove the temp dir 134 | rm -r "$dl" 135 | done >sources 149 | } 150 | --------------------------------------------------------------------------------