Skip to content

Commit 2e14c1a

Browse files
authored
Adding sort.py to GitLab CI (#2973)
* Add contrib/sort.py to Gitlab CI Not adding to Debian Jessie or CentOS since python >=3.6 is not available See #2870 * Updates Explicitly install python3 on Ubuntu (should be pre-installed but not working as-is) Remove running python3 code on CentOS * ci: comment out contrib/sort.py for Alpine Getting this error: $ python3 contrib/sort.py etc/*.{profile,inc} [ Error ] Can't find `etc/*.{profile,inc}' ERROR: Job failed: exit code 1 For now it's better to debug later and enable this test for the other jobs
1 parent 2678e3b commit 2e14c1a

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.gitlab-ci.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ build_ubuntu_package:
99
image: ubuntu:rolling
1010
script:
1111
- apt-get update -qq
12-
- apt-get install -y -qq build-essential lintian pkg-config
12+
- apt-get install -y -qq build-essential lintian pkg-config python3
1313
- ./configure --prefix=/usr && make deb && dpkg -i firejail*.deb
14+
- python3 contrib/sort.py etc/*.{profile,inc}
1415

1516
build_debian_package:
1617
image: debian:jessie
@@ -32,14 +33,16 @@ build_fedora_package:
3233
- dnf update -y
3334
- dnf install -y rpm-build gcc make
3435
- ./configure --prefix=/usr && make rpms && rpm -i firejail*.rpm
36+
- python3 contrib/sort.py etc/*.{profile,inc}
3537

3638
build_src_package:
3739
image: alpine:latest
3840
script:
3941
- apk update
4042
- apk upgrade
41-
- apk add build-base linux-headers
43+
- apk add build-base linux-headers python3
4244
- ./configure --prefix=/usr && make && make install-strip
45+
# - python3 contrib/sort.py etc/*.{profile,inc}
4346

4447
build_apparmor:
4548
image: ubuntu:latest

contrib/sort.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
# python >= 3.6
2424
from sys import argv
2525

26+
2627
def sort_alphabetical(raw_items):
2728
items = raw_items.split(",")
2829
items.sort(key=lambda s: s.casefold())
2930
return ",".join(items)
3031

32+
3133
def sort_protocol(protocols):
3234
"""sort the given protocole into this scheme: unix,inet,inet6,netlink,packet"""
3335
# shortcut for common protocol lines
@@ -64,6 +66,7 @@ def sort_protocol(protocols):
6466
fixed_protocols += "packet,"
6567
return fixed_protocols[:-1]
6668

69+
6770
def fix_profile(filename):
6871
with open(filename, "r+") as profile:
6972
lines = profile.read().split("\n")
@@ -94,6 +97,7 @@ def fix_profile(filename):
9497
return 101
9598
return 0
9699

100+
97101
def main(args):
98102
exit_code = 0
99103
for filename in args:
@@ -103,15 +107,16 @@ def main(args):
103107
else:
104108
fix_profile(filename)
105109
except FileNotFoundError:
106-
print(f"[ Error ] Can't find {filename}")
110+
print(f"[ Error ] Can't find `{filename}'")
107111
exit_code = 1
108112
except PermissionError:
109-
print(f"[ Error ] Can't read/write {filename}")
113+
print(f"[ Error ] Can't read/write `{filename}'")
110114
exit_code = 1
111115
except:
112-
print(f"[ Error ] An error occurred while processing {filename}")
116+
print(f"[ Error ] An error occurred while processing `{filename}'")
113117
exit_code = 1
114118
return exit_code
115119

120+
116121
if __name__ == "__main__":
117122
exit(main(argv[1:]))

0 commit comments

Comments
 (0)