From 86c10c94ddf1001f8019b5e135bc1777e6f50763 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Fri, 6 Sep 2024 17:02:53 -0400 Subject: [PATCH] modules: Add a modules directory for mcl code Details in the README file. --- modules/README.md | 38 ++++++++++++++++ modules/purpleidea/main.mcl | 78 ++++++++++++++++++++++++++++++++ modules/purpleidea/metadata.yaml | 0 test/test-modules.sh | 33 ++++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 modules/README.md create mode 100644 modules/purpleidea/main.mcl create mode 100644 modules/purpleidea/metadata.yaml create mode 100755 test/test-modules.sh diff --git a/modules/README.md b/modules/README.md new file mode 100644 index 000000000..1d5046cb5 --- /dev/null +++ b/modules/README.md @@ -0,0 +1,38 @@ +# Modules! + +This is a collection of `mcl` modules that may be of general interest. + +## Why? + +In particular while the project is evolving very rapidly, it makes sense to keep +these alongside the compiler so that if anything needs refactoring, it happens +together in the same commit, and if there are improvements made and new features +added, you can see exactly what commit brought in this change! + +## Acceptance criteria + +It's sort of arbitrary at the moment, but I'm putting in what I find to be +generally helpful for my needs. Patches are welcome, but expect I might be a bit +discerning if it's not what I'm looking for right now. + +## Long-term + +I see `mgmt` and `mcl` as being able to replace a traditional software +management daemon, and front-end configuration interface for many projects. As a +result, it might end up being the de facto way to interact with certain +services. For example, the `dhcpd` project could decide to provide an mcl module +as either the primary or secondary interface for managing that service, and in +that case, it would make sense for that module to live in that source tree. + +## Importing? + +You can import any of these modules into your `mcl` project with the following +example for the `purpleidea` module: + +```mcl +import "git://github.com/purpleidea/mgmt/modules/purpleidea/" +``` + +## Bugs, questions, thanks? + +Reach out and let us know! diff --git a/modules/purpleidea/main.mcl b/modules/purpleidea/main.mcl new file mode 100644 index 000000000..3b3531c09 --- /dev/null +++ b/modules/purpleidea/main.mcl @@ -0,0 +1,78 @@ +# Mgmt +# Copyright (C) 2013-2024+ James Shubin and the project contributors +# Written by James Shubin and the project contributors +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Additional permission under GNU GPL version 3 section 7 +# +# If you modify this program, or any covered work, by linking or combining it +# with embedded mcl code and modules (and that the embedded mcl code and +# modules which link with this program, contain a copy of their source code in +# the authoritative form) containing parts covered by the terms of any other +# license, the licensors of this program grant you additional permission to +# convey the resulting work. Furthermore, the licensors of this program grant +# the original author, James Shubin, additional permission to update this +# additional permission if he deems it necessary to achieve the goals of this +# additional permission. + +import "os" + +# base contains the personal tweaks and utilities of james (purpleidea) +class base() { + if os.is_redhat() { + pkg [ + "ack", + "bash-completion", + "direnv", + "fping", + "git", + "htop", + "lshw", + "nethogs", + "nmap", + "screen", + "socat", + "strace", + "telnet", + "tree", + "vim-enhanced", + "wget2-wget", + ] { + state => "installed", + } + } + if os.is_debian() { + pkg [ + "ack", + "bash-completion", + "direnv", + "fping", + "git", + "htop", + "lshw", + "nethogs", + "nmap", + "screen", + "socat", + "strace", + "telnet", + "tree", + "vim", + "wget", + ] { + state => "installed", + } + } +} diff --git a/modules/purpleidea/metadata.yaml b/modules/purpleidea/metadata.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/test/test-modules.sh b/test/test-modules.sh new file mode 100755 index 000000000..39ee7f30d --- /dev/null +++ b/test/test-modules.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# check that our modules still build, even if we don't run them here + +# shellcheck disable=SC1091 +. test/util.sh + +echo running "$0" + +ROOT=$(dirname "${BASH_SOURCE}")/.. +cd "${ROOT}" + +failures='' + +# Test modules/ directory to see if the .mcl files compile correctly. + +find_mcl_modules() { + git ls-files | grep '\.mcl$' | grep '^modules/' | grep -v 'examples/lang/' +} + +# TODO: It might be better to only test from the root module entrypoint. +for file in $(find_mcl_modules); do + #echo "mcl: $file" + run-test ./mgmt run --tmp-prefix lang --only-unify "$file" &> /dev/null || fail_test "could not compile: $file" +done + +if [[ -n "$failures" ]]; then + echo 'FAIL' + echo "The following tests (in: ${linkto}) have failed:" + echo -e "$failures" + echo + exit 1 +fi +echo 'PASS'