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
Build failures of PPA
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Build failures of PPA
"integrate" works for me. Maybe "adapt and integrate". I knew not to copy and paste the script into the rules file!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!
Thanks for this f2nix I will attempt to "integrate" this into the PPA.
"fight the good fight"
Re: Build failures of PPA
@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).
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.
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}
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.
Re: Build failures of PPA
Hi.sgrogan wrote:Thanks for this f2nix I will attempt to "integrate" this into the PPA.
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.
Re: Build failures of PPA
Build failed again with this error:
https://git.launchpad.net/~freecad-main ... 017411f05a
See the lacking quotation mark after "master".
which is caused by this commitIn 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
https://git.launchpad.net/~freecad-main ... 017411f05a
See the lacking quotation mark after "master".
Re: Build failures of PPA
@sgroganwmayer wrote:See the lacking quotation mark after "master".
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