Additional improvements to the debian build + a setup command built into ncc
This commit is contained in:
parent
5b57f12365
commit
b102089d80
6 changed files with 156 additions and 4 deletions
4
Makefile
4
Makefile
|
@ -90,8 +90,6 @@ debian_prepare: autoload
|
|||
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 $(INSTALLER_SRC_PATH)/ncc.sh $(DEBIAN_BUILD_PATH)/usr/share/ncc/ncc.sh
|
||||
chmod +x $(DEBIAN_BUILD_PATH)/usr/share/ncc/ncc.sh
|
||||
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
|
||||
|
@ -106,6 +104,8 @@ debian_prepare: autoload
|
|||
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
|
||||
cp -rf $(DEBIAN_SRC_PATH)/copyright $(DEBIAN_BUILD_PATH)/DEBIAN/copyright
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ Vcs-Git: https://git.n64.cc/nosial/ncc.git
|
|||
Vcs-Browser: https://git.n64.cc/nosial/ncc
|
||||
Name: Nosial Code Compiler
|
||||
Architecture: all
|
||||
Depends: php (>= 8.0), php-mbstring, php-common, php-ctype, php-curl, zlib1g, php-zip
|
||||
Depends: shared-mime-info, php (>= 8.0), php-mbstring, php-common, php-ctype, php-curl, zlib1g, php-zip
|
||||
Description: Nosial Code Compiler is a multi-purpose compiler, package manager, and toolkit written in PHP.
|
||||
NCC (Nosial Code Compiler) is a versatile tool designed for various tasks related to PHP development.
|
||||
It allows you to compile PHP code, manage packages, and perform various tasks in a PHP-centric environment.
|
||||
|
|
|
@ -1,2 +1,33 @@
|
|||
#!/bin/bash
|
||||
update-mime-database /usr/share/mime
|
||||
set -e
|
||||
|
||||
# Update MIME database
|
||||
if ! update-mime-database /usr/share/mime; then
|
||||
echo "Error: Failed to update MIME database"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure PHP is installed
|
||||
PHP_BIN=$(command -v php)
|
||||
if [ -z "$PHP_BIN" ]; then
|
||||
echo "Error: PHP binary not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create symlink for ncc-cli
|
||||
ENTRY_POINT="/usr/bin/ncc"
|
||||
if ! cat <<EOF > "$ENTRY_POINT"
|
||||
#!/bin/bash
|
||||
$PHP_BIN /usr/share/ncc/ncc --ncc-cli "\$@"
|
||||
EOF
|
||||
then
|
||||
echo "Error: Failed to create entry point script at $ENTRY_POINT"
|
||||
exit 1
|
||||
fi
|
||||
chmod +x "$ENTRY_POINT"
|
||||
|
||||
# Initialize ncc
|
||||
if ! ncc setup --default-repositories=/usr/share/ncc/default_repositories.json; then
|
||||
echo "Error: Failed to setup ncc"
|
||||
exit 1
|
||||
fi
|
21
src/debian/postrm
Normal file
21
src/debian/postrm
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
remove|purge)
|
||||
# Remove the entry point script
|
||||
ENTRY_POINT="/usr/bin/ncc"
|
||||
|
||||
if [ -f "$ENTRY_POINT" ]; then
|
||||
rm -f "$ENTRY_POINT"
|
||||
echo "Removed $ENTRY_POINT"
|
||||
else
|
||||
echo "$ENTRY_POINT not found. Skipping removal."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
|
||||
# End of the script
|
||||
exit 0
|
96
src/ncc/CLI/Commands/SetupCommand.php
Normal file
96
src/ncc/CLI/Commands/SetupCommand.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\CLI\Commands;
|
||||
|
||||
use Exception;
|
||||
use ncc\Objects\CliHelpSection;
|
||||
use ncc\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
|
||||
class SetupCommand
|
||||
{
|
||||
/**
|
||||
* Sets up the NCC environment (usually used during installation)
|
||||
*
|
||||
* @param array $args
|
||||
* @return int
|
||||
*/
|
||||
public static function start(array $args): int
|
||||
{
|
||||
if(isset($args['help']))
|
||||
{
|
||||
return self::help();
|
||||
}
|
||||
|
||||
$default_repositories = [];
|
||||
if(isset($args['default-repositories']))
|
||||
{
|
||||
try
|
||||
{
|
||||
$default_repositories = Functions::loadJsonFile($args['default-repositories'], Functions::FORCE_ARRAY);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException(sprintf('Failed to load the default repositories from the given path: %s', $e->getMessage()), $e);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Functions::initializeFiles($default_repositories);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException(sprintf('Failed to initialize the files: %s', $e->getMessage()), $e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Displays the help menu for the setup command
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function help(): int
|
||||
{
|
||||
$options = [
|
||||
new CliHelpSection(['help'], 'Displays this help menu about the command'),
|
||||
new CliHelpSection(['--default-repositories=path'], 'Optional. The path to the default repositories file. If not specified, no default repositories will be loaded')
|
||||
];
|
||||
|
||||
$options_padding = Functions::detectParametersPadding($options) + 4;
|
||||
|
||||
Console::out('Usage: ncc setup [options]');
|
||||
Console::out('Options:' . PHP_EOL);
|
||||
foreach($options as $option)
|
||||
{
|
||||
Console::out(' ' . $option->toString($options_padding));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@
|
|||
use ncc\CLI\Commands\BuildCommand;
|
||||
use ncc\CLI\Commands\ExecCommand;
|
||||
use ncc\CLI\Commands\PackageInspectorCommand;
|
||||
use ncc\CLI\Commands\SetupCommand;
|
||||
use ncc\CLI\Management\ConfigMenu;
|
||||
use ncc\CLI\Management\CredentialMenu;
|
||||
use ncc\CLI\Management\PackageManagerMenu;
|
||||
|
@ -148,6 +149,9 @@
|
|||
Console::out('Unknown command ' . strtolower(self::$args['ncc-cli']));
|
||||
break;
|
||||
|
||||
case 'setup':
|
||||
return SetupCommand::start(self::$args);
|
||||
|
||||
case 'project':
|
||||
return ProjectMenu::start(self::$args);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue