Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ sudo apk add alpine-sdk lmdb-dev openssl-dev bison flex-dev acl-dev pcre2-dev au

Note that in order for process promises to work you must install the procps package for a "proper" ps command instead of busybox.

* Termux (2020-04-24)
* Termux (2025-10-10)

pkg install build-essential git autoconf automake bison flex liblmdb openssl pcre2 libacl libyaml
./autogen.sh --without-pam
pkg install build-essential git autoconf automake bison flex liblmdb openssl pcre2 libacl libyaml binutils librsync
# maybe binutils-is-llvm - Use llvm as binutils instead of binutils to get ld
LDFLAGS='-landroid-glob' ./autogen.sh --without-pam --prefix=$PREFIX --with-workdir=$PREFIX/var/lib/cfengine --without-systemd-service --without-selinux-policy
make && make install

* OSX (2021-10-20)

Expand Down
10 changes: 9 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ CC="$PTHREAD_CC"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"

dnl ######################################################################
dnl libpromises/evalfunction.c isreadable() uses pthread_cancel so check
dnl if available and reverts to pthread_kill if not.
dnl This check must come after ACX_PTHREAD is called so that CC, CFLAGS,
dnl and LIBS are appropriately set for the local pthreads situation.
dnl ######################################################################
AC_CHECK_FUNCS([pthread_cancel])

dnl ######################################################################
dnl Whether to build extensions as builtin extensions or a separate
dnl plugin. The default is plugin.
Expand Down Expand Up @@ -1341,7 +1349,7 @@ AC_CHECK_DECLS([FALLOC_FL_PUNCH_HOLE], [], [], [
])
AC_CHECK_HEADERS([sys/sendfile.h])
AC_CHECK_FUNCS([sendfile])
AC_CHECK_FUNCS([copy_file_range])
AC_CHECK_DECL([copy_file_range])


dnl #######################################################################
Expand Down
11 changes: 11 additions & 0 deletions i
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -ex
export LDFLAGS+=" -landroid-glob"
./autogen.sh \
--prefix=$PREFIX \
--with-workdir=$PREFIX/var/lib/cfengine \
--without-pam \
--without-selinux-policy \
--without-systemd-service
make -j8 install
#DESTDIR=/data/data/com.termux/files make -j8 install
6 changes: 6 additions & 0 deletions libenv/sysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -3809,6 +3809,12 @@ static void SysOSNameHuman(EvalContext *ctx)
"Alpine", CF_DATA_TYPE_STRING,
"source=agent,derived-from=alpine");
}
else if (EvalContextClassGet(ctx, NULL, "termux") != NULL)
{
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_SYS, lval,
"Termux", CF_DATA_TYPE_STRING,
"source=agent,derived-from=termux");
}
else if (EvalContextClassGet(ctx, NULL, "gentoo") != NULL)
{
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_SYS, lval,
Expand Down
2 changes: 2 additions & 0 deletions libpromises/dbm_test_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
included file COSL.txt.
*/

#ifndef __ANDROID__
#include <platform.h>
#include <stdlib.h> /* lrand48_r() */
#include <unistd.h> /* usleep(), syscall()/gettid() */
Expand Down Expand Up @@ -735,3 +736,4 @@ void RemoveFilament(DBFilament *filament)
free(filament);
CloseDB(db);
}
#endif /* not __ANDROID__ */
2 changes: 2 additions & 0 deletions libpromises/dbm_test_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
included file COSL.txt.
*/

#ifndef __ANDROID__
#ifndef CFENGINE_DBM_TEST_API_H
#define CFENGINE_DBM_TEST_API_H

Expand Down Expand Up @@ -55,3 +56,4 @@ DBFilament *FillUpDB(dbid db_id, int usage_pct);
void RemoveFilament(DBFilament *filament);

#endif /* CFENGINE_DBM_TEST_API_H */
#endif /* not __ANDROID__ */
26 changes: 26 additions & 0 deletions libpromises/evalfunction.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#include <version_comparison.h>
#include <mutex.h> /* ThreadWait */
#include <glob_lib.h>
#include <signal_lib.h> /* MaskTerminationSignalsInThread */

#include <math_eval.h>

Expand Down Expand Up @@ -9672,10 +9673,29 @@ struct IsReadableThreadData
bool success;
};

#ifndef HAVE_PTHREAD_CANCEL
#define PTHREAD_CANCELED ((void *)-1)
static void ThreadSignalHandler(int signum)
{
pthread_exit(PTHREAD_CANCELED);
}
#endif

static void *IsReadableThreadRoutine(void *data)
{
assert(data != NULL);

#ifndef HAVE_PTHREAD_CANCEL
MaskTerminationSignalsInThread();
struct sigaction actions;
memset(&actions, 0, sizeof(actions));
sigemptyset(&actions.sa_mask);
actions.sa_flags = 0;
actions.sa_handler = ThreadSignalHandler;
sigaction(SIGHUP, &actions, NULL);
MaskTerminationSignalsInThread();
#endif

struct IsReadableThreadData *const thread_data = data;

// Give main thread time to call pthread_cond_timedwait(3)
Expand Down Expand Up @@ -9827,7 +9847,11 @@ static FnCallResult FnCallIsReadable(ARG_UNUSED EvalContext *const ctx,
"Read operation timed out, exceeded %ld seconds.", path,
timeout);

#ifdef HAVE_PTHREAD_CANCEL
ret = pthread_cancel(thread_data.thread);
#else
ret = pthread_kill(thread_data.thread, SIGUSR2);
#endif
if (ret != 0)
{
Log(LOG_LEVEL_ERR, "Failed to cancel thread");
Expand Down Expand Up @@ -9857,10 +9881,12 @@ static FnCallResult FnCallIsReadable(ARG_UNUSED EvalContext *const ctx,
return FnFailure();
}

#ifdef HAVE_PTHREAD_CANCEL
if (status == PTHREAD_CANCELED)
{
Log(LOG_LEVEL_DEBUG, "Thread was canceled");
}
#endif

return FnReturnContext(success);
}
Expand Down
11 changes: 11 additions & 0 deletions libpromises/generic_agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -2476,6 +2476,17 @@ bool GenericAgentConfigParseArguments(GenericAgentConfig *config, int argc, char

if (argc > 1)
{
Log(LOG_LEVEL_ERR, "Special 1-arg <policy-file> expected, got %d arguments instead. See debug output for details.", argc);
for (int i=0; i<argc; i++) {
char raw[256] = "";
for(int j=0; j<20; j++) {
char chunk[256];
snprintf(chunk, 256, "0x%02x ", argv[i][j]);
StringAppend(raw, chunk, 256);
if (argv[i][j] == 0) break;
}
Log(LOG_LEVEL_DEBUG, "Too many args, argv[%d] is '%s' [%s]", i, argv[i], raw);
}
return false;
}

Expand Down
150 changes: 150 additions & 0 deletions termux.INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
PREREQUISITES
-------------

In order to build CFEngine you need the following tools and libraries installed:

* C compiler supporting C90 + selected C99 constructs:
- _Bool type
- anonymous aggregates "(MyType) { .foo = 1, .bar = 2 }"
- declarations in "for" loop
- named initializers
- uintmax_t and corresponding printf/scanf formats
The following compilers are known to work:
- gcc >= 3.0
- clang >= 2.6
* GNU make

* PAM library
* OpenSSL library
* PCRE library
* POSIX threads (pthreads) library, if not provided by the operating system
* Latest available LMDB (Lightning Memory-mapped DataBase), Tokyo Cabinet or QDBM

* MySQL client library (optional)
* PostgreSQL client library (optional)
* libacl library (optional)

In order to build CFEngine cloned from git, you will need the
following additional tools:

* GNU Automake >= 1.10.1
* GNU Autoconf >= 2.60
* GNU Libtool >= 1.5.24
* Yacc (note: GNU Bison 2.4.2 has troubles invoking m4)
* Lex

Latest stable versions of the tools and libraries are generally advised.

See INSTALL DEPENDENCIES below for example of deps for various systems.

OPERATING SYSTEMS
-----------------

CFEngine is regularly built and tested on the following operating systems:

* GNU/Linux (many distributions)
* Solaris
* Windows with MinGW

HARDWARE PLATFORMS
------------------

CFEngine is regularly built and tested on the following CPU architectures:

* x86
* x86-64
* SPARC

OTHER CONFIGURATIONS
--------------------

In case you have successfully compiled CFEngine on a different OS and/or using
different tools or versions of tools, please report it to help-cfengine@ mailing
list[1]. Please consider running a testsuite (see below), and posting results to
mailing list too.

[1] https://groups.google.com/forum/#!forum/help-cfengine

BUILD INSTRUCTIONS
------------------

From tarball:

$ ./configure [configure options]
$ make [-jN]

From git checkout:

$ ./autogen.sh [configure options]
$ make [-jN]

See the available configure options:

$ ./configure --help
or
$ ./autogen.sh --help

INSTALLATION INSTRUCTIONS
-------------------------

CFEngine might be installed in two configurations:

* (default) Native CFEngine file layout. Everything is installed in
/var/cfengine, laid out as a "secondary FHS root". This layout is designed to
keep CFEngine running even if most of the system is broken (e.g. /usr is not
mounted due to NFS breakage).

* FHS file layout, enabled by --enable-fhs. This layout follows FHS 2.3.

After the build process has completed (see BUILD INSTRUCTIONS above), type:

$ make install

RUNNING TESTSUITE
-----------------

Please refer to the instructions in tests/README file.

INSTALL DEPENDENCIES
--------------------

Here we have examples of command lines for various systems to install dependencies
needed to build. The version and date checked are noted in parenthesis. Please
submit PRs with updates to this information.

* RedHat/CentOS (rhel-8/rhel-9/centos-7 2022-11-15)

Note that first you will need to install epel-release (https://fedoraproject.org/wiki/EPEL) for lmdb-devel to be available.

$ sudo yum install -y gcc gdb make git libtool autoconf automake byacc flex openssl-devel pcre-devel lmdb-devel pam-devel flex-devel libyaml-devel

For SELinux support you will need selinux-policy-devel package and specify `--with-selinux-policy` to `autogen.sh` or `configure`

* Debian (Raspbian 10 2021-07-02)

$ sudo apt-get install -y build-essential git libtool autoconf automake bison flex libssl-dev libpcre3-dev libbison-dev libacl1 libacl1-dev lmdb-utils liblmdb-dev libpam0g-dev libtool libyaml-dev

* FreeBSD (12.1 2020-04-07)

See docs/BSD.md

* SUSE (Tumbleweed 2020-02-02)

$ sudo zypper install gdb gcc make lmdb autoconf automake libtool git python3 pcre-devel libopenssl-devel pam-devel

* AlpineOS (3.11.3 x86_64 2020-04-13)

$ sudo apk add alpine-sdk lmdb-dev openssl-dev bison flex-dev acl-dev pcre-dev autoconf automake libtool git python3 gdb
$ ./autogen.sh --without-pam

* Termux (2020-04-24)

pkg install -y build-essential git autoconf automake bison flex liblmdb openssl pcre libacl libyaml
# ld is not found with clang (from build-essential?) so add binutils
# also need rsync
./autogen.sh --without-pam

* OSX (2021-10-20)

brew install openssl@1.1 lmdb autoconf automake libtool bison flex pcre m4 gcc make
./autogen.sh --enable-debug --with-openssl="$(brew --prefix openssl@1.1)"
Loading
Loading