Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to makefiles to compile on Debian/CFEngine 3.15 #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Make with:
#
# make CFENGINE_SOURCE=/path/to/cfengine/source CFENGINE_INSTALLDIR=/path/to/cfengine/installdir
# make CFENGINE_SOURCE=/path/to/cfengine/source CFENGINE_PREFIX=/path/to/cfengine/installdir
#
CC=gcc -std=gnu99

CFENGINE_SOURCE=/usr/local/src
CFENGINE_PREFIX=/usr/local
CFLAGS=-I$(CFENGINE_PREFIX)/include -I$(CFENGINE_SOURCE) -I$(CFENGINE_SOURCE)/libutils -I$(CFENGINE_SOURCE)/libpromises -I$(CFENGINE_SOURCE)/libcfnet
CFENGINE_PREFIX=/var/cfengine
CFLAGS=-I$(CFENGINE_PREFIX)/include -I$(CFENGINE_SOURCE) -I$(CFENGINE_SOURCE)/libntech/libutils -I$(CFENGINE_SOURCE)/libpromises -I$(CFENGINE_SOURCE)/libcfnet

UNAME_S := $(shell uname -s)

Expand All @@ -24,10 +24,13 @@ endif

ifeq ($(UNAME_S),Linux)
# Linux
LDFLAGS=-L$(CFENGINE_PREFIX)/lib
LDFLAGS=-L$(CFENGINE_PREFIX)/lib -L$(CFENGINE_SOURCE)/libpromises/.libs
LDLIBS=-Wl,-rpath,$(CFENGINE_PREFIX)/lib -lpromises -lcrypto
endif

OBJECTS=cf-keycrypt

all: $(OBJECTS)

clean:
rm -f cf-keycrypt
93 changes: 88 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,90 @@
cf-keycrypt
===========
# cf-keycrypt

Build with:
This version is the same C code as the original from [cfengineers](https://github.com/cfengineers-net/cf-keycrypt).
The only thing I updated are both
the `Makefile` and `debian/rules`, so that cf-keycrypt compiles on Debian Linux 10 and works with
CFEngine 3.15. Following these instructions you should be able to compile the tool yourself.

```make
# make CFENGINE_SOURCE=/path/to/cfengine/source CFENGINE_PREFIX=/path/to/cfengine/installdir
# Prerequisites

## Install prerequisite packages

Whether you want to build a plain binary or a Debian package, you must be able to compile the CFEngine sources on your system. In addition, cf-keycrypt requires the development files for libtokyocabinet and the cfengine community package to be installed.

Assuming that you have already installed cfengine-community on the system, to install the rest of prerequisites, run:

```
sudo apt-get install \
bison flex binutils build-essential \
pkg-config autoconf libtool liblmdb-dev \
libssl-dev libpcre3-dev libpam0g-dev \
git libtokyocabinet-dev
```

If you need to install the cfengine-community package, refer to [this page](https://cfengine.com/product/community/) on the official web site.

## Clone the cf-keycrypt repository

In a directory of your choice, run:

```
git clone [email protected]:brontolinux/cf-keycrypt.git
```


# Building the binary

## Clone the cfengine core repository

To clone the latest 3.15 branch, run the following command in a directory of your choice:

```
git clone --recursive --single-branch --branch 3.15.x [email protected]:cfengine/core.git
```

## Build CFEngine 3.15

Enter the `core` directory and run:

```
./autogen.sh -C
make
```

## Compile cf-keycrypt

Assuming that you cloned and compiled CFEngine in, say, `/usr/local/src/cfengine/core`, enter the `cf-keycrypt` directory and run

```
make CFENGINE_SOURCE=/usr/local/src/cfengine/core
```

This should return pretty fast. If there are no errors, you'll find a `cf-keycrypt` executable in the directory where you cloned the sources. Congratulations.

# Building a Debian package

Enter the directory where you cloned cf-keycrypt and run:

```
sudo dpkg-buildpackage -us -uc
```

In a little while a number of files will be created in the directory above the source directory:

```
cf-keycrypt-dbgsym_0.1.1_amd64.deb
cf-keycrypt_0.1.1.dsc
cf-keycrypt_0.1.1.tar.xz
cf-keycrypt_0.1.1_amd64.buildinfo
cf-keycrypt_0.1.1_amd64.changes
cf-keycrypt_0.1.1_amd64.deb
```

You are probably most interested in `cf-keycrypt_0.1.1_amd64.deb`.

That's it!


# Acknowledgements

Instructions about how to compile CFEngine from source on a Debian system were kindly provided by Vratislav Podzimek and double checked by Bas van der Vlies. The tinkering on makefiles to make this compile on Debian is mine.
3 changes: 2 additions & 1 deletion cf-keycrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

#include <lastseen.h>
#include <conversion.h>
#include <files_hashes.h>
// #include <files_hashes.h>
#include <hash.h>
#include <locks.h>
#include <item_lib.h>
#include <known_dirs.h>
Expand Down
5 changes: 3 additions & 2 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ include /usr/share/dpkg/default.mk
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

CF_SRC = /tmp/cf-keycrypt-cf3src
CF_BRANCH = 3.15.x

clean:
rm -f cf-keycrypt
Expand All @@ -25,9 +26,9 @@ clean:

binary:
mkdir -p $(CF_SRC)
git clone https://github.com/cfengine/core.git $(CF_SRC)
git clone --recursive --single-branch --branch $(CF_BRANCH) https://github.com/cfengine/core.git $(CF_SRC)
cd $(CF_SRC) ; ./autogen.sh ; make
gcc -std=gnu99 -I/var/cfengine/include -I$(CF_SRC) -I$(CF_SRC)/libutils -I$(CF_SRC)/libpromises -I$(CF_SRC)/libcfnet -L$(CF_SRC)/libpromises/.libs cf-keycrypt.c -Wl,-rpath,/var/cfengine/lib/ -lpromises -lcrypto -o cf-keycrypt
gcc -std=gnu99 -I/var/cfengine/include -I$(CF_SRC) -I$(CF_SRC)/libntech/libutils -I$(CF_SRC)/libpromises -I$(CF_SRC)/libcfnet -L$(CF_SRC)/libpromises/.libs cf-keycrypt.c -Wl,-rpath,/var/cfengine/lib/ -lpromises -lcrypto -o cf-keycrypt
rm -rf $(CF_SRC)
dh $@

Expand Down