-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
151 lines (128 loc) · 4.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
NAME = oscap-anaconda-addon
VERSION = 0.37.0
ADDON = org_fedora_oscap
TESTS = tests \
testing_files
DEFAULT_INSTALL_OF_PO_FILES ?= yes
PYVERSION = -3
TRANSLATIONS_DIR ?= po
FILES = $(ADDON) \
$(TESTS) \
data \
po \
COPYING \
Makefile \
README.md
EXCLUDES = \
*~ \
*.pyc
L10N_REPO_RELATIVE_PATH ?= OpenSCAP/oscap-anaconda-addon-l10n.git
L10N_REPOSITORY ?= https://github.com/$(L10N_REPO_RELATIVE_PATH)
L10N_REPOSITORY_RW ?= [email protected]:$(L10N_REPO_RELATIVE_PATH)
# Branch used in anaconda-l10n repository.
# This should be master all the time, unless you are testing translation PRs.
GIT_L10N_BRANCH ?= master
# The base branch, used to pair code with translations
OAA_PARENT_BRANCH ?= rawhide
all:
DISTNAME = $(NAME)-$(VERSION)
ADDONDIR = /usr/share/anaconda/addons/
SERVICEDIR = /usr/share/anaconda/dbus/services/
CONFDIR = /usr/share/anaconda/dbus/confs/
DISTBALL = $(DISTNAME).tar.gz
NUM_PROCS = $$(getconf _NPROCESSORS_ONLN)
install:
mkdir -p $(DESTDIR)$(ADDONDIR)
mkdir -p $(DESTDIR)$(SERVICEDIR)
mkdir -p $(DESTDIR)$(CONFDIR)
cp -rv $(ADDON) $(DESTDIR)$(ADDONDIR)
install -c -m 644 data/*.service $(DESTDIR)$(SERVICEDIR)
install -c -m 644 data/*.conf $(DESTDIR)$(CONFDIR)
ifeq ($(DEFAULT_INSTALL_OF_PO_FILES),yes)
$(MAKE) install-po-files
endif
uninstall:
rm -rfv $(DESTDIR)$(ADDONDIR)
dist:
rm -rf $(DISTNAME)
mkdir -p $(DISTNAME)
@if test -d ".git"; \
then \
echo Creating ChangeLog && \
( cd "$(top_srcdir)" && \
echo '# Generate automatically. Do not edit.'; echo; \
git log --stat --date=short ) > ChangeLog.tmp \
&& mv -f ChangeLog.tmp $(DISTNAME)/ChangeLog \
|| ( rm -f ChangeLog.tmp ; \
echo Failed to generate ChangeLog >&2 ); \
else \
echo A git clone is required to generate a ChangeLog >&2; \
fi
for file in $(FILES); do \
cp -rpv $$file $(DISTNAME)/$$file; \
done
for excl in $(EXCLUDES); do \
find $(DISTNAME) -name "$$excl" -delete; \
done
tar -czvf $(DISTBALL) $(DISTNAME)
rm -rf $(DISTNAME)
potfile:
$(MAKE) -C po potfile
# po-pull and update-pot are "inspired" by corresponding Anaconda code at
# https://github.com/rhinstaller/anaconda/blob/master/Makefile.am
# Our use case is slightly simpler (only one pot file), but we don't use automake,
# so there have to be some differences.
po-pull:
TEMP_DIR=$$(mktemp --tmpdir -d oscap-anaconda-addon-l10n-XXXXXXXXXX) && \
git clone --depth 1 -b $(GIT_L10N_BRANCH) -- $(L10N_REPOSITORY) $$TEMP_DIR && \
mkdir -p $(TRANSLATIONS_DIR) && \
cp $$TEMP_DIR/$(OAA_PARENT_BRANCH)/*.po $(TRANSLATIONS_DIR)/ && \
rm -rf $$TEMP_DIR
# This algorithm will make these steps:
# - clone localization repository
# - copy pot file to this repository
# - check if pot file is changed (ignore the POT-Creation-Date otherwise it's always changed)
# - if not changed:
# - remove cloned repository
# - if changed:
# - add pot file
# - commit pot file
# - tell user to verify this file and push to the remote from the temp dir
POTFILE_BASENAME = oscap-anaconda-addon.pot
update-pot:
$(MAKE) -C po potfile
TEMP_DIR=$$(mktemp --tmpdir -d oscap-anaconda-addon-l10n-XXXXXXXXXX) || exit 1 ; \
git clone --depth 1 -b $(GIT_L10N_BRANCH) -- $(L10N_REPOSITORY_RW) $$TEMP_DIR || exit 2 ; \
mkdir -p $$TEMP_DIR/$(OAA_PARENT_BRANCH) ; \
cp po/$(POTFILE_BASENAME) $$TEMP_DIR/$(OAA_PARENT_BRANCH)/ || exit 3 ; \
pushd $$TEMP_DIR/$(OAA_PARENT_BRANCH) ; \
git difftool --trust-exit-code -y -x "diff -u -I '^\"POT-Creation-Date: .*$$'" HEAD ./$(POTFILE_BASENAME) &>/dev/null ; \
if [ $$? -eq 0 ] ; then \
popd ; \
echo "Pot file is up to date" ; \
rm -rf $$TEMP_DIR ; \
else \
git add ./$(POTFILE_BASENAME) && \
git commit -m "Update $(POTFILE_BASENAME)" && \
popd && \
echo "Pot file updated for the localization repository $(L10N_REPOSITORY)" && \
echo "Please confirm changes (git diff HEAD~1) and push:" && \
echo "$$TEMP_DIR" ; \
fi ;
install-po-files:
$(MAKE) -C po install RPM_BUILD_ROOT=$(DESTDIR)
CONTAINER_NAME = oscap-anaconda-addon-ci
container-test:
podman build --tag $(CONTAINER_NAME) --file tests/Dockerfile
podman run --volume .:/oscap-anaconda-addon:Z $(CONTAINER_NAME) make test
container-update-image:
podman build --tag $(CONTAINER_NAME) --file tests/Dockerfile
podman run --volume .:/oscap-anaconda-addon:Z $(CONTAINER_NAME) ./create_update_image.sh -r / download_rpms
test: unittest runpylint
runpylint:
@echo "***Running pylint checks***"
python3 -m pylint org_fedora_oscap -E 2> /dev/null
@echo "[ OK ]"
unittest:
@echo "***Running unittests checks***"
PYTHONPATH=. python3 -m pytest -v tests/