@@ 10,8 10,10 @@ format: ## Format files using nimpretty
nimpretty src/**/*.nim
run: build ## Run brrr
- ./brrr uninstall exa ;\
- ./brrr install exa
+ ./brrr freezer generate
+ #./brrr upgrade
+ #./brrr uninstall exa ;\
+# ./brrr install exa
help: ## Print this message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@@ 0,0 1,33 @@
+import std/[os, parsecfg, sequtils, strutils, sugar, tables]
+import ../lib/[common, repository, types]
+
+const archs = @["linux", "macos"]
+
+proc generate() =
+ let currentDir = getCurrentDir()
+ let targetDir = currentDir / "data"
+
+ var config = newConfig()
+
+ let pkgDefs = collect(for k in walkDir(currentDir): k.path)
+ .filter(proc(x: string): bool = x.endsWith(".yaml"))
+ .map(proc(x: string): BrrrFile = getLocalPackageDefinition(x))
+
+ for pkg in pkgDefs:
+ let templateVersion = pkg.versions[star]
+ for a in archs:
+ let arch = a
+ if pkg.templates[templateVersion].hasKey(arch):
+ config.setSectionKey(pkg.name, arch, "true")
+
+ discard existsOrCreateDir(targetDir)
+ config.writeConfig(targetDir / "apps.cfg")
+
+proc freezer*(cmd: string) =
+ case cmd:
+ of "generate":
+ generate()
+ of "":
+ log("freezer needs a command!")
+ else:
+ log("unknown command: " & cmd)
@@ 1,14 1,16 @@
import std/[parseopt, strutils]
-import commands/[help, install, uninstall, upgrade, version], lib/types
+import commands/[freezer, help, install, uninstall, upgrade, version], lib/types
# Many lines come from nimble.
type
ActionType* = enum
- actionNil, actionHelp, actionInstall, actionUninstall, actionUpgrade, actionVersion
+ actionNil, actionFreezer, actionHelp, actionInstall, actionUninstall, actionUpgrade, actionVersion
Action* = object
case typ*: ActionType
of actionNil, actionHelp, actionVersion: nil
+ of actionFreezer:
+ sub*: string
of actionInstall, actionUninstall, actionUpgrade:
packages*: seq[PkgTuple]
Options* = object
@@ 16,6 18,8 @@ type
proc parseActionType*(action: string): ActionType =
case action.normalize()
+ of "freezer":
+ result = actionFreezer
of "help":
result = actionHelp
of "install":
@@ 38,6 42,8 @@ proc parseArgument*(key: string, result: var Options) =
assert false
of actionHelp, actionVersion:
discard
+ of actionFreezer:
+ result.action.sub = key
of actionInstall, actionUninstall, actionUpgrade:
if '@' in key:
let i = find(key, '@')
@@ 50,6 56,8 @@ proc doAction*(options: var Options) =
case options.action.typ
of actionHelp, actionNil:
writeHelp()
+ of actionFreezer:
+ freezer(options.action.sub)
of actionInstall:
install(options.action.packages)
of actionUninstall: