I am working on a package system, which is described in this post. It will be often updated.
Executables
pkg.exe
This comandline tool ist for all stuff about installing/uninstalling or upgrading. It has accesse to the database of installed software packages and can handle dependencies.
It is able to install package files and packages from web/file-archives.
Parameters
pkg action filename[|packagename]
-
actions:
- install installs the package
- uninstall removes all of this package, except the settings
- remove deletes everything of the package (also settings!)
- upgrade Upgrades a package
- info Prints general information about the package.
File-format
Package Index
There is an index file, containing all installed software. Its called database.xml.
Example:
<?xml version="1.0" encoding="utf-8"?>
<wnp>
<packages>
<installed>
<package name="firefox" version="2.0.1" language="deDE" file="firefox-deDE-2.0.1.wnp" />
<package name="azureus" version="1.5" language="enEN" file="azureus-enEN-1.5.wnp" />
</installed>
</packages>
</wnp>
Package .wnp
A
wi
ndows
package is in general a zip-archive with predefined style.
It always contains the following things:
-
index.xml
Contains important data about the package.
Packagetypes:
- application Packages which have application type can be installed via the normal view.
- library Those packages are libraries needed for execution of applications, they are only visible in expert mode.
- addon Addons are additions to application and also not visible in normal view.
- instructions (directory) Instructions for install, remove, uninstall & upgrade
- files (directory) Contains all files used by the installer. [em](Can be empty, must exist)[/em]
Lua-Functions
This part describes all functions a install/uninstall script can use. It is very useful to check if a package can be installed or to perform specific actions, needed to install the software.
Package
- pkg.export (pkgfilename,exportedfilename) : true/false Extract a file to a specific filename
- pkg.fileexists (pkgfilename) : true/false Check if a file exists in the archive.
- pkg.fileconten t (pkgfilename) : string/nil Return the package file's content
Filesystem
- fs.fileexists (filename) : true/false Check wether a file exists in the filesystem
- fs.filecontent (filename) : string/nil Return a file's content
- fs.filesetcontent (filename,content) : true/false Return a file's content
- fs.delete (name) : true/false Deletes folders and clients, returns if it was possible.
- fs.copy (source,target) : true/false Copys a source to a target location.
- fs.chdir (dirname) Switches to this directory
- fs.dir (): string Returns current directory
-
fs.setAttributes (filename,attr)
Example:
- fs.setAttributes('example.txt',FILE_ATTRIBUTE_READONLY+FILE_ATTRIBUTE_HIDDEN)
- FILE_ATTRIBUTE_READONLY
- FILE_ATTRIBUTE_HIDDEN
- FILE_ATTRIBUTE_SYSTEM
- FILE_ATTRIBUTE_ARCHIVE
- FILE_ATTRIBUTE_NORMAL
- FILE_ATTRIBUTE_TEMPORARY
- FILE_ATTRIBUTE_OFFLINE
-
fs.fileinfo (filename,key) : string
Possible Values for [em]Key[/em]
- CompanyName
- FileDescription
- FileVersion
- InternalName
- LegalCopyRight
- LegalTradeMarks
- OriginalFileName
- ProductName
- ProductVersion
- Comments
- SpecialBuild
- PrivateBuild
- fs.fileversion (filename) : string Returns the version of the file. (Can be different from fs.fileinfo's data)
- fs.extractfilepath (filename) : string Returns path to the file/folder.
Registry
- reg.read (rootkey,type,key,var) : string/float/int Returns content of a registry key.
- reg.write(rootkey,type,key,var,value) : true/false Sets a value of a registry key.types: 'INT','FLOAT,'STRING' rootkey: 'HKEY_CURRENT_USER','HKEY_LOCAL_MACHINE','HKEY_CLASSES_ROOT','HKEY_CURRENT_CONFIG','HKEY_USERS'
Operating System
- os.sleep (seconds) Script will sleep for the amount of seconds
- os.beep () Create an audio beep.
- os.msg (message) Show a message as HintBox
- os.build () : majorversion , minversion , build Return the versiondetails about the windows version
- os.computer () : string Returns the computer's name
- os.login () : string Return the loginname of the current user.
- os.captureconsole (cmdline) : string Returns what was returned after [em]cmdline[/em] was executed.
- pkg_dir Var which contains path to the pkg-directory, must be used to include the pkg-library.
- print_r (element) Prints a php's print_r-alike information about an element.
Archives
- zip.list (zipname) : Table Returns information in an table, which has following structure: [Path\..\Folder\Filename] => Table { { [packed_size] => 2406 [crc] => E7141879 [size] => 4911 }
- zip.extract (zipname,file,todir,overwrite,fullpath) Exports [em]file[/em] (optional, default:all files) from [em]zipname[/em] and puts it into [em]todir[/em] (optional, default:current directory). If [em]overwrite[/em] is set (optional, default: true) all files will be replaced, if they exist. If you set [em]fullpath[/em] (optional, default:true) the files are exported with path information saved in the zip archive. Set it to false, if you want to lose the path information.
- zip.insert (zipname,filename) Inserts [em]filename[/em] (with path from the current directory) to the zipfile named with [em]zipname[/em].
- zip.delete (zipname,filename) Removes the file from the archive
- zip.create (zipname) Creates an ziparchive.
- zip.remove (zipname) Removes the ziparchive.
Features
- feature.add (featurename,version,lang) : Boolean Adds a new feature (version and lang are optional parameters) [em] Hint: Only available in detect\*.lua-Scripts[/em]
- feature.delete (featurename,version,lang) : Boolean Removes a feature. [em] Hint: Only available in detect\*.lua-Scripts[/em]
- feature.detail (featurename,key) Returns a detail about a feature
- feature.setdetail (featurename,key,value) Sets a detail about a feature
Doc-Updates:
- Added docs for feature-functions and some of the filesystem functions 15th March 2007
- Added new functions 14th March 2007
- New functions 5th March 2007
- Update 21 Feb 2007
- Initial Version 14th Feb 2007