-
Notifications
You must be signed in to change notification settings - Fork 25
Internals
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.
The installation of a single package follows this procedure:
First Npackd downloads the package binary.
The downloaded binary is checked using the default anti-virus software installed on the computer.
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.
If the file is of type "zip", it is unzipped.
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.
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.
The entry under "HKEY_LOCAL_MACHINE\SOFTWARE\Npackd\Npackd\Packages" in the Windows registry is created marking this package as "installed".
An entry in the Windows event log "Application" is created.
The removal of a single package follows this procedure:
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.
All Windows start menu shortcuts pointing to files in the package directory are deleted. Any errors during this process are ignored.
The package directory is deleted. Any errors during this process are ignored.
An entry in the Windows event log "Application" is created.
The detection of foreign packages installed on the computer follows this procedure:
Check if the directory for each installed package still exist. If the corresponding directory is missing, the package version is marked as not installed.
JRE, JDK, .NET, "MS XML libraries", "Microsoft Installer" are detected and marked as installed in the registry.
The system-wide environment variable "NPACKD_CL" is updated with the path to the newest installed package version of NpackdCL.
The MSI packages installed on the computer are detected and marked as installed in the Windows registry.
The programs installed on the computer as shown in the control panel "Software" are detected and marked as installed in the Windows registry.
Npackd does not support nested installation directories for packages. If such directories are detected, the nested packages are marked as not installed.
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.
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.