[Pkg-giraffe-discuss] kopano-core 8.5.3 broken build due misbehaving script versionheader.sh?

Carsten Schoenert c.schoenert at t-online.de
Tue Feb 27 16:56:06 UTC 2018


Hello Mark,

I wanted to import and prepare kopano-core 8.5.3.
The import and other things went fine, but the package can't be build
due the recent changes made to the script versionheader.sh.

> make[1]: Leaving directory '/build/kopanocore-8.5.3'
>    dh_auto_build -O--builddirectory=debian/build
> 	cd debian/build && make -j4 -O
> make[1]: Entering directory '/build/kopanocore-8.5.3/debian/build'
> echo "8.5.3" >.version
> make[1]: Leaving directory '/build/kopanocore-8.5.3/debian/build'
> make[1]: Entering directory '/build/kopanocore-8.5.3/debian/build'
> /usr/bin/swig -python -external-runtime spooler/PythonSWIGRuntime.h
> make[1]: Leaving directory '/build/kopanocore-8.5.3/debian/build'
> make[1]: Entering directory '/build/kopanocore-8.5.3/debian/build'
> /bin/mkdir -p common/include/kopano
> sh ../../versionheader.sh >common/include/kopano/ecversion.h
> ../../versionheader.sh: 10: ../../versionheader.sh: Bad substitution
> make[1]: *** [Makefile:4786: common/include/kopano/ecversion.h] Error 2
> make[1]: Leaving directory '/build/kopanocore-8.5.3/debian/build'
> make[1]: *** Waiting for unfinished jobs....

The error message looks like bashism on a non Bash shell. And yes, the
shebang is set to /bin/sh and Makefile.am uses also just 'sh" so this
must fail on Debian default systems as Debian uses Dash as standard Shell.

> $ ls -la /bin/sh
> lrwxrwxrwx 2 root root 4 Feb  2 19:44 /bin/sh -> dash

So I modified Makefile.am and additionally the Shebang too. Now no error
message about 'Bad substitution' is shown any more but the build failing
also again.

So I tried to understand the logic of the script versionheader.sh a bit
more.

> #!/bin/sh
> 
> # file generated by configure (allows overriding by rpmbuild between configure and make)
> acver=$(cat .version)
> if test -z "$acver"; then
> 	echo "Missing the .version file as created by configure."
> 	exit 1
> fi
> version=$(cat version 2>/dev/null)
> if test "${version:0:${#acver}}" != "$acver"; then
> 	echo "You can only append, not override, the version specified in AC_INIT."
> 	exit 1
> fi
> set -- $(sed -e 's/ .*//g;s/[^0-9a-z][^0-9a-z]*/ /g' <version 2>/dev/null)
> major_version="$1"
> minor_version="$2"
> micro_version="$3"
> localrev="$4"
> if test -z "$major_version"; then major_version=0; fi
> if test -z "$minor_version"; then minor_version=0; fi
> if test -z "$micro_version"; then micro_version=0; fi
> if test -z "$localrev"; then localrev=0; fi
> globalrev=$(( $localrev | ($micro_version << 16) | ($minor_version << 20) | ($major_version << 28) ))
> 
> cat << EOF
> #define PROJECT_VERSION                 "$version"
> #define PROJECT_VERSION_MAJOR           $major_version
> #define PROJECT_VERSION_MINOR           $minor_version
> #define PROJECT_VERSION_MICRO           $micro_version
> #define PROJECT_VERSION_REVISION        ${globalrev}UL
> #define PROJECT_VERSION_COMMIFIED       "$major_version,$minor_version,$micro_version"
> EOF

First a file '.version' is used to find the kopano-core version.
Next a file 'version' (without dots or equal) is picked up. I haven't
found such a file so obviously it seem to come from elsewhere.

Next a comparison is done which errors out if the test isn't equal on
both sides.

Next I've looked into the file where versionheader.sh is proposed
writing to.

> cat common/include/kopano/ecversion.h
> You can only append, not override, the version specified in AC_INIT.

Hmm, this is the exact error message from that check, that should be
here I guess. It looks like the script isn't really error proof enough.

I'm not that familiar with shell variable substitution and I'm currently
not really understand what the check is for and I've done some try and
error.

> $ dot_version=8.5.3
> $ version=
> $ echo "${version:0:${#dot_version}}"
>    <--- empty output
> $ version=1.0
> $ echo "${version:0:${#dot_version}}"
> 1.0

Looks to me that the variable 'version' is needed otherwise the check
will fail.

I haven't much time to dig into the problem right now, I just want to
notice you about the issue we currently have here. I guess some kind of
fix is needed here.

-- 
Regards
Carsten Schoenert



More information about the Pkg-giraffe-discuss mailing list