Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit bd0039a

Browse files
Release 3.2.0
2 parents c5e4e4e + 82c0b6d commit bd0039a

20 files changed

+630
-251
lines changed

CHANGES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
3.2.0
2+
* Support architecture for alternates/templates (#202, #203, #393)
3+
* Support distro_family for alternates/templates (#213)
4+
* Support setting multiple classes (#185, #304)
5+
* Support environment variables in default template processor (#347)
6+
* Update version command to include Bash & Git versions (#377)
7+
18
3.1.1
29
* Fix clone support for older versions of Git (#348)
310
* Fix support for multiple GPG recipients (#342)

CONTRIBUTORS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,35 @@ Tin Lai
1111
Espen Henriksen
1212
Cameron Eagans
1313
Klas Mellbourn
14+
James Clark
1415
Tomas Cernaj
1516
jonasc
1617
Chad Wade Day, Jr
1718
Sébastien Gross
1819
David Mandelberg
20+
Paulo Köch
21+
Oren Zipori
1922
Daniel Gray
2023
Paraplegic Racehorse
2124
japm48
2225
Siôn Le Roux
2326
Mateusz Piotrowski
2427
Uroš Golja
2528
Satoshi Ohki
29+
Nicolas stig124 FORMICHELLA
30+
Jonas
2631
Franciszek Madej
2732
Daniel Wagenknecht
2833
Stig Palmquist
2934
Patrick Hof
3035
con-f-use
36+
Samisafool
3137
Bram Ceulemans
3238
Travis A. Everett
3339
Sheng Yang
3440
Jared Smartt
3541
Adam Jimerson
42+
dessert1
3643
addshore
3744
Tim Condit
3845
Thomas Luzat

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PYTESTS = $(wildcard test/test_*.py)
2-
IMAGE = yadm/testbed:2020-12-29
2+
IMAGE = yadm/testbed:2022-01-07
33

44
.PHONY: all
55
all:
@@ -192,9 +192,9 @@ install:
192192
@[ -n "$(PREFIX)" ] || { echo "PREFIX is not set"; exit 1; }
193193
@{\
194194
set -e ;\
195-
bin="$(PREFIX)/bin" ;\
196-
doc="$(PREFIX)/share/doc/yadm" ;\
197-
man="$(PREFIX)/share/man/man1" ;\
195+
bin="$(DESTDIR)$(PREFIX)/bin" ;\
196+
doc="$(DESTDIR)$(PREFIX)/share/doc/yadm" ;\
197+
man="$(DESTDIR)$(PREFIX)/share/man/man1" ;\
198198
install -d "$$bin" "$$doc" "$$man" ;\
199199
install -m 0755 yadm "$$bin" ;\
200200
install -m 0644 yadm.1 "$$man" ;\

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Latest Version][releases-badge]][releases-link]
44
[![Homebrew Version][homebrew-badge]][homebrew-link]
55
[![OBS Version][obs-badge]][obs-link]
6-
[![Arch Version][aur-badge]][aur-link]
6+
[![Arch Version][arch-badge]][arch-link]
77
[![License][license-badge]][license-link]<br />
88
[![Master Update][master-date]][master-commits]
99
[![Develop Update][develop-date]][develop-commits]
@@ -56,8 +56,8 @@ The star count helps others discover yadm.
5656
[Git]: https://git-scm.com/
5757
[GnuPG]: https://gnupg.org/
5858
[OpenSSL]: https://www.openssl.org/
59-
[aur-badge]: https://img.shields.io/aur/version/yadm.svg
60-
[aur-link]: https://aur.archlinux.org/packages/yadm
59+
[arch-badge]: https://img.shields.io/archlinux/v/community/any/yadm
60+
[arch-link]: https://archlinux.org/packages/community/any/yadm/
6161
[dev-pages-badge]: https://img.shields.io/github/workflow/status/TheLocehiliosan/yadm/Test%20Site/dev-pages?label=dev-pages
6262
[develop-badge]: https://img.shields.io/github/workflow/status/TheLocehiliosan/yadm/Tests/develop?label=develop
6363
[develop-commits]: https://github.com/TheLocehiliosan/yadm/commits/develop
@@ -72,7 +72,7 @@ The star count helps others discover yadm.
7272
[master-badge]: https://img.shields.io/github/workflow/status/TheLocehiliosan/yadm/Tests/master?label=master
7373
[master-commits]: https://github.com/TheLocehiliosan/yadm/commits/master
7474
[master-date]: https://img.shields.io/github/last-commit/TheLocehiliosan/yadm/master.svg?label=master
75-
[obs-badge]: https://img.shields.io/badge/OBS-v3.1.1-blue
75+
[obs-badge]: https://img.shields.io/badge/OBS-v3.2.0-blue
7676
[obs-link]: https://software.opensuse.org//download.html?project=home%3ATheLocehiliosan%3Ayadm&package=yadm
7777
[releases-badge]: https://img.shields.io/github/tag/TheLocehiliosan/yadm.svg?label=latest+release
7878
[releases-link]: https://github.com/TheLocehiliosan/yadm/releases

pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ max-attributes=8
88
max-statements=65
99

1010
[SIMILARITIES]
11-
min-similarity-lines=6
11+
min-similarity-lines=8
1212

1313
[MESSAGES CONTROL]
1414
disable=redefined-outer-name

test/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ FROM ubuntu:18.04
22
MAINTAINER Tim Byrne <[email protected]>
33

44
# Shellcheck and esh versions
5-
ARG SC_VER=0.7.1
6-
ARG ESH_VER=0.3.0
5+
ARG SC_VER=0.8.0
6+
ARG ESH_VER=0.3.1
77

88
# Install prerequisites and configure UTF-8 locale
99
RUN \

test/conftest.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def pytest_addoption(parser):
2525
@pytest.fixture(scope='session')
2626
def shellcheck_version():
2727
"""Version of shellcheck supported"""
28-
return '0.7.1'
28+
return '0.8.0'
2929

3030

3131
@pytest.fixture(scope='session')
@@ -68,12 +68,29 @@ def tst_distro(runner):
6868
return distro
6969

7070

71+
@pytest.fixture(scope='session')
72+
def tst_distro_family(runner):
73+
"""Test session's distro_family"""
74+
family = ''
75+
with contextlib.suppress(Exception):
76+
run = runner(command=[
77+
'grep', '-oP', r'ID_LIKE=\K.+', '/etc/os-release'], report=False)
78+
family = run.out.strip()
79+
return family
80+
81+
7182
@pytest.fixture(scope='session')
7283
def tst_sys():
7384
"""Test session's uname value"""
7485
return platform.system()
7586

7687

88+
@pytest.fixture(scope='session')
89+
def tst_arch():
90+
"""Test session's uname value"""
91+
return platform.machine()
92+
93+
7794
@pytest.fixture(scope='session')
7895
def supported_commands():
7996
"""List of supported commands
@@ -109,6 +126,7 @@ def supported_configs():
109126
This list should be updated every time yadm learns a new config.
110127
"""
111128
return [
129+
'local.arch',
112130
'local.class',
113131
'local.hostname',
114132
'local.os',

test/test_alt.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,32 @@ def test_relative_link(runner, paths, yadm_alt):
8282
@pytest.mark.parametrize('suffix', [
8383
'##default',
8484
'##default,e.txt', '##default,extension.txt',
85+
'##a.$tst_arch', '##arch.$tst_arch',
8586
'##o.$tst_sys', '##os.$tst_sys',
8687
'##d.$tst_distro', '##distro.$tst_distro',
88+
'##f.$tst_distro_family', '##distro_family.$tst_distro_family',
8789
'##c.$tst_class', '##class.$tst_class',
8890
'##h.$tst_host', '##hostname.$tst_host',
8991
'##u.$tst_user', '##user.$tst_user',
9092
])
9193
def test_alt_conditions(
9294
runner, paths,
93-
tst_sys, tst_distro, tst_host, tst_user, suffix):
95+
tst_arch, tst_sys, tst_distro, tst_distro_family, tst_host, tst_user,
96+
suffix):
9497
"""Test conditions supported by yadm alt"""
9598
yadm_dir, yadm_data = setup_standard_yadm_dir(paths)
9699

97100
# set the class
98101
tst_class = 'testclass'
99-
utils.set_local(paths, 'class', tst_class)
102+
utils.set_local(paths, 'class', tst_class + ".before")
103+
utils.set_local(paths, 'class', tst_class, add=True)
104+
utils.set_local(paths, 'class', tst_class + ".after", add=True)
100105

101106
suffix = string.Template(suffix).substitute(
107+
tst_arch=tst_arch,
102108
tst_sys=tst_sys,
103109
tst_distro=tst_distro,
110+
tst_distro_family=tst_distro_family,
104111
tst_class=tst_class,
105112
tst_host=tst_host,
106113
tst_user=tst_user,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Unit tests: query_distro_family"""
2+
import pytest
3+
4+
5+
@pytest.mark.parametrize(
6+
'condition', ['os-release', 'os-release-quotes', 'missing'])
7+
def test_query_distro_family(runner, yadm, tmp_path, condition):
8+
"""Match ID_LIKE when present"""
9+
test_family = 'testfamily'
10+
os_release = tmp_path.joinpath('os-release')
11+
if 'os-release' in condition:
12+
quotes = '"' if 'quotes' in condition else ''
13+
os_release.write_text(
14+
f"testing\nID_LIKE={quotes}{test_family}{quotes}\nfamily")
15+
script = f"""
16+
YADM_TEST=1 source {yadm}
17+
OS_RELEASE="{os_release}"
18+
query_distro_family
19+
"""
20+
run = runner(command=['bash'], inp=script)
21+
assert run.success
22+
assert run.err == ''
23+
if 'os-release' in condition:
24+
assert run.out.rstrip() == test_family
25+
else:
26+
assert run.out.rstrip() == ''

test/test_unit_score_file.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,33 @@
66
'labels': ['default'],
77
'modifier': 0,
88
},
9+
'arch': {
10+
'labels': ['a', 'arch'],
11+
'modifier': 1,
12+
},
913
'system': {
1014
'labels': ['o', 'os'],
11-
'modifier': 1,
15+
'modifier': 2,
1216
},
1317
'distro': {
1418
'labels': ['d', 'distro'],
15-
'modifier': 2,
19+
'modifier': 4,
20+
},
21+
'distro_family': {
22+
'labels': ['f', 'distro_family'],
23+
'modifier': 8,
1624
},
1725
'class': {
1826
'labels': ['c', 'class'],
19-
'modifier': 4,
27+
'modifier': 16,
2028
},
2129
'hostname': {
2230
'labels': ['h', 'hostname'],
23-
'modifier': 8,
31+
'modifier': 32,
2432
},
2533
'user': {
2634
'labels': ['u', 'user'],
27-
'modifier': 16,
35+
'modifier': 64,
2836
},
2937
}
3038
TEMPLATE_LABELS = ['t', 'template', 'yadm']
@@ -44,6 +52,12 @@ def calculate_score(filename):
4452
label, value = condition.split('.', 1)
4553
if label in CONDITION['default']['labels']:
4654
score += 1000
55+
elif label in CONDITION['arch']['labels']:
56+
if value == 'testarch':
57+
score += 1000 + CONDITION['arch']['modifier']
58+
else:
59+
score = 0
60+
break
4761
elif label in CONDITION['system']['labels']:
4862
if value == 'testsystem':
4963
score += 1000 + CONDITION['system']['modifier']
@@ -82,6 +96,8 @@ def calculate_score(filename):
8296

8397
@pytest.mark.parametrize(
8498
'default', ['default', None], ids=['default', 'no-default'])
99+
@pytest.mark.parametrize(
100+
'arch', ['arch', None], ids=['arch', 'no-arch'])
85101
@pytest.mark.parametrize(
86102
'system', ['system', None], ids=['system', 'no-system'])
87103
@pytest.mark.parametrize(
@@ -93,10 +109,11 @@ def calculate_score(filename):
93109
@pytest.mark.parametrize(
94110
'user', ['user', None], ids=['user', 'no-user'])
95111
def test_score_values(
96-
runner, yadm, default, system, distro, cla, host, user):
112+
runner, yadm, default, arch, system, distro, cla, host, user):
97113
"""Test score results"""
98114
# pylint: disable=too-many-branches
99115
local_class = 'testclass'
116+
local_arch = 'testarch'
100117
local_system = 'testsystem'
101118
local_distro = 'testdistro'
102119
local_host = 'testhost'
@@ -111,6 +128,18 @@ def test_score_values(
111128
newfile += ','
112129
newfile += label
113130
filenames[newfile] = calculate_score(newfile)
131+
if arch:
132+
for filename in list(filenames):
133+
for match in [True, False]:
134+
for label in CONDITION[arch]['labels']:
135+
newfile = filename
136+
if not newfile.endswith('##'):
137+
newfile += ','
138+
newfile += '.'.join([
139+
label,
140+
local_arch if match else 'badarch'
141+
])
142+
filenames[newfile] = calculate_score(newfile)
114143
if system:
115144
for filename in list(filenames):
116145
for match in [True, False]:
@@ -176,6 +205,8 @@ def test_score_values(
176205
YADM_TEST=1 source {yadm}
177206
score=0
178207
local_class={local_class}
208+
local_classes=({local_class})
209+
local_arch={local_arch}
179210
local_system={local_system}
180211
local_distro={local_distro}
181212
local_host={local_host}
@@ -221,6 +252,7 @@ def test_extensions(runner, yadm, ext):
221252
def test_score_values_templates(runner, yadm):
222253
"""Test score results"""
223254
local_class = 'testclass'
255+
local_arch = 'arch'
224256
local_system = 'testsystem'
225257
local_distro = 'testdistro'
226258
local_host = 'testhost'
@@ -239,6 +271,7 @@ def test_score_values_templates(runner, yadm):
239271
YADM_TEST=1 source {yadm}
240272
score=0
241273
local_class={local_class}
274+
local_arch={local_arch}
242275
local_system={local_system}
243276
local_distro={local_distro}
244277
local_host={local_host}

0 commit comments

Comments
 (0)