mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 06:06:02 -06:00
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 https://github.com/netblue30/firejail/pull/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
This commit is contained in:
parent
2678e3bef6
commit
2e14c1a1d0
2 changed files with 13 additions and 5 deletions
|
|
@ -9,8 +9,9 @@ build_ubuntu_package:
|
|||
image: ubuntu:rolling
|
||||
script:
|
||||
- apt-get update -qq
|
||||
- apt-get install -y -qq build-essential lintian pkg-config
|
||||
- apt-get install -y -qq build-essential lintian pkg-config python3
|
||||
- ./configure --prefix=/usr && make deb && dpkg -i firejail*.deb
|
||||
- python3 contrib/sort.py etc/*.{profile,inc}
|
||||
|
||||
build_debian_package:
|
||||
image: debian:jessie
|
||||
|
|
@ -32,14 +33,16 @@ build_fedora_package:
|
|||
- dnf update -y
|
||||
- dnf install -y rpm-build gcc make
|
||||
- ./configure --prefix=/usr && make rpms && rpm -i firejail*.rpm
|
||||
- python3 contrib/sort.py etc/*.{profile,inc}
|
||||
|
||||
build_src_package:
|
||||
image: alpine:latest
|
||||
script:
|
||||
- apk update
|
||||
- apk upgrade
|
||||
- apk add build-base linux-headers
|
||||
- apk add build-base linux-headers python3
|
||||
- ./configure --prefix=/usr && make && make install-strip
|
||||
# - python3 contrib/sort.py etc/*.{profile,inc}
|
||||
|
||||
build_apparmor:
|
||||
image: ubuntu:latest
|
||||
|
|
|
|||
|
|
@ -23,11 +23,13 @@ Exit-Codes:
|
|||
# python >= 3.6
|
||||
from sys import argv
|
||||
|
||||
|
||||
def sort_alphabetical(raw_items):
|
||||
items = raw_items.split(",")
|
||||
items.sort(key=lambda s: s.casefold())
|
||||
return ",".join(items)
|
||||
|
||||
|
||||
def sort_protocol(protocols):
|
||||
"""sort the given protocole into this scheme: unix,inet,inet6,netlink,packet"""
|
||||
# shortcut for common protocol lines
|
||||
|
|
@ -64,6 +66,7 @@ def sort_protocol(protocols):
|
|||
fixed_protocols += "packet,"
|
||||
return fixed_protocols[:-1]
|
||||
|
||||
|
||||
def fix_profile(filename):
|
||||
with open(filename, "r+") as profile:
|
||||
lines = profile.read().split("\n")
|
||||
|
|
@ -94,6 +97,7 @@ def fix_profile(filename):
|
|||
return 101
|
||||
return 0
|
||||
|
||||
|
||||
def main(args):
|
||||
exit_code = 0
|
||||
for filename in args:
|
||||
|
|
@ -103,15 +107,16 @@ def main(args):
|
|||
else:
|
||||
fix_profile(filename)
|
||||
except FileNotFoundError:
|
||||
print(f"[ Error ] Can't find {filename}")
|
||||
print(f"[ Error ] Can't find `{filename}'")
|
||||
exit_code = 1
|
||||
except PermissionError:
|
||||
print(f"[ Error ] Can't read/write {filename}")
|
||||
print(f"[ Error ] Can't read/write `{filename}'")
|
||||
exit_code = 1
|
||||
except:
|
||||
print(f"[ Error ] An error occurred while processing {filename}")
|
||||
print(f"[ Error ] An error occurred while processing `{filename}'")
|
||||
exit_code = 1
|
||||
return exit_code
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main(argv[1:]))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue