1111 PLATFORM_STR := --platform linux/$(TARGET_ARCH )
1212endif
1313
14+ # Debian version and Python version (can be overridden via environment)
15+ DEBIAN_VER ?= bookworm
16+ ifeq ($(DEBIAN_VER ) ,trixie)
17+ PYTHON_VER ?= python3.13
18+ else
19+ PYTHON_VER ?= python3.11
20+ endif
21+
1422# Configurable paths and settings
1523VENV := _venv
1624PYTHON := $(VENV ) /bin/python
@@ -21,10 +29,10 @@ PY_SRC := $(wildcard *.py) $(wildcard organizer/**/*.py) $(DEPS_SRC)
2129
2230DEB_SRC := debian/* README* LICENSE* requirements.txt setup.py pyproject.toml
2331
24- DOCKER_IMG_NAME := clapshot_org_basic_folders_${ARCH}
32+ DOCKER_IMG_NAME := clapshot_org_basic_folders_${DEBIAN_VER}_${ ARCH}
2533DEV_VERSION := $(shell git rev-parse --short HEAD || date +"% Y-% m-% d" || echo "dev")
2634
27- PROTOLIB := clapshot_grpc-0.0.0+dev.tar.gz
35+ PROTOLIB := clapshot_grpc-0.0.0+dev-py3-none-any.whl
2836TARGET_BIN := $(VENV ) /bin/clapshot-organizer-basic-folders
2937
3038
@@ -73,7 +81,7 @@ docker:
7381 @echo " NOTE! Creating current user and UID/GID in Docker so bind mount is owned by it."
7482 @echo " Otherwise you wouldn't be able to access it without root privileges."
7583 @echo " -------------------------------------------------------------------------------"
76- cd ../.. && DOCKER_BUILDKIT=1 docker build $(PLATFORM_STR ) -t ${DOCKER_IMG_NAME} :${DEV_VERSION} --build-arg USER=${USER} --build-arg UID=${UID} --build-arg GID=${GID} -f Dockerfile.org-python .
84+ cd ../.. && DOCKER_BUILDKIT=1 docker build $(PLATFORM_STR ) -t ${DOCKER_IMG_NAME} :${DEV_VERSION} --build-arg USER=${USER} --build-arg UID=${UID} --build-arg GID=${GID} --build-arg DEBIAN_VER= ${DEBIAN_VER} --build-arg PYTHON_VER= ${PYTHON_VER} - f Dockerfile.org-python .
7785 docker tag ${DOCKER_IMG_NAME} :${DEV_VERSION} ${DOCKER_IMG_NAME} :latest
7886
7987dist_deb/built.${ARCH}.target : ${DEB_SRC} deps/$(PROTOLIB )
@@ -87,16 +95,25 @@ test-local: $(TARGET_BIN)
8795
8896debian-local : dist_deb/built.${ARCH}.target
8997
90- debian-docker : dist_deb/built.${ARCH}.docker
98+ debian-docker : dist_deb/built.${DEBIAN_VER}.${ ARCH}.docker
9199
92- dist_deb/built.${ARCH}.docker : ${PY_SRC} ${DEB_SRC} ../../Dockerfile.org-python
100+ dist_deb/built.${DEBIAN_VER}.${ ARCH}.docker : ${PY_SRC} ${DEB_SRC} ../../Dockerfile.org-python
93101 @echo " -------------------------------------------------------------------------------"
102+ @echo " Building organizer for Debian ${DEBIAN_VER} (${ARCH} ) with ${PYTHON_VER} "
94103 @echo " NOTE! Creating current user and UID/GID in Docker so bind mount is owned by it."
95104 @echo " Otherwise you wouldn't be able to access it without root privileges."
96105 @echo " -------------------------------------------------------------------------------"
97106 @mkdir -p dist_deb
98- cd ../.. && DOCKER_BUILDKIT=1 docker build $(PLATFORM_STR ) -t ${DOCKER_IMG_NAME} :${DEV_VERSION} --build-arg USER=${USER} --build-arg UID=${UID} --build-arg GID=${GID} -f Dockerfile.org-python .
107+ cd ../.. && DOCKER_BUILDKIT=1 docker build $(PLATFORM_STR ) -t ${DOCKER_IMG_NAME} :${DEV_VERSION} --build-arg USER=${USER} --build-arg UID=${UID} --build-arg GID=${GID} --build-arg DEBIAN_VER= ${DEBIAN_VER} --build-arg PYTHON_VER= ${PYTHON_VER} - f Dockerfile.org-python .
99108 docker tag ${DOCKER_IMG_NAME} :${DEV_VERSION} ${DOCKER_IMG_NAME} :latest
100- $(eval CMD="cd /build/organizer/basic_folders && cp -r --preserve=mode,ownership,timestamps /deb ./dist_deb && ls -l ./dist_deb && make debian-local && cp dist_deb/* .* /deb/ && chown -R ${UID}:${GID} /deb")
101- docker run --rm --mount type=bind,source=" $$ (pwd)/dist_deb" ,target=" /deb" --user root ${DOCKER_IMG_NAME} :latest bash -c ${CMD}
109+ docker run --rm $(PLATFORM_STR ) --mount type=bind,source=" $$ (pwd)/dist_deb" ,target=" /deb" --user root ${DOCKER_IMG_NAME} :latest \
110+ bash -c " cd /build/organizer/basic_folders && cp -r --preserve=mode,ownership,timestamps /deb ./dist_deb && \
111+ sed -i ' s/python3\\.11/${PYTHON_VER}/g' debian/control && \
112+ PYTHON_VER=${PYTHON_VER} make debian-local && cp dist_deb/* .deb /deb/ && chown -R ${UID} :${GID} /deb"
113+ @# Rename .deb files to include Debian version (skip if already contains it)
114+ for f in dist_deb/* .deb; do \
115+ case " $$ f" in * _${DEBIAN_VER} _* ) continue ;; esac ; \
116+ newname=$$(echo "$$f" | sed -E 's/(_[0-9.]+-?[0-9]*_ ) /\1 ${DEBIAN_VER} _/' ); \
117+ [ " $$ f" != " $$ newname" ] && mv " $$ f" " $$ newname" || true ; \
118+ done
102119 touch $@
0 commit comments