Build failures of PPA

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
f3nix
Posts: 346
Joined: Sat May 30, 2015 11:58 am

Re: Build failures of PPA

Post by f3nix »

Maybe the "integrate" word isn't the best to describe it. But I couldn't come up with a better one. Tips from native speakers highly appreciated! :)

Cheers,
Mateusz
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Build failures of PPA

Post by sgrogan »

f3nix wrote:Maybe the "integrate" word isn't the best to describe it. But I couldn't come up with a better one. Tips from native speakers highly appreciated! :)
"integrate" works for me. Maybe "adapt and integrate". I knew not to copy and paste the script into the rules file!
Thanks for this f2nix I will attempt to "integrate" :D this into the PPA.
"fight the good fight"
blacey
Posts: 370
Joined: Tue Dec 08, 2015 11:28 pm

Re: Build failures of PPA

Post by blacey »

@f3nix, good idea. I have not been a fan of the git counting method because it requires a full clone, or at least a clone to the reference sha depth, and that isn't very efficient for things like CI builds (i.e. Travis) and is inaccurate on branches other than master. @sgrogan pointed me to this thread and I hacked your script a little to take advantage of the information that is already available in a shallow clone (i.e. Travis).

Code: Select all

#!/bin/bash

origin_url=$(git config --get remote.origin.url)
github_repo_owner=$(basename $(dirname ${origin_url}))
github_repo_name=$(basename ${origin_url})
github_repo_api_url="https://api.github.com/repos/${github_repo_owner}/${github_repo_name%.git}"

first_commit="6b3d7b17a749e03bcbf2cf79bbbb903137298c44"
latest_commit=$(git rev-parse HEAD)
commit_date=$(git show -s --format=%ci HEAD)

github_compare=$(curl -s "$github_repo_api_url"/compare/${first_commit}...${latest_commit})
num_commits=$(echo "${github_compare}" | jq '. | .total_commits')
revision=$((num_commits + 5235))

version_file="src/Build/Version.h"

echo -e "" > ${version_file}
echo -e "// Version Number" >> ${version_file}
echo -e "#define FCVersionMajor \"0\"" >> ${version_file}
echo -e "#define FCVersionMinor \"17\"" >> ${version_file}
echo -e "#define FCVersionName  \"Vulcan\"" >> ${version_file}
echo -e "// test: \$Format:Hash (%H), Date: %ci$" >> ${version_file}
echo -e "#define FCRevision      \"${revision} (Git)\"      //Highest committed revision number" >> ${version_file}
echo -e "#define FCRevisionDate  \"${commit_date}\"     //Date of highest committed revision" >> ${version_file}
echo -e "#define FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\"      //Repository URL of the working copy" >> ${version_file}
echo -e "" >> ${version_file}
echo -e "// Git relevant stuff" >> ${version_file}
echo -e "#define FCRepositoryHash   \"${latest_commit}\"" >> ${version_file}
echo -e "#define FCRepositoryBranch \"master\"" >> ${version_file}
echo -e "" >> ${version_file}
The only real difference is to get the information about the HEAD commit from the shallow clone and use jq instead of jshon because we already us jq for port-cache management and it is available in Linux apt and for Windows. I tried listing the commits since the reference sha using the GitHub API but GitHub wouldn't return more than 30 commits even if I used an OAUTH token; seemed listing and counting would be more efficient than comparing just to get a total number of commits.

If/when we do this, we could add a script to src/Tools so it is available everywhere and even consider adding logic to the cmake configs to use it if the reference commit is not available in the local git repo or if the git repo depth is shallow such as Travis or launchpad.
User avatar
f3nix
Posts: 346
Joined: Sat May 30, 2015 11:58 am

Re: Build failures of PPA

Post by f3nix »

sgrogan wrote:Thanks for this f2nix I will attempt to "integrate" :D this into the PPA.
Hi.
I have found some time to test this on my PPA. No luck :/ External network is not available inside the builder. You can't get any data from GitHub while building. I guess they have locked it down for security reasons. What is interesting is that the api.launchpad.net is visible.

So back to the drawing board to figure out how to make use of Launchpad's API only.

Cheers,
Mateusz

P.S. This version of script could still be useful to automate generation of Version.h in gitversioning branch.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Build failures of PPA

Post by wmayer »

Build failed again with this error:
In file included from /<<BUILDDIR>>/freecad-daily-0.17~alpha1+git201701221411~ubuntu14.04.1/src/App/Application.cpp:115:0:
/<<BUILDDIR>>/freecad-daily-0.17~alpha1+git201701221411~ubuntu14.04.1/obj-x86_64-linux-gnu/src/Build/Version.h:13:28: warning: missing terminating " character [enabled by default]
#define FCRepositoryBranch "master
which is caused by this commit
https://git.launchpad.net/~freecad-main ... 017411f05a

See the lacking quotation mark after "master".
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Build failures of PPA

Post by NormandC »

wmayer wrote:See the lacking quotation mark after "master".
@sgrogan

That's the second time this happens. Are you editing the Version.h file manually? Why? :?

When I was managing the PPA, I had it automated with a bash script. I had a desktop launcher that called up the script so all I had to do was double-click on the launcher.

The script pulled the latest source code, then generated the Version.h file in my out-of-source freecad-build directory; next it overwrote the Version.h file in my local versioning bzr branch, and finally it made a commit and pushed it to Launchpad.

Code: Select all

cd /path/to/freecad-code
git pull
cd /path/to/freecad-build
cmake .
cp /path/to/freecad-build/src/Build/Version.h /path/to/versioning.git/src/Build/Version.h
bzr commit -m "Update version number"
bzr push lp:~freecad-maintainers/freecad/versioning.git
echo "End of treatment."

exit 0
Of course the versioning branch is on Git now, so you'd just need to replace "bzr" with "git" and put the updated git url.
Post Reply