diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-10-06 02:27:38 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2025-10-06 02:27:38 +0000 |
| commit | 0ea45c6552010c36e4718542db759ec6cdfce58a (patch) | |
| tree | 273f222c2d108e9daa687d5f4ea2a068a75dc550 | |
| parent | 399184cad0c0dd63a39de775130a2a73d0325913 (diff) | |
| download | s6-rc-0ea45c6552010c36e4718542db759ec6cdfce58a.tar.gz | |
Add s6-rc-set-install, repodefs page
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | doc/repodefs.html | 259 | ||||
| -rw-r--r-- | package/deps.mak | 19 | ||||
| -rw-r--r-- | package/modes | 3 | ||||
| -rw-r--r-- | package/targets.mak | 3 | ||||
| -rw-r--r-- | src/include/s6-rc/repo.h | 2 | ||||
| -rw-r--r-- | src/libs6rc/deps-lib/s6rc | 2 | ||||
| -rw-r--r-- | src/libs6rc/s6rc_repo_checkset.c | 40 | ||||
| -rw-r--r-- | src/libs6rc/s6rc_repo_compile.c | 2 | ||||
| -rw-r--r-- | src/libs6rc/s6rc_repo_setuptodate.c | 45 | ||||
| -rw-r--r-- | src/repo/deps-exe/s6-rc-set-change (renamed from src/repo/deps-exe/s6-rc-set-changestate) | 0 | ||||
| -rw-r--r-- | src/repo/deps-exe/s6-rc-set-install | 3 | ||||
| -rw-r--r-- | src/repo/s6-rc-set-change.c (renamed from src/repo/s6-rc-set-changestate.c) | 4 | ||||
| -rw-r--r-- | src/repo/s6-rc-set-commit.c | 64 | ||||
| -rw-r--r-- | src/repo/s6-rc-set-install.c | 205 |
15 files changed, 588 insertions, 67 deletions
@@ -17,9 +17,9 @@ /s6-rc-format-upgrade /s6-rc-repo-init /s6-rc-repo-sync -/s6-rc-repo-populate /s6-rc-set-new /s6-rc-set-copy /s6-rc-set-delete -/s6-rc-set-changestate +/s6-rc-set-change /s6-rc-set-commit +/s6-rc-set-install diff --git a/doc/repodefs.html b/doc/repodefs.html new file mode 100644 index 0000000..ff2bd32 --- /dev/null +++ b/doc/repodefs.html @@ -0,0 +1,259 @@ +<html> + <head> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <meta http-equiv="Content-Language" content="en" /> + <title>s6-rc: the "repo" subset of commands: definitions and concepts</title> + <meta name="Description" content="s6-rc: an overview" /> + <meta name="Keywords" content="s6-rc overview" /> + <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> --> + </head> +<body> + +<p> +<a href="index.html">s6-rc</a><br /> +<a href="//skarnet.org/software/">Software</a><br /> +<a href="//skarnet.org/">skarnet.org</a> +</p> + +<h1> The <em>repo</em> subset of s6-rc commands: management of source definition directories </h1> + +<p> + s6-rc commands such as +<a href="s6-rc.html">s6-rc</a>, +<a href="s6-rc-compile.html">s6-rc-compile</a>, or +<a href="s6-rc-db.html">s6-rc-db</a>, implement pure <em>mechanism</em>, and +leave all the burden of <em>policy</em>, i.e. how to organize source files, +when to compile a service database, etc., to the user. This is on purpose, but +does not make it easy to integrate s6-rc in a distribution, where service +files are provided by packages installed by a package manager, and where the +user wants to be able to easily define which services start at boot time and +which do not, etc. +</p> + +<p> + The solution to this conundrum is the high-level user interface to s6-rc +(and more generally to the s6 ecosystem) named +<a href="//skarnet.org/software/s6-frontend/">s6-frontend</a> (currently +in development). But in order for +<a href="//skarnet.org/software/s6-frontend/">s6-frontend</a> to be a +<em>user interface</em> and not a whole engine in its own right, some +stepping stones are in order: intermediary-level helpers to manage s6-rc +source definition directories in a way that maps better to the way that +distributions work than just the raw <a href="s6-rc-compile.html">s6-rc-compile</a>. +</p> + +<p> + These intermediary-level helpers made their appearance in version 0.6.0.0 +of s6-rc, and they're collectively known as <em>repo</em> commands — +simply because they manage a <em>repository</em> of services. +</p> + +<h2> Definitions </h2> + +<div id="repository"> +<h3> Repository </h3> +</div> + +<p> + An s6-rc <em>repository</em> is a place in the filesystem where the +<em>repo</em> commands perform their work and store their data. It +is made of hierarchies of symlinks (lots and lots of symlinks), that +ultimately point to source definition directories in the +<a href="#store">stores</a>, as well as several compiled databases: +the <a href="#refdb">reference database</a>, and the compiled databases +made of the <a href="#set">sets</a> you have +<a href="#commit">committed</a>, including the one you will eventually +<a href="#install">install</a>. +</p> + +<p> + A <em>repository</em> is where <strong>offline</strong> work on +services happens. It must be located on a read-write filesystem, but +that filesystem does not need to be accessible during the early boot. +The default repository is located in <tt>/var/lib/s6-rc/repository</tt> +(configurable at build-time). Other repositories can be created and +used at will, typically by non-root users who want to manage their own +sets of services. +</p> + +<div id="store"> +<h3> Store </h3> +</div> + +<p> + A service <em>store</em> is a place in the filesystem where source +definition directories are written by the package manager or the +user, where you can find the real contents of the services (instead +of just symlinks), as in, source definition directories that are +processed by <a href="s6-rc-compile.html">s6-rc-compile</a>. +A repository will typically link to several stores: one provided by +the package manager, and one — or more — provided locally +by the admin. No s6-rc command will ever write to a store, but most +repo commands read from all the stores. +</p> + +<p> + The location of the stores is entirely determined by distribution +policy, and s6-rc hardcodes no default for them. A good place to +host service definition directories installed by a package manager +could be, for instance, <tt>/usr/lib/s6-rc/sources</tt>. A good +place to host local service definition directories managed by +an administrator could be <tt>/etc/s6-rc/sources</tt>. +</p> + +<div id="refdb"> +<h3> Reference database </h3> +</div> + +<p> + When a repository is created or updated, the list of all services +defined in all the <a href="#store">stores</a> used by this repository +is analyzed, and all these services are automatically compiled into a +<em>reference database</em>, stored in the repository. The reference +database is never meant to be installed or go live in any way; its +purpose is mainly to give repo commands access to the full dependency +graph of all the services in the store. Additionally, compiling this +reference database ensures that the whole set of services defined +in all the used stores is consistent: if not, the initialization fails, +so the problem is reported as early as possible. +</p> + +<div id="set"> +<h3> Set </h3> +</div> + +<p> + Inside a repository, a <em>set</em> is the fundamental unit of operation, +and what users will interact the most with. A set is a map associating +each service contained in the <a href="#refdb">reference database</a> +(so, each service listed in all the <a href="#store">stores</a> used by the +repository) to a given state that the user wants this service in when +booting the system. This target state is also called a +<a href="#sub">sub</a>, because target states are implemented by +subdirectories of the directory holding a set. +</p> + +<p> + The idea is that the user can work on a set, making modifications to +the target states as they see fit; the repo commands always ensure that +the set will be consistent, i.e. that dependencies will be respected and +target states are reachable. When satisfied with the states, the user +can <a href="#commit">commit</a> the set, then <a href="#install">install</a> it. +</p> + +<div id="sub"> +<h3> Subs </h3> +</div> + +<p> + A <em>sub</em> is the target state for every service in a set. At all times, +each service is in one and only one sub. The list of subs the service can be in +is the following: +</p> + +<ul> + <li> <em>masked</em>: when the set is committed, masked services <em>will not</em> +be included in the compiled set database. They will be completely absent; if +the set database is installed, <a href="s6-rc.html">s6-rc</a> will not know them. +A service in another sub cannot depend on a masked service. </li> + <li> <em>disabled</em>, aka <em>unmasked</em>, aka <em>active</em> (yes, the +naming may seem inconsistent, but bear with me): these services will appear in +the compiled set database, and be startable by <a href="s6-rc.html">s6-rc</a> if +the database is installed. However, they will not be included in the default +bundle, i.e. they will not be automatically started at boot time. </li> + <li> <em>enabled</em>: these services will appear in the compiled set database, +<em>and</em> in the default bundle. They will be started at boot time. </li> + <li> <em>essential</em>, aka <em>always</em>: these services have been marked +as essential in their source definition directories, so they will always be +enabled. They cannot be disabled or masked. They cannot depend on non-essential +services. This sub is typically used by early boot services that should always +be run. </li> +</ul> + +<p> + Working on a set basically means moving services from one of these subs to +another, mostly choosing what services you will enable or disable, and sometimes +masking services you don't want to see at all. And once you are happy with a set, +you can commit it. +</p> + +<div id="commit"> +<h3> Commit </h3> +</div> + +<p> + <em>Committing</em> a set means assembling a subset of all the source +definition directories in the set and compiling them into a +<em>set database</em>, replacing any previous database for the same +set. This set database can then be <em>installed</em>. +</p> + +<div id="install"> +<h3> Install </h3> +</div> + +<p> + <em>Installing</em> a committed set means copying the compiled set +database to the place (defined by policy distribution) where it can be +used as a <em>live database</em>, i.e. booted on, and then switching +the live database to it. In other words: making the set database into +the new live database. +</p> + +<h2> Workflow </h2> + +<ul> + <li> <strong>At distribution installation time</strong>: + <ul> + <li> The installer creates a repository with +<a href="s6-rc-repo-init.html">s6-rc-repo-init</a>, linking to stores +according to distribution policy. </li> + <li> The installer also sets a default live service database up. </li> + </ul> </li> + <li> <strong>Whenever distribution policies change</strong>, for instance +when declaring an additional local store: + <ul> + <li> The admin updates the list of stores with +<a href="s6-rc-repo-init.html">s6-rc-repo-init -U</a>. </li> + </ul> </li> + <li> <strong>Whenever service files change</strong>, typically when the +package manager installs/updates/deletes packages that provide daemons, +or admins modify services in local stores: + <ul> + <li> The package manager, or the admin, invokes +<a href="s6-rc-repo-sync.html">s6-rc-repo-sync</a> to keep the sets in the +repository in sync with the stores. </li> + <li> It may also be necessary to commit the live set again with +<a href="s6-rc-set-commit.html">s6-rc-set-commit</a>, and to install it with +<a href="s6-rc-repo-set-install.html">s6-rc-repo-set-install</a>, so the live +database is also kept in sync with the machine state. (Failure to do so may +prevent the machine from booting next time.) + </ul> </li> + <li> <strong>Whenever the admin wants to customize their startup process</strong>: + <ul> + <li> They can create new sets (with default subs coming from policy that's +hardcoded in the stores) with <a href="s6-rc-set-new.html">s6-rc-set-new</a>, +make a copy of an existing set with <a href="s6-rc-set-copy.html">s6-rc-set-copy</a>, +or delete sets with <a href="s6-rc-set-delete.html">s6-rc-set-delete</a>. </li> + <li> They mask, unmask, enable or disable services in their favorite set with +<a href="s6-rc-set-change.html">s6-rc-set-change</a>. </li> + <li> They commit the set with <a href="s6-rc-set-commit.html">s6-rc-set-commit</a>. </li> + <li> They install the set with <a href="s6-rc-set-install.html">s6-rc-set-install</a>. +This action potentially modifies the current state of the machine! </li> + </ul> </li> + <li> <strong>At boot time</strong>: + <ul> + <li> The system boots on the installed live database. None of the <em>repo</em> +commands are involved. </li> + </ul> </li> +</ul> + +<p> + Note that all these steps will be made easier in the near future by the higher-level +user interface provided by +<a href="s6-frontend.html">s6-frontend</a>. +</p> + +</body> +</html> diff --git a/package/deps.mak b/package/deps.mak index 2f7e0f0..73bb12d 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -22,6 +22,7 @@ src/libs6rc/s6rc_ls.o src/libs6rc/s6rc_ls.lo: src/libs6rc/s6rc_ls.c src/include/ src/libs6rc/s6rc_nlto0.o src/libs6rc/s6rc_nlto0.lo: src/libs6rc/s6rc_nlto0.c src/include/s6-rc/s6rc-utils.h src/libs6rc/s6rc_read_uint.o src/libs6rc/s6rc_read_uint.lo: src/libs6rc/s6rc_read_uint.c src/include/s6-rc/s6rc-utils.h src/libs6rc/s6rc_repo_badsub.o src/libs6rc/s6rc_repo_badsub.lo: src/libs6rc/s6rc_repo_badsub.c src/include/s6-rc/repo.h +src/libs6rc/s6rc_repo_checkset.o src/libs6rc/s6rc_repo_checkset.lo: src/libs6rc/s6rc_repo_checkset.c src/include/s6-rc/repo.h src/include/s6-rc/s6rc-utils.h src/libs6rc/s6rc_repo_cleanup.o src/libs6rc/s6rc_repo_cleanup.lo: src/libs6rc/s6rc_repo_cleanup.c src/include/s6-rc/repo.h src/libs6rc/s6rc_repo_compile.o src/libs6rc/s6rc_repo_compile.lo: src/libs6rc/s6rc_repo_compile.c src/include/s6-rc/config.h src/include/s6-rc/repo.h src/libs6rc/s6rc_repo_fillset.o src/libs6rc/s6rc_repo_fillset.lo: src/libs6rc/s6rc_repo_fillset.c src/include/s6-rc/repo.h src/include/s6-rc/s6rc-utils.h @@ -43,6 +44,7 @@ src/libs6rc/s6rc_repo_makesvlist_byname.o src/libs6rc/s6rc_repo_makesvlist_bynam src/libs6rc/s6rc_repo_moveservices.o src/libs6rc/s6rc_repo_moveservices.lo: src/libs6rc/s6rc_repo_moveservices.c src/include/s6-rc/repo.h src/libs6rc/s6rc_repo_refcompile.o src/libs6rc/s6rc_repo_refcompile.lo: src/libs6rc/s6rc_repo_refcompile.c src/include/s6-rc/repo.h src/libs6rc/s6rc_repo_setcompile.o src/libs6rc/s6rc_repo_setcompile.lo: src/libs6rc/s6rc_repo_setcompile.c src/include/s6-rc/repo.h +src/libs6rc/s6rc_repo_setuptodate.o src/libs6rc/s6rc_repo_setuptodate.lo: src/libs6rc/s6rc_repo_setuptodate.c src/include/s6-rc/repo.h src/include/s6-rc/s6rc-utils.h src/libs6rc/s6rc_repo_subnames.o src/libs6rc/s6rc_repo_subnames.lo: src/libs6rc/s6rc_repo_subnames.c src/include/s6-rc/repo.h src/libs6rc/s6rc_repo_sv_bcmpr.o src/libs6rc/s6rc_repo_sv_bcmpr.lo: src/libs6rc/s6rc_repo_sv_bcmpr.c src/include/s6-rc/repo.h src/libs6rc/s6rc_repo_sv_cmpr.o src/libs6rc/s6rc_repo_sv_cmpr.lo: src/libs6rc/s6rc_repo_sv_cmpr.c src/include/s6-rc/repo.h @@ -63,10 +65,11 @@ src/libs6rc/s6rc_strrefcmp.o src/libs6rc/s6rc_strrefcmp.lo: src/libs6rc/s6rc_str src/libs6rc/s6rc_type_check.o src/libs6rc/s6rc_type_check.lo: src/libs6rc/s6rc_type_check.c src/include/s6-rc/s6rc-utils.h src/repo/s6-rc-repo-init.o src/repo/s6-rc-repo-init.lo: src/repo/s6-rc-repo-init.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/repo/s6-rc-repo-sync.o src/repo/s6-rc-repo-sync.lo: src/repo/s6-rc-repo-sync.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h -src/repo/s6-rc-set-changestate.o src/repo/s6-rc-set-changestate.lo: src/repo/s6-rc-set-changestate.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h +src/repo/s6-rc-set-change.o src/repo/s6-rc-set-change.lo: src/repo/s6-rc-set-change.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/repo/s6-rc-set-commit.o src/repo/s6-rc-set-commit.lo: src/repo/s6-rc-set-commit.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/repo/s6-rc-set-copy.o src/repo/s6-rc-set-copy.lo: src/repo/s6-rc-set-copy.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/repo/s6-rc-set-delete.o src/repo/s6-rc-set-delete.lo: src/repo/s6-rc-set-delete.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h +src/repo/s6-rc-set-install.o src/repo/s6-rc-set-install.lo: src/repo/s6-rc-set-install.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/repo/s6-rc-set-new.o src/repo/s6-rc-set-new.lo: src/repo/s6-rc-set-new.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/s6-rc/s6-rc-bundle.o src/s6-rc/s6-rc-bundle.lo: src/s6-rc/s6-rc-bundle.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/s6-rc/s6-rc-compile.o src/s6-rc/s6-rc-compile.lo: src/s6-rc/s6-rc-compile.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h @@ -80,27 +83,29 @@ src/s6-rc/s6-rc-update.o src/s6-rc/s6-rc-update.lo: src/s6-rc/s6-rc-update.c src src/s6-rc/s6-rc.o src/s6-rc/s6-rc.lo: src/s6-rc/s6-rc.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) -libs6rc.a.xyzzy: src/libs6rc/s6rc_db_check_depcycles.o src/libs6rc/s6rc_db_check_pipelines.o src/libs6rc/s6rc_db_check_revdeps.o src/libs6rc/s6rc_db_read.o src/libs6rc/s6rc_db_read_sizes.o src/libs6rc/s6rc_db_read_uint32.o src/libs6rc/s6rc_graph_closure.o src/libs6rc/s6rc_live_state_size.o src/libs6rc/s6rc_live_state_read.o src/libs6rc/s6rc_livedir_canon.o src/libs6rc/s6rc_livedir_create.o src/libs6rc/s6rc_livedir_prefix.o src/libs6rc/s6rc_livedir_prefixsize.o src/libs6rc/s6rc_lock.o src/libs6rc/s6rc_ls.o src/libs6rc/s6rc_nlto0.o src/libs6rc/s6rc_read_uint.o src/libs6rc/s6rc_repo_badsub.o src/libs6rc/s6rc_repo_cleanup.o src/libs6rc/s6rc_repo_compile.o src/libs6rc/s6rc_repo_fillset.o src/libs6rc/s6rc_repo_fixset.o src/libs6rc/s6rc_repo_flattenservices.o src/libs6rc/s6rc_repo_list_sets.o src/libs6rc/s6rc_repo_listalldeps.o src/libs6rc/s6rc_repo_listcontents.o src/libs6rc/s6rc_repo_listdeps.o src/libs6rc/s6rc_repo_listdeps_internal.o src/libs6rc/s6rc_repo_listsub.o src/libs6rc/s6rc_repo_lock.o src/libs6rc/s6rc_repo_makedefbundle.o src/libs6rc/s6rc_repo_makesetbundles.o src/libs6rc/s6rc_repo_makestores.o src/libs6rc/s6rc_repo_makesvlist.o src/libs6rc/s6rc_repo_makesvlist_byname.o src/libs6rc/s6rc_repo_moveservices.o src/libs6rc/s6rc_repo_refcompile.o src/libs6rc/s6rc_repo_setcompile.o src/libs6rc/s6rc_repo_subnames.o src/libs6rc/s6rc_repo_sv_bcmpr.o src/libs6rc/s6rc_repo_sv_cmpr.o src/libs6rc/s6rc_repo_sync.o src/libs6rc/s6rc_repo_syncset.o src/libs6rc/s6rc_repo_syncset_tmp.o src/libs6rc/s6rc_repo_touch.o src/libs6rc/s6rc_repo_touchset.o src/libs6rc/s6rc_sanitize_dir.o src/libs6rc/s6rc_servicedir_internal.o src/libs6rc/s6rc_servicedir_block.o src/libs6rc/s6rc_servicedir_unblock.o src/libs6rc/s6rc_servicedir_copy_offline.o src/libs6rc/s6rc_servicedir_copy_online.o src/libs6rc/s6rc_servicedir_manage.o src/libs6rc/s6rc_servicedir_unsupervise.o src/libs6rc/s6rc_strrefcmp.o src/libs6rc/s6rc_type_check.o +libs6rc.a.xyzzy: src/libs6rc/s6rc_db_check_depcycles.o src/libs6rc/s6rc_db_check_pipelines.o src/libs6rc/s6rc_db_check_revdeps.o src/libs6rc/s6rc_db_read.o src/libs6rc/s6rc_db_read_sizes.o src/libs6rc/s6rc_db_read_uint32.o src/libs6rc/s6rc_graph_closure.o src/libs6rc/s6rc_live_state_size.o src/libs6rc/s6rc_live_state_read.o src/libs6rc/s6rc_livedir_canon.o src/libs6rc/s6rc_livedir_create.o src/libs6rc/s6rc_livedir_prefix.o src/libs6rc/s6rc_livedir_prefixsize.o src/libs6rc/s6rc_lock.o src/libs6rc/s6rc_ls.o src/libs6rc/s6rc_nlto0.o src/libs6rc/s6rc_read_uint.o src/libs6rc/s6rc_repo_badsub.o src/libs6rc/s6rc_repo_checkset.o src/libs6rc/s6rc_repo_cleanup.o src/libs6rc/s6rc_repo_compile.o src/libs6rc/s6rc_repo_fillset.o src/libs6rc/s6rc_repo_fixset.o src/libs6rc/s6rc_repo_flattenservices.o src/libs6rc/s6rc_repo_list_sets.o src/libs6rc/s6rc_repo_listalldeps.o src/libs6rc/s6rc_repo_listcontents.o src/libs6rc/s6rc_repo_listdeps.o src/libs6rc/s6rc_repo_listdeps_internal.o src/libs6rc/s6rc_repo_listsub.o src/libs6rc/s6rc_repo_lock.o src/libs6rc/s6rc_repo_makedefbundle.o src/libs6rc/s6rc_repo_makesetbundles.o src/libs6rc/s6rc_repo_makestores.o src/libs6rc/s6rc_repo_makesvlist.o src/libs6rc/s6rc_repo_makesvlist_byname.o src/libs6rc/s6rc_repo_moveservices.o src/libs6rc/s6rc_repo_refcompile.o src/libs6rc/s6rc_repo_setcompile.o src/libs6rc/s6rc_repo_setuptodate.o src/libs6rc/s6rc_repo_subnames.o src/libs6rc/s6rc_repo_sv_bcmpr.o src/libs6rc/s6rc_repo_sv_cmpr.o src/libs6rc/s6rc_repo_sync.o src/libs6rc/s6rc_repo_syncset.o src/libs6rc/s6rc_repo_syncset_tmp.o src/libs6rc/s6rc_repo_touch.o src/libs6rc/s6rc_repo_touchset.o src/libs6rc/s6rc_sanitize_dir.o src/libs6rc/s6rc_servicedir_internal.o src/libs6rc/s6rc_servicedir_block.o src/libs6rc/s6rc_servicedir_unblock.o src/libs6rc/s6rc_servicedir_copy_offline.o src/libs6rc/s6rc_servicedir_copy_online.o src/libs6rc/s6rc_servicedir_manage.o src/libs6rc/s6rc_servicedir_unsupervise.o src/libs6rc/s6rc_strrefcmp.o src/libs6rc/s6rc_type_check.o else -libs6rc.a.xyzzy:src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_live_state_size.lo src/libs6rc/s6rc_live_state_read.lo src/libs6rc/s6rc_livedir_canon.lo src/libs6rc/s6rc_livedir_create.lo src/libs6rc/s6rc_livedir_prefix.lo src/libs6rc/s6rc_livedir_prefixsize.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_ls.lo src/libs6rc/s6rc_nlto0.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_repo_badsub.lo src/libs6rc/s6rc_repo_cleanup.lo src/libs6rc/s6rc_repo_compile.lo src/libs6rc/s6rc_repo_fillset.lo src/libs6rc/s6rc_repo_fixset.lo src/libs6rc/s6rc_repo_flattenservices.lo src/libs6rc/s6rc_repo_list_sets.lo src/libs6rc/s6rc_repo_listalldeps.lo src/libs6rc/s6rc_repo_listcontents.lo src/libs6rc/s6rc_repo_listdeps.lo src/libs6rc/s6rc_repo_listdeps_internal.lo src/libs6rc/s6rc_repo_listsub.lo src/libs6rc/s6rc_repo_lock.lo src/libs6rc/s6rc_repo_makedefbundle.lo src/libs6rc/s6rc_repo_makesetbundles.lo src/libs6rc/s6rc_repo_makestores.lo src/libs6rc/s6rc_repo_makesvlist.lo src/libs6rc/s6rc_repo_makesvlist_byname.lo src/libs6rc/s6rc_repo_moveservices.lo src/libs6rc/s6rc_repo_refcompile.lo src/libs6rc/s6rc_repo_setcompile.lo src/libs6rc/s6rc_repo_subnames.lo src/libs6rc/s6rc_repo_sv_bcmpr.lo src/libs6rc/s6rc_repo_sv_cmpr.lo src/libs6rc/s6rc_repo_sync.lo src/libs6rc/s6rc_repo_syncset.lo src/libs6rc/s6rc_repo_syncset_tmp.lo src/libs6rc/s6rc_repo_touch.lo src/libs6rc/s6rc_repo_touchset.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo src/libs6rc/s6rc_servicedir_manage.lo src/libs6rc/s6rc_servicedir_unsupervise.lo src/libs6rc/s6rc_strrefcmp.lo src/libs6rc/s6rc_type_check.lo +libs6rc.a.xyzzy:src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_live_state_size.lo src/libs6rc/s6rc_live_state_read.lo src/libs6rc/s6rc_livedir_canon.lo src/libs6rc/s6rc_livedir_create.lo src/libs6rc/s6rc_livedir_prefix.lo src/libs6rc/s6rc_livedir_prefixsize.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_ls.lo src/libs6rc/s6rc_nlto0.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_repo_badsub.lo src/libs6rc/s6rc_repo_checkset.lo src/libs6rc/s6rc_repo_cleanup.lo src/libs6rc/s6rc_repo_compile.lo src/libs6rc/s6rc_repo_fillset.lo src/libs6rc/s6rc_repo_fixset.lo src/libs6rc/s6rc_repo_flattenservices.lo src/libs6rc/s6rc_repo_list_sets.lo src/libs6rc/s6rc_repo_listalldeps.lo src/libs6rc/s6rc_repo_listcontents.lo src/libs6rc/s6rc_repo_listdeps.lo src/libs6rc/s6rc_repo_listdeps_internal.lo src/libs6rc/s6rc_repo_listsub.lo src/libs6rc/s6rc_repo_lock.lo src/libs6rc/s6rc_repo_makedefbundle.lo src/libs6rc/s6rc_repo_makesetbundles.lo src/libs6rc/s6rc_repo_makestores.lo src/libs6rc/s6rc_repo_makesvlist.lo src/libs6rc/s6rc_repo_makesvlist_byname.lo src/libs6rc/s6rc_repo_moveservices.lo src/libs6rc/s6rc_repo_refcompile.lo src/libs6rc/s6rc_repo_setcompile.lo src/libs6rc/s6rc_repo_setuptodate.lo src/libs6rc/s6rc_repo_subnames.lo src/libs6rc/s6rc_repo_sv_bcmpr.lo src/libs6rc/s6rc_repo_sv_cmpr.lo src/libs6rc/s6rc_repo_sync.lo src/libs6rc/s6rc_repo_syncset.lo src/libs6rc/s6rc_repo_syncset_tmp.lo src/libs6rc/s6rc_repo_touch.lo src/libs6rc/s6rc_repo_touchset.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo src/libs6rc/s6rc_servicedir_manage.lo src/libs6rc/s6rc_servicedir_unsupervise.lo src/libs6rc/s6rc_strrefcmp.lo src/libs6rc/s6rc_type_check.lo endif libs6rc.pc: EXTRA_LIBS := -ls6 -lskarnet ${SPAWN_LIB} libs6rc.so.xyzzy: EXTRA_LIBS := -ls6 -lskarnet ${SPAWN_LIB} -libs6rc.so.xyzzy:src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_live_state_size.lo src/libs6rc/s6rc_live_state_read.lo src/libs6rc/s6rc_livedir_canon.lo src/libs6rc/s6rc_livedir_create.lo src/libs6rc/s6rc_livedir_prefix.lo src/libs6rc/s6rc_livedir_prefixsize.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_ls.lo src/libs6rc/s6rc_nlto0.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_repo_badsub.lo src/libs6rc/s6rc_repo_cleanup.lo src/libs6rc/s6rc_repo_compile.lo src/libs6rc/s6rc_repo_fillset.lo src/libs6rc/s6rc_repo_fixset.lo src/libs6rc/s6rc_repo_flattenservices.lo src/libs6rc/s6rc_repo_list_sets.lo src/libs6rc/s6rc_repo_listalldeps.lo src/libs6rc/s6rc_repo_listcontents.lo src/libs6rc/s6rc_repo_listdeps.lo src/libs6rc/s6rc_repo_listdeps_internal.lo src/libs6rc/s6rc_repo_listsub.lo src/libs6rc/s6rc_repo_lock.lo src/libs6rc/s6rc_repo_makedefbundle.lo src/libs6rc/s6rc_repo_makesetbundles.lo src/libs6rc/s6rc_repo_makestores.lo src/libs6rc/s6rc_repo_makesvlist.lo src/libs6rc/s6rc_repo_makesvlist_byname.lo src/libs6rc/s6rc_repo_moveservices.lo src/libs6rc/s6rc_repo_refcompile.lo src/libs6rc/s6rc_repo_setcompile.lo src/libs6rc/s6rc_repo_subnames.lo src/libs6rc/s6rc_repo_sv_bcmpr.lo src/libs6rc/s6rc_repo_sv_cmpr.lo src/libs6rc/s6rc_repo_sync.lo src/libs6rc/s6rc_repo_syncset.lo src/libs6rc/s6rc_repo_syncset_tmp.lo src/libs6rc/s6rc_repo_touch.lo src/libs6rc/s6rc_repo_touchset.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo src/libs6rc/s6rc_servicedir_manage.lo src/libs6rc/s6rc_servicedir_unsupervise.lo src/libs6rc/s6rc_strrefcmp.lo src/libs6rc/s6rc_type_check.lo +libs6rc.so.xyzzy:src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_live_state_size.lo src/libs6rc/s6rc_live_state_read.lo src/libs6rc/s6rc_livedir_canon.lo src/libs6rc/s6rc_livedir_create.lo src/libs6rc/s6rc_livedir_prefix.lo src/libs6rc/s6rc_livedir_prefixsize.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_ls.lo src/libs6rc/s6rc_nlto0.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_repo_badsub.lo src/libs6rc/s6rc_repo_checkset.lo src/libs6rc/s6rc_repo_cleanup.lo src/libs6rc/s6rc_repo_compile.lo src/libs6rc/s6rc_repo_fillset.lo src/libs6rc/s6rc_repo_fixset.lo src/libs6rc/s6rc_repo_flattenservices.lo src/libs6rc/s6rc_repo_list_sets.lo src/libs6rc/s6rc_repo_listalldeps.lo src/libs6rc/s6rc_repo_listcontents.lo src/libs6rc/s6rc_repo_listdeps.lo src/libs6rc/s6rc_repo_listdeps_internal.lo src/libs6rc/s6rc_repo_listsub.lo src/libs6rc/s6rc_repo_lock.lo src/libs6rc/s6rc_repo_makedefbundle.lo src/libs6rc/s6rc_repo_makesetbundles.lo src/libs6rc/s6rc_repo_makestores.lo src/libs6rc/s6rc_repo_makesvlist.lo src/libs6rc/s6rc_repo_makesvlist_byname.lo src/libs6rc/s6rc_repo_moveservices.lo src/libs6rc/s6rc_repo_refcompile.lo src/libs6rc/s6rc_repo_setcompile.lo src/libs6rc/s6rc_repo_setuptodate.lo src/libs6rc/s6rc_repo_subnames.lo src/libs6rc/s6rc_repo_sv_bcmpr.lo src/libs6rc/s6rc_repo_sv_cmpr.lo src/libs6rc/s6rc_repo_sync.lo src/libs6rc/s6rc_repo_syncset.lo src/libs6rc/s6rc_repo_syncset_tmp.lo src/libs6rc/s6rc_repo_touch.lo src/libs6rc/s6rc_repo_touchset.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo src/libs6rc/s6rc_servicedir_manage.lo src/libs6rc/s6rc_servicedir_unsupervise.lo src/libs6rc/s6rc_strrefcmp.lo src/libs6rc/s6rc_type_check.lo libs6rc.dylib.xyzzy: EXTRA_LIBS := -ls6 -lskarnet ${SPAWN_LIB} -libs6rc.dylib.xyzzy:src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_live_state_size.lo src/libs6rc/s6rc_live_state_read.lo src/libs6rc/s6rc_livedir_canon.lo src/libs6rc/s6rc_livedir_create.lo src/libs6rc/s6rc_livedir_prefix.lo src/libs6rc/s6rc_livedir_prefixsize.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_ls.lo src/libs6rc/s6rc_nlto0.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_repo_badsub.lo src/libs6rc/s6rc_repo_cleanup.lo src/libs6rc/s6rc_repo_compile.lo src/libs6rc/s6rc_repo_fillset.lo src/libs6rc/s6rc_repo_fixset.lo src/libs6rc/s6rc_repo_flattenservices.lo src/libs6rc/s6rc_repo_list_sets.lo src/libs6rc/s6rc_repo_listalldeps.lo src/libs6rc/s6rc_repo_listcontents.lo src/libs6rc/s6rc_repo_listdeps.lo src/libs6rc/s6rc_repo_listdeps_internal.lo src/libs6rc/s6rc_repo_listsub.lo src/libs6rc/s6rc_repo_lock.lo src/libs6rc/s6rc_repo_makedefbundle.lo src/libs6rc/s6rc_repo_makesetbundles.lo src/libs6rc/s6rc_repo_makestores.lo src/libs6rc/s6rc_repo_makesvlist.lo src/libs6rc/s6rc_repo_makesvlist_byname.lo src/libs6rc/s6rc_repo_moveservices.lo src/libs6rc/s6rc_repo_refcompile.lo src/libs6rc/s6rc_repo_setcompile.lo src/libs6rc/s6rc_repo_subnames.lo src/libs6rc/s6rc_repo_sv_bcmpr.lo src/libs6rc/s6rc_repo_sv_cmpr.lo src/libs6rc/s6rc_repo_sync.lo src/libs6rc/s6rc_repo_syncset.lo src/libs6rc/s6rc_repo_syncset_tmp.lo src/libs6rc/s6rc_repo_touch.lo src/libs6rc/s6rc_repo_touchset.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo src/libs6rc/s6rc_servicedir_manage.lo src/libs6rc/s6rc_servicedir_unsupervise.lo src/libs6rc/s6rc_strrefcmp.lo src/libs6rc/s6rc_type_check.lo +libs6rc.dylib.xyzzy:src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_live_state_size.lo src/libs6rc/s6rc_live_state_read.lo src/libs6rc/s6rc_livedir_canon.lo src/libs6rc/s6rc_livedir_create.lo src/libs6rc/s6rc_livedir_prefix.lo src/libs6rc/s6rc_livedir_prefixsize.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_ls.lo src/libs6rc/s6rc_nlto0.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_repo_badsub.lo src/libs6rc/s6rc_repo_checkset.lo src/libs6rc/s6rc_repo_cleanup.lo src/libs6rc/s6rc_repo_compile.lo src/libs6rc/s6rc_repo_fillset.lo src/libs6rc/s6rc_repo_fixset.lo src/libs6rc/s6rc_repo_flattenservices.lo src/libs6rc/s6rc_repo_list_sets.lo src/libs6rc/s6rc_repo_listalldeps.lo src/libs6rc/s6rc_repo_listcontents.lo src/libs6rc/s6rc_repo_listdeps.lo src/libs6rc/s6rc_repo_listdeps_internal.lo src/libs6rc/s6rc_repo_listsub.lo src/libs6rc/s6rc_repo_lock.lo src/libs6rc/s6rc_repo_makedefbundle.lo src/libs6rc/s6rc_repo_makesetbundles.lo src/libs6rc/s6rc_repo_makestores.lo src/libs6rc/s6rc_repo_makesvlist.lo src/libs6rc/s6rc_repo_makesvlist_byname.lo src/libs6rc/s6rc_repo_moveservices.lo src/libs6rc/s6rc_repo_refcompile.lo src/libs6rc/s6rc_repo_setcompile.lo src/libs6rc/s6rc_repo_setuptodate.lo src/libs6rc/s6rc_repo_subnames.lo src/libs6rc/s6rc_repo_sv_bcmpr.lo src/libs6rc/s6rc_repo_sv_cmpr.lo src/libs6rc/s6rc_repo_sync.lo src/libs6rc/s6rc_repo_syncset.lo src/libs6rc/s6rc_repo_syncset_tmp.lo src/libs6rc/s6rc_repo_touch.lo src/libs6rc/s6rc_repo_touchset.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo src/libs6rc/s6rc_servicedir_manage.lo src/libs6rc/s6rc_servicedir_unsupervise.lo src/libs6rc/s6rc_strrefcmp.lo src/libs6rc/s6rc_type_check.lo s6-rc-repo-init: EXTRA_LIBS := ${SYSCLOCK_LIB} s6-rc-repo-init: src/repo/s6-rc-repo-init.o ${LIBS6RC} -lskarnet s6-rc-repo-sync: EXTRA_LIBS := ${SYSCLOCK_LIB} s6-rc-repo-sync: src/repo/s6-rc-repo-sync.o ${LIBS6RC} -lskarnet -s6-rc-set-changestate: EXTRA_LIBS := ${SYSCLOCK_LIB} -s6-rc-set-changestate: src/repo/s6-rc-set-changestate.o ${LIBS6RC} -lskarnet +s6-rc-set-change: EXTRA_LIBS := ${SYSCLOCK_LIB} +s6-rc-set-change: src/repo/s6-rc-set-change.o ${LIBS6RC} -lskarnet s6-rc-set-commit: EXTRA_LIBS := ${SYSCLOCK_LIB} s6-rc-set-commit: src/repo/s6-rc-set-commit.o ${LIBS6RC} -lskarnet s6-rc-set-copy: EXTRA_LIBS := ${SYSCLOCK_LIB} s6-rc-set-copy: src/repo/s6-rc-set-copy.o ${LIBS6RC} -lskarnet s6-rc-set-delete: EXTRA_LIBS := ${SYSCLOCK_LIB} s6-rc-set-delete: src/repo/s6-rc-set-delete.o ${LIBS6RC} -lskarnet +s6-rc-set-install: EXTRA_LIBS := ${SYSCLOCK_LIB} +s6-rc-set-install: src/repo/s6-rc-set-install.o ${LIBS6RC} -lskarnet s6-rc-set-new: EXTRA_LIBS := ${SYSCLOCK_LIB} s6-rc-set-new: src/repo/s6-rc-set-new.o ${LIBS6RC} -lskarnet s6-rc: EXTRA_LIBS := ${SYSCLOCK_LIB} ${SPAWN_LIB} diff --git a/package/modes b/package/modes index f565295..a940c7a 100644 --- a/package/modes +++ b/package/modes @@ -13,5 +13,6 @@ s6-rc-repo-sync 0755 s6-rc-set-new 0755 s6-rc-set-copy 0755 s6-rc-set-delete 0755 -s6-rc-set-changestate 0755 +s6-rc-set-change 0755 s6-rc-set-commit 0755 +s6-rc-set-install 0755 diff --git a/package/targets.mak b/package/targets.mak index feffc92..08f564b 100644 --- a/package/targets.mak +++ b/package/targets.mak @@ -12,8 +12,9 @@ s6-rc-repo-sync \ s6-rc-set-new \ s6-rc-set-copy \ s6-rc-set-delete \ -s6-rc-set-changestate \ +s6-rc-set-change \ s6-rc-set-commit \ +s6-rc-set-install \ LIBEXEC_TARGETS := \ s6-rc-fdholder-filler \ diff --git a/src/include/s6-rc/repo.h b/src/include/s6-rc/repo.h index 5d0426a..f611059 100644 --- a/src/include/s6-rc/repo.h +++ b/src/include/s6-rc/repo.h @@ -32,6 +32,8 @@ extern int s6rc_repo_syncset_tmp (char const *, char const *, stralloc *, genall extern int s6rc_repo_lock (char const *, int) ; extern int s6rc_repo_touch (char const *) ; extern int s6rc_repo_touchset (char const *, char const *) ; +extern int s6rc_repo_checkset (char const *, char const *) ; +extern int s6rc_repo_setuptodate (char const *, char const *) ; extern int s6rc_repo_makesetbundles (char const *, char const *, unsigned int) ; extern int s6rc_repo_makedefbundle (char const *, char const *, char const *) ; diff --git a/src/libs6rc/deps-lib/s6rc b/src/libs6rc/deps-lib/s6rc index 79c2909..02797a8 100644 --- a/src/libs6rc/deps-lib/s6rc +++ b/src/libs6rc/deps-lib/s6rc @@ -16,6 +16,7 @@ s6rc_ls.o s6rc_nlto0.o s6rc_read_uint.o s6rc_repo_badsub.o +s6rc_repo_checkset.o s6rc_repo_cleanup.o s6rc_repo_compile.o s6rc_repo_fillset.o @@ -36,6 +37,7 @@ s6rc_repo_makesvlist_byname.o s6rc_repo_moveservices.o s6rc_repo_refcompile.o s6rc_repo_setcompile.o +s6rc_repo_setuptodate.o s6rc_repo_subnames.o s6rc_repo_sv_bcmpr.o s6rc_repo_sv_cmpr.o diff --git a/src/libs6rc/s6rc_repo_checkset.c b/src/libs6rc/s6rc_repo_checkset.c new file mode 100644 index 0000000..adf8674 --- /dev/null +++ b/src/libs6rc/s6rc_repo_checkset.c @@ -0,0 +1,40 @@ +/* ISC license. */ + +#include <string.h> +#include <errno.h> + +#include <skalibs/stat.h> +#include <skalibs/strerr.h> + +#include <s6-rc/s6rc-utils.h> +#include <s6-rc/repo.h> + +int s6rc_repo_checkset (char const *repo, char const *set) +{ + struct stat st ; + size_t repolen = strlen(repo) ; + size_t setlen = strlen(set) ; + char fn[repolen + 10 + setlen] ; + memcpy(fn, repo, repolen) ; + memcpy(fn + repolen, "/sources/", 9) ; + memcpy(fn + repolen + 9, set, setlen + 1) ; + if (stat(fn, &st) == -1) + { + if (errno == ENOENT) + { + strerr_warnf4x("set ", set, " does not exist in repository ", repo) ; + return 3 ; + } + else + { + strerr_warnfu2sys("stat ", fn) ; + return 111 ; + } + } + if (!S_ISDIR(st.st_mode)) + { + strerr_warnf3x("file ", fn, " is not a directory") ; + return 102 ; + } + return 0 ; +} diff --git a/src/libs6rc/s6rc_repo_compile.c b/src/libs6rc/s6rc_repo_compile.c index b31a981..ac4207d 100644 --- a/src/libs6rc/s6rc_repo_compile.c +++ b/src/libs6rc/s6rc_repo_compile.c @@ -93,7 +93,7 @@ int s6rc_repo_compile (char const *repo, char const *set, char const *const *sub char fn[repolen + setlen + 11] ; memcpy(fn, newc, repolen + 10) ; memcpy(fn + repolen + 10, set, setlen + 1) ; - if (!atomic_symlink4(newc + repolen + 10, fn, oldc + repolen + 10, repolen + setlen + 45)) + if (!atomic_symlink4(newc + repolen + 10, fn, oldc + repolen + 10, setlen + 35)) { int e = errno ; rm_rf(newc) ; diff --git a/src/libs6rc/s6rc_repo_setuptodate.c b/src/libs6rc/s6rc_repo_setuptodate.c new file mode 100644 index 0000000..9e9fe58 --- /dev/null +++ b/src/libs6rc/s6rc_repo_setuptodate.c @@ -0,0 +1,45 @@ +/* ISC license. */ + +#include <skalibs/bsdsnowflake.h> + +#include <string.h> +#include <errno.h> + +#include <skalibs/stat.h> +#include <skalibs/strerr.h> + +#include <s6-rc/s6rc-utils.h> +#include <s6-rc/repo.h> + +int s6rc_repo_setuptodate (char const *repo, char const *set) +{ + struct stat stsource ; + struct stat stcompiled ; + size_t repolen = strlen(repo) ; + size_t setlen = strlen(set) ; + char srcfn[repolen + 17 + setlen] ; + char dstfn[repolen + 11 + setlen] ; + memcpy(srcfn, repo, repolen) ; + memcpy(srcfn + repolen, "/sources/", 9) ; + memcpy(srcfn + repolen + 9, set, setlen) ; + memcpy(srcfn + repolen + 9 + setlen, "/.stamp", 8) ; + memcpy(dstfn, repo, repolen) ; + memcpy(dstfn + repolen, "/compiled/", 10) ; + memcpy(dstfn + repolen + 10, set, setlen + 1) ; + if (stat(srcfn, &stsource) == -1) + { + strerr_warnfu2sys("stat ", srcfn) ; + return -1 ; + } + if (stat(dstfn, &stcompiled) == -1) + { + if (errno == ENOENT) return 0 ; + strerr_warnfu2sys("stat ", dstfn) ; + return -1 ; + } + return + stsource.st_atim.tv_sec < stcompiled.st_atim.tv_sec ? 1 : + stsource.st_atim.tv_sec > stcompiled.st_atim.tv_sec ? 0 : + stsource.st_atim.tv_nsec < stcompiled.st_atim.tv_nsec ; +} + diff --git a/src/repo/deps-exe/s6-rc-set-changestate b/src/repo/deps-exe/s6-rc-set-change index 6dd7af7..6dd7af7 100644 --- a/src/repo/deps-exe/s6-rc-set-changestate +++ b/src/repo/deps-exe/s6-rc-set-change diff --git a/src/repo/deps-exe/s6-rc-set-install b/src/repo/deps-exe/s6-rc-set-install new file mode 100644 index 0000000..6dd7af7 --- /dev/null +++ b/src/repo/deps-exe/s6-rc-set-install @@ -0,0 +1,3 @@ +${LIBS6RC} +-lskarnet +${SYSCLOCK_LIB} diff --git a/src/repo/s6-rc-set-changestate.c b/src/repo/s6-rc-set-change.c index 1064051..c659471 100644 --- a/src/repo/s6-rc-set-changestate.c +++ b/src/repo/s6-rc-set-change.c @@ -17,7 +17,7 @@ #include <s6-rc/config.h> #include <s6-rc/s6rc.h> -#define USAGE "s6-rc-set-changestate [ -v verbosity ] [ -r repo ] [ -E ] [ -f | -I fail|pull|warn ] [ -n ] set newstate services..." +#define USAGE "s6-rc-set-change [ -v verbosity ] [ -r repo ] [ -E ] [ -f | -I fail|pull|warn ] [ -n ] set newstate services..." #define dieusage() strerr_dieusage(100, USAGE) enum golb_e @@ -101,7 +101,7 @@ int main (int argc, char const *const *argv) s6rc_repo_sv *list ; uint32_t listn, n ; - PROG = "s6-rc-set-changestate" ; + PROG = "s6-rc-set-change" ; wgola[GOLA_REPODIR] = S6RC_REPO_BASE ; golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ; diff --git a/src/repo/s6-rc-set-commit.c b/src/repo/s6-rc-set-commit.c index 908f307..efdb2a9 100644 --- a/src/repo/s6-rc-set-commit.c +++ b/src/repo/s6-rc-set-commit.c @@ -51,60 +51,12 @@ static gol_arg const rgola[] = { .so = 'h', .lo = "fdholder-user", .i = GOLA_FDHUSER } } ; -static uint64_t wgolb = 0 ; - -static inline void check_set (char const *repo, char const *set) -{ - struct stat st ; - size_t repolen = strlen(repo) ; - size_t setlen = strlen(set) ; - char fn[repolen + 10 + setlen] ; - memcpy(fn, repo, repolen) ; - memcpy(fn + repolen, "/sources/", 9) ; - memcpy(fn + repolen + 9, set, setlen + 1) ; - if (stat(fn, &st) == -1) - { - if (errno == ENOENT) - strerr_dief4x(3, "set ", set, " does not exist in repository ", repo) ; - else strerr_diefu2sys(111, "stat ", fn) ; - } - if (!S_ISDIR(st.st_mode)) - strerr_dief3x(102, "file ", fn, " is not a directory") ; -} - -static inline int uptodate (char const *repo, char const *set) -{ - struct stat stsource ; - struct stat stcompiled ; - size_t repolen = strlen(repo) ; - size_t setlen = strlen(set) ; - char srcfn[repolen + 17 + setlen] ; - char dstfn[repolen + 11 + setlen] ; - memcpy(srcfn, repo, repolen) ; - memcpy(srcfn + repolen, "/sources/", 9) ; - memcpy(srcfn + repolen + 9, set, setlen) ; - memcpy(srcfn + repolen + 9 + setlen, "/.stamp", 8) ; - memcpy(dstfn, repo, repolen) ; - memcpy(dstfn + repolen, "/compiled/", 10) ; - memcpy(dstfn + repolen + 10, set, setlen + 1) ; - if (stat(srcfn, &stsource) == -1) - strerr_diefu2sys(111, "stat ", srcfn) ; - if (stat(dstfn, &stcompiled) == -1) - { - if (errno == ENOENT) return 0 ; - else strerr_diefu2sys(111, "stat ", dstfn) ; - } - return - stsource.st_atim.tv_sec < stcompiled.st_atim.tv_sec ? 1 : - stsource.st_atim.tv_sec > stcompiled.st_atim.tv_sec ? 0 : - stsource.st_atim.tv_nsec < stcompiled.st_atim.tv_nsec ; -} - int main (int argc, char const *const *argv) { int fdlock ; unsigned int verbosity = 1 ; char const *wgola[GOLA_N] = { 0 } ; + uint64_t wgolb = 0 ; unsigned int golc ; int r ; @@ -122,11 +74,17 @@ int main (int argc, char const *const *argv) fdlock = s6rc_repo_lock(wgola[GOLA_REPODIR], 1) ; if (fdlock == -1) strerr_diefu2sys(111, "lock ", wgola[GOLA_REPODIR]) ; - check_set(wgola[GOLA_REPODIR], argv[0]) ; - if (!(wgolb & GOLB_FORCE) && uptodate(wgola[GOLA_REPODIR], argv[0])) + r = s6rc_repo_checkset(wgola[GOLA_REPODIR], argv[0]) ; + if (r) _exit(r) ; + if (!(wgolb & GOLB_FORCE)) { - if (verbosity >= 2) strerr_warni3x("set ", argv[0], " is already up-to-date.") ; - _exit(0) ; + r = s6rc_repo_setuptodate(wgola[GOLA_REPODIR], argv[0]) ; + if (r == -1) _exit(111) ; + if (r) + { + if (verbosity >= 2) strerr_warni3x("set ", argv[0], " is already up-to-date.") ; + _exit(0) ; + } } size_t oldclen = S6RC_REPO_COMPILE_BUFLEN(strlen(wgola[GOLA_REPODIR]), strlen(argv[0])) ; diff --git a/src/repo/s6-rc-set-install.c b/src/repo/s6-rc-set-install.c new file mode 100644 index 0000000..2e0b7a0 --- /dev/null +++ b/src/repo/s6-rc-set-install.c @@ -0,0 +1,205 @@ +/* ISC license. */ + +#include <skalibs/bsdsnowflake.h> + +#include <string.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/wait.h> +#include <errno.h> + +#include <skalibs/uint64.h> +#include <skalibs/stat.h> +#include <skalibs/types.h> +#include <skalibs/posixplz.h> +#include <skalibs/prog.h> +#include <skalibs/buffer.h> +#include <skalibs/strerr.h> +#include <skalibs/gol.h> +#include <skalibs/djbunix.h> +#include <skalibs/cspawn.h> + +#include <s6-rc/config.h> +#include <s6-rc/s6rc.h> + +#define USAGE "s6-rc-set-install [ -v verbosity ] [ -l livedir ] [ -r repo ] [ -f convfile ] [ -b ] [ -K ] set bootdbdir" +#define dieusage() strerr_dieusage(100, USAGE) + +enum golb_e +{ + GOLB_BLOCK = 0x01, + GOLB_KEEPOLD = 0x02 +} ; + +enum gola_e +{ + GOLA_VERBOSITY, + GOLA_LIVEDIR, + GOLA_REPODIR, + GOLA_CONVFILE, + GOLA_N +} ; + +static gol_bool const rgolb[] = +{ + { .so = 'b', .lo = "block", .clear = 0, .set = GOLB_BLOCK }, + { .so = 'K', .lo = "keep-old", .clear = 0, .set = GOLB_KEEPOLD } +} ; + +static gol_arg const rgola[] = +{ + { .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY }, + { .so = 'l', .lo = "livedir", .i = GOLA_LIVEDIR }, + { .so = 'r', .lo = "repodir", .i = GOLA_REPODIR }, + { .so = 'f', .lo = "conversion-file", .i = GOLA_CONVFILE } +} ; + +int main (int argc, char const *const *argv) +{ + int fdlock ; + unsigned int verbosity = 1 ; + char const *wgola[GOLA_N] = { 0 } ; + uint64_t wgolb = 0 ; + unsigned int golc ; + int r ; + + PROG = "s6-rc-set-install" ; + wgola[GOLA_LIVEDIR] = S6RC_LIVE_BASE ; + wgola[GOLA_REPODIR] = S6RC_REPO_BASE ; + + golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ; + argc -= golc ; argv += golc ; + if (wgola[GOLA_VERBOSITY] && !uint0_scan(wgola[GOLA_VERBOSITY], &verbosity)) + strerr_dief1x(100, "verbosity needs to be an unsigned integer") ; + if (argc < 2) dieusage() ; + if (strchr(argv[0], '/') || strchr(argv[0], '\n')) + strerr_dief1x(100, "set names cannot contain / or newlines") ; + + fdlock = s6rc_repo_lock(wgola[GOLA_REPODIR], 0) ; + if (fdlock == -1) strerr_diefu2sys(111, "lock ", wgola[GOLA_REPODIR]) ; + r = s6rc_repo_checkset(wgola[GOLA_REPODIR], argv[0]) ; + if (r) _exit(r) ; + + r = s6rc_repo_setuptodate(wgola[GOLA_REPODIR], argv[0]) ; + if (r == -1) _exit(111) ; + if (!r) strerr_dief3x(1, "set ", argv[0], " is not up-to-date; commit it first") ; + + { + size_t repolen = strlen(wgola[GOLA_REPODIR]) ; + size_t setlen = strlen(argv[0]) ; + size_t clen = S6RC_REPO_COMPILE_BUFLEN(repolen, setlen) ; + size_t dstlen = strlen(argv[1]) ; + ssize_t l ; + pid_t pid ; + int wstat ; + char *olddb = 0 ; + char const *uargv[11] ; + char fmtv[UINT_FMT] ; + char clink[repolen + setlen + 11] ; + char cfull[clen] ; + char dstfn[dstlen + setlen + 36] ; + fmtv[uint_fmt(fmtv, verbosity)] = 0 ; + memcpy(clink, wgola[GOLA_REPODIR], repolen) ; + memcpy(clink + repolen, "/compiled/", 10) ; + memcpy(clink + repolen + 10, argv[0], setlen + 1) ; + memcpy(cfull, clink, repolen + 10) ; + memcpy(dstfn, argv[1], dstlen) ; + dstfn[dstlen] = '/' ; + l = readlink(clink, cfull + repolen + 10, setlen + 35) ; + if (l == -1) strerr_diefu2sys(111, "readlink ", clink) ; + if (l >= setlen + 35) strerr_diefu2x(102, "incorrect/unexpected link contents for ", clink) ; + cfull[repolen + 10 + l] = 0 ; + memcpy(dstfn + dstlen + 1, cfull + repolen + 10, l+1) ; + l = 0 ; + { + struct stat st ; + if (stat(argv[1], &st) == -1) + strerr_diefu2sys(111, "stat ", argv[1]) ; + if (!S_ISDIR(st.st_mode)) + strerr_dief2x(100, argv[1], " is not a directory") ; + if (stat(dstfn, &st) == -1) + { + if (errno != ENOENT) + strerr_diefu2sys(111, "stat ", dstfn) ; + } + else strerr_dief2x(102, dstfn, " already exists!?") ; + } + { + size_t llen = strlen(wgola[GOLA_LIVEDIR]) ; + char cfn[llen + 10] ; + memcpy(cfn, wgola[GOLA_LIVEDIR], llen) ; + memcpy(cfn + llen, "/compiled", 10) ; + olddb = realpath(cfn, 0) ; + if (!olddb && errno != ENOENT) strerr_diefu2sys(111, "realpath ", cfn) ; + } + + if (!hiercopy(cfull, dstfn)) + { + int e = errno ; + rm_rf(dstfn) ; + errno = e ; + strerr_diefu4sys(111, "recursively copy ", cfull, " to ", dstfn) ; + } + + uargv[l++] = S6RC_BINPREFIX "s6-rc-update" ; + if (wgolb & GOLB_BLOCK) uargv[l++] = "-b" ; + uargv[l++] = "-v" ; + uargv[l++] = fmtv ; + uargv[l++] = "-l" ; + uargv[l++] = wgola[GOLA_LIVEDIR] ; + if (wgola[GOLA_CONVFILE]) + { + uargv[l++] = "-f" ; + uargv[l++] = wgola[GOLA_CONVFILE] ; + } + uargv[l++] = "--" ; + uargv[l++] = dstfn ; + uargv[l++] = 0 ; + + pid = cspawn(uargv[0], uargv, (char const *const *)environ, 0, 0, 0) ; + if (!pid) + { + int e = errno ; + rm_rf(dstfn) ; + errno = e ; + strerr_diefu2sys(111, "spawn ", uargv[0]) ; + } + r = wait_pid(pid, &wstat) ; + if (r == -1) strerr_diefu3sys(111, "wait for the ", uargv[0], " process (updating may yet succeed)") ; + if (WIFSIGNALED(wstat)) + { + char fmt[INT_FMT] ; + fmt[int_fmt(fmt, WTERMSIG(wstat))] = 0 ; + strerr_dief3x(wait_estatus(wstat), uargv[0], " crashed with signal ", fmt) ; + } + r = WEXITSTATUS(wstat) ; + if (r == 111) + strerr_dief2x(111, uargv[0], " exited 111, unable to know the state of the live db or clean up") ; + if ((r >= 3 && r <= 10) || r == 100) + { + int e = errno ; + char fmt[INT_FMT] ; + fmt[int_fmt(fmt, r)] = 0 ; + rm_rf(dstfn) ; + errno = e ; + strerr_dief4x(r, uargv[0], " exited with code ", fmt, ": live database switch NOT performed") ; + } + if (olddb) + { + if (wgolb & GOLB_KEEPOLD) + { + if (buffer_puts(buffer_1small, olddb) == -1 + || !buffer_putflush(buffer_1small, "\n", 1)) + strerr_diefu1sys(111, "write to stdout (live database switch performed)") ; + } + else rm_rf(olddb) ; + } + if (r) + { + char fmt[INT_FMT] ; + fmt[int_fmt(fmt, r)] = 0 ; + strerr_dief4x(r, uargv[0], " exited with code ", fmt, ", but the live database switch was performed") ; + } + } + _exit(0) ; +} |
