1
0

Fix Makefile. Use Python 3 for scripts.

This commit is contained in:
Markus Birth 2017-11-16 00:19:08 +00:00
parent 8c64fb6b3b
commit 32e50d8334
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
3 changed files with 34 additions and 27 deletions

View File

@ -1,22 +1,29 @@
ALL_FOLDERS := ${shell find ./src/ -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0}
#ALL_FOLDERS := $(dir $(wildcard ./src/*/.))
#ALL_TARGETS = $(ALL_FOLDERS:./src/%=build/%.mkp)
SRC_DIR := src/
ALL_FOLDERS := $(shell find $(SRC_DIR) -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0)
ALL_MODULES := $(sort $(subst $(SRC_DIR),,$(ALL_FOLDERS)))
ALL_TARGETS := ${shell bin/findtargets.py build/ $(ALL_FOLDERS)}
all: $(ALL_TARGETS)
$(ALL_TARGETS): $(ALL_FOLDERS)
@echo "Building $@ from $<"
bin/makemkp.py $< ./build/
# cleanup
.PHONY: clean show_targets
clean:
-rm ./build/*.mkp
# debug
show_targets:
@echo $(ALL_FOLDERS)
@echo $(ALL_TARGETS)
@echo $(ALL_MODULES)
# setup
define make-goal
${shell bin/findtargets.py build/ $(SRC_DIR)$1}: $(SRC_DIR)$1
echo "Building $$@"
bin/makemkp.py $$< ./build/
endef
$(foreach mod,$(ALL_MODULES),$(eval $(call make-goal,$(mod))))

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import configparser

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import configparser
@ -45,7 +45,7 @@ cfg = configparser.ConfigParser()
cfg.read(src_dir + "/baseinfo.ini")
for key in cfg["info"]:
info[key] = cfg["info"][key].encode("utf-8")
info[key] = cfg["info"][key]
dst_file = os.path.normpath(dst_dir + "/" + "{}-{}.mkp".format(info["name"], info["version"]))
@ -57,17 +57,17 @@ tar = tarfile.open(name=dst_file, mode="w:gz")
# COLLECT FILES
package_parts = [ (part, title, perm) for part, title, perm in [
( "checks", "Checks", 0644 ),
( "notifications", "Notification scripts", 0755 ),
( "inventory", "Inventory plugins", 0644 ),
( "checkman", "Checks' man pages", 0644 ),
( "agents", "Agents", 0755 ),
( "web", "Multisite extensions", 0644 ),
( "pnp-templates", "PNP4Nagios templates", 0644 ),
( "doc", "Documentation files", 0644 ),
( "bin", "Binaries", 0755 ),
( "lib", "Libraries", 0644 ),
( "mibs", "SNMP MIBs", 0644 ),
( "checks", "Checks", 0o644 ),
( "notifications", "Notification scripts", 0o755 ),
( "inventory", "Inventory plugins", 0o644 ),
( "checkman", "Checks' man pages", 0o644 ),
( "agents", "Agents", 0o755 ),
( "web", "Multisite extensions", 0o644 ),
( "pnp-templates", "PNP4Nagios templates", 0o644 ),
( "doc", "Documentation files", 0o644 ),
( "bin", "Binaries", 0o755 ),
( "lib", "Libraries", 0o644 ),
( "mibs", "SNMP MIBs", 0o644 ),
]]
def files_in_dir(dir, prefix = ""):
@ -94,7 +94,7 @@ def create_tar_info(filename, size):
info.uid = 0
info.gid = 0
info.size = size
info.mode = 0644
info.mode = 0o644
info.type = tarfile.REGTYPE
info.name = filename
return info
@ -116,8 +116,8 @@ info["num_files"] = num_files
info_file = pprint.pformat(info)
info_json = json.dumps(info)
tar_from_string(tar, "info", info_file)
tar_from_string(tar, "info.json", info_json)
tar_from_string(tar, "info", info_file.encode("utf-8"))
tar_from_string(tar, "info.json", info_json.encode("utf-8"))
for part in info["files"]: