Skip to content
Open
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
46 changes: 46 additions & 0 deletions build/pkg-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh

set -e

_IFS="$IFS"; IFS=':'
for dir in $PKG_CONFIG_PATH `pkg-config --variable pc_path pkg-config`; do
if [ -d "${dir}" -a -w "${dir}" -a -d "${dir}/../../include" ]; then
DST="$dir"
break
fi
done
IFS="$_IFS"; unset _IFS

if [ -z "${DST}" ]; then
echo "no suitable pkg-config directory found."
exit 1
fi

if [ `basename $0` = "pkg-install.sh" ]; then
SRC=`dirname $0`
SRC=`(cd $SRC/..; [ -d .git ] && pwd)`
fi

export DST
cd ${TMPDIR:-/tmp}

trap 'rm -rf blst.$$' 0
git clone ${SRC:-"https://github.com/supranational/blst"} blst.$$
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please have a way to override invoking git via env vars?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I genuinely don't understand. What is the goal? Why specifically via environment variables? Note that git is used to figure out version...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to package blst in a downstream project (FreeBSD). Package building infrastructure usually disable any networking access during the build, so in this case I'd need a way to prevent this script from calling git.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If $SRC is assigned, it's a local directory, so that git won't use network.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is still has to be a git repository. At least RPM and FreeBSD ports do not usually use git to fetch the distribution files, so in these contexts there would be no git repo at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FreeBSD ports do not usually use git to fetch the distribution files,

But they have to use something and hence they could use git. Yes, it would be unusual, but in the essence it's just a download.

Again, the suggested script uses git for unambiguous versioning while also preserving custody. It's argued that it's reasonable trade-off for the unconventional download method.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are common and established ways to build software (meson, CMake, git tags and GitHub releases, etc.), which are easily connected to downstream package building infrastructures. When a project goes its own way with custom building scripts it immediately makes it much harder to be properly packaged. But that's my problem anyways, so do whatever you want.

( trap '[ $? -ne 0 ] && rm "${DST}/blst.pc" 2>/dev/null' 0
cd blst.$$
tag=`git tag --sort=v:refname | tail -1`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The git tag version is currently v0.3.16 and the leading v messes up version comparisons.

I had to modify that line to:

  tag=`git tag --sort=v:refname | tail -1 | sed "s/^v//"`

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the next line. I've pushed a fixup...

git checkout --detach ${tag}
tag=`expr substr $tag 2 8`
./build.sh "$@"
cp libblst.a "${DST}/.."
cp bindings/blst.h* "${DST}/../../include"
cat > "${DST}/blst.pc" << blst.pc
libdir=\${pcfiledir}/..
incdir=\${pcfiledir}/../../include
Name: blst
Version: $tag
Description: blst core library
Cflags: -I\${incdir}
Libs: -L\${libdir} -lblst
blst.pc
)