123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687(** Configuration information to set up a store. *)openLwt.Infixtypet=[|`Btrfsofstring(* Path *)|`Zfsofstring(* Path with pool at end *)|`Rsyncof(string*Rsync_store.mode)(* Path for the root of the store *)]letis_absolutepath=not(Filename.is_relativepath)letof_strings=matchAstring.String.cuts~sep:":"with|Some("zfs",pool)->Ok(`Zfspool)|Some("btrfs",path)whenis_absolutepath->Ok(`Btrfspath)|Some("rsync",path)whenis_absolutepath->Ok(`Rsyncpath)|_->Error(`Msg"Store must start with zfs: or btrfs:/ or rsync:/")letppf=function|`Zfspath->Fmt.pff"zfs:%s"path|`Btrfspath->Fmt.pff"btrfs:%s"path|`Rsyncpath->Fmt.pff"rsync:%s"pathtypestore=Store:(moduleS.STOREwithtypet='a)*'a->storeletto_store=function|`Btrfspath->Btrfs_store.createpath>|=funstore->Store((moduleBtrfs_store),store)|`Zfspath->Zfs_store.create~path>|=funstore->Store((moduleZfs_store),store)|`Rsync(path,rsync_mode)->Rsync_store.create~path~mode:rsync_mode()>|=funstore->Store((moduleRsync_store),store)openCmdlinerletstore_t=Arg.conv(of_string,pp)letstore?docsnames=Arg.optArg.(somestore_t)None@@Arg.info~doc:"$(docv) must be one of $(b,btrfs:/path), $(b,rsync:/path) or $(b,zfs:pool) for the OBuilder cache."~docv:"STORE"?docsnamesletrsync_mode_opt=letoptions=[("copy",Rsync_store.Copy);("hardlink",Rsync_store.Hardlink);("hardlink_unsafe",Rsync_store.Hardlink_unsafe)]inArg.optArg.(some(enumoptions))None@@Arg.info~doc:(Printf.sprintf"Optimize for speed or low disk usage. $(docv) must be %s."(Arg.doc_alts_enumoptions))~docv:"RSYNC_MODE"~docs:"RSYNC STORE"["rsync-mode"]letrsync_mode=Arg.value@@rsync_mode_opt(** Transform a [store] and [rsync-mode] into a validated combination.
For example an rsync store must supply an rsync-mode.
*)letof_tstorersync_mode=matchstore,rsync_modewith|Some(`Rsyncpath),Somersync_mode->`Rsync(path,rsync_mode)|Some(`Rsync_path),None->failwith"Store rsync:/ must supply an rsync-mode"|Some(`Btrfspath),None->(`Btrfspath)|Some(`Zfspath),None->(`Zfspath)|_,_->failwith"Store type required must be one of $(b,btrfs:/path), $(b,rsync:/path) or $(b,zfs:pool) for the OBuilder cache."(** Parse cli arguments for t *)letv=Term.(constof_t$Arg.value@@store["store"]$Arg.value@@rsync_mode_opt)(** Parse cli arguments for t and initialise a [store]. *)letcmdliner=Term.(constto_store$v)