102 lines
2.7 KiB
C
102 lines
2.7 KiB
C
/*
|
|
* pkgops.h - Package-related function declarations for libglacier
|
|
*
|
|
* This file is part of Glacier.
|
|
*
|
|
* Glacier is free software: you can redistribute it and/or modify it under the terms of the
|
|
* GNU Lesser General Public License as published by the Free Software Foundation, either
|
|
* version 3 of the License, or (at your option) any later version.
|
|
*
|
|
* Glacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License along with Glacier. If
|
|
* not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef GLACIERPKGOPS_H_
|
|
#define GLACIERPKGOPS_H_
|
|
|
|
/* Permission constant for workspace directory creation */
|
|
#define DEFAULT_PERMISSIONS 0750
|
|
|
|
/* Maximum size for path buffers */
|
|
#define PATH_MAX_SIZE 512
|
|
|
|
/*
|
|
* gl_mkworkspace
|
|
*
|
|
* DESCRIPTION: gl_mkworkspace prepares /tmp/glacier-workspace for an operation
|
|
*
|
|
* EXAMPLE:
|
|
* gl_mkworkspace();
|
|
*
|
|
* RETURNS: 0 on success, 1 if workspace already exists, -1 on failure
|
|
*/
|
|
int gl_mkworkspace(void);
|
|
|
|
/*
|
|
* gl_prepare_pkg
|
|
*
|
|
* DESCRIPTION: gl_prepare_pkg copies a package archive from the localdb, and untars it
|
|
*
|
|
* EXAMPLE:
|
|
* gl_prepare_pkg("/glacier/localdb/epkgs-x86_64-musl/foo.tar");
|
|
*
|
|
* RETURNS: 0 on success, 1 on failure
|
|
*/
|
|
int gl_prepare_pkg(char PACKAGE[]);
|
|
|
|
/*
|
|
* gl_run_make_task
|
|
*
|
|
* DESCRIPTION: gl_run_make_task runs a specified make task in a package's current working directory
|
|
*
|
|
* EXAMPLE:
|
|
* MUST be run after gl_prepare_pkg(), or else errors will occur
|
|
* gl_prepare_pkg("/glacier/localdb/epkgs-x86_64-musl/foo.tar");
|
|
* gl_run_make_task("installpkg");
|
|
*
|
|
* RETURNS: 0 on success, 1 on failure
|
|
*/
|
|
int gl_run_make_task(char TASK[]);
|
|
|
|
/*
|
|
* gl_lock_file
|
|
*
|
|
* DESCRIPTION: Locks a specified file using fcntl
|
|
* PARAMETERS:
|
|
* const char *filepath -> The path to the file to lock
|
|
* RETURN VALUES:
|
|
* File descriptor on success, -1 on failure
|
|
* CAVEATS:
|
|
* The returned file descriptor must be passed to gl_unlock_file() to release the lock
|
|
* EXAMPLE:
|
|
* int fd = gl_lock_file("/path/to/file");
|
|
* if (fd >= 0) {
|
|
* // Do work with locked file
|
|
* gl_unlock_file(fd);
|
|
* }
|
|
*/
|
|
|
|
int gl_lock_file(const char *filepath);
|
|
|
|
/*
|
|
* gl_unlock_file
|
|
*
|
|
* DESCRIPTION: Unlocks a specified file using fcntl
|
|
* PARAMETERS:
|
|
* int file_descriptor -> The file descriptor returned by gl_lock_file()
|
|
* RETURN VALUES:
|
|
* 0 on success, 1 on failure
|
|
* CAVEATS:
|
|
* Only the process that acquired the lock can release it
|
|
* EXAMPLE:
|
|
* gl_unlock_file(file_descriptor);
|
|
*/
|
|
|
|
int gl_unlock_file(int file_descriptor);
|
|
|
|
#endif
|