Skip to content
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ test-driver
ylwrap
# A popular IDE
*.code-workspace
*/*.o
*/*.lo
*/*.a
*/*.la
41 changes: 35 additions & 6 deletions build-deb.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
#!/usr/bin/env bash
#
# Build a Debian package (.deb) from the pilot-link source tree.
# Build Debian packages from the pilot-link source tree.
# Run from the project root. Requires build dependencies (see debian/control).
#
set -e
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR" && pwd)"
cd "$ROOT_DIR"

sanitize_warning_error_flags() {
local token
local sanitized=()

for token in $1; do
case "$token" in
-Werror|-Werror=*)
;;
*)
sanitized+=("$token")
;;
esac
done

printf '%s ' "${sanitized[@]}"
}

# Optional: regenerate configure and Makefiles (use when building from git without committed configure)
RECONFIGURE=false
if [[ "${1:-}" == "--reconfigure" ]]; then
Expand Down Expand Up @@ -37,9 +54,21 @@ fi

echo "Building Debian package..."
# -us: do not sign source package; -uc: do not sign .changes; -b: binary-only
# dpkg-buildflags can inject CFLAGS with "-Wformat =format-security" (space breaks the linker).
# Until this is fixed, use DEB_BUILD_MAINT_OPTIONS="hardening=-format"
# dpkg-buildpackage -us -uc -b "$@"
DEB_BUILD_MAINT_OPTIONS="hardening=-format" dpkg-buildpackage -us -uc -b "$@"
# Clear stale debhelper state so package splits/installs are recalculated cleanly.
rm -rf debian/.debhelper

# configure.ac strips "-Werror" naively, which corrupts Debian flags like
# "-Werror=format-security" into "=format-security". Preserve the normal Debian
# flags but remove the -Werror entries before running the package build.
BUILD_CFLAGS="$(sanitize_warning_error_flags "$(dpkg-buildflags --get CFLAGS)")"
BUILD_CXXFLAGS="$(sanitize_warning_error_flags "$(dpkg-buildflags --get CXXFLAGS)")"
BUILD_CPPFLAGS="$(dpkg-buildflags --get CPPFLAGS)"
BUILD_LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"

CFLAGS="$BUILD_CFLAGS" \
CXXFLAGS="$BUILD_CXXFLAGS" \
CPPFLAGS="$BUILD_CPPFLAGS" \
LDFLAGS="$BUILD_LDFLAGS" \
dpkg-buildpackage -us -uc -b "$@"

echo "Done. .deb and related files are in: $PARENT_DIR"
5 changes: 5 additions & 0 deletions build-debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/build-deb.sh" "$@"
2 changes: 1 addition & 1 deletion include/pi-md5.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#if HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H || HAVE_STDINT_H
#if HAVE_INTTYPES_H || HAVE_STDINT_H
#define UINT8 uint8_t
#define UINT32 uint32_t
#else
Expand Down
6 changes: 3 additions & 3 deletions libpisock/pi-header.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <stdio.h>

void print_splash(const char *progname) {
char *patchlevel = "";
const char *patchlevel = "";

fprintf(stderr, " DEPRECATED: The application is calling print_splash()\n");
#ifdef PILOT_LINK_PATCH
Expand All @@ -41,9 +41,9 @@ void print_splash(const char *progname) {
" `--------------------------------------------'\n"
" This is %s, from pilot-link version %d.%d.%d%s\n\n"
" Build target..: %s\n"
" Build date....: %s %s\n\n",
" Build date....: unavailable\n\n",
progname, PILOT_LINK_VERSION, PILOT_LINK_MAJOR, PILOT_LINK_MINOR,
patchlevel, HOST_OS, __DATE__, __TIME__);
patchlevel, HOST_OS);

printf(" pilot-link %d.%d.%d%s is covered under the GPL/LGPL\n",
PILOT_LINK_VERSION, PILOT_LINK_MAJOR, PILOT_LINK_MINOR, patchlevel);
Expand Down
8 changes: 5 additions & 3 deletions libpisock/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,10 @@ pi_serial_bind(pi_socket_t *ps, struct sockaddr *addr, size_t addrlen)
char realport[4096];
# endif /* PATH_MAX */
#endif /* MAXPATHLEN */
const char *port_for_messages = pa->pi_device;

realpath(pa->pi_device, realport);
if (realpath(pa->pi_device, realport) != NULL)
port_for_messages = realport;
errno = save_errno;

if (errno == ENOENT) {
Expand All @@ -387,10 +389,10 @@ pi_serial_bind(pi_socket_t *ps, struct sockaddr *addr, size_t addrlen)
} else if (errno == EACCES) {
LOG((PI_DBG_DEV, PI_DBG_LVL_ERR,
" Please check the "
"permissions on %s..\n", realport));
"permissions on %s..\n", port_for_messages));
LOG((PI_DBG_DEV, PI_DBG_LVL_ERR,
" Possible solution:\n\n\tchmod 0666 "
"%s\n\n", realport));
"%s\n\n", port_for_messages));
} else if (errno == ENODEV) {
while (count <= 5) {
if (isatty(fileno(stdout))) {
Expand Down
Loading