{"id":13588218,"url":"https://github.com/lonkamikaze/bsda2","last_synced_at":"2025-04-08T03:32:52.989Z","repository":{"id":79477113,"uuid":"59940978","full_name":"lonkamikaze/bsda2","owner":"lonkamikaze","description":"BSD Administration Scripts v2","archived":false,"fork":false,"pushed_at":"2024-08-09T20:11:31.000Z","size":918,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-10T21:14:32.479Z","etag":null,"topics":["administration","freebsd","pkg","shell-script"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lonkamikaze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":"deinstall.sh","publiccode":null,"codemeta":null}},"created_at":"2016-05-29T12:02:58.000Z","updated_at":"2024-08-09T20:11:34.000Z","dependencies_parsed_at":"2024-07-30T01:23:59.749Z","dependency_job_id":null,"html_url":"https://github.com/lonkamikaze/bsda2","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonkamikaze%2Fbsda2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonkamikaze%2Fbsda2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonkamikaze%2Fbsda2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonkamikaze%2Fbsda2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lonkamikaze","download_url":"https://codeload.github.com/lonkamikaze/bsda2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223300736,"owners_count":17122679,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["administration","freebsd","pkg","shell-script"],"created_at":"2024-08-01T15:06:34.598Z","updated_at":"2024-11-06T07:31:06.755Z","avatar_url":"https://github.com/lonkamikaze.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"\t    ______ ______ ___    _____ _________\n\t   /  _  //   __//   \\  /  _  /_      _/\n\t  /  ___/ \\  \\  /  /  \\/     / /  /  /\n\t /  __  /_/   \\/  /   /  //  //  /  /\n\t/______/______/______/__//__//  /  /\n\t                           _/  /  /_\n\tREVENGE OF THE SCRIPT     /________/\n\nBSD Administration Scripts II\n=============================\n\nI started this long overdue overhaul of the BSD Administration Scripts\nat the 31C3 (Hamburg, 2014).\n\nIt provides a recode of pkg_libchk, distviper and a cleaned up version\nof the buildflags toolset. The first tool exclusive to bsda2 is pkg_trim.\n\nOther members of the original bsdadminscripts are not provided, because\nthey have become obsolete due to changes in the FreeBSD operating\nsystem.\n\nTOC\n---\n\n1. [Tools](#tools)\n   1. [pkg_libchk](#pkg_libchk)\n   2. [pkg_trim](#pkg_trim)\n   3. [pkg_validate](#pkg_validate)\n   4. [pkg_version](#pkg_version)\n   5. [distviper](#distviper)\n   6. [buildflags](#buildflags)\n   7. [makeplist](#makeplist)\n   8. [loaderupdate](#loaderupdate)\n   9. [bprintf](#bprintf)\n2. [Libraries](#libraries)\n   1. [bsda:obj](#bsdaobj)\n   2. [TYPE.SH](#typesh)\n   3. [LST.SH](#lstsh)\n3. [Install](#install)\n3. [LICENSE](#license)\n\nTools\n-----\n\nThe tools provided rely on basic FreeBSD system tools but provide\nadditional convenience and/or speed.\n\nOne of the advantages common to all pkg_* tools is that they include\nthe package flavour when printing package origins.\n\n### pkg_libchk\n\nThe pkg_libchk tool provides the means to find packages that need to be\nrebuild/reinstalled, because they have been linked to a library that\nis no longer around.\n\nWhat sets its apart from other such tools or pkg-check, is that it makes\na decent job of avoiding false positives.\n\nThe recode is also 6 times faster than the old script.\n\n### pkg_trim\n\nThe pkg_trim tool provides a convenient means to get rid of (no longer\nrequired) packages.\n\nIt presents leaf packages (packages that are not required by other\npackages) in a checklist and offers the option to delete them or\nmark them for later removal with `pkg autoremove`.\n\n### pkg_validate\n\nThe pkg_validate tool lists mismatched and missing files of installed\npackages.\n\nIts advantages over running `pkg check -s` are faster execution time\nand the ability to run it as an unprivileged user.\n\n### pkg_version\n\nThe pkg_version tool checks the installed package versions against\na source of updates, such as a ports INDEX, ports tree or a package\nrepository.\n\nIts two advantages over running pkg-version(8) directly are the faster\nexecution time when using it with the ports tree and its ability to\nprint the names/origins of packages without the comparison operator\nif `-ql` is used. Thus no additional output filtering is required to\nfeed the output into another tool:\n\n```\n# pkg_version -ql\\\u003c\nbind-tools-9.18.19\nc-ares-1.21.0\nboost-libs-1.83.0\ncargo-c-0.9.27_2\ncups-2.4.6\ncups-filters-1.28.16_6\n...\n```\n\n### distviper\n\nThe distviper tool removes obsolete files from `/usr/ports/distfiles`\n(or wherever `DISTDIR` points).\n\n### buildflags\n\nBuildflags provides a configuration wrapper to set `make` flags  depending\non the current location in the file system.\n\nA `buildflags.conf` may look like this:\n\n```mk\n/usr/ports/*{\n\tWRKDIRPREFIX=/tmp/obj\n\n\t# Porting\n\tDEVELOPER\n\t.sinclude \"${HOME}/mk/makeplist.mk\"\n\n\t# Clustering\n\tUSE_DISTCC\n\tUSE_CCACHE\n\n\t# Common settings that are applied to all ports in hope to do some good\n\tTEX_DEFAULT=texlive\n\tPAPERSIZE=a4\n\n\t# Problems with ccache/distcc\n\t*/audio/cmus             {!USE_CCACHE !USE_DISTCC}\n\t*/archivers/lzip         {!USE_CCACHE !USE_DISTCC}\n}\n```\n\nIt results in the following `make` output:\n\n```mk\n.if ${.CURDIR:M/usr/ports/*}\nWRKDIRPREFIX=/tmp/obj\n\n# Porting\nDEVELOPER=              yes\n.sinclude \"${HOME}/mk/makeplist.mk\"\n\n# Clustering\nUSE_DISTCC=             yes\nUSE_CCACHE=             yes\n\n# Common settings that are applied to all ports in hope to do some good\nTEX_DEFAULT=texlive\nPAPERSIZE=a4\n\n# Problems with ccache/distcc\n.if ${.CURDIR:M*/audio/cmus}\n.undef USE_CCACHE\n.undef USE_DISTCC\n.endif # */audio/cmus\n.if ${.CURDIR:M*/archivers/lzip}\n.undef USE_CCACHE\n.undef USE_DISTCC\n.endif # */archivers/lzip\n.endif # /usr/ports/*\n```\n\n### makeplist\n\nThe makeplist script provides a means for port maintainers and committers\nto automatically generate a `pkg-plist` file.\n\nWhat sets it apart is its support for options and that it plays nice\nwith a lot of `bsd.port.mk` macros like `DESKTOP_ENTRIES`, `USE_RC_SUBR`\nor `PLIST_FILES`.\n\n### loaderupdate\n\nUpdate the boot loaders of bootable devices, by applying the loaders\nfrom a boot environment to a set of bootable devices.\n\nA boot environment, a mount containing a populated `/boot`, can be\nprovided via the `-d` parameter or `DESTDIR` environment variable.\n\nThe first command to run is `loaderupdate --dump`, it publishes\nloaderupdate's understanding of the boot environment and its tasks:\n\n```sh\n# loaderupdate -P nda0\nBoot Environment\n----------------\ndestdir:                /\nostype:                 FreeBSD\nkernel version:         FreeBSD 14.0-STABLE #0 stable/14-n265732-260e63b3d53c: Tue Nov 14 14:35:08 CET 2023\nkernel arch:            amd64\nfile system:            zfs\nprotective MBR:         /boot/pmbr\nfreebsd-boot loader:    /boot/gptzfsboot\nEFI loader:             /boot/loader.efi\n\nDevice nda0\n-----------\n    install:            /boot/pmbr \u003e nda0\n    install:            /boot/gptzfsboot \u003e nda0p1\n    install:            /boot/loader.efi \u003e nda0p2:/efi/FreeBSD/bootamd64.efi\n    EFI boot entry:     FreeBSD 14.0-STABLE #0 stable/14-n265732-260e63b3d53c: Tue Nov 14 14:35:08 CET 2023 amd64 [nda0p2]\n```\n\nBefore committing to an update `loaderupdate --dry-run` can list all\nof the commands it will run:\n\n```sh\nroot# loaderupdate -D nda0\ngpart bootcode -b/boot/pmbr nda0\ngpart bootcode -p/boot/gptzfsboot -i1 nda0\nmkdir -p nda0p2\nmount -tmsdosfs -osync /dev/nda0p2 nda0p2\nmkdir -p nda0p2/efi/FreeBSD\ncp /boot/loader.efi nda0p2/efi/FreeBSD/bootamd64.efi\nefibootmgr -Bb 0001\nefibootmgr -cl nda0p2:/efi/FreeBSD/bootamd64.efi -L 'FreeBSD 14.0-STABLE #0 stable/14-n265732-260e63b3d53c: Tue Nov 14 14:35:08 CET 2023 amd64 [nda0p2]'\nefibootmgr -ab 0001\n```\n\nThis enables users to review every command performed and tweak parameters.\n\n### bprintf\n\nA printf(1) like tool providing string formatting based on named\nfields instead of argument order.\n\n- Named arguments enable multiple use of the same argument within\n  a string\n- Formatting strings that do not use all arguments can be used\n- Arithmetic expressions within format specifications provide additional\n  formatting flexibility\n\n```sh\n# bprintf '| {var:(wx/3-3)} | {value:(wx/3+wx%3-2).3f} {unit:-(wx/3-3)} |\\n' wx=36 var=g value=9.81 unit=m/s^2\n|         g |      9.810 m/s^2     |\n```\n\nLibraries\n---------\n\nBsda2 comes bundled with a couple of general purpose standalone libraries.\n\n### [bsda:obj](ref/bsda_obj.md)\n\nThe bsda:obj framework dates back to the hacker conference GPN8\n(Karlsruhe, 2009). It provides OO fu for shell scripts, like classes with\nintrospection, return by reference, serialisation or lazy garbage collection.\n\nAlong with it comes a bunch of libraries targeted at common tasks like\nrich status line display, formatting and inter process communication.\n\nIt was presented at EuroBSDCon 2010.\n\n### [TYPE.SH](ref/type.md)\n\nThe TYPE.SH standalone library provides useful functions to handle\nuser inputs:\n\n- Supports: *uint*, *int*, *bool*, *empty*, *argname*, *varname*,\n  *funcname*\n- `type:match` checks whether at least one of a given set of types\n  matches a given value\n- `type:which` picks the first match from a given set of types\n- `type:cast[int]` can convert *uint*, *int*, *bool* and *empty*\n  inputs to a plain decimal integer\n- Depending on shell builtins only\n\n### [LST.SH](ref/lst.md)\n\nLST.SH is another standalone library that allows using shell strings\nas lists or arrays:\n\n- Configurable Record Separator\n- Batch operations (multiple push, pop etc. in one command)\n- Stack/Queue style operations:\n  - `push_back` and `push_front`\n  - `pop_back` and `pop_front`\n- Random access support:\n  - Read by index\n  - Assign by index\n  - Delete by index\n  - Supports arithmetic expressions in indices\n- Value matching:\n  - `contains`, `contains_any`, `contains_all`\n  - `rm_first`, `rm_last`\n- Record Separator conversions:\n  - `lst:convert`, `lst:cast`\n- Concatenate: `lst:cat` aka `a=cat`\n- Depending on shell builtins only\n\nInstall\n-------\n\nTo install the scripts run `install.sh`:\n\n\t./install.sh\n\nThe install script supports the following parameters, which are set in the\nfollowing way:\n\n\t-parameter=value\n\n* `-destdir=`\n  This is prepended to prefix and can be used to install into a\n  jail/chroot, other mounted systems etc. It does not affect\n  where installed scripts assume they are.\n* `-prefix=/usr/local`\n  The prefix that separates the files to be installed from the\n  base system.\n* `-datadir=$prefix/share/bsda2`\n  The data dir where shared code is installed.\n* `-docsdir=$prefix/share/doc/bsda2`\n  The location to install markdown documentation files.\n* `-ports=/usr/ports`\n  The location of the ports tree.\n* `-nodoc`\n  Set this to not install manual pages and markdown documentation.\n\nBe aware that `install.sh` and `deinstall.sh` have to be called with the same\narguments to install/deinstall the same files.\n\nLICENSE\n-------\n\nFor those who care about this stuff, this project is available under\nthe [ISC license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flonkamikaze%2Fbsda2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flonkamikaze%2Fbsda2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flonkamikaze%2Fbsda2/lists"}