Internals - npackd/npackd GitHub Wiki

Introduction

Npackd was built from the beginning to make the hosting of repositories as easy as possible with minimal requirements to the hosting infrastructure. The second idea was to allow alternative implementations using the same repository format. This document describes the most important internal processes in the Npackd implementation.

Installation of a package

The installation of a single package follows this procedure:

Binary download

First Npackd downloads the package binary.

Anti-virus check

The downloaded binary is checked using the default anti-virus software installed on the computer.

Installation directory

The package installation directory is always created in the default installation directory. The default installation directory can be changed under settings in GUI and using "ncl set-install-dir".

The name of the package version directory corresponds to the title of the package where all characters invalid in file names are replaced with underscores. If the directory already exists, Npackd tries to append "-X.X.X" to the directory name where "X.X.X" is the version number of the package. If this directory also exists, an additional suffix "_Y" with a growing number is created.

Un-zip

If the file is of type "zip", it is unzipped.

Installation script

Npackd executes the ".Npackd\Install.bat", if present. The following parameters are used for "cmd.exe": cmd.exe /U /E:ON /V:OFF /C ""..."". The "cmd.exe" exit code 0 means that the script succeeded. Any other value means that the installation failed. In the latter case Npackd deletes the whole directory and presents the script log to the user. If multiple packages are installed in parallel, only one installation script is running at any moment.

Start menu shortcuts

In the last installation step shortcuts in the Windows start menu are created, if defined for the package version. If the target file for a shortcut does not exist, the installation fails.

Registry

The entry under "HKEY_LOCAL_MACHINE\SOFTWARE\Npackd\Npackd\Packages" in the Windows registry is created marking this package as "installed".

Event log

An entry in the Windows event log "Application" is created.

Removal of a package

The removal of a single package follows this procedure:

Stopping the package

If the file ".Npackd\Stop.bat" exists, it will be executed to stop the package. If the exit code is not equal to zero, the removal fails. If the ".Npackd\Stop.bat" script does not exist, Npackd tries to close top-level windows, disconnect users from the Windows file shares, send Ctrl+C and kill processes. Which actions are allowed can be configured.

Start menu shortcuts

All Windows start menu shortcuts pointing to files in the package directory are deleted. Any errors during this process are ignored.

Package directory

The package directory is deleted. Any errors during this process are ignored.

Event log

An entry in the Windows event log "Application" is created.

Package detection

The detection of foreign packages installed on the computer follows this procedure:

Detecting deleted packages

Check if the directory for each installed package still exist. If the corresponding directory is missing, the package version is marked as not installed.

Detection of the well-known packages

JRE, JDK, .NET, "MS XML libraries", "Microsoft Installer" are detected and marked as installed in the registry.

NPACKD_CL

The system-wide environment variable "NPACKD_CL" is updated with the path to the newest installed package version of NpackdCL.

MSI packages

The MSI packages installed on the computer are detected and marked as installed in the Windows registry.

Control panel "Software"

The programs installed on the computer as shown in the control panel "Software" are detected and marked as installed in the Windows registry.

Nested package directories

Npackd does not support nested installation directories for packages. If such directories are detected, the nested packages are marked as not installed.

NpackdDetected directory

For some detected packages it is impossible to find out the installation directory. For these packages directories under "C:\Program Files\NpackdDetected" are created and the corresponding ".Npackd\Uninstall.bat" script is written. This makes it possible to handle detected packages in the same way as installed via Npackd.

Building packages

Since Npackd 1.25 it is possible to build packages. This is normally used to compile programs from source. The command "ncl build" can be used to build a package. A new empty directory will be created and the file ".Npackd\Build.bat" will be executed from the newly created directory. The environment variable "NPACKD_PACKAGE_DIR" will point to the directory where the source package is installed and "NPACKD_OUTPUT_PACKAGE" will contain the name of the output package.