ncc/Makefile

166 lines
6.2 KiB
Makefile
Raw Normal View History

# Variables
2023-08-16 11:58:50 -04:00
PHPCC := $(shell which php)
PHPAB := $(shell which phpab)
2023-10-06 02:48:32 -04:00
DEBPKG := $(shell which dpkg-deb)
2023-08-16 11:58:50 -04:00
SRC_PATH := src
2023-10-06 02:48:32 -04:00
ASSETS_PATH := assets
INSTALLER_SRC_PATH := $(SRC_PATH)/installer
CONFIG_PATH := $(SRC_PATH)/config
BUILD_VERSION := $(shell cat $(SRC_PATH)/ncc/VERSION)
2023-10-06 02:48:32 -04:00
BUILD_PATH := build
2023-10-07 04:35:46 -04:00
ifndef GENERIC_BUILD_PATH
GENERIC_BUILD_PATH := $(BUILD_PATH)/ncc_$(BUILD_VERSION)
endif
2023-10-06 02:48:32 -04:00
TAR_BUILD:= ncc_$(BUILD_VERSION).tar.gz
DEBIAN_SRC_PATH := $(SRC_PATH)/debian
DEBIAN_BUILD_PATH := $(BUILD_PATH)/debian/ncc_$(BUILD_VERSION)_all
DEBIAN_PACKAGE_BUILD_PATH := $(BUILD_PATH)/ncc_$(BUILD_VERSION)_all.deb
2023-08-16 11:58:50 -04:00
# List of paths for autoloading
AUTOLOAD_PATHS := $(addprefix $(SRC_PATH)/ncc/ThirdParty/, \
- Cleaned up imports - Various bug fixes and improved performance on package reading/writing - Corrected CHANGELOG.md - Updated dependency `Symfony/polyfill-mbstring` to 1.28.0 - Updated dependency `Symfony/polyfill-uuid` to 1.28.0 - Updated dependency `Symfony/Process` to 6.3.4 - Updated dependency `Symfony/Uid` to 6.3.0 - Updated dependency `Symfony/Yaml` to 6.3.3 - Added support for Gitea repositories - Added support for Packagist repositories - Added a new default Gitea repository nocturn9x at git.nocturn9x.space - Added a new default Gitea repository martinvlba at git.martinvlba.eu - Added a new default Gitea repository kuny at git.it-kuny.ch - Added dependency composer/semver version 3.4.0 for composer version comparison compatibility - Added a new class \ncc\Classes\ArchiveExtractor to extract multiple archive types - Refactored \ncc\Objects\RemoteRepository - Refactored the repository system - Refactored Github's repository interface - Refactored Gitlab's repository interface - Refactored SourcesMenu in the CLI to use the new repository system - Updated dependency nikic/php-parser to version 4.17.1 - Added a simple security measure in \ncc\Objects\Value\Entry to delay returns randomly when the password is incorrect - Refactored the CLI menu system to use a return exit code system - Updated the installer to remove unused components and installation steps - Updated dependency Symfony/Filesystem to 6.3.1 - Updated dependency Symfony/polyfill-ctype to 1.28.0 - Enforced credential storage security by applying 600 permissions to the storage file so that only the owner can read/write to the file; this will require root access to perform any operations on the credential file. A password will still be needed to decrypt entries in the file if any entries are encrypted. - Removed \ncc\Classes\NccExtension\Runner in favor of the new Execution Unit system - Removed \ncc\Managers\ExecutionPointerManager in favor of the new Execution Unit system
2023-09-21 17:24:12 -04:00
composer/semver \
defuse/php-encryption \
jelix/version \
nikic/PhpParser \
- Cleaned up imports - Various bug fixes and improved performance on package reading/writing - Corrected CHANGELOG.md - Updated dependency `Symfony/polyfill-mbstring` to 1.28.0 - Updated dependency `Symfony/polyfill-uuid` to 1.28.0 - Updated dependency `Symfony/Process` to 6.3.4 - Updated dependency `Symfony/Uid` to 6.3.0 - Updated dependency `Symfony/Yaml` to 6.3.3 - Added support for Gitea repositories - Added support for Packagist repositories - Added a new default Gitea repository nocturn9x at git.nocturn9x.space - Added a new default Gitea repository martinvlba at git.martinvlba.eu - Added a new default Gitea repository kuny at git.it-kuny.ch - Added dependency composer/semver version 3.4.0 for composer version comparison compatibility - Added a new class \ncc\Classes\ArchiveExtractor to extract multiple archive types - Refactored \ncc\Objects\RemoteRepository - Refactored the repository system - Refactored Github's repository interface - Refactored Gitlab's repository interface - Refactored SourcesMenu in the CLI to use the new repository system - Updated dependency nikic/php-parser to version 4.17.1 - Added a simple security measure in \ncc\Objects\Value\Entry to delay returns randomly when the password is incorrect - Refactored the CLI menu system to use a return exit code system - Updated the installer to remove unused components and installation steps - Updated dependency Symfony/Filesystem to 6.3.1 - Updated dependency Symfony/polyfill-ctype to 1.28.0 - Enforced credential storage security by applying 600 permissions to the storage file so that only the owner can read/write to the file; this will require root access to perform any operations on the credential file. A password will still be needed to decrypt entries in the file if any entries are encrypted. - Removed \ncc\Classes\NccExtension\Runner in favor of the new Execution Unit system - Removed \ncc\Managers\ExecutionPointerManager in favor of the new Execution Unit system
2023-09-21 17:24:12 -04:00
Symfony/polyfill_ctype \
Symfony/polyfill_mbstring \
Symfony/polyfill_uuid \
Symfony/Process \
Symfony/Uid \
Symfony/Filesystem \
Symfony/Yaml \
theseer/DirectoryScanner \
)
2023-08-16 11:58:50 -04:00
# Check for necessary binaries
ifndef PHPCC
$(error "PHP binary not found. Please install PHP or check your PATH")
endif
2023-10-07 04:35:46 -04:00
# Check if phpab is installed
ifndef PHPAB
2023-10-07 04:35:46 -04:00
$(error "phpab (PHP Autoload Builder) not found. Please install phpab or check your PATH")
endif
# Build rules
2023-08-16 11:58:50 -04:00
$(SRC_PATH)/%/autoload_spl.php:
$(PHPCC) $(PHPAB) --output $@ $(SRC_PATH)/$*
$(SRC_PATH)/ncc/autoload_spl.php:
2023-08-16 11:58:50 -04:00
$(PHPCC) $(PHPAB) --output $@ \
2023-08-19 05:02:22 -04:00
$(SRC_PATH)/ncc/Enums \
$(SRC_PATH)/ncc/Classes \
$(SRC_PATH)/ncc/CLI \
$(SRC_PATH)/ncc/Exceptions \
$(SRC_PATH)/ncc/Extensions \
$(SRC_PATH)/ncc/Interfaces \
$(SRC_PATH)/ncc/Managers \
$(SRC_PATH)/ncc/Objects \
$(SRC_PATH)/ncc/Utilities \
2023-01-29 23:27:56 +00:00
$(SRC_PATH)/ncc/ncc.php \
$(SRC_PATH)/ncc/Runtime.php
2022-08-11 14:04:33 -04:00
# Phony targets
2023-08-16 11:58:50 -04:00
.PHONY: autoload
autoload: $(addsuffix /autoload_spl.php, $(AUTOLOAD_PATHS)) $(SRC_PATH)/ncc/autoload_spl.php
cp -f $(SRC_PATH)/autoload/autoload.php $(SRC_PATH)/ncc/autoload.php
2023-08-16 11:58:50 -04:00
.PHONY: redist
2022-08-11 14:04:33 -04:00
redist: autoload
2023-10-06 02:48:32 -04:00
rm -rf $(GENERIC_BUILD_PATH)
mkdir -p $(GENERIC_BUILD_PATH)
cp -rf $(SRC_PATH)/ncc/* $(GENERIC_BUILD_PATH)
cp -f $(INSTALLER_SRC_PATH)/installer $(GENERIC_BUILD_PATH)/INSTALL
cp -f $(INSTALLER_SRC_PATH)/ncc.sh $(GENERIC_BUILD_PATH)/ncc.sh
cp -f $(CONFIG_PATH)/ncc.yaml $(GENERIC_BUILD_PATH)/default_config.yaml
cp -f $(CONFIG_PATH)/ncc.yaml $(GENERIC_BUILD_PATH)/CLI/template_config.yaml
cp -f $(CONFIG_PATH)/default_repositories.json $(GENERIC_BUILD_PATH)/default_repositories.json
cp -f $(INSTALLER_SRC_PATH)/ncc-package.xml $(GENERIC_BUILD_PATH)/ncc-package.xml
cp -f $(INSTALLER_SRC_PATH)/extension $(GENERIC_BUILD_PATH)/extension
chmod +x $(GENERIC_BUILD_PATH)/INSTALL
cp -f LICENSE $(GENERIC_BUILD_PATH)/LICENSE
cp -f README.md $(GENERIC_BUILD_PATH)/README.md
cp -f $(INSTALLER_SRC_PATH)/hash_check.php $(GENERIC_BUILD_PATH)/hash_check.php
$(PHPCC) $(GENERIC_BUILD_PATH)/hash_check.php
rm $(GENERIC_BUILD_PATH)/hash_check.php
cp -f $(INSTALLER_SRC_PATH)/generate_build_files.php $(GENERIC_BUILD_PATH)/generate_build_files.php
$(PHPCC) $(GENERIC_BUILD_PATH)/generate_build_files.php
rm $(GENERIC_BUILD_PATH)/generate_build_files.php
.PHONY: debian_prepare
debian_prepare: autoload
rm -rf $(DEBIAN_BUILD_PATH)
mkdir -p $(DEBIAN_BUILD_PATH)
mkdir -p $(DEBIAN_BUILD_PATH)/DEBIAN
mkdir -p $(DEBIAN_BUILD_PATH)/usr/share/ncc
cp -rf $(SRC_PATH)/ncc/* $(DEBIAN_BUILD_PATH)/usr/share/ncc
cp -rf $(CONFIG_PATH)/ncc.yaml $(DEBIAN_BUILD_PATH)/usr/share/ncc/default_config.yaml
cp -rf $(CONFIG_PATH)/ncc.yaml $(DEBIAN_BUILD_PATH)/usr/share/ncc/CLI/template_config.yaml
cp -rf $(CONFIG_PATH)/default_repositories.json $(DEBIAN_BUILD_PATH)/usr/share/ncc/default_repositories.json
cp -f LICENSE $(DEBIAN_BUILD_PATH)/usr/share/ncc/LICENSE
mkdir -p $(DEBIAN_BUILD_PATH)/usr/share/mime/packages
cp -rf $(INSTALLER_SRC_PATH)/ncc-package.xml $(DEBIAN_BUILD_PATH)/usr/share/mime/packages/ncc-package.xml
mkdir -p $(DEBIAN_BUILD_PATH)/usr/share/applications
cp -rf $(INSTALLER_SRC_PATH)/ncc.desktop $(DEBIAN_BUILD_PATH)/usr/share/applications/ncc.desktop
mkdir -p $(DEBIAN_BUILD_PATH)/usr/share/icons
cp -rf $(ASSETS_PATH)/icon/ncc@256px.png $(DEBIAN_BUILD_PATH)/usr/share/icons/ncc.png
cp -rf $(INSTALLER_SRC_PATH)/hash_check.php $(DEBIAN_BUILD_PATH)/usr/share/ncc/hash_check.php
cp -rf $(DEBIAN_SRC_PATH)/control $(DEBIAN_BUILD_PATH)/DEBIAN/control
cp -rf $(DEBIAN_SRC_PATH)/postinst $(DEBIAN_BUILD_PATH)/DEBIAN/postinst
chmod +x $(DEBIAN_BUILD_PATH)/DEBIAN/postinst
cp -rf $(DEBIAN_SRC_PATH)/postrm $(DEBIAN_BUILD_PATH)/DEBIAN/postrm
chmod +x $(DEBIAN_BUILD_PATH)/DEBIAN/postrm
2023-10-06 02:48:32 -04:00
cp -rf $(DEBIAN_SRC_PATH)/copyright $(DEBIAN_BUILD_PATH)/DEBIAN/copyright
2023-10-06 02:48:32 -04:00
$(BUILD_PATH)/$(TAR_BUILD): redist
cd $(GENERIC_BUILD_PATH) && tar -czf ../$(TAR_BUILD) *
2023-08-16 11:58:50 -04:00
.PHONY: tar
2023-10-06 02:48:32 -04:00
tar: $(BUILD_PATH)/$(TAR_BUILD)
$(DEBIAN_PACKAGE_BUILD_PATH): debian_prepare
$(DEBPKG) --build $(DEBIAN_BUILD_PATH) $(DEBIAN_PACKAGE_BUILD_PATH)
.PHONY: deb
deb: $(DEBIAN_PACKAGE_BUILD_PATH)
2022-08-11 14:04:33 -04:00
2023-10-07 04:35:46 -04:00
.PHONY: install
install: redist
$(GENERIC_BUILD_PATH)/INSTALL --auto
.PHONY: docker-debian
docker-debian:
docker build -t ncc-debian -f Dockerfile.debian .
.PHONY: docker-debian-run
docker-debian-run:
docker run -it --rm -v $(PWD):/ncc ncc-debian /bin/bash
.PHONY: docker-alpine
docker-alpine:
docker build -t ncc-alpine -f Dockerfile.alpine .
.PHONY: docker-alpine-run
docker-alpine-run:
docker run -it --rm -v $(PWD):/ncc ncc-alpine /bin/sh
2023-08-16 11:58:50 -04:00
.PHONY: clean
2022-08-11 14:04:33 -04:00
clean:
rm -rf $(BUILD_PATH)
rm -f $(SRC_PATH)/ncc/autoload_spl.php
2023-08-16 11:58:50 -04:00
rm -f $(addsuffix /autoload_spl.php, $(AUTOLOAD_PATHS))
.PHONY: help
help:
@echo "Available commands:"
@echo " make autoload - Generate autoload files"
@echo " make redist - Prepare the project for redistribution"
@echo " make install - Installs ncc on the system (requires root privileges & php)"
2023-10-06 02:48:32 -04:00
@echo " make tar - Package the project into a tarball (Generic installer, requires php)"
@echo " make deb - Package the project into a Debian package"
@echo " make docker-debian - Build a Debian Docker image"
@echo " make docker-debian-run - Run the Debian Docker image"
@echo " make docker-alpine - Build an Alpine Docker image"
@echo " make docker-alpine-run - Run the Alpine Docker image"
@echo " make clean - Clean the build artifacts"