From ae2c08d5dfdf801c070620cf55b6c318250c7544 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Tue, 24 Sep 2024 16:27:54 -0700 Subject: [PATCH 1/5] client: src: lib_docker: filter docker related .in files Creates a clutter-free finalized Dockerfile and docker-compose.yml by removing all comments and blank lines. --- client/src/docker/lib/internal/lib_docker.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/docker/lib/internal/lib_docker.bash b/client/src/docker/lib/internal/lib_docker.bash index 15cde64..802f6d5 100644 --- a/client/src/docker/lib/internal/lib_docker.bash +++ b/client/src/docker/lib/internal/lib_docker.bash @@ -74,6 +74,7 @@ function lib_docker::__docker() -e "s|@DOCKER_FINANCE_IMAGE@|${global_image}:${global_tag}|g" \ -e "s|@DOCKER_FINANCE_CONTAINER@|${global_container}|g" \ -e "s|@DOCKER_FINANCE_NETWORK@|${global_network}|g" \ + -e "/^ *#/d" -e "/^$/d" \ "${_path}.${global_platform}.in" >"$_path" || return $? } @@ -318,6 +319,9 @@ function lib_docker::__build() echo -e "# WARNING: keep at end of file\nUSER ${DOCKER_FINANCE_USER}\nWORKDIR /home/${DOCKER_FINANCE_USER}\n" \ >>"$_final" + # Remove all comments and empty lines + sed -i -e "/^ *#/d" -e "/^$/d" "$_final" + # # Execute # From f18bd9aabb4115299dbecb4d86cddc2f3db6a5a4 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Tue, 24 Sep 2024 19:18:05 -0700 Subject: [PATCH 2/5] client: docker-finance.d: fetch: re-add docker-finance version tag This was originally removed because it lacked functional usage, as there already exists a 'version' key. However, for consistency across all .in files, adding a version *tag* (non-YAML) serves to quickly indentify what program this configuration file actually belongs to. --- client/docker-finance.d/container/fetch/fetch.yaml.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/docker-finance.d/container/fetch/fetch.yaml.in b/client/docker-finance.d/container/fetch/fetch.yaml.in index 1844361..d6561ba 100644 --- a/client/docker-finance.d/container/fetch/fetch.yaml.in +++ b/client/docker-finance.d/container/fetch/fetch.yaml.in @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# docker-finance @DOCKER_FINANCE_VERSION@ + # # Configuration for `fetch` command # From 4a836a77c4fab484e73f7906d6226993ee24a415 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Tue, 24 Sep 2024 19:33:46 -0700 Subject: [PATCH 3/5] client: src: lib_gen: filter container config .in files Adds filters to remove noisy license clutter in configuration output. This is needed because of the amount of `edit` used on configurations. The license still applies, regardless. --- client/src/docker/lib/internal/lib_gen.bash | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/client/src/docker/lib/internal/lib_gen.bash b/client/src/docker/lib/internal/lib_gen.bash index d8ddb29..f43014f 100644 --- a/client/src/docker/lib/internal/lib_gen.bash +++ b/client/src/docker/lib/internal/lib_gen.bash @@ -580,7 +580,11 @@ function lib_gen::__gen_superscript_write() [ -z "$global_superscript" ] && lib_utils::die_fatal lib_utils::print_debug "global_superscript=${global_superscript}" + # Filter to de-clutter output file (license cleanup) + local -r _filter="3,19d" + sed \ + -e "$_filter" \ -e "s:@DOCKER_FINANCE_VERSION@:${global_client_version}:g" \ "${global_repo_conf_dir}/container/shell/superscript.bash.in" >"$global_superscript" } @@ -846,7 +850,11 @@ function lib_gen::__gen_subprofile_flow_subscript_write() [ -z "$global_client_version" ] && lib_utils::die_fatal [ -z "$global_repo_conf_dir" ] && lib_utils::die_fatal + # Filter to de-clutter output file (license cleanup) + local -r _filter="3,19d" + sed \ + -e "$_filter" \ -e "s:@DOCKER_FINANCE_CONTAINER_CMD@:${DOCKER_FINANCE_CONTAINER_CMD}:g" \ -e "s:@DOCKER_FINANCE_CONTAINER_REPO@:${DOCKER_FINANCE_CONTAINER_REPO}:g" \ -e "s:@DOCKER_FINANCE_VERSION@:${global_client_version}:g" \ @@ -917,7 +925,11 @@ function lib_gen::__gen_subprofile_flow_fetch_write() [ -z "$global_client_version" ] && lib_utils::die_fatal [ -z "$global_repo_conf_dir" ] && lib_utils::die_fatal + # Filter to de-clutter output file (license cleanup) + local -r _filter="1,17d" + sed \ + -e "$_filter" \ -e "s:@DOCKER_FINANCE_VERSION@:${global_client_version}:g" \ -e "s:@DOCKER_FINANCE_PROFILE@:${_profile}:g" \ -e "s:@DOCKER_FINANCE_SUBPROFILE@:${_subprofile}:g" \ @@ -965,6 +977,7 @@ function lib_gen::__gen_subprofile_flow_meta_write() [ -z "$global_repo_conf_dir" ] && lib_utils::die_fatal # Deletes default comments or else ROOT meta sample won't work out-of-the-box + # TODO: possible to keep filtered comments using upstream options? sed \ -e "/\/\/\\!/d" \ -e "s:@DOCKER_FINANCE_VERSION@:${global_client_version}:g" \ @@ -1013,7 +1026,11 @@ function lib_gen::__gen_subprofile_flow_hledger_write() [ -z "$global_repo_conf_dir" ] && lib_utils::die_fatal lib_utils::print_debug "global_repo_conf_dir=${global_repo_conf_dir}" + # Filter to de-clutter output file (license cleanup) + local -r _filter="1,17d" + sed \ + -e "$_filter" \ -e "s:@DOCKER_FINANCE_VERSION@:${global_client_version}:g" \ "${global_repo_conf_dir}/container/hledger/hledger.conf.in" >"$_file" } From a1cea1fd1edbb26de5288ddf566abba7b434621c Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 25 Sep 2024 20:54:00 -0700 Subject: [PATCH 4/5] client: docker-finance.d: Dockerfiles: add docker-finance version tag --- .../client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in | 2 ++ .../client/Dockerfiles/finance/Dockerfile.archlinux.in | 2 ++ .../client/Dockerfiles/finance/Dockerfile.ubuntu.in | 2 ++ 3 files changed, 6 insertions(+) diff --git a/client/docker-finance.d/client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in b/client/docker-finance.d/client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in index 3f7ddba..7e5b60b 100644 --- a/client/docker-finance.d/client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in +++ b/client/docker-finance.d/client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# docker-finance @DOCKER_FINANCE_VERSION@ + # # Custom (optional) Dockerfile # diff --git a/client/docker-finance.d/client/Dockerfiles/finance/Dockerfile.archlinux.in b/client/docker-finance.d/client/Dockerfiles/finance/Dockerfile.archlinux.in index c4c9076..504c44e 100644 --- a/client/docker-finance.d/client/Dockerfiles/finance/Dockerfile.archlinux.in +++ b/client/docker-finance.d/client/Dockerfiles/finance/Dockerfile.archlinux.in @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# docker-finance @DOCKER_FINANCE_VERSION@ + # # Custom (optional) Dockerfile # diff --git a/client/docker-finance.d/client/Dockerfiles/finance/Dockerfile.ubuntu.in b/client/docker-finance.d/client/Dockerfiles/finance/Dockerfile.ubuntu.in index 04ecfc2..41bbc92 100644 --- a/client/docker-finance.d/client/Dockerfiles/finance/Dockerfile.ubuntu.in +++ b/client/docker-finance.d/client/Dockerfiles/finance/Dockerfile.ubuntu.in @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# docker-finance @DOCKER_FINANCE_VERSION@ + # # Custom (optional) Dockerfile # From bfdc2452da7de2eed85243c44199305ff2fb3844 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 25 Sep 2024 20:59:09 -0700 Subject: [PATCH 5/5] client: src: lib_gen: filter custom Dockerfile's .in files Adds filter to remove noisy license clutter in custom Dockerfile output. This is needed because of the amount of `edit` used on the file. The license still applies, regardless. --- client/src/docker/lib/internal/lib_gen.bash | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/src/docker/lib/internal/lib_gen.bash b/client/src/docker/lib/internal/lib_gen.bash index f43014f..da23470 100644 --- a/client/src/docker/lib/internal/lib_gen.bash +++ b/client/src/docker/lib/internal/lib_gen.bash @@ -455,7 +455,6 @@ function lib_gen::__gen_client() local _confirm="${_read:-y}" if [[ "$_confirm" == [yY] || -z "$global_arg_confirm" ]]; then cp -a "$global_custom_dockerfile" "${global_custom_dockerfile}_${global_suffix}" || lib_utils::die_fatal - cp -fa "$global_repo_custom_dockerfile" "$global_custom_dockerfile" || lib_utils::die_fatal fi else lib_utils::print_custom " \e[32m│\e[0m\n" @@ -463,10 +462,16 @@ function lib_gen::__gen_client() lib_utils::print_debug "$global_repo_custom_dockerfile" lib_utils::print_debug "$global_custom_dockerfile" - - cp -a "$global_repo_custom_dockerfile" "$global_custom_dockerfile" fi + # Filter to de-clutter output file (license cleanup) + local -r _filter="1,17d" + + sed \ + -e "$_filter" \ + -e "s:@DOCKER_FINANCE_VERSION@:${global_client_version}:g" \ + "$global_repo_custom_dockerfile" >"$global_custom_dockerfile" || lib_utils::die_fatal + lib_utils::print_custom " \e[32m│ └─\e[34m Edit file now? [Y/n] \e[0m" lib_gen::__gen_edit "$global_custom_dockerfile" fi