Filesystem
Miscellaneous filesystem-related functions.Functions in this category
| Name | Parameters |
|---|---|
| baselineFile | <FILENAME> |
| dirIsEmpty | <DIRECTORY> [--no-recurse] |
| getBaseline | [OPTIONS] <MATCH> |
| getFile | [OPTIONS] <FILENAME> |
| getFileMD5 | <FILENAME> |
| haveWriteAccess | <DIRECTORY> |
| recoverFile | <FILENAME> |
| removeFile | <FILENAME> |
| removeDir | <DIRECTORY> |
Details
| baselineFile | ||||||||
| Syntax: baselineFile <FILENAME> | ||||||||
| ||||||||
Process to compare two files and archive FILE if it is different from file information which is archived in a baseline file defined by $ROOTNAME/baseline.
baselineFile() is the companion to installConfig() function. During the installConfig, a MD5 of the original configuration file is added to the baseline file called $ROOTNAME/baseline. The logfile would have a baselineFile to determine how to handle this special file. During the uninstall, baselineFile() creates a MD5 of the configuration file to delete and compares it the baseline MD5. autopackage will archive configuration files that are different from installed files while deleting the configuration files if they match. So custom or modified configuration files will still exist in the system for reference purposes.
If files are different then FILE is archived to FILE.apkgsave . If FILE.apkgsave exists then FILE.apkgsave is moved to FILE.apkgsave.1 and FILE is copied to FILE.apkgsave . With this method, if FILE is archived then FILE.apkgsave is the latest saved version. Archived version are then FILE.apkgsave.2, FILE.apkgsave.3, etc. See also: installConfig(). | ||||||||
Example:
installConfig "etc/foo-config" # uninstall log would have either entry # baselineFile /home/user/.local/etc/foo-config # or # baselineFile /etc/foo-config |
| dirIsEmpty | ||||||||||
| Syntax: dirIsEmpty <DIRECTORY> [--no-recurse] | ||||||||||
| ||||||||||
Check whether DIRECTORY is empty. If DIRECTORY only contains empty subdirectories then DIRECTORY will be considered empty, unless --no-recurse is passed. |
| getBaseline | ||||||||||||||||||||||||
| Syntax: getBaseline [OPTIONS] <MATCH> | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
Returns any information from the baseline file that matches the defined string. The MATCH string must match an entire piece of data, therefore a string that is a filename must be absolute. See also: getFile(). | ||||||||||||||||||||||||
Example:
getBaseline "/lib/libfoo.so.1.1.2" |
| getFile | ||||||||||||||||||||||||||
| Syntax: getFile [OPTIONS] <FILENAME> | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
Returns any information about a valid file. See also: getFileMD5(). | ||||||||||||||||||||||||||
Example:
getFile "/lib/libfoo.so.1.1.2" |
| getFileMD5 | ||||||
| Syntax: getFileMD5 <FILENAME> | ||||||
| ||||||
Generate a MD5 checksum for the given file. See also: getFile(), getBaseline(). | ||||||
Example:
getFileMD5 "/lib/libfoo.so.1.1.2" |
| haveWriteAccess | ||||||||
| Syntax: haveWriteAccess <DIRECTORY> | ||||||||
| ||||||||
Checks whether we have write access to DIRECTORY. |
| recoverFile | ||||||||
| Syntax: recoverFile <FILENAME> | ||||||||
| ||||||||
Recovers file or directory from the package's BACKUP environment variable directory and moves it back into the filesystem.
recoverFile() is the companion to the copyFile() functions. During a copy process if the file exists, the previous file is moved to $autopackage_db/$BACKUP/<mimic filesystem>. The $BACKUP variable is set as `$ROOTNAME/backup'. See also: copyFiles(), copyFile(), linkFile(). | ||||||||
Example:
copyFiles "foo" "/some/directory" collides with a pre-existing file # uninstall log would have the entry # recoverFile /some/directory/foo and the colliding file # would be copied to $autopackage_db/$BACKUP/some/directory/foo |
| removeFile | ||||||||
| Syntax: removeFile <FILENAME> | ||||||||
|
| removeDir | ||||||||
| Syntax: removeDir <DIRECTORY> | ||||||||
| ||||||||
Recursively check if DIRECTORY is empty, and remove it if it is. Checks for any directory in the DIRECTORYs path. See also: dirIsEmpty() | ||||||||
Example:
mkdir -p a/deep/directory touch a/file pruneDir a/deep/directory ls a/deep # => "a/deep: no such file or directory" ls a/file # => exists |