Internal functions
From HadronWiki
lpms provides lots of internal fucntions which are easy to learn to the package developers. Thanks to this you can easily do what you need without using import or writing a module name. Of course you can use all Python libraries if you want.
Contents |
Folder & File Operations
isdir
Checks if there is a directory (named in parameter) in the build directory. If there is, it returns True. If not, returns False.
isdir("src")
isfile
Checks if there is a file (named in parameter) in the build directory. If there is, it returns True. If not, returns False.
isfile("config.guess")
islink
Checks if there is a symbolic link (named in parameter) in the build directory. If there is, it returns True. If not, returns False.
islink("src/ui")
dirname
Returns the directory name of the parameter.
dirname("src/commons/main.c")
basename
Returns the path of the parameter.
basename("src/commnons/main.c")
realpath
Returns the real file path of the symbolic link which is in parameter.
realpath("src/ui")
touch
Like the touch command, creates an empty file in the given path.
touch(path)
echo
Writes a content to a target file.
echo(target, content)
isempty
Checks if the path is empty or not.
isempty(path)
cd
Navigates to the given path in the parameter. If no path provided, navigates to parent directory.
cd(path)
ls
If the provided path is a folder, lists the inside.
ls(path)
makedirs
Creates non-existing directories for given path (like mkdir -p).
makedirs(path)
makesym
Creates a symbolic link of the file which is provided in "source" to the "target".
makesym(source, target)
rmfile
If the provided parameter is a file, deletes it.
rmfile(target)
rmdir
If the provided parameter is a folder, deletes it.
rmdir(target)
pwd
Returns the path of current directory.
pwd()
joinpath
Creates a valid path with given parameters.
joinpath("/var", "tmp", "lpms", ...)
move
Moves the "source" to the "target".
move(source, target)
copy
Copies the "source" to the "target" with preserving permissions.
copytree(source, target, sym=True)
sed
Runs GNU sed command with the given parameters.
sed(*parameters)
setgroup
Runs GNU chgrp command with the given parameters.
setgroup(*parameters)
setowner
Runs GNU chown command with the given parameters.
setowner(*parameters)
setmod
Runs GNU chmod command with the given parameters.
setmod(*parameters)
Configuration Operations
opt
Checks if the given option is enabled. Returns True or False.
opt("doc")
config_enable
If the given option is enabled, prints --enable-option-name, if not prints --disable-option-name. If the option and parameter will be different, packager must provide it in the second parameter.
config_enable("gtk") --> if "gtk" option is enabled, returns "--enable-gtk"
config_enable("mp3", "libid3tag") --> if "mp3" option is enabled, returns "--enable-libid3tag"
config_with
If the given option is enabled, prints --with-option-name, if not prints --without-option-name. If the option and parameter will be different, packager must provide it in the second parameter.
config_with("python") --> if "python" option is enabled, returns "--with-python"
config_with("mp3", "libid3tag") --> if "mp3" option is enabled, returns "--with-libid3tag"
Installation Operations
insdoc
Copies given files to the /usr/share/doc/package-name folder.
insdoc("README", "COPYING", "TODO", "ChangeLog")
insinfo
Copies given GNU Info files to the /usr/share/info folder.
insinfo(param1, param2)
inslib
Copies given library file to the /usr/lib by default. If target is different, you can specify it. Default permission is 755.
inslib(source, target='/usr/lib')
insbin
Copies given binary file to the /usr/bin by default. If target is different, you can specify it. You can also change the target file name.
insbin(source, target='/usr/bin', name=None)
insinto
Copies given folder, or by default current folder, to the target directory with included files&folders. Also preserves permissions.
insinto(source, target)
insinfo
Copies given file to the target directory.
insfile(source, target)
Build Operations
make
Standard build function to build a package. You can give parameters if you want.
make()
make("contrib")
For MakeOpts like -j1:
make(j1)
conf
Standard configuration function for configure action. Accepts different kinds of parameters. If you want to run this somewhere outside of the current directory, you can add run_dir=folder_name at the end. Uses some default values for standard GNU Makefiles.
conf("--enable-foo",
config_with("bar"),
run_dir=build_dir)
raw_configure
For using with packages which don't accept standard conf() function. Also accepts parameters.
raw_configure(*parameters)
install
Installs the package to the temporary folder. By default, just runs make install command. Packager can change this behaviour by defining arg parameter. Also accepts parameters. Uses some default values for standard GNU Makefiles.
install(parameters=, arg='install')
raw_install
For using with packages which don't accept standard make install command. Accepts parameters.
raw_install('DESTDIR=%s' % install_dir)
installd
This is a shortcut for using "raw_install('DESTDIR=%s' % install_dir)" as a lot of packages can be installed with DESTDIR.
autoconf
Runs the "autoconf" command with given parameters.
autoconf(*parameters)
automake
Runs the "automake" command with given parameters.
automake(*parameters)
autoheader
Runs the "autoheader" command with given parameters.
autoheader(*parameters)
autoreconf
Runs the "autoreconf" command with given parameters.
autoreconf(*parameters)
Environment Related functions
append_${BUILD_VARIABLE}
- append_cflags
- append_cxxflags
- append_ldflags
These functions append the given flags to the build environment.
append_cflags("-fwprep")
append_ldflags("-Wl,--foo")
has_${BUILD_VARIABLE}
- has_cflags
- has_cxxflags
- has_ldflags
These functions check existence of the given flags in the build environment.
has_cflags("-pipe")
del_${BUILD_VARIABLE}
- del_cflags
- del_cxxflags
- del_ldflags
These functions delete the given flags from the build environment.
del_cflags("-pipe")
unset_env_variable
Unsets the given variable.
unset_env_variable("foo")
unset_env_variables
Unsets the environment variables.
unset_env_variables()
Others
fetch
Runs lpms' internal fetcher with the given parameters.
fetch(*urls, **params)

