Skip to content

Commit

Permalink
Problem: out of date with zproject
Browse files Browse the repository at this point in the history
Solution: regenerate
  • Loading branch information
bluca committed Aug 28, 2016
1 parent add4ca4 commit 5bc3ea7
Show file tree
Hide file tree
Showing 12 changed files with 402 additions and 30 deletions.
8 changes: 8 additions & 0 deletions builds/rpi/.gitignore
@@ -0,0 +1,8 @@
libzmq
raspbian-boot
raspbian-root
tmp/
tools/

*.img
*.zip
49 changes: 49 additions & 0 deletions builds/rpi/README.md
@@ -0,0 +1,49 @@
# Raspberry Pi

Cross compile environment for the Raspberry Pi (all models)

## Cross compile for Raspbian

Simply run

./build.sh

Once the build script finishes the installation data is located at `tmp/`.
To copy those files to your Raspberry Pi you can use `rsync`. Therefore
you'll have to make sure rsync is installed on the Raspberry Pi

apt-get install rsync

Next make sure your Pi user has sufficient access rights to copy data to
`/usr/local`. To force this you can use the following command to change
the ownership of the directory accordingly.

chown -R root:users /usr/local/

And finally sync your libraries to the Pi

rsync -avz tmp/ <pi-user>@<pi-ip>:/usr/local

The first time you install a library onto the Raspberry Pi you'll need to run

sudo ldconfig

## Cross compile and install to Raspbian image

This requires sudo access rights on your local maschine. Also make sure
you have `kpartx`, `qemu-user` and `proot` installed.

To cross compile and install this project to an raspbian image run

./build_image.sh

This script will download the latest Raspbian image extend it so we can install
software into it and finally copy the cross compiled stuff to it. Once it's done
simple copy the image to a SD card and plug it into your Raspberry Pi.

```
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
```
88 changes: 88 additions & 0 deletions builds/rpi/build.sh
@@ -0,0 +1,88 @@
#!/usr/bin/env bash
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################

# Download cross compiler and sysroot
if [ ! -d $PWD/tools ]; then
git clone --depth 1 https://github.com/raspberrypi/tools
else
( cd tools && git pull --rebase --quiet ) || exit 1
fi

# Cross build for the Raspberry Pi
mkdir -p $PWD/tmp
BUILD_PREFIX=$PWD/tmp
TOOLCHAIN_HOST="arm-linux-gnueabihf"
TOOLCHAIN_PATH="${PWD}/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin"
SYSROOT=$PWD/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot

CFLAGS="--sysroot=${SYSROOT} -I${BUILD_PREFIX}/include"
CPPFLAGS="--sysroot=${SYSROOT} -I${BUILD_PREFIX}/include"
CXXFLAGS="--sysroot=${SYSROOT} -I${BUILD_PREFIX}/include"
LDFLAGS="-L${BUILD_PREFIX}/lib"

CONFIG_OPTS=()
CONFIG_OPTS+=("CFLAGS=${CFLAGS}")
CONFIG_OPTS+=("CPPFLAGS=${CPPFLAGS}")
CONFIG_OPTS+=("CXXFLAGS=${CXXFLAGS}")
CONFIG_OPTS+=("LDFLAGS=${LDFLAGS}")
CONFIG_OPTS+=("PKG_CONFIG_DIR=")
CONFIG_OPTS+=("PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/arm-linux-gnueabihf/pkgconfig:${SYSROOT}/usr/share/pkgconfig")
CONFIG_OPTS+=("PKG_CONFIG_SYSROOT=${SYSROOT}")
CONFIG_OPTS+=("PKG_CONFIG_PATH=${BUILD_PREFIX}/lib/pkgconfig")
CONFIG_OPTS+=("--prefix=${BUILD_PREFIX}")
CONFIG_OPTS+=("--host=${TOOLCHAIN_HOST}")
CONFIG_OPTS+=("--with-docs=no")

CPP="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-cpp"
CC="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-gcc"
CXX="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-g++"
LD="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ld"
AS="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-as"
AR="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ar"
RANLIB="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ranlib"

CONFIG_OPTS+=("CPP=${CPP}")
CONFIG_OPTS+=("CC=${CC}")
CONFIG_OPTS+=("CXX=${CXX}")
CONFIG_OPTS+=("LD=${LD}")
CONFIG_OPTS+=("AS=${AS}")
CONFIG_OPTS+=("AR=${AR}")
CONFIG_OPTS+=("RANLIB=${RANLIB}")

# Clone and build dependencies
if [ ! -e libzmq ]; then
git clone --quiet --depth 1 https://github.com/zeromq/libzmq libzmq
fi
pushd libzmq
(
git --no-pager log --oneline -n1
if [ -e autogen.sh ]; then
./autogen.sh 2> /dev/null
fi
if [ -e buildconf ]; then
./buildconf 2> /dev/null
fi
./configure "${CONFIG_OPTS[@]}"
make -j4
make install
) || exit 1
popd


# Cross build this project
pushd ../..
(
./autogen.sh 2> /dev/null
./configure --enable-drafts=yes "${CONFIG_OPTS[@]}"
make -j4
make install
) || exit 1
popd

################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
32 changes: 32 additions & 0 deletions builds/rpi/build_image.sh
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################

# Cross compile this project and its dependencies
./build.sh

# Get the latest Raspbian image and enlarge it so there is enough space to
# install to it.
sudo ./prepare_img.sh

# Sync with image
sudo rsync -avz --no-p --no-g --chmod=ugo=rwX tmp/ raspbian-root/usr
sudo proot -Q qemu-arm -B -r raspbian-root -b raspbian-boot:/boot sudo ldconfig

# Umount image
sync; sudo umount ./raspbian-boot ./raspbian-root
# Make sure all allocated loop devices are free'd
for i in {0..7};
do
sudo sudo dmsetup clear loop${i}p1 &&
sudo sudo dmsetup clear loop${i}p2 &&
sudo sudo dmsetup remove loop${i}p1 &&
sudo sudo dmsetup remove loop${i}p2 &&
sudo sudo losetup -d /dev/loop$i
done
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
111 changes: 111 additions & 0 deletions builds/rpi/prepare_img.sh
@@ -0,0 +1,111 @@
#!/usr/bin/env bash
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################

if [ ! -f $PWD/raspbian_lite_latest.zip ]; then
wget --connect-timeout=10 https://downloads.raspberrypi.org/raspbian_lite_latest -O raspbian_lite_latest.zip
fi

RASPBIAN_IMG=$(unzip -Z1 raspbian_lite_latest.zip)
if [ ! -f $PWD/$RASPBIAN_IMG ]; then
unzip raspbian_lite_latest.zip
fi

if [ ! -f $PWD/raspbian_czmq.img ]; then

# Allocate disk space for extended image
truncate -s 1536M raspbian_czmq.img

# Begin partitioning disk image.
# Creating two partitions:
# BOOT = 100 MB
# ROOT = 1536 MB
fdisk raspbian_czmq.img <<EOF
o
n
p
1
+100M
t
c
n
p
2
w
EOF

# Create a loop device and mount the extended image's partitions
export LOOPDEV_EX="$(losetup --show --find raspbian_czmq.img)"

# Use sudo kpartx to create partitions in /dev/mapper
kpartx -av $LOOPDEV_EX
dmsetup --noudevsync mknodes

# Create partition names to mount
export BOOTPARTION_EX=$(echo $LOOPDEV_EX | sed 's|'/dev'/|'/dev/mapper/'|')p1
export ROOTPARTION_EX=$(echo $LOOPDEV_EX | sed 's|'/dev'/|'/dev/mapper/'|')p2

# Create file systems for the partitions
mkfs.vfat $BOOTPARTION_EX
mkfs.ext4 $ROOTPARTION_EX

# Create a loop device and mount the original image's partitions
export LOOPDEV_ORIG="$(losetup --show --find $RASPBIAN_IMG)"

# Use sudo kpartx to create partitions in /dev/mapper
kpartx -av $LOOPDEV_ORIG
dmsetup --noudevsync mknodes

# Create partition names to mount
export BOOTPARTION_ORIG=$(echo $LOOPDEV_ORIG | sed 's|'/dev'/|'/dev/mapper/'|')p1
export ROOTPARTION_ORIG=$(echo $LOOPDEV_ORIG | sed 's|'/dev'/|'/dev/mapper/'|')p2

# Copy data from original image to extended image
dd if=$BOOTPARTION_ORIG of=$BOOTPARTION_EX bs=64K conv=noerror,sync
dd if=$ROOTPARTION_ORIG of=$ROOTPARTION_EX bs=64K conv=noerror,sync

# Remove loop devices for original image
dmsetup clear $BOOTPARTION_ORIG
dmsetup clear $ROOTPARTION_ORIG
dmsetup remove $BOOTPARTION_ORIG
dmsetup remove $ROOTPARTION_ORIG
losetup -d $LOOPDEV_ORIG
fi

# Try to mount extended image
if [ -z "$(mount|grep raspbian-boot)" ] && [ -z "$(mount|grep raspbian-root)" ]; then

# Create a loop device and mount the disk image
export LOOPDEV_EX="$(losetup --show --find ./raspbian_czmq.img)"

# Use sudo kpartx to create partitions in /dev/mapper
kpartx -av $LOOPDEV_EX
dmsetup --noudevsync mknodes

# Create partition names to mount
export BOOTPARTION_EX=$(echo $LOOPDEV_EX | sed 's|'/dev'/|'/dev/mapper/'|')p1
export ROOTPARTION_EX=$(echo $LOOPDEV_EX | sed 's|'/dev'/|'/dev/mapper/'|')p2

# Make sure mount points exist and are clean
mkdir -p raspbian-boot
mkdir -p raspbian-root
rm -rf raspbian-boot/*
rm -rf raspbian-root/*

# Mount partitions
mount $BOOTPARTION_EX -t vfat raspbian-boot
mount $ROOTPARTION_EX -t ext4 raspbian-root
else
echo "Image already mounted!"
fi

################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
18 changes: 0 additions & 18 deletions configure.ac
Expand Up @@ -388,19 +388,6 @@ AC_SUBST([pkgconfigdir])


# enable specific system integration features
AC_ARG_WITH([systemd-units],
AS_HELP_STRING([--with-systemd-units],
[Build and install with systemd units integration [default=no]]),
[with_systemd_units=$withval],
[with_systemd_units=no])

AM_CONDITIONAL([WITH_SYSTEMD_UNITS], [test x$with_systemd_units != xno])

AM_COND_IF([WITH_SYSTEMD_UNITS],
[AC_DEFINE(WITH_SYSTEMD_UNITS, 1, [systemd units are going to be installed])
AC_SUBST(WITH_SYSTEMD_UNITS)],
[])

if test "x$cross_compiling" = "xyes"; then
# Enable draft by default when cross-compiling
defaultval=yes
Expand Down Expand Up @@ -433,11 +420,6 @@ AC_CONFIG_FILES([Makefile
src/libczmq.pc
])

AM_COND_IF([WITH_SYSTEMD_UNITS],
[AC_CONFIG_FILES([
])],
[])


AC_OUTPUT

Expand Down
2 changes: 1 addition & 1 deletion doc/Makefile.am
Expand Up @@ -18,7 +18,7 @@ dist_man_MANS = $(MAN_DOC)
endif

if BUILD_DOC
MAINTAINERCLEANFILES = $(MAN_DOC)
DISTCLEANFILES = $(MAN_DOC)

dist-hook : $(MAN_DOC)

Expand Down
3 changes: 0 additions & 3 deletions packaging/debian/control
Expand Up @@ -20,9 +20,6 @@ Build-Depends: debhelper (>= 9),
libzmq3-dev,
uuid-dev,
libsystemd-dev,
dh-autoreconf,
systemd,
dh-systemd
Build-Depends-Indep: asciidoc,
xmlto

Expand Down
3 changes: 0 additions & 3 deletions packaging/debian/czmq.dsc.obs
Expand Up @@ -10,9 +10,6 @@ Build-Depends: debhelper (>= 9),
libzmq3-dev,
uuid-dev,
libsystemd-dev,
dh-autoreconf,
systemd,
dh-systemd
Build-Depends-Indep: asciidoc,
xmlto

Expand Down
28 changes: 25 additions & 3 deletions packaging/debian/rules 100644 → 100755
@@ -1,15 +1,37 @@
#!/usr/bin/make -f
# -*- makefile -*-

DRAFTS=no

# OBS build: add
# Macros:
# %_with_drafts 1
# at the BOTTOM of the OBS prjconf
OBS_BUILD_CFG=/.build/build.dist
ifeq ("$(wildcard $(OBS_BUILD_CFG))","")
BUILDCONFIG=$(shell ls -1 /usr/src/packages/SOURCES/_buildconfig* | head -n 1)
endif
ifneq ("$(wildcard $(OBS_BUILD_CFG))","")
ifneq ("$(shell grep drafts $(OBS_BUILD_CFG))","")
DRAFTS=yes
endif
endif

# User build: DEB_BUILD_OPTIONS=drafts dpkg-buildpackage
ifneq (,$(findstring drafts,$(DEB_BUILD_OPTIONS)))
DRAFTS=yes
endif

override_dh_strip:
dh_strip --dbg-package=czmq-dbg

override_dh_auto_test:
echo "Skipped for now"

override_dh_auto_configure:
dh_auto_configure -- --with-systemd-units
dh_auto_configure -- \
--enable-drafts=$(DRAFTS)

%:
dh $@ --with autoreconf,systemd

dh $@ \
--with autoreconf

0 comments on commit 5bc3ea7

Please sign in to comment.