Release 3.2.0

This commit is contained in:
Tim Byrne 2022-03-16 10:22:30 -05:00
commit bd0039a650
No known key found for this signature in database
GPG Key ID: 14DB4FC2465A4B12
20 changed files with 633 additions and 254 deletions

View File

@ -1,3 +1,10 @@
3.2.0
* Support architecture for alternates/templates (#202, #203, #393)
* Support distro_family for alternates/templates (#213)
* Support setting multiple classes (#185, #304)
* Support environment variables in default template processor (#347)
* Update version command to include Bash & Git versions (#377)
3.1.1
* Fix clone support for older versions of Git (#348)
* Fix support for multiple GPG recipients (#342)

View File

@ -11,11 +11,14 @@ Tin Lai
Espen Henriksen
Cameron Eagans
Klas Mellbourn
James Clark
Tomas Cernaj
jonasc
Chad Wade Day, Jr
Sébastien Gross
David Mandelberg
Paulo Köch
Oren Zipori
Daniel Gray
Paraplegic Racehorse
japm48
@ -23,16 +26,20 @@ Siôn Le Roux
Mateusz Piotrowski
Uroš Golja
Satoshi Ohki
Nicolas stig124 FORMICHELLA
Jonas
Franciszek Madej
Daniel Wagenknecht
Stig Palmquist
Patrick Hof
con-f-use
Samisafool
Bram Ceulemans
Travis A. Everett
Sheng Yang
Jared Smartt
Adam Jimerson
dessert1
addshore
Tim Condit
Thomas Luzat

View File

@ -1,5 +1,5 @@
PYTESTS = $(wildcard test/test_*.py)
IMAGE = yadm/testbed:2020-12-29
IMAGE = yadm/testbed:2022-01-07
.PHONY: all
all:
@ -192,9 +192,9 @@ install:
@[ -n "$(PREFIX)" ] || { echo "PREFIX is not set"; exit 1; }
@{\
set -e ;\
bin="$(PREFIX)/bin" ;\
doc="$(PREFIX)/share/doc/yadm" ;\
man="$(PREFIX)/share/man/man1" ;\
bin="$(DESTDIR)$(PREFIX)/bin" ;\
doc="$(DESTDIR)$(PREFIX)/share/doc/yadm" ;\
man="$(DESTDIR)$(PREFIX)/share/man/man1" ;\
install -d "$$bin" "$$doc" "$$man" ;\
install -m 0755 yadm "$$bin" ;\
install -m 0644 yadm.1 "$$man" ;\

View File

@ -3,7 +3,7 @@
[![Latest Version][releases-badge]][releases-link]
[![Homebrew Version][homebrew-badge]][homebrew-link]
[![OBS Version][obs-badge]][obs-link]
[![Arch Version][aur-badge]][aur-link]
[![Arch Version][arch-badge]][arch-link]
[![License][license-badge]][license-link]<br />
[![Master Update][master-date]][master-commits]
[![Develop Update][develop-date]][develop-commits]
@ -56,8 +56,8 @@ The star count helps others discover yadm.
[Git]: https://git-scm.com/
[GnuPG]: https://gnupg.org/
[OpenSSL]: https://www.openssl.org/
[aur-badge]: https://img.shields.io/aur/version/yadm.svg
[aur-link]: https://aur.archlinux.org/packages/yadm
[arch-badge]: https://img.shields.io/archlinux/v/community/any/yadm
[arch-link]: https://archlinux.org/packages/community/any/yadm/
[dev-pages-badge]: https://img.shields.io/github/workflow/status/TheLocehiliosan/yadm/Test%20Site/dev-pages?label=dev-pages
[develop-badge]: https://img.shields.io/github/workflow/status/TheLocehiliosan/yadm/Tests/develop?label=develop
[develop-commits]: https://github.com/TheLocehiliosan/yadm/commits/develop
@ -72,7 +72,7 @@ The star count helps others discover yadm.
[master-badge]: https://img.shields.io/github/workflow/status/TheLocehiliosan/yadm/Tests/master?label=master
[master-commits]: https://github.com/TheLocehiliosan/yadm/commits/master
[master-date]: https://img.shields.io/github/last-commit/TheLocehiliosan/yadm/master.svg?label=master
[obs-badge]: https://img.shields.io/badge/OBS-v3.1.1-blue
[obs-badge]: https://img.shields.io/badge/OBS-v3.2.0-blue
[obs-link]: https://software.opensuse.org//download.html?project=home%3ATheLocehiliosan%3Ayadm&package=yadm
[releases-badge]: https://img.shields.io/github/tag/TheLocehiliosan/yadm.svg?label=latest+release
[releases-link]: https://github.com/TheLocehiliosan/yadm/releases

View File

@ -8,7 +8,7 @@ max-attributes=8
max-statements=65
[SIMILARITIES]
min-similarity-lines=6
min-similarity-lines=8
[MESSAGES CONTROL]
disable=redefined-outer-name

View File

@ -2,8 +2,8 @@ FROM ubuntu:18.04
MAINTAINER Tim Byrne <sultan@locehilios.com>
# Shellcheck and esh versions
ARG SC_VER=0.7.1
ARG ESH_VER=0.3.0
ARG SC_VER=0.8.0
ARG ESH_VER=0.3.1
# Install prerequisites and configure UTF-8 locale
RUN \

View File

@ -25,7 +25,7 @@ def pytest_addoption(parser):
@pytest.fixture(scope='session')
def shellcheck_version():
"""Version of shellcheck supported"""
return '0.7.1'
return '0.8.0'
@pytest.fixture(scope='session')
@ -68,12 +68,29 @@ def tst_distro(runner):
return distro
@pytest.fixture(scope='session')
def tst_distro_family(runner):
"""Test session's distro_family"""
family = ''
with contextlib.suppress(Exception):
run = runner(command=[
'grep', '-oP', r'ID_LIKE=\K.+', '/etc/os-release'], report=False)
family = run.out.strip()
return family
@pytest.fixture(scope='session')
def tst_sys():
"""Test session's uname value"""
return platform.system()
@pytest.fixture(scope='session')
def tst_arch():
"""Test session's uname value"""
return platform.machine()
@pytest.fixture(scope='session')
def supported_commands():
"""List of supported commands
@ -109,6 +126,7 @@ def supported_configs():
This list should be updated every time yadm learns a new config.
"""
return [
'local.arch',
'local.class',
'local.hostname',
'local.os',

View File

@ -82,25 +82,32 @@ def test_relative_link(runner, paths, yadm_alt):
@pytest.mark.parametrize('suffix', [
'##default',
'##default,e.txt', '##default,extension.txt',
'##a.$tst_arch', '##arch.$tst_arch',
'##o.$tst_sys', '##os.$tst_sys',
'##d.$tst_distro', '##distro.$tst_distro',
'##f.$tst_distro_family', '##distro_family.$tst_distro_family',
'##c.$tst_class', '##class.$tst_class',
'##h.$tst_host', '##hostname.$tst_host',
'##u.$tst_user', '##user.$tst_user',
])
def test_alt_conditions(
runner, paths,
tst_sys, tst_distro, tst_host, tst_user, suffix):
tst_arch, tst_sys, tst_distro, tst_distro_family, tst_host, tst_user,
suffix):
"""Test conditions supported by yadm alt"""
yadm_dir, yadm_data = setup_standard_yadm_dir(paths)
# set the class
tst_class = 'testclass'
utils.set_local(paths, 'class', tst_class)
utils.set_local(paths, 'class', tst_class + ".before")
utils.set_local(paths, 'class', tst_class, add=True)
utils.set_local(paths, 'class', tst_class + ".after", add=True)
suffix = string.Template(suffix).substitute(
tst_arch=tst_arch,
tst_sys=tst_sys,
tst_distro=tst_distro,
tst_distro_family=tst_distro_family,
tst_class=tst_class,
tst_host=tst_host,
tst_user=tst_user,

View File

@ -0,0 +1,26 @@
"""Unit tests: query_distro_family"""
import pytest
@pytest.mark.parametrize(
'condition', ['os-release', 'os-release-quotes', 'missing'])
def test_query_distro_family(runner, yadm, tmp_path, condition):
"""Match ID_LIKE when present"""
test_family = 'testfamily'
os_release = tmp_path.joinpath('os-release')
if 'os-release' in condition:
quotes = '"' if 'quotes' in condition else ''
os_release.write_text(
f"testing\nID_LIKE={quotes}{test_family}{quotes}\nfamily")
script = f"""
YADM_TEST=1 source {yadm}
OS_RELEASE="{os_release}"
query_distro_family
"""
run = runner(command=['bash'], inp=script)
assert run.success
assert run.err == ''
if 'os-release' in condition:
assert run.out.rstrip() == test_family
else:
assert run.out.rstrip() == ''

View File

@ -6,25 +6,33 @@ CONDITION = {
'labels': ['default'],
'modifier': 0,
},
'arch': {
'labels': ['a', 'arch'],
'modifier': 1,
},
'system': {
'labels': ['o', 'os'],
'modifier': 1,
'modifier': 2,
},
'distro': {
'labels': ['d', 'distro'],
'modifier': 2,
'modifier': 4,
},
'distro_family': {
'labels': ['f', 'distro_family'],
'modifier': 8,
},
'class': {
'labels': ['c', 'class'],
'modifier': 4,
'modifier': 16,
},
'hostname': {
'labels': ['h', 'hostname'],
'modifier': 8,
'modifier': 32,
},
'user': {
'labels': ['u', 'user'],
'modifier': 16,
'modifier': 64,
},
}
TEMPLATE_LABELS = ['t', 'template', 'yadm']
@ -44,6 +52,12 @@ def calculate_score(filename):
label, value = condition.split('.', 1)
if label in CONDITION['default']['labels']:
score += 1000
elif label in CONDITION['arch']['labels']:
if value == 'testarch':
score += 1000 + CONDITION['arch']['modifier']
else:
score = 0
break
elif label in CONDITION['system']['labels']:
if value == 'testsystem':
score += 1000 + CONDITION['system']['modifier']
@ -82,6 +96,8 @@ def calculate_score(filename):
@pytest.mark.parametrize(
'default', ['default', None], ids=['default', 'no-default'])
@pytest.mark.parametrize(
'arch', ['arch', None], ids=['arch', 'no-arch'])
@pytest.mark.parametrize(
'system', ['system', None], ids=['system', 'no-system'])
@pytest.mark.parametrize(
@ -93,10 +109,11 @@ def calculate_score(filename):
@pytest.mark.parametrize(
'user', ['user', None], ids=['user', 'no-user'])
def test_score_values(
runner, yadm, default, system, distro, cla, host, user):
runner, yadm, default, arch, system, distro, cla, host, user):
"""Test score results"""
# pylint: disable=too-many-branches
local_class = 'testclass'
local_arch = 'testarch'
local_system = 'testsystem'
local_distro = 'testdistro'
local_host = 'testhost'
@ -111,6 +128,18 @@ def test_score_values(
newfile += ','
newfile += label
filenames[newfile] = calculate_score(newfile)
if arch:
for filename in list(filenames):
for match in [True, False]:
for label in CONDITION[arch]['labels']:
newfile = filename
if not newfile.endswith('##'):
newfile += ','
newfile += '.'.join([
label,
local_arch if match else 'badarch'
])
filenames[newfile] = calculate_score(newfile)
if system:
for filename in list(filenames):
for match in [True, False]:
@ -176,6 +205,8 @@ def test_score_values(
YADM_TEST=1 source {yadm}
score=0
local_class={local_class}
local_classes=({local_class})
local_arch={local_arch}
local_system={local_system}
local_distro={local_distro}
local_host={local_host}
@ -221,6 +252,7 @@ def test_extensions(runner, yadm, ext):
def test_score_values_templates(runner, yadm):
"""Test score results"""
local_class = 'testclass'
local_arch = 'arch'
local_system = 'testsystem'
local_distro = 'testdistro'
local_host = 'testhost'
@ -239,6 +271,7 @@ def test_score_values_templates(runner, yadm):
YADM_TEST=1 source {yadm}
score=0
local_class={local_class}
local_arch={local_arch}
local_system={local_system}
local_distro={local_distro}
local_host={local_host}

View File

@ -7,6 +7,7 @@ import utils
'override', [
False,
'class',
'arch',
'os',
'hostname',
'user',
@ -14,6 +15,7 @@ import utils
ids=[
'no-override',
'override-class',
'override-arch',
'override-os',
'override-hostname',
'override-user',
@ -21,7 +23,7 @@ import utils
)
@pytest.mark.usefixtures('ds1_copy')
def test_set_local_alt_values(
runner, yadm, paths, tst_sys, tst_host, tst_user, override):
runner, yadm, paths, tst_arch, tst_sys, tst_host, tst_user, override):
"""Use issue_legacy_path_warning"""
script = f"""
YADM_TEST=1 source {yadm} &&
@ -29,12 +31,16 @@ def test_set_local_alt_values(
YADM_DIR={paths.yadm} YADM_DATA={paths.data} configure_paths &&
set_local_alt_values
echo "class='$local_class'"
echo "arch='$local_arch'"
echo "os='$local_system'"
echo "host='$local_host'"
echo "user='$local_user'"
"""
if override:
if override == 'class':
utils.set_local(paths, override, 'first')
utils.set_local(paths, override, 'override', add=True)
elif override:
utils.set_local(paths, override, 'override')
run = runner(command=['bash'], inp=script)
@ -46,6 +52,11 @@ def test_set_local_alt_values(
else:
assert "class=''" in run.out
if override == 'arch':
assert "arch='override'" in run.out
else:
assert f"arch='{tst_arch}'" in run.out
if override == 'os':
assert "os='override'" in run.out
else:
@ -62,17 +73,20 @@ def test_set_local_alt_values(
assert f"user='{tst_user}'" in run.out
def test_distro(runner, yadm):
"""Assert that local_distro is set"""
def test_distro_and_family(runner, yadm):
"""Assert that local_distro/local_distro_family are set"""
script = f"""
YADM_TEST=1 source {yadm}
function config() {{ echo "$1"; }}
function query_distro() {{ echo "testdistro"; }}
function query_distro_family() {{ echo "testfamily"; }}
set_local_alt_values
echo "distro='$local_distro'"
echo "distro_family='$local_distro_family'"
"""
run = runner(command=['bash'], inp=script)
assert run.success
assert run.err == ''
assert run.out.strip() == "distro='testdistro'"
assert "distro='testdistro'" in run.out
assert "distro_family='testfamily'" in run.out

View File

@ -5,17 +5,23 @@ FILE_MODE = 0o754
# these values are also testing the handling of bizarre characters
LOCAL_CLASS = "default_Test+@-!^Class"
LOCAL_CLASS2 = "default_Test+@-|^2nd_Class withSpace"
LOCAL_ARCH = "default_Test+@-!^Arch"
LOCAL_SYSTEM = "default_Test+@-!^System"
LOCAL_HOST = "default_Test+@-!^Host"
LOCAL_USER = "default_Test+@-!^User"
LOCAL_DISTRO = "default_Test+@-!^Distro"
LOCAL_DISTRO_FAMILY = "default_Test+@-!^Family"
TEMPLATE = f'''
start of template
default class = >{{{{yadm.class}}}}<
default arch = >{{{{yadm.arch}}}}<
default os = >{{{{yadm.os}}}}<
default host = >{{{{yadm.hostname}}}}<
default user = >{{{{yadm.user}}}}<
default distro = >{{{{yadm.distro}}}}<
default distro_family = >{{{{yadm.distro_family}}}}<
classes = >{{{{yadm.classes}}}}<
{{% if yadm.class == "else1" %}}
wrong else 1
{{% else %}}
@ -30,9 +36,21 @@ Multiple lines
{{% else %}}
Should not be included...
{{% endif %}}
{{% if yadm.class == "{LOCAL_CLASS2}" %}}
Included section for second class
{{% endif %}}
{{% if yadm.class == "wrongclass2" %}}
wrong class 2
{{% endif %}}
{{% if yadm.arch == "wrongarch1" %}}
wrong arch 1
{{% endif %}}
{{% if yadm.arch == "{LOCAL_ARCH}" %}}
Included section for arch = {{{{yadm.arch}}}} ({{{{yadm.arch}}}} repeated)
{{% endif %}}
{{% if yadm.arch == "wrongarch2" %}}
wrong arch 2
{{% endif %}}
{{% if yadm.os == "wrongos1" %}}
wrong os 1
{{% endif %}}
@ -69,22 +87,40 @@ Included section for distro = {{{{yadm.distro}}}} ({{{{yadm.distro}}}} again)
{{% if yadm.distro == "wrongdistro2" %}}
wrong distro 2
{{% endif %}}
{{% if yadm.distro_family == "wrongfamily1" %}}
wrong family 1
{{% endif %}}
{{% if yadm.distro_family == "{LOCAL_DISTRO_FAMILY}" %}}
Included section for distro_family = \
{{{{yadm.distro_family}}}} ({{{{yadm.distro_family}}}} again)
{{% endif %}}
{{% if yadm.distro_family == "wrongfamily2" %}}
wrong family 2
{{% endif %}}
end of template
'''
EXPECTED = f'''
start of template
default class = >{LOCAL_CLASS}<
default arch = >{LOCAL_ARCH}<
default os = >{LOCAL_SYSTEM}<
default host = >{LOCAL_HOST}<
default user = >{LOCAL_USER}<
default distro = >{LOCAL_DISTRO}<
default distro_family = >{LOCAL_DISTRO_FAMILY}<
classes = >{LOCAL_CLASS2}
{LOCAL_CLASS}<
Included section from else
Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
Multiple lines
Included section for second class
Included section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated)
Included section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
Included section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
Included section for user = {LOCAL_USER} ({LOCAL_USER} repeated)
Included section for distro = {LOCAL_DISTRO} ({LOCAL_DISTRO} again)
Included section for distro_family = \
{LOCAL_DISTRO_FAMILY} ({LOCAL_DISTRO_FAMILY} again)
end of template
'''
@ -137,10 +173,13 @@ def test_template_default(runner, yadm, tmpdir):
YADM_TEST=1 source {yadm}
set_awk
local_class="{LOCAL_CLASS}"
local_classes=("{LOCAL_CLASS2}" "{LOCAL_CLASS}")
local_arch="{LOCAL_ARCH}"
local_system="{LOCAL_SYSTEM}"
local_host="{LOCAL_HOST}"
local_user="{LOCAL_USER}"
local_distro="{LOCAL_DISTRO}"
local_distro_family="{LOCAL_DISTRO_FAMILY}"
template_default "{input_file}" "{output_file}"
"""
run = runner(command=['bash'], inp=script)
@ -202,3 +241,22 @@ def test_include(runner, yadm, tmpdir):
assert run.err == ''
assert output_file.read() == EXPECTED_INCLUDE
assert os.stat(output_file).st_mode == os.stat(input_file).st_mode
def test_env(runner, yadm, tmpdir):
"""Test env"""
input_file = tmpdir.join('input')
input_file.write('{{env.PWD}}', ensure=True)
input_file.chmod(FILE_MODE)
output_file = tmpdir.join('output')
script = f"""
YADM_TEST=1 source {yadm}
set_awk
template_default "{input_file}" "{output_file}"
"""
run = runner(command=['bash'], inp=script)
assert run.success
assert run.err == ''
assert output_file.read().strip() == os.environ['PWD']

View File

@ -4,31 +4,50 @@ import os
FILE_MODE = 0o754
LOCAL_CLASS = "esh_Test+@-!^Class"
LOCAL_CLASS2 = "esh_Test+@-|^2nd_Class withSpace"
LOCAL_ARCH = "esh_Test+@-!^Arch"
LOCAL_SYSTEM = "esh_Test+@-!^System"
LOCAL_HOST = "esh_Test+@-!^Host"
LOCAL_USER = "esh_Test+@-!^User"
LOCAL_DISTRO = "esh_Test+@-!^Distro"
LOCAL_DISTRO_FAMILY = "esh_Test+@-!^Family"
TEMPLATE = f'''
start of template
esh class = ><%=$YADM_CLASS%><
esh arch = ><%=$YADM_ARCH%><
esh os = ><%=$YADM_OS%><
esh host = ><%=$YADM_HOSTNAME%><
esh user = ><%=$YADM_USER%><
esh distro = ><%=$YADM_DISTRO%><
esh distro_family = ><%=$YADM_DISTRO_FAMILY%><
esh classes = ><%=$YADM_CLASSES%><
<% if [ "$YADM_CLASS" = "wrongclass1" ]; then -%>
wrong class 1
<% fi -%>
<% if [ "$YADM_CLASS" = "{LOCAL_CLASS}" ]; then -%>
Included section for class = <%=$YADM_CLASS%> (<%=$YADM_CLASS%> repeated)
Included esh section for class = <%=$YADM_CLASS%> (<%=$YADM_CLASS%> repeated)
<% fi -%>
<% if [ "$YADM_CLASS" = "wrongclass2" ]; then -%>
wrong class 2
<% fi -%>
<% echo "$YADM_CLASSES" | while IFS='' read cls; do
if [ "$cls" = "{LOCAL_CLASS2}" ]; then -%>
Included esh section for second class
<% fi; done -%>
<% if [ "$YADM_ARCH" = "wrongarch1" ]; then -%>
wrong arch 1
<% fi -%>
<% if [ "$YADM_ARCH" = "{LOCAL_ARCH}" ]; then -%>
Included esh section for arch = <%=$YADM_ARCH%> (<%=$YADM_ARCH%> repeated)
<% fi -%>
<% if [ "$YADM_ARCH" = "wrongarch2" ]; then -%>
wrong arch 2
<% fi -%>
<% if [ "$YADM_OS" = "wrongos1" ]; then -%>
wrong os 1
<% fi -%>
<% if [ "$YADM_OS" = "{LOCAL_SYSTEM}" ]; then -%>
Included section for os = <%=$YADM_OS%> (<%=$YADM_OS%> repeated)
Included esh section for os = <%=$YADM_OS%> (<%=$YADM_OS%> repeated)
<% fi -%>
<% if [ "$YADM_OS" = "wrongos2" ]; then -%>
wrong os 2
@ -37,7 +56,7 @@ wrong os 2
wrong host 1
<% fi -%>
<% if [ "$YADM_HOSTNAME" = "{LOCAL_HOST}" ]; then -%>
Included section for host = <%=$YADM_HOSTNAME%> (<%=$YADM_HOSTNAME%> again)
Included esh section for host = <%=$YADM_HOSTNAME%> (<%=$YADM_HOSTNAME%> again)
<% fi -%>
<% if [ "$YADM_HOSTNAME" = "wronghost2" ]; then -%>
wrong host 2
@ -46,7 +65,7 @@ wrong host 2
wrong user 1
<% fi -%>
<% if [ "$YADM_USER" = "{LOCAL_USER}" ]; then -%>
Included section for user = <%=$YADM_USER%> (<%=$YADM_USER%> repeated)
Included esh section for user = <%=$YADM_USER%> (<%=$YADM_USER%> repeated)
<% fi -%>
<% if [ "$YADM_USER" = "wronguser2" ]; then -%>
wrong user 2
@ -55,25 +74,42 @@ wrong user 2
wrong distro 1
<% fi -%>
<% if [ "$YADM_DISTRO" = "{LOCAL_DISTRO}" ]; then -%>
Included section for distro = <%=$YADM_DISTRO%> (<%=$YADM_DISTRO%> again)
Included esh section for distro = <%=$YADM_DISTRO%> (<%=$YADM_DISTRO%> again)
<% fi -%>
<% if [ "$YADM_DISTRO" = "wrongdistro2" ]; then -%>
wrong distro 2
<% fi -%>
<% if [ "$YADM_DISTRO_FAMILY" = "wrongfamily1" ]; then -%>
wrong family 1
<% fi -%>
<% if [ "$YADM_DISTRO_FAMILY" = "{LOCAL_DISTRO_FAMILY}" ]; then -%>
Included esh section for distro_family = \
<%=$YADM_DISTRO_FAMILY%> (<%=$YADM_DISTRO_FAMILY%> again)
<% fi -%>
<% if [ "$YADM_DISTRO" = "wrongfamily2" ]; then -%>
wrong family 2
<% fi -%>
end of template
'''
EXPECTED = f'''
start of template
esh class = >{LOCAL_CLASS}<
esh arch = >{LOCAL_ARCH}<
esh os = >{LOCAL_SYSTEM}<
esh host = >{LOCAL_HOST}<
esh user = >{LOCAL_USER}<
esh distro = >{LOCAL_DISTRO}<
Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
Included section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
Included section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
Included section for user = {LOCAL_USER} ({LOCAL_USER} repeated)
Included section for distro = {LOCAL_DISTRO} ({LOCAL_DISTRO} again)
esh distro_family = >{LOCAL_DISTRO_FAMILY}<
esh classes = >{LOCAL_CLASS2} {LOCAL_CLASS}<
Included esh section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
Included esh section for second class
Included esh section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated)
Included esh section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
Included esh section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
Included esh section for user = {LOCAL_USER} ({LOCAL_USER} repeated)
Included esh section for distro = {LOCAL_DISTRO} ({LOCAL_DISTRO} again)
Included esh section for distro_family = \
{LOCAL_DISTRO_FAMILY} ({LOCAL_DISTRO_FAMILY} again)
end of template
'''
@ -95,10 +131,13 @@ def test_template_esh(runner, yadm, tmpdir):
script = f"""
YADM_TEST=1 source {yadm}
local_class="{LOCAL_CLASS}"
local_classes=("{LOCAL_CLASS2}" "{LOCAL_CLASS}")
local_arch="{LOCAL_ARCH}"
local_system="{LOCAL_SYSTEM}"
local_host="{LOCAL_HOST}"
local_user="{LOCAL_USER}"
local_distro="{LOCAL_DISTRO}"
local_distro_family="{LOCAL_DISTRO_FAMILY}"
template_esh "{input_file}" "{output_file}"
"""
run = runner(command=['bash'], inp=script)

View File

@ -5,31 +5,50 @@ import pytest
FILE_MODE = 0o754
LOCAL_CLASS = "j2_Test+@-!^Class"
LOCAL_CLASS2 = "j2_Test+@-|^2nd_Class withSpace"
LOCAL_ARCH = "j2_Test+@-!^Arch"
LOCAL_SYSTEM = "j2_Test+@-!^System"
LOCAL_HOST = "j2_Test+@-!^Host"
LOCAL_USER = "j2_Test+@-!^User"
LOCAL_DISTRO = "j2_Test+@-!^Distro"
LOCAL_DISTRO_FAMILY = "j2_Test+@-!^Family"
TEMPLATE = f'''
start of template
j2 class = >{{{{YADM_CLASS}}}}<
j2 arch = >{{{{YADM_ARCH}}}}<
j2 os = >{{{{YADM_OS}}}}<
j2 host = >{{{{YADM_HOSTNAME}}}}<
j2 user = >{{{{YADM_USER}}}}<
j2 distro = >{{{{YADM_DISTRO}}}}<
j2 distro_family = >{{{{YADM_DISTRO_FAMILY}}}}<
j2 classes = >{{{{YADM_CLASSES}}}}<
{{%- if YADM_CLASS == "wrongclass1" %}}
wrong class 1
{{%- endif %}}
{{%- if YADM_CLASS == "{LOCAL_CLASS}" %}}
Included section for class = {{{{YADM_CLASS}}}} ({{{{YADM_CLASS}}}} repeated)
Included j2 section for class = \
{{{{YADM_CLASS}}}} ({{{{YADM_CLASS}}}} repeated)
{{%- endif %}}
{{%- if YADM_CLASS == "wrongclass2" %}}
wrong class 2
{{%- endif %}}
{{%- if "{LOCAL_CLASS2}" in YADM_CLASSES.split("\\n") %}}
Included j2 section for second class
{{%- endif %}}
{{%- if YADM_ARCH == "wrongarch1" %}}
wrong arch 1
{{%- endif %}}
{{%- if YADM_ARCH == "{LOCAL_ARCH}" %}}
Included j2 section for arch = {{{{YADM_ARCH}}}} ({{{{YADM_ARCH}}}} repeated)
{{%- endif %}}
{{%- if YADM_ARCH == "wrongarch2" %}}
wrong arch 2
{{%- endif %}}
{{%- if YADM_OS == "wrongos1" %}}
wrong os 1
{{%- endif %}}
{{%- if YADM_OS == "{LOCAL_SYSTEM}" %}}
Included section for os = {{{{YADM_OS}}}} ({{{{YADM_OS}}}} repeated)
Included j2 section for os = {{{{YADM_OS}}}} ({{{{YADM_OS}}}} repeated)
{{%- endif %}}
{{%- if YADM_OS == "wrongos2" %}}
wrong os 2
@ -38,7 +57,8 @@ wrong os 2
wrong host 1
{{%- endif %}}
{{%- if YADM_HOSTNAME == "{LOCAL_HOST}" %}}
Included section for host = {{{{YADM_HOSTNAME}}}} ({{{{YADM_HOSTNAME}}}} again)
Included j2 section for host = \
{{{{YADM_HOSTNAME}}}} ({{{{YADM_HOSTNAME}}}} again)
{{%- endif %}}
{{%- if YADM_HOSTNAME == "wronghost2" %}}
wrong host 2
@ -47,7 +67,7 @@ wrong host 2
wrong user 1
{{%- endif %}}
{{%- if YADM_USER == "{LOCAL_USER}" %}}
Included section for user = {{{{YADM_USER}}}} ({{{{YADM_USER}}}} repeated)
Included j2 section for user = {{{{YADM_USER}}}} ({{{{YADM_USER}}}} repeated)
{{%- endif %}}
{{%- if YADM_USER == "wronguser2" %}}
wrong user 2
@ -56,25 +76,44 @@ wrong user 2
wrong distro 1
{{%- endif %}}
{{%- if YADM_DISTRO == "{LOCAL_DISTRO}" %}}
Included section for distro = {{{{YADM_DISTRO}}}} ({{{{YADM_DISTRO}}}} again)
Included j2 section for distro = \
{{{{YADM_DISTRO}}}} ({{{{YADM_DISTRO}}}} again)
{{%- endif %}}
{{%- if YADM_DISTRO == "wrongdistro2" %}}
wrong distro 2
{{%- endif %}}
{{%- if YADM_DISTRO_FAMILY == "wrongfamily1" %}}
wrong family 1
{{%- endif %}}
{{%- if YADM_DISTRO_FAMILY == "{LOCAL_DISTRO_FAMILY}" %}}
Included j2 section for distro_family = \
{{{{YADM_DISTRO_FAMILY}}}} ({{{{YADM_DISTRO_FAMILY}}}} again)
{{%- endif %}}
{{%- if YADM_DISTRO_FAMILY == "wrongfamily2" %}}
wrong family 2
{{%- endif %}}
end of template
'''
EXPECTED = f'''
start of template
j2 class = >{LOCAL_CLASS}<
j2 arch = >{LOCAL_ARCH}<
j2 os = >{LOCAL_SYSTEM}<
j2 host = >{LOCAL_HOST}<
j2 user = >{LOCAL_USER}<
j2 distro = >{LOCAL_DISTRO}<
Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
Included section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
Included section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
Included section for user = {LOCAL_USER} ({LOCAL_USER} repeated)
Included section for distro = {LOCAL_DISTRO} ({LOCAL_DISTRO} again)
j2 distro_family = >{LOCAL_DISTRO_FAMILY}<
j2 classes = >{LOCAL_CLASS2}
{LOCAL_CLASS}<
Included j2 section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
Included j2 section for second class
Included j2 section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated)
Included j2 section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
Included j2 section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
Included j2 section for user = {LOCAL_USER} ({LOCAL_USER} repeated)
Included j2 section for distro = {LOCAL_DISTRO} ({LOCAL_DISTRO} again)
Included j2 section for distro_family = \
{LOCAL_DISTRO_FAMILY} ({LOCAL_DISTRO_FAMILY} again)
end of template
'''
@ -97,10 +136,13 @@ def test_template_j2(runner, yadm, tmpdir, processor):
script = f"""
YADM_TEST=1 source {yadm}
local_class="{LOCAL_CLASS}"
local_classes=("{LOCAL_CLASS2}" "{LOCAL_CLASS}")
local_arch="{LOCAL_ARCH}"
local_system="{LOCAL_SYSTEM}"
local_host="{LOCAL_HOST}"
local_user="{LOCAL_USER}"
local_distro="{LOCAL_DISTRO}"
local_distro_family="{LOCAL_DISTRO_FAMILY}"
template_{processor} "{input_file}" "{output_file}"
"""
run = runner(command=['bash'], inp=script)

View File

@ -29,8 +29,10 @@ def test_semantic_version(expected_version):
@pytest.mark.parametrize('cmd', ['--version', 'version'])
def test_reported_version(
runner, yadm_cmd, cmd, expected_version):
"""Report correct version"""
"""Report correct version and bash/git versions"""
run = runner(command=yadm_cmd(cmd))
assert run.success
assert run.err == ''
assert run.out == f'yadm {expected_version}\n'
assert 'bash version' in run.out
assert 'git version' in run.out
assert run.out.endswith(f'\nyadm version {expected_version}\n')

View File

@ -21,11 +21,12 @@ INCLUDE_DIRS = ['', 'test alt']
INCLUDE_CONTENT = '8780846c02e34c930d0afd127906668f'
def set_local(paths, variable, value):
def set_local(paths, variable, value, add=False):
"""Set local override"""
add = "--add" if add else ""
os.system(
f'GIT_DIR={str(paths.repo)} '
f'git config --local "local.{variable}" "{value}"'
f'git config --local {add} "local.{variable}" "{value}"'
)

123
yadm
View File

@ -1,6 +1,6 @@
#!/bin/sh
# yadm - Yet Another Dotfiles Manager
# Copyright (C) 2015-2021 Tim Byrne
# Copyright (C) 2015-2022 Tim Byrne
# 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
@ -21,7 +21,7 @@ if [ -z "$BASH_VERSION" ]; then
[ "$YADM_TEST" != 1 ] && exec bash "$0" "$@"
fi
VERSION=3.1.1
VERSION=3.2.0
YADM_WORK="$HOME"
YADM_DIR=
@ -170,8 +170,8 @@ function score_file() {
tgt="${src%%##*}"
conditions="${src#*##}"
if [ "${tgt#$YADM_ALT/}" != "${tgt}" ]; then
tgt="${YADM_BASE}/${tgt#$YADM_ALT/}"
if [ "${tgt#"$YADM_ALT/"}" != "${tgt}" ]; then
tgt="${YADM_BASE}/${tgt#"$YADM_ALT/"}"
fi
score=0
@ -189,37 +189,51 @@ function score_file() {
if [[ "$label" =~ ^(default)$ ]]; then
score=$((score + 0))
# variable conditions
elif [[ "$label" =~ ^(a|arch)$ ]]; then
if [ "$value" = "$local_arch" ]; then
score=$((score + 1))
else
score=0
return
fi
elif [[ "$label" =~ ^(o|os)$ ]]; then
if [ "$value" = "$local_system" ]; then
score=$((score + 1))
score=$((score + 2))
else
score=0
return
fi
elif [[ "$label" =~ ^(d|distro)$ ]]; then
if [ "$value" = "$local_distro" ]; then
score=$((score + 2))
score=$((score + 4))
else
score=0
return
fi
elif [[ "$label" =~ ^(f|distro_family)$ ]]; then
if [ "$value" = "$local_distro_family" ]; then
score=$((score + 8))
else
score=0
return
fi
elif [[ "$label" =~ ^(c|class)$ ]]; then
if [ "$value" = "$local_class" ]; then
score=$((score + 4))
if in_list "$value" "${local_classes[@]}"; then
score=$((score + 16))
else
score=0
return
fi
elif [[ "$label" =~ ^(h|hostname)$ ]]; then
if [ "$value" = "$local_host" ]; then
score=$((score + 8))
score=$((score + 32))
else
score=0
return
fi
elif [[ "$label" =~ ^(u|user)$ ]]; then
if [ "$value" = "$local_user" ]; then
score=$((score + 16))
score=$((score + 64))
else
score=0
return
@ -358,10 +372,13 @@ function template_default() {
BEGIN {
blank = "[ ]"
c["class"] = class
c["classes"] = classes
c["arch"] = arch
c["os"] = os
c["hostname"] = host
c["user"] = user
c["distro"] = distro
c["distro_family"] = distro_family
c["source"] = source
ifs = "^{%" blank "*if"
els = "^{%" blank "*else" blank "*%}$"
@ -409,13 +426,26 @@ function replace_vars() {
for (label in c) {
gsub(("{{" blank "*yadm\\." label blank "*}}"), c[label])
}
for (label in ENVIRON) {
gsub(("{{" blank "*env\\." label blank "*}}"), ENVIRON[label])
}
}
function condition_helper(label, value) {
gsub(/[\\.^$(){}\[\]|*+?]/, "\\\\&", value)
return sprintf("yadm\\.%s" blank "*==" blank "*\"%s\"", label, value)
}
function conditions() {
pattern = ifs blank "+("
for (label in c) {
if (label != "class") {
value = c[label]
gsub(/[\\.^$(){}\[\]|*+?]/, "\\\\&", value)
pattern = sprintf("%syadm\\.%s" blank "*==" blank "*\"%s\"|", pattern, label, value)
pattern = sprintf("%s%s|", pattern, condition_helper(label, value));
}
}
split(classes, cls_array, "\n")
for (idx in cls_array) {
value = cls_array[idx]
pattern = sprintf("%s%s|", pattern, condition_helper("class", value));
}
sub(/\|$/, ")" blank "*%}$", pattern)
return pattern
@ -424,12 +454,15 @@ EOF
"${AWK_PROGRAM[0]}" \
-v class="$local_class" \
-v arch="$local_arch" \
-v os="$local_system" \
-v host="$local_host" \
-v user="$local_user" \
-v distro="$local_distro" \
-v distro_family="$local_distro_family" \
-v source="$input" \
-v source_dir="$(dirname "$input")" \
-v classes="$(join_string $'\n' "${local_classes[@]}")" \
"$awk_pgm" \
"$input" > "$temp_file" || rm -f "$temp_file"
@ -442,11 +475,14 @@ function template_j2cli() {
temp_file="${output}.$$.$RANDOM"
YADM_CLASS="$local_class" \
YADM_ARCH="$local_arch" \
YADM_OS="$local_system" \
YADM_HOSTNAME="$local_host" \
YADM_USER="$local_user" \
YADM_DISTRO="$local_distro" \
YADM_DISTRO_FAMILY="$local_distro_family" \
YADM_SOURCE="$input" \
YADM_CLASSES="$(join_string $'\n' "${local_classes[@]}")" \
"$J2CLI_PROGRAM" "$input" -o "$temp_file"
move_file "$input" "$output" "$temp_file"
@ -458,11 +494,14 @@ function template_envtpl() {
temp_file="${output}.$$.$RANDOM"
YADM_CLASS="$local_class" \
YADM_ARCH="$local_arch" \
YADM_OS="$local_system" \
YADM_HOSTNAME="$local_host" \
YADM_USER="$local_user" \
YADM_DISTRO="$local_distro" \
YADM_DISTRO_FAMILY="$local_distro_family" \
YADM_SOURCE="$input" \
YADM_CLASSES="$(join_string $'\n' "${local_classes[@]}")" \
"$ENVTPL_PROGRAM" --keep-template "$input" -o "$temp_file"
move_file "$input" "$output" "$temp_file"
@ -473,12 +512,15 @@ function template_esh() {
output="$2"
temp_file="${output}.$$.$RANDOM"
YADM_CLASSES="$(join_string $'\n' "${local_classes[@]}")" \
"$ESH_PROGRAM" -o "$temp_file" "$input" \
YADM_CLASS="$local_class" \
YADM_ARCH="$local_arch" \
YADM_OS="$local_system" \
YADM_HOSTNAME="$local_host" \
YADM_USER="$local_user" \
YADM_DISTRO="$local_distro" \
YADM_DISTRO_FAMILY="$local_distro_family" \
YADM_SOURCE="$input"
move_file "$input" "$output" "$temp_file"
@ -509,10 +551,13 @@ function alt() {
# gather values for processing alternates
local local_class
local -a local_classes
local local_arch
local local_system
local local_host
local local_user
local local_distro
local local_distro_family
set_local_alt_values
# only be noisy if the "alt" command was run directly
@ -539,8 +584,8 @@ function alt() {
if [[ $possible_alt =~ .\#\#. ]]; then
base_alt="${possible_alt%%##*}"
yadm_alt="${YADM_BASE}/${base_alt}"
if [ "${yadm_alt#$YADM_ALT/}" != "${yadm_alt}" ]; then
base_alt="${yadm_alt#$YADM_ALT/}"
if [ "${yadm_alt#"$YADM_ALT/"}" != "${yadm_alt}" ]; then
base_alt="${yadm_alt#"$YADM_ALT/"}"
fi
possible_alts+=("$YADM_BASE/${base_alt}")
fi
@ -607,7 +652,17 @@ function remove_stale_links() {
function set_local_alt_values() {
local_class="$(config local.class)"
local -a all_classes
all_classes=$(config --get-all local.class)
while IFS='' read -r local_class; do
local_classes+=("$local_class")
done <<< "$all_classes"
local_class="${local_classes[-1]:-}"
local_arch="$(config local.arch)"
if [ -z "$local_arch" ] ; then
local_arch=$(uname -m)
fi
local_system="$(config local.os)"
if [ -z "$local_system" ] ; then
@ -626,6 +681,7 @@ function set_local_alt_values() {
fi
local_distro="$(query_distro)"
local_distro_family="$(query_distro_family)"
}
@ -819,7 +875,7 @@ EOF
function config() {
use_repo_config=0
local_options="^local\.(class|os|hostname|user)$"
local_options="^local\.(class|arch|os|hostname|user)$"
for option in "$@"; do
[[ "$option" =~ $local_options ]] && use_repo_config=1
done
@ -1191,6 +1247,7 @@ EOF
function introspect_configs() {
local msg
read -r -d '' msg <<-EOF
local.arch
local.class
local.hostname
local.os
@ -1364,7 +1421,7 @@ function upgrade() {
;
do
if [ -e "$legacy_path" ]; then
new_filename=${legacy_path#$YADM_LEGACY_DIR/}
new_filename="${legacy_path#"$YADM_LEGACY_DIR/"}"
new_filename="$YADM_DIR/$new_filename"
actions_performed=1
echo "Moving $legacy_path to $new_filename"
@ -1395,7 +1452,9 @@ function upgrade() {
function version() {
echo "yadm $VERSION"
echo "bash version $BASH_VERSION"
printf " "; "$GIT_PROGRAM" --version
echo "yadm version $VERSION"
exit_with_hook 0
}
@ -1466,6 +1525,20 @@ function query_distro() {
echo "$distro"
}
function query_distro_family() {
family=""
if [ -f "$OS_RELEASE" ]; then
while IFS='' read -r line || [ -n "$line" ]; do
if [[ "$line" = ID_LIKE=* ]]; then
family="${line#ID_LIKE=}"
family="${family//\"}"
break
fi
done < "$OS_RELEASE"
fi
echo "$family"
}
function process_global_args() {
# global arguments are removed before the main processing is done
@ -1928,7 +2001,7 @@ function relative_path() {
result=""
count=0
while [ "${full#$common_part}" == "${full}" ]; do
while [ "${full#"$common_part"}" == "${full}" ]; do
[ "$count" = "500" ] && return # this is a failsafe
# no match, means that candidate common part is not correct
# go up one level (reduce common part)
@ -1949,7 +2022,7 @@ function relative_path() {
# since we now have identified the common part,
# compute the non-common part
forward_part="${full#$common_part}"
forward_part="${full#"$common_part"}"
# and now stick all parts together
if [[ -n $result ]] && [[ -n $forward_part ]]; then
@ -2014,6 +2087,16 @@ function join_string {
printf "%s" "${*:2}"
}
function in_list {
local element="$1"
shift
for e in "$@"; do
[[ "$e" = "$element" ]] && return 0
done
return 1
}
function get_mode {
local filename="$1"
local mode

71
yadm.1
View File

@ -1,5 +1,5 @@
.\" vim: set spell so=8:
.TH yadm 1 "23 August 2021" "3.1.1"
.TH yadm 1 "16 March 2022" "3.2.0"
.SH NAME
@ -427,7 +427,7 @@ Disable the permission changes to
This feature is enabled by default.
.RE
The following four "local" configurations are not stored in the
The following five "local" configurations are not stored in the
.IR $HOME/.config/yadm/config,
they are stored in the local repository.
@ -435,6 +435,14 @@ they are stored in the local repository.
.B local.class
Specify a class for the purpose of symlinking alternate files.
By default, no class will be matched.
The local host can be assigned multiple classes using command:
.RS
yadm config --add local.class <additional-class>
.RE
.TP
.B local.arch
Override the architecture for the purpose of symlinking alternate files.
.TP
.B local.hostname
Override the hostname for the purpose of symlinking alternate files.
@ -478,17 +486,11 @@ Valid if the value matches the current user.
Current user is calculated by running
.BR "id -u -n" .
.TP
.BR distro , " d
Valid if the value matches the distro.
Distro is calculated by running
.B "lsb_release -si"
or by inspecting the ID from
.BR "/etc/os-release" .
.TP
.BR os , " o
Valid if the value matches the OS.
OS is calculated by running
.BR "uname -s" .
.BR hostname , " h
Valid if the value matches the short hostname.
Hostname is calculated by running
.BR "uname -n" ,
and trimming off any domain.
.TP
.BR class , " c
Valid if the value matches the
@ -499,11 +501,27 @@ Class must be manually set using
See the CONFIGURATION section for more details about setting
.BR local.class .
.TP
.BR hostname , " h
Valid if the value matches the short hostname.
Hostname is calculated by running
.BR "uname -n" ,
and trimming off any domain.
.BR distro , " d
Valid if the value matches the distro.
Distro is calculated by running
.B "lsb_release -si"
or by inspecting the ID from
.BR "/etc/os-release" .
.TP
.BR distro_family , " f
Valid if the value matches the distro family.
Distro family is calculated by inspecting the ID_LIKE line from
.BR "/etc/os-release" .
.TP
.BR os , " o
Valid if the value matches the OS.
OS is calculated by running
.BR "uname -s" .
.TP
.BR arch , " a
Valid if the value matches the architecture.
Architecture is calculated by running
.BR "uname -m" .
.TP
.B default
Valid when no other alternate is valid.
@ -577,7 +595,7 @@ If no "##default" version exists and no files have valid conditions, then no
link will be created.
Links are also created for directories named this way, as long as they have at
least one yadm managed file within them.
least one yadm managed file within them (at the top level).
yadm will automatically create these links by default. This can be disabled
using the
@ -596,8 +614,9 @@ command. The following sets the class to be "Work".
yadm config local.class Work
Similarly, the values of os, hostname, and user can be manually overridden
using the configuration options
Similarly, the values of architecture, os, hostname, and user can be manually
overridden using the configuration options
.BR local.arch ,
.BR local.os ,
.BR local.hostname ,
and
@ -646,13 +665,17 @@ to create or overwrite files.
During processing, the following variables are available in the template:
Default Jinja or ESH Description
------------- ------------- --------------------------
yadm.class YADM_CLASS Locally defined yadm class
------------- ------------- ----------------------------
yadm.arch YADM_ARCH uname -m
yadm.class YADM_CLASS Last locally defined class
yadm.classes YADM_CLASSES All classes
yadm.distro YADM_DISTRO lsb_release -si
yadm.distro_family YADM_DISTRO_FAMILY ID_LIKE from /etc/os-release
yadm.hostname YADM_HOSTNAME uname -n (without domain)
yadm.os YADM_OS uname -s
yadm.user YADM_USER id -u -n
yadm.source YADM_SOURCE Template filename
yadm.user YADM_USER id -u -n
env.VAR Environment variable VAR
.BR NOTE :
The OS for "Windows Subsystem for Linux" is reported as "WSL", even

57
yadm.md
View File

@ -331,13 +331,20 @@
Disable the permission changes to $HOME/.ssh/*. This feature is
enabled by default.
The following four "local" configurations are not stored in the
The following five "local" configurations are not stored in the
$HOME/.config/yadm/config, they are stored in the local repository.
local.class
Specify a class for the purpose of symlinking alternate files.
By default, no class will be matched.
By default, no class will be matched. The local host can be
assigned multiple classes using command:
yadm config --add local.class <additional-class>
local.arch
Override the architecture for the purpose of symlinking alter-
nate files.
local.hostname
Override the hostname for the purpose of symlinking alternate
@ -384,13 +391,9 @@
Valid if the value matches the current user. Current user is
calculated by running id -u -n.
distro, d
Valid if the value matches the distro. Distro is calculated by
running lsb_release -si or by inspecting the ID from /etc/os-
release.
os, o Valid if the value matches the OS. OS is calculated by running
uname -s.
hostname, h
Valid if the value matches the short hostname. Hostname is cal-
culated by running uname -n, and trimming off any domain.
class, c
Valid if the value matches the local.class configuration. Class
@ -398,9 +401,21 @@
the CONFIGURATION section for more details about setting
local.class.
hostname, h
Valid if the value matches the short hostname. Hostname is cal-
culated by running uname -n, and trimming off any domain.
distro, d
Valid if the value matches the distro. Distro is calculated by
running lsb_release -si or by inspecting the ID from /etc/os-
release.
distro_family, f
Valid if the value matches the distro family. Distro family is
calculated by inspecting the ID_LIKE line from /etc/os-release.
os, o Valid if the value matches the OS. OS is calculated by running
uname -s.
arch, a
Valid if the value matches the architecture. Architecture is
calculated by running uname -m.
default
Valid when no other alternate is valid.
@ -474,7 +489,7 @@
then no link will be created.
Links are also created for directories named this way, as long as they
have at least one yadm managed file within them.
have at least one yadm managed file within them (at the top level).
yadm will automatically create these links by default. This can be dis-
abled using the yadm.auto-alt configuration. Even if disabled, links
@ -488,9 +503,9 @@
yadm config local.class Work
Similarly, the values of os, hostname, and user can be manually over-
ridden using the configuration options local.os, local.hostname, and
local.user.
Similarly, the values of architecture, os, hostname, and user can be
manually overridden using the configuration options local.arch,
local.os, local.hostname, and local.user.
## TEMPLATES
@ -533,13 +548,17 @@
plate:
Default Jinja or ESH Description
------------- ------------- --------------------------
yadm.class YADM_CLASS Locally defined yadm class
------------- ------------- ----------------------------
yadm.arch YADM_ARCH uname -m
yadm.class YADM_CLASS Last locally defined class
yadm.classes YADM_CLASSES All classes
yadm.distro YADM_DISTRO lsb_release -si
yadm.distro_family YADM_DISTRO_FAMILY ID_LIKE from /etc/os-release
yadm.hostname YADM_HOSTNAME uname -n (without domain)
yadm.os YADM_OS uname -s
yadm.user YADM_USER id -u -n
yadm.source YADM_SOURCE Template filename
yadm.user YADM_USER id -u -n
env.VAR Environment variable VAR
NOTE: The OS for "Windows Subsystem for Linux" is reported as "WSL",
even though uname identifies as "Linux".

View File

@ -1,7 +1,7 @@
%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}}
Name: yadm
Summary: Yet Another Dotfiles Manager
Version: 3.1.1
Version: 3.2.0
Group: Development/Tools
Release: 1%{?dist}
URL: https://yadm.io