t-richards/mausberry-switch

Build for PI2?

Closed this issue · 13 comments

Hello, is it possible to create a .deb for the Pi2? It uses armv7 so the current package doesn't install correctly.

Thank you!

I don't own an RPi2, so this isn't something I can do personally. Perhaps I should add some "build-from-source" instructions to the readme?

Yes, that would be super helpful. Thanks, I (and I'm sure many others) appreciate it!

I would also like to know how to make a build for the Pi 2.

I am also looking to install this on a RPI 2 OpenElec build. Do I need to build from source? how is it done?

Add me to the list of getting build instructions. I figured:

cmake .
make

I don't know how to setup to use armv7, though. I also don't understand how to build the deb.

Finally unboxed the Raspberry Pi 2 today; hope to have some functionality and packaging improvements soon.

@t-richards,

Could you post what packages are necessary from apt for development? Also, a script or list of commands to create and package the .deb file would be awesome!

I gave up on trying to figure out how to cross compile for arm7 on my desktop and instead just installed all my build tools on my Pi2. I was able to build the output, but I couldn't package a deb file.

I don't actually own one of the switches, but my co-worker does. I told him to install the release which has been noted as not working and then to replace the binary with the one I compiled. I haven't gotten feedback from him yet, however.

@mikejr83 ,

There are some instructions I began writing a while ago: https://github.com/t-richards/mausberry-switch/blob/0.6/docs/debian-building-packaging.md

...but I can't guarantee their completeness 😛

Sorry I don't have more information! It's been a while since I touched this project or anything debian-packaging related. One I dig in again, I'll be able to provide much more detail about how to make this thing work.

@t-richards,

Great! That's probably enough to get me going!

Seeing this problem when following those instructions:

pi@raspberrypi:~/projects/mausberry-switch$ git-buildpackage
gbp:error: You are not on branch 'master' but on '0.6'
gbp:error: Use --git-ignore-branch to ignore or --git-debian-branch to set the branch name.
1 pi@raspberrypi:~/projects/mausberry-switch$ git-buildpackage --git-ignore-branch
gbp:error: upstream/0.6 is not a valid treeish

Tried running this:

debuild -b -uc -us

Got this error:

dpkg-buildpackage -rfakeroot -D -us -uc -b
dpkg-buildpackage: source package mausberry-switch
dpkg-buildpackage: source version 0.6-1
dpkg-buildpackage: source distribution UNRELEASED
dpkg-buildpackage: source changed by Tom Richards <tom@tomrichards.net>
 dpkg-source --before-build mausberry-switch
dpkg-buildpackage: host architecture armhf
 fakeroot debian/rules clean
dh clean
   dh_testdir
   dh_auto_clean
   dh_clean
 debian/rules build
dh build
   dh_testdir
   dh_auto_configure
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.28") 
-- checking for module 'libconfig>=1.4'
--   found libconfig, version 1.4.9
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf
   dh_auto_build
make[1]: Entering directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
/usr/bin/cmake -H/home/pi/projects/mausberry-switch -B/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/CMakeFiles /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[2]: Entering directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
make -f src/CMakeFiles/mausberry-switch.dir/build.make src/CMakeFiles/mausberry-switch.dir/depend
make[3]: Entering directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
cd /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/projects/mausberry-switch /home/pi/projects/mausberry-switch/src /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/src /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/src/CMakeFiles/mausberry-switch.dir/DependInfo.cmake --color=
Scanning dependencies of target mausberry-switch
make[3]: Leaving directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
make -f src/CMakeFiles/mausberry-switch.dir/build.make src/CMakeFiles/mausberry-switch.dir/build
make[3]: Entering directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
/usr/bin/cmake -E cmake_progress_report /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/CMakeFiles 1
[100%] Building C object src/CMakeFiles/mausberry-switch.dir/switch.c.o
cd /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/src && /usr/bin/cc  -DCONFFILE=\"/usretc/mausberry-switch.conf\" -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -o CMakeFiles/mausberry-switch.dir/switch.c.o   -c /home/pi/projects/mausberry-switch/src/switch.c
/home/pi/projects/mausberry-switch/src/switch.c: In function ‘GPIOExport’:
/home/pi/projects/mausberry-switch/src/switch.c:48:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
     write(fd, buffer, to_write);
     ^
/home/pi/projects/mausberry-switch/src/switch.c: In function ‘GPIOUnexport’:
/home/pi/projects/mausberry-switch/src/switch.c:66:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
     write(fd, buffer, to_write);
     ^
/home/pi/projects/mausberry-switch/src/switch.c: In function ‘main’:
/home/pi/projects/mausberry-switch/src/switch.c:292:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
     system("poweroff");
     ^
Linking C executable mausberry-switch
cd /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/mausberry-switch.dir/link.txt --verbose=1
/usr/bin/cc  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -Wl,-z,relro CMakeFiles/mausberry-switch.dir/switch.c.o  -o mausberry-switch -rdynamic -lconfig 
make[3]: Leaving directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
/usr/bin/cmake -E cmake_progress_report /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/CMakeFiles  1
[100%] Built target mausberry-switch
make[2]: Leaving directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
/usr/bin/cmake -E cmake_progress_start /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/CMakeFiles 0
make[1]: Leaving directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
   dh_auto_test
 fakeroot debian/rules binary
dh binary
   dh_testroot
   dh_prep
   dh_auto_install
make[1]: Entering directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
/usr/bin/cmake -H/home/pi/projects/mausberry-switch -B/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/CMakeFiles /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[2]: Entering directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
make -f src/CMakeFiles/mausberry-switch.dir/build.make src/CMakeFiles/mausberry-switch.dir/depend
make[3]: Entering directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
cd /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/projects/mausberry-switch /home/pi/projects/mausberry-switch/src /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/src /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/src/CMakeFiles/mausberry-switch.dir/DependInfo.cmake --color=
make[3]: Leaving directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
make -f src/CMakeFiles/mausberry-switch.dir/build.make src/CMakeFiles/mausberry-switch.dir/build
make[3]: Entering directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
make[3]: Nothing to be done for 'src/CMakeFiles/mausberry-switch.dir/build'.
make[3]: Leaving directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
/usr/bin/cmake -E cmake_progress_report /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/CMakeFiles  1
[100%] Built target mausberry-switch
make[2]: Leaving directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
/usr/bin/cmake -E cmake_progress_start /home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf/CMakeFiles 0
make -f CMakeFiles/Makefile2 preinstall
make[2]: Entering directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
make[2]: Nothing to be done for 'preinstall'.
make[2]: Leaving directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
Install the project...
/usr/bin/cmake -P cmake_install.cmake
-- Install configuration: "None"
-- Installing: /home/pi/projects/mausberry-switch/debian/mausberry-switch/usr/etc/mausberry-switch.conf
-- Installing: /home/pi/projects/mausberry-switch/debian/mausberry-switch/usr/usr/bin/mausberry-switch
make[1]: Leaving directory '/home/pi/projects/mausberry-switch/obj-arm-linux-gnueabihf'
   dh_install
dh_install: mausberry-switch missing files (src/etc/*), aborting
debian/rules:6: recipe for target 'binary' failed
make: *** [binary] Error 2
dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit status 2

The doc with the instructions along with the build script made it very easy to get a .deb file. I have it shipped out for testing with a real switch. Thanks a ton!

Now that I successfully have built it on the pi I'm trying to figure out how to cross compile on my Ubuntu 16.04 machine.

I tried changing the build script to put the host argument to arm-linux and set the prefix to point at the pi's toolchain:

./configure --host=arm-linux --prefix=/home/mg/Projects/rpi/tools/arm-bcm2708 --sysconfdir=/etc

Getting the following error:

Invalid package configuration: Cannot package the path '/tmp/installdir/usr/bin', does it exist? {:level=>:error}

Actually, leaving the prefix alone may have been fine since I already had the toolchain on my PATH. Got some output and will have to test that too!

The official build docs should now be complete enough to build a working binary and debian package.