Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Package Installation with Improved Dependency Management and Extended Environment Configuration #84

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

tiff-ritz
Copy link

@tiff-ritz tiff-ritz commented Dec 27, 2024

Summary of Changes

This pull request introduces several enhancements and improvements to the buildpack-deb-packages project. The package installation process has been enhanced with the addition of support for default and configurable environment variables. Dependency management has been improved with better logic for handling special case packages that require additional package installation. The metadata used for caching has been improved with the addition of a timestamp Cache Management was improved with the introduction of an environment variable.

Detailed Changes

A tokio runtime has been introduced for asynchronous operations.

The package index creation process has been enhanced with the addition of a timestamp for updating and caching package sources. PACKAGE_CACHE_DAYS defines the number of days for which package cache is considered valid. The value of 0 will cause the cache to be recreated. Unit tests for package index creation functions have also been added.

Dependency management has been improved with the addition of support for special case constant defining packages and their required packages in order to cover all dependencies. Unit tests for dependency resolution functions have been added.

Error handling has been enhanced with the additional of new error types and messages for the new functionality. Unit tests for error handling functions have been added.

The package installation process has been enhanced with the addition of a timestamp for updating and caching packages. The PACKAGE_CACHE_DAYS environment variable has been introduced which helps control how frequently the package cache is refreshed to ensure the most up-to-date packages are used. Support for defining environment variables in the project.toml has been introduced. The package_env_vars constant and function has been added to define environment variables for specific packages. The logic for downloading and extracting package control.tar has been improved, and the execute_postinst_script function has been introduced to handle post-installation scripts. The logic for configuring environment variables for installed packages has been enhanced, and unit tests for package installation functions have been added.

The README.md has been updated to contain more documentation for the new features. Separate documentation has been created for special case map, default package environment variables, and configurable environment variables

Tests

Unit tests have been added for error handling functions in src/errors.rs, package installation functions in src/install_packages.rs, package index creation functions in src/create_package_index.rs, and dependency resolution functions in src/determine_packages_to_install.rs. Integration tests have been added in src/tests/integration_tests.rs.

Miscellaneous

Code formatting and cleanup have been applied across all modified files. Unnecessary comments and unused imports have been removed. Code readability has been improved by adding comments and structuring code logically.

New Features

The PACKAGE_ENV_VARS constant is a new feature in src/install_packages.rs. It defines environment variables for specific packages.

const PACKAGE_ENV_VARS: &[(&str, &[(&str, &str)])] = &[
    ("git", &[("GIT_EXEC_PATH", "{install_dir}/usr/lib/git-core"), ("GIT_TEMPLATE_DIR", "{install_dir}/usr/share/git-core/templates")]),
    ("ghostscript", &[("GS_LIB", "{install_dir}/var/lib/ghostscript")]),
    // define additional variable here
];

The SPECIAL_CASE_MAP constant is a new feature in src/determine_packages_to_install.rs. It maps special case packages to their required packages.

const SPECIAL_CASE_MAP: &[(&str, &[&str])] = &[
    ("portaudio19-dev", &["libportaudio2"]),
    ("7zip", &["7zip-standalone"]),
    // define additional packages here
];

The project.toml has been updated to support enhanced package installation and environment variable configuration.

schema-version = "0.2"

[com.heroku.buildpacks.deb-packages]
install = [
  "libgwenhywfar79",
  "libgwenhywfar-data",
  { name = "xmlsec1", skip_dependencies = true },
  "wget",
  "libvips",
  { name = "curl", force = true },
  { name = "git", env = {"GIT_EXEC_PATH" = "{install_dir}/usr/lib/git-core", "GIT_TEMPLATE_DIR" = "{install_dir}/usr/share/git-core/templates"}},
  { name = "ghostscript", env = {"GS_LIB" = "{install_dir}/var/lib/ghostscript"}},
]

@tiff-ritz tiff-ritz requested a review from a team as a code owner December 27, 2024 18:57
@tiff-ritz tiff-ritz changed the title Added a FromStr implementation to debian::MultiarchName Configurable Env Vars from project.toml Dec 27, 2024
Added a FromStr implementation to debian::MultiarchName
Implment functionality to load the environment variables associate with packages from the project.toml file
@tiff-ritz tiff-ritz changed the title Configurable Env Vars from project.toml Configurable Env Vars and Post Installation Commands from project.toml Dec 31, 2024
@tiff-ritz tiff-ritz marked this pull request as draft December 31, 2024 21:01
@edmorley edmorley removed the request for review from a team January 1, 2025 12:33
# This is the 1st commit message:

added code to set GIT_EXEC_PATH while installing packages.  Added a FromStr implementation to debian::MultiarchName in order to implement a unit test
document adding GIT_EXEC_PATH in the readme table of environment variables

# This is the commit message #2:

add setting of GS_LIB
Added a FromStr implementation to debian::MultiarchName
Implment functionality to load the environment variables associate with packages from the project.toml file
use PACKAGE_ENV_VARS constand to map default env vars to be defined if the package is in the project.toml file - these can be overwritten by the values in the project.toml file
define the package_env_vars before the env vars in the project.toml file
update README to reflect the PACKAGE_ENV_VARS

testing the buildpack, added a variable for skipped_packages.  Will incorporate that into install_packages

move the env logic into configure_layer_environment.  Iterate through the skipped_packages to make sure all the env vars are set and the post install command are run

flushed out a test in order to accomindate the new parameters passed to configure_layer_environment

finished the test for skipped packages

update the unit test to use a fixture to create the env correctly

use  a fixture for the test project.toml file; update the README
@tiff-ritz tiff-ritz marked this pull request as ready for review January 10, 2025 22:43
@tiff-ritz tiff-ritz changed the title Configurable Env Vars and Post Installation Commands from project.toml PACKAGE_ENV_VARS for package environment variable mapping Jan 15, 2025
@tiff-ritz tiff-ritz changed the title PACKAGE_ENV_VARS for package environment variable mapping Enhanced Package Installation with Improved Dependency Management and Extended Environment Configuration Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants