2014-10-03 18:06:49 +04:00
#!/bin/sh
2018-09-11 17:11:27 +03:00
set -xeuo pipefail
2014-10-03 18:06:49 +04:00
srcdir = $1
shift
PKG_VER = $1
shift
GITREV = $1
shift
TARFILE = ${ PKG_VER } .tar
2018-06-06 00:49:48 +03:00
TARFILE_TMP = $( pwd ) /${ TARFILE } .tmp
2014-10-03 18:06:49 +04:00
test -n " ${ srcdir } "
test -n " ${ PKG_VER } "
test -n " ${ GITREV } "
TOP = $( git rev-parse --show-toplevel)
echo " Archiving ${ PKG_VER } at ${ GITREV } to ${ TARFILE_TMP } "
( cd ${ TOP } ; git archive --format= tar --prefix= ${ PKG_VER } / ${ GITREV } ) > ${ TARFILE_TMP }
ls -al ${ TARFILE_TMP }
( cd ${ TOP } ; git submodule status) | while read line; do
rev = $( echo ${ line } | cut -f 1 -d ' ' ) ; path = $( echo ${ line } | cut -f 2 -d ' ' )
echo " Archiving ${ path } at ${ rev } "
( cd ${ srcdir } /${ path } ; git archive --format= tar --prefix= ${ PKG_VER } /${ path } / ${ rev } ) > submodule.tar
tar -A -f ${ TARFILE_TMP } submodule.tar
rm submodule.tar
done
2018-06-06 00:49:48 +03:00
tmpd = ${ TOP } /.dist-tmp
trap cleanup EXIT
function cleanup ( ) {
if test -f ${ tmpd } /.tmp; then
rm " ${ tmpd } " -rf
fi
}
# Run it now
cleanup
mkdir ${ tmpd } && touch ${ tmpd } /.tmp
( cd ${ tmpd }
mkdir -p .cargo vendor
2019-09-06 21:27:26 +03:00
( cd ${ TOP } /rust && cargo vendor ${ tmpd } /vendor)
2018-06-06 00:49:48 +03:00
cp ${ TOP } /rust/Cargo.lock .
cp ${ TOP } /rust/cargo-vendor-config .cargo/config
2018-10-11 21:25:31 +03:00
# Filter out bundled libcurl and systemd; we always want the pkgconfig ones
for crate_subdir in curl-sys/curl \
libz-sys/src/zlib \
systemd/libsystemd-sys/systemd \
libsystemd-sys/systemd; do
rm -rf vendor/$crate_subdir
2019-05-08 17:15:48 +03:00
python3 -c '
2018-10-11 21:25:31 +03:00
import json, sys
crate, subdir = sys.argv[ 1] .split( "/" , 1)
checksum_file = ( "vendor/%s/.cargo-checksum.json" % crate)
j = json.load( open( checksum_file) )
j[ "files" ] = { f:c for f, c in j[ "files" ] .items( ) if not f.startswith( subdir) }
open( checksum_file, "w" ) .write( json.dumps( j) ) ' $crate_subdir
2018-12-14 23:58:40 +03:00
done
2019-01-15 19:16:08 +03:00
# Also drop a couple of files that get mangled by %configure during hardening.
2018-12-14 23:58:40 +03:00
for crate in backtrace-sys; do
2019-05-08 17:15:48 +03:00
python3 -c '
2018-12-14 23:58:40 +03:00
import json, sys, os
checksum_file = ( "vendor/%s/.cargo-checksum.json" % sys.argv[ 1] )
j = json.load( open( checksum_file) )
2019-01-15 19:16:08 +03:00
j[ "files" ] = { f:c for f, c in j[ "files" ] .items( ) if os.path.basename( f) not in [ "ltmain.sh" , "libtool.m4" , "configure" , "config.guess" , "config.sub" ] }
2018-12-14 23:58:40 +03:00
open( checksum_file, "w" ) .write( json.dumps( j) ) ' $crate
2018-10-11 21:25:31 +03:00
done
2018-06-08 18:26:09 +03:00
tar --transform= " s,^, ${ PKG_VER } /rust/, " -rf ${ TARFILE_TMP } * .cargo/
2018-06-06 00:49:48 +03:00
)
2018-09-22 01:02:18 +03:00
# And finally, vendor rpmostree-rust.h; it's generated by cbindgen,
# and it's easier than vendoring all of the source for that too.
# This is currently the *only* generated file we treat this way. See also
# https://github.com/projectatomic/rpm-ostree/pull/1573
( cd ${ srcdir } && tar --transform " s,^, ${ PKG_VER } /, " -rf ${ TARFILE_TMP } rpmostree-rust.h)
2014-10-03 18:06:49 +04:00
mv ${ TARFILE_TMP } ${ TARFILE }