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

Commit 4d475a2

Browse files
William Douglasbryteise
authored andcommitted
Relax bundle name requirements
Both '.' and '+' are valid names for bundles for swupd-client. In order to use package names, mixer-tools also needs to allow these characters. Signed-off-by: William Douglas <william.douglas@intel.com>
1 parent fbd41ac commit 4d475a2

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

bat/tests/bundle-commands/run.bats

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ setup() {
1717
}
1818

1919
@test "List the bundles in the mix" {
20-
mixer bundle create foo.bar # 'bundle list' should work even if an invalid bundle is created
20+
mixer bundle create foo^bar # 'bundle list' should work even if an invalid bundle is created
21+
mixer bundle add foo\^bar # 'bundle add' will not add an invalid name but won't fail
2122

2223
bundles=$(mixer $MIXARGS bundle list | grep -v "(included)")
2324
[[ $(echo "$bundles" | wc -l) -eq 4 ]] # Exactly 4 bundles in the mix
@@ -26,7 +27,7 @@ setup() {
2627
[[ "$bundles" =~ kernel-native ]]
2728
[[ "$bundles" =~ bootloader ]]
2829

29-
rm -f local-bundles/foo.bar # Delete invalid bundle from local-bundles (test case clean up)
30+
rm -f local-bundles/foo\^bar # Delete invalid bundle from local-bundles (test case clean up)
3031
}
3132

3233
@test "Add an upstream bundle to the mix" {
@@ -97,47 +98,47 @@ setup() {
9798
}
9899

99100
@test "Skip invalid bundles from mix" {
100-
mixer $MIXARGS bundle create foocar foo.car foojar --add # Create and add valid as well as invalid bundles
101+
mixer $MIXARGS bundle create foo.bar foo\^car foojar --add # Create and add valid as well as invalid bundles
101102

102-
mixer $MIXARGS bundle list | grep -q foocar # "foocar" bundle is in the mix
103+
mixer $MIXARGS bundle list | grep -q foo\.bar # "foo.car" bundle is in the mix
103104
mixer $MIXARGS bundle list | grep -q foojar # "foojar" bundle is in the mix
104105

105-
run $(mixer $MIXARGS bundle list | grep foo.car) # "foo.car" is an invalid bundle and is not in the mix
106+
run $(mixer $MIXARGS bundle list | grep foo\^car) # "foo^car" is an invalid bundle and is not in the mix
106107
[[ ${#lines[@]} -eq 0 ]]
107108

108109
# Delete bundle from local-bundles and mix (test case clean up)
109-
mixer $MIXARGS bundle remove foocar foojar
110-
rm -f local-bundles/foocar local-bundles/foojar local-bundles/foo.car
110+
mixer $MIXARGS bundle remove foo.bar foojar
111+
rm -f local-bundles/foo.bar local-bundles/foojar local-bundles/foo\^car
111112
}
112113

113114
@test "Validate a bundle" {
114-
echo "package" >> $BATS_TEST_DIRNAME/local-bundles/foobar
115-
mixer $MIXARGS bundle create foo.bar
115+
echo "package" >> $BATS_TEST_DIRNAME/local-bundles/foo+bar
116+
mixer $MIXARGS bundle create foo\^bar
116117

117-
run mixer $MIXARGS bundle validate foobar
118+
run mixer $MIXARGS bundle validate foo+bar
118119
[[ "$status" -eq 0 ]] # basic validation should pass
119120

120-
run mixer $MIXARGS bundle validate foobar --strict
121+
run mixer $MIXARGS bundle validate foo+bar --strict
121122
[[ "$status" -eq 1 ]] # strict validation should fail
122123
[[ "$output" =~ "Empty Description in bundle header" ]]
123124
[[ "$output" =~ "Empty Maintainer in bundle header" ]]
124125
[[ "$output" =~ "Empty Status in bundle header" ]]
125126
[[ "$output" =~ "Empty Capabilities in bundle header" ]]
126127

127-
run mixer $MIXARGS bundle validate foo.bar
128+
run mixer $MIXARGS bundle validate foo\^bar
128129
[[ "$status" -eq 1 ]] # basic validation should fail
129-
[[ "$output" =~ "Invalid bundle name \"foo.bar\" derived from file" ]]
130+
[[ "$output" =~ "Invalid bundle name \"foo^bar\" derived from file" ]]
130131

131-
run mixer $MIXARGS bundle validate foo.bar --strict
132+
run mixer $MIXARGS bundle validate foo\^bar --strict
132133
[[ "$status" -eq 1 ]] # strict validation should fail
133-
[[ "$output" =~ "Invalid bundle name \"foo.bar\" derived from file" ]]
134-
[[ "$output" =~ "Invalid bundle name \"foo.bar\" in bundle header Title" ]]
134+
[[ "$output" =~ "Invalid bundle name \"foo^bar\" derived from file" ]]
135+
[[ "$output" =~ "Invalid bundle name \"foo^bar\" in bundle header Title" ]]
135136
[[ "$output" =~ "Empty Description in bundle header" ]]
136137
[[ "$output" =~ "Empty Maintainer in bundle header" ]]
137138
[[ "$output" =~ "Empty Status in bundle header" ]]
138139
[[ "$output" =~ "Empty Capabilities in bundle header" ]]
139140

140-
rm -f local-bundles/foo.bar # Delete invalid bundle from local-bundles (test case clean up)
141+
rm -f local-bundles/foo\^bar # Delete invalid bundle from local-bundles (test case clean up)
141142
}
142143

143144
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80

builder/bundleset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
var (
18-
validBundleNameRegex = regexp.MustCompile(`^[A-Za-z0-9-_]+$`)
18+
validBundleNameRegex = regexp.MustCompile(`^[A-Za-z0-9-_+.]+$`)
1919
validPackageNameRegex = regexp.MustCompile(`^[A-Za-z0-9-_+.]+$`)
2020
bundleHeaderFieldRegex = regexp.MustCompile(`^# \[([A-Z]+)\]:\s*(.*)$`)
2121
)

0 commit comments

Comments
 (0)