2016-02-25 13:33:59 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-06-11 16:39:45 +00:00
|
|
|
# Don't inherit the -x from the testsuite
|
|
|
|
set +x
|
|
|
|
|
2016-02-25 13:33:59 +00:00
|
|
|
DIR=`mktemp -d`
|
|
|
|
|
2017-05-10 07:43:33 +00:00
|
|
|
REPONAME=$1
|
|
|
|
shift
|
2016-05-02 12:15:32 +00:00
|
|
|
ID=$1
|
|
|
|
shift
|
2017-08-11 11:33:34 +00:00
|
|
|
COLLECTION_ID=$1
|
|
|
|
shift
|
2016-05-02 12:15:32 +00:00
|
|
|
|
2017-01-27 12:56:04 +00:00
|
|
|
mkdir ${DIR}/files
|
|
|
|
mkdir ${DIR}/usr
|
|
|
|
cat > ${DIR}/metadata <<EOF
|
|
|
|
[Runtime]
|
|
|
|
name=${ID}
|
|
|
|
EOF
|
|
|
|
|
2018-06-11 16:39:45 +00:00
|
|
|
# On Debian derivatives, /usr/sbin and /sbin aren't in ordinary users'
|
|
|
|
# PATHs, but ldconfig is kept in /sbin
|
|
|
|
PATH="$PATH:/usr/sbin:/sbin"
|
2016-02-25 13:33:59 +00:00
|
|
|
|
|
|
|
# Add bash and dependencies
|
|
|
|
mkdir -p ${DIR}/usr/bin
|
|
|
|
mkdir -p ${DIR}/usr/lib
|
|
|
|
ln -s ../lib ${DIR}/usr/lib64
|
2016-04-27 19:23:42 +00:00
|
|
|
ln -s ../lib ${DIR}/usr/lib32
|
2017-10-09 13:45:25 +00:00
|
|
|
if test -f /sbin/ldconfig.real; then
|
|
|
|
cp /sbin/ldconfig.real ${DIR}/usr/bin/ldconfig
|
|
|
|
else
|
|
|
|
cp `which ldconfig` ${DIR}/usr/bin
|
|
|
|
fi
|
2018-06-11 16:39:45 +00:00
|
|
|
LIBS=`mktemp`
|
|
|
|
BINS=`mktemp`
|
|
|
|
|
|
|
|
add_bin() {
|
|
|
|
local f=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
if grep -qFe "${f}" $BINS; then
|
|
|
|
# Already handled
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo $f >> $BINS
|
|
|
|
|
|
|
|
# Add library dependencies
|
|
|
|
(ldd "${f}" | sed "s/.* => //" | awk '{ print $1}' | grep ^/ | sort -u -o $LIBS $LIBS -) || true
|
|
|
|
|
|
|
|
local shebang=$(sed -n '1s/^#!\([^ ]*\).*/\1/p' "${f}")
|
|
|
|
if [ x$shebang != x ]; then
|
|
|
|
add_bin "$shebang"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-05-02 12:15:32 +00:00
|
|
|
for i in $@; do
|
|
|
|
I=`which $i`
|
2018-06-11 16:39:45 +00:00
|
|
|
add_bin $I
|
2016-08-10 12:47:04 +00:00
|
|
|
if test $i == python2; then
|
|
|
|
mkdir -p ${DIR}/usr/lib/python2.7/lib-dynload
|
|
|
|
# This is a hardcoded minimal set of modules we need in the current tests.
|
|
|
|
# Pretty hacky stuff. Add modules as needed.
|
2016-08-22 12:39:07 +00:00
|
|
|
PYDIR=/usr/lib/python2.7
|
|
|
|
if test -d /usr/lib64/python2.7; then PYDIR=/usr/lib64/python2.7; fi
|
2016-08-10 12:47:04 +00:00
|
|
|
for py in site os stat posixpath genericpath warnings \
|
|
|
|
linecache types UserDict abc _abcoll \
|
|
|
|
_weakrefset copy_reg traceback sysconfig \
|
|
|
|
re sre_compile sre_parse sre_constants \
|
|
|
|
_sysconfigdata ; do
|
2016-08-22 12:39:07 +00:00
|
|
|
cp ${PYDIR}/$py.py ${DIR}/usr/lib/python2.7
|
2016-08-10 12:47:04 +00:00
|
|
|
done
|
2016-09-06 10:10:55 +00:00
|
|
|
# These might not exist, depending how Python was configured; and the
|
|
|
|
# part after ${so} might be "module" or ".x86_64-linux-gnu" or
|
|
|
|
# something else
|
2016-08-10 12:47:04 +00:00
|
|
|
for so in _locale strop ; do
|
2016-09-06 10:10:55 +00:00
|
|
|
cp ${PYDIR}/lib-dynload/${so}*.so ${DIR}/usr/lib/python2.7/lib-dynload || :
|
|
|
|
done
|
|
|
|
for plat in $( cd ${PYDIR} && echo plat-* ); do
|
|
|
|
test -e ${PYDIR}/${plat} || continue
|
|
|
|
mkdir -p ${DIR}/usr/lib/python2.7/${plat}
|
|
|
|
cp ${PYDIR}/${plat}/*.py ${DIR}/usr/lib/python2.7/${plat}/
|
2016-08-10 12:47:04 +00:00
|
|
|
done
|
|
|
|
fi
|
2016-05-02 12:15:32 +00:00
|
|
|
done
|
2018-06-11 16:39:45 +00:00
|
|
|
for i in `cat $BINS`; do
|
|
|
|
echo Adding binary $i 1>&2
|
|
|
|
cp "$i" ${DIR}/usr/bin/
|
|
|
|
done
|
|
|
|
for i in `cat $LIBS`; do
|
|
|
|
echo Adding library $i 1>&2
|
2016-02-25 13:33:59 +00:00
|
|
|
cp "$i" ${DIR}/usr/lib/
|
|
|
|
done
|
2018-06-11 16:39:45 +00:00
|
|
|
ln -s bash ${DIR}/usr/bin/sh
|
2016-02-25 13:33:59 +00:00
|
|
|
|
2016-05-09 11:10:13 +00:00
|
|
|
# We copy the C.UTF8 locale and call it en_US. Its a bit of a lie, but
|
|
|
|
# the real en_US locale is often not available, because its in the
|
|
|
|
# local archive.
|
|
|
|
mkdir -p ${DIR}/usr/lib/locale/
|
|
|
|
cp -r /usr/lib/locale/C.* ${DIR}/usr/lib/locale/en_US
|
|
|
|
|
2017-08-11 11:33:34 +00:00
|
|
|
if [ x$COLLECTION_ID != x ]; then
|
|
|
|
collection_args=--collection-id=${COLLECTION_ID}
|
|
|
|
else
|
|
|
|
collection_args=
|
|
|
|
fi
|
|
|
|
|
2017-01-11 23:04:36 +00:00
|
|
|
mkdir -p repos
|
2017-08-11 11:33:34 +00:00
|
|
|
flatpak build-export ${collection_args} --runtime ${GPGARGS-} repos/${REPONAME} ${DIR}
|
2016-02-25 13:33:59 +00:00
|
|
|
rm -rf ${DIR}
|