Cross compiling for Debian 8 (jessie)

Hi there,

I’m trying to install Mender client to an armhf Debian (8) jessie system via deb packages but even the oldest one does not fit the because of the glibc version (mender requires at least 2.29 but jessie has 2.19).

Cross-compiling is also not working because of libtool and automake version incompatibility when building glib-2.0.

As the last chance I tried native compilation on the target device but it seems the golang version on the jessie 8 does not let me compile it.

Any suggestions? My host device is Arch-x86.

I have not tried this myself. Perhaps @kacf or @lluiscampos may be able to help.

I think I tried to cross-compile in Jessie once, too. And from my blurry memory I just remember it being quite a nightmare…

Cross-compile support in Debian had really improved in Debian Stretch and earlier, as you can easily configure apt to get packages for other architectures (namely libraries), but from your question I assume you need it to be Jessie.

So without and strong proof but I would suggest native compilation. If you try with an old Mender client you might be able to workaround the golang version requirement. Otherwise post us here the golang version you are using, and the compile error to see if it is possible to workaround by patching the code…

1 Like

Here’re the native compilation issues coming from versions 1.3.x, 1.4.x, and 1.5.x;

mender-1.x.x # make
go build -ldflags "-X main.Version=a8d1d2f"  
../src/github.com/sirupsen/logrus/entry.go:5:2: cannot find package "context" in any of:
        /usr/lib/go/src/pkg/context (from $GOROOT)
        /root/src/context (from $GOPATH)
deployment_log_hook.go:20:2: cannot find package "github.com/Sirupsen/logrus" in any of:
        /usr/lib/go/src/pkg/github.com/Sirupsen/logrus (from $GOROOT)
        /root/src/github.com/Sirupsen/logrus (from $GOPATH)
../src/github.com/minio/sha256-simd/cpuid_other.go:23:2: cannot find package "github.com/klauspost/cpuid/v2" in any of:
        /usr/lib/go/src/pkg/github.com/klauspost/cpuid/v2 (from $GOROOT)
        /root/src/github.com/klauspost/cpuid/v2 (from $GOPATH)
auth.go:20:2: cannot find package "github.com/mendersoftware/log" in any of:
        /usr/lib/go/src/pkg/github.com/mendersoftware/log (from $GOROOT)
        /root/src/github.com/mendersoftware/log (from $GOPATH)
../src/golang.org/x/sys/unix/affinity_linux.go:10:2: cannot find package "math/bits" in any of:
        /usr/lib/go/src/pkg/math/bits (from $GOROOT)
        /root/src/math/bits (from $GOPATH)
Makefile:37: recipe for target 'build' failed
make: *** [build] Error 1

And I couldn’t install any of those packages with go get (go1.3.3 linux/arm).

Hi @hancerli

Unfortunately, I found out that Debian Jessie uses golang 1.3… which predates Mender 1.0. After adding some hacks to make the GOPAH find packages in the vendor/ folder (maybe this was not supported at the time of golang 1.3?) I came to simple errors like:

root@73cc9bd2c724:~/go/src/github.com/mendersoftware/mender# go build
# github.com/mendersoftware/log
../log/log.go:188: undefined: strings.LastIndexByte
../log/log.go:192: undefined: strings.LastIndexByte
# github.com/mendersoftware/mender-artifact/parser
../mender-artifact/parser/generic_parser.go:82: undefined: strings.Compare
../mender-artifact/parser/generic_parser.go:89: undefined: strings.Compare
(...)

So yeah, that seems to be a dead road.

Next to try could be downloading a newer golang from upstream (instead of using Jessie’s one)

1 Like

So unfortunate but thanks anyway. I’ll give it a try with a newer golang version.

Any suggestion on which version I should try?

I would actually try latest :crossed_fingers:

1 Like

Thanks for the suggestion. Btw, I’m kind of new to golang, so please consider I may follow incorrect leads or report unrelated outputs mistakenly :).

Trying with go v1.16 but keep getting these issues:

mender-1.5 # make 
go build -ldflags "-X main.Version=4dc2179"  
deployment_log_hook.go:20:2: cannot find package "github.com/Sirupsen/logrus" in any of:
        /usr/lib/go/src/pkg/github.com/Sirupsen/logrus (from $GOROOT)
        /root/go/src/github.com/Sirupsen/logrus (from $GOPATH)
../go/src/github.com/minio/sha256-simd/cpuid_other.go:23:2: cannot find package "github.com/klauspost/cpuid/v2" in any of:
        /usr/lib/go/src/pkg/github.com/klauspost/cpuid/v2 (from $GOROOT)
        /root/go/src/github.com/klauspost/cpuid/v2 (from $GOPATH)
auth.go:20:2: cannot find package "github.com/mendersoftware/log" in any of:
        /usr/lib/go/src/pkg/github.com/mendersoftware/log (from $GOROOT)
        /root/go/src/github.com/mendersoftware/log (from $GOPATH)
Makefile:37: recipe for target 'build' failed
make: *** [build] Error 1

However, both cpuid and logrus packages are already installed.

 mender-1.5 # tree -L 2 /root/go/src/github.com/
/root/go/src/github.com/
|-- bmatsuo
|   `-- lmdb-go
|-- davecgh
|   `-- go-spew
|-- klauspost
|   |-- compress
|   |-- cpuid
|   `-- pgzip
|-- mattn
|   `-- go-isatty
|-- mendersoftware
|   |-- mender
|   |-- mender-artifact
|   |-- openssl
|   `-- progressbar
|-- minio
|   `-- sha256-simd
|-- pkg
|   `-- errors
|-- pmezard
|   `-- go-difflib
|-- remyoudompheng
|   `-- go-liblzma
|-- sirupsen
|   `-- logrus
|-- stretchr
|   |-- objx
|   `-- testify
|-- ungerik
|   `-- go-sysfs
`-- urfave
    `-- cli

Hi @hancerli

Yes, golang it a bit picky when it comes to paths. I seems like you have cloned it in a directory named “mender-1.5”? That won’t work… You need to clone mender in your GOPATH, following the project directory hierarchy and then checkout the version you want.

git clone https://github.com/mendersoftware/mender.git /root/go/src/github.com/mendersoftware/mender
cd /root/go/src/github.com/mendersoftware/mender
git checkout 1.7.0
make

Let me know if this does not solve the issue.

If using latest golang, I encourage you to try newer Mender versions though.

1 Like

Hi @lluiscampos,

Thanks for the suggestions, they pushed me a bit more. After trying and fixing a couple of issues between the mender version and golang version here is the point that I got stuck.

go build -ldflags "-X github.com/mendersoftware/mender/conf.Version=2.4.2"  
# github.com/mendersoftware/mender/vendor/github.com/mendersoftware/openssl
vendor/github.com/mendersoftware/openssl/conn.go:100:61: could not determine kind of name for C.X509_V_ERR_CA_KEY_TOO_SMALL
vendor/github.com/mendersoftware/openssl/conn.go:101:61: could not determine kind of name for C.X509_V_ERR_CA_MD_TOO_WEAK
vendor/github.com/mendersoftware/openssl/conn.go:103:61: could not determine kind of name for C.X509_V_ERR_DANE_NO_MATCH
vendor/github.com/mendersoftware/openssl/conn.go:105:61: could not determine kind of name for C.X509_V_ERR_EE_KEY_TOO_SMALL
vendor/github.com/mendersoftware/openssl/conn.go:106:61: could not determine kind of name for C.X509_V_ERR_EMAIL_MISMATCH
vendor/github.com/mendersoftware/openssl/conn.go:108:61: could not determine kind of name for C.X509_V_ERR_HOSTNAME_MISMATCH
vendor/github.com/mendersoftware/openssl/conn.go:109:61: could not determine kind of name for C.X509_V_ERR_INVALID_CALL
vendor/github.com/mendersoftware/openssl/conn.go:110:61: could not determine kind of name for C.X509_V_ERR_IP_ADDRESS_MISMATCH
vendor/github.com/mendersoftware/openssl/conn.go:111:61: could not determine kind of name for C.X509_V_ERR_NO_VALID_SCTS
vendor/github.com/mendersoftware/openssl/conn.go:116:49: could not determine kind of name for C.X509_V_ERR_PATH_LOOP
vendor/github.com/mendersoftware/openssl/conn.go:118:49: could not determine kind of name for C.X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION
vendor/github.com/mendersoftware/openssl/conn.go:119:49: could not determine kind of name for C.X509_V_ERR_STORE_LOOKUP
vendor/github.com/mendersoftware/openssl/conn.go:121:49: could not determine kind of name for C.X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256
vendor/github.com/mendersoftware/openssl/conn.go:122:49: could not determine kind of name for C.X509_V_ERR_SUITE_B_INVALID_ALGORITHM
vendor/github.com/mendersoftware/openssl/conn.go:123:49: could not determine kind of name for C.X509_V_ERR_SUITE_B_INVALID_CURVE
vendor/github.com/mendersoftware/openssl/conn.go:124:49: could not determine kind of name for C.X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM
vendor/github.com/mendersoftware/openssl/conn.go:125:49: could not determine kind of name for C.X509_V_ERR_SUITE_B_INVALID_VERSION
vendor/github.com/mendersoftware/openssl/conn.go:126:49: could not determine kind of name for C.X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED
Makefile:76: recipe for target 'mender' failed
make: *** [mender] Error 2

Using golang v1.12 (also tried with 1.10) and mender 2.4.2 (also tried with 2.5.x and 2.6.x).

Any idea on how I can proceed?

Edit:
Tried mender v1.7 and compiled it successfully. I’ll give it a shot first, then try to build v2.x.x if there are any missing functionalities.

Hi @hancerli,

The error you posted is an incompatibility with OpenSSL version,

I can see that OpenSSL version in Debian Jessie is 1.0.1t. Modern mender clients require OpenSSL 1.1.1 (I think 1.1.1k, but unsure about the exact version).

Mender client added OpenSSL dependency in 2.4.0 (see changelog here), so your best shot now is with Mender client 2.3.3.

Quite an adventure :slight_smile:

1 Like

1.7 is pretty old. If you can make it compile, 2.3 is much more feature rich. Mender client 2.3 is EOL as for this month, but 1.7 has been EOL for couple of years now…

1 Like

Way more than an adventure :)) 2.3 compiled and worked pretty well, so going with that one.

Thanks for the help all the way down, you did our day, cheers :beers:

here’s a pretty bear and sweet bee for you :bear: :honeybee:

Thanks for the emojis, glad you made it work!