diff options
Diffstat (limited to 'make_source_tarball.sh')
-rwxr-xr-x | make_source_tarball.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/make_source_tarball.sh b/make_source_tarball.sh new file mode 100755 index 0000000..ec8b290 --- /dev/null +++ b/make_source_tarball.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Copyright (C) 2021 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +set -e + +usage() +{ + echo "$0 <tag> <output directory>" + exit 1 +} + +tag="$1" +outdir="$2" + +replicant_dir="${outdir}/${tag}" +repo_branch="refs/tags/${tag}" + +if [ $# -ne 2 ] ; then + usage +fi + +mkdir -p "${replicant_dir}" +cd "${replicant_dir}" +if [ ! -d .repo ] ; then + yes | repo init \ + -u https://git.replicant.us/replicant/manifest.git \ + -b "${repo_branch}" \ + --depth=1 || rm -rf .repo/ +fi + +repo sync + +cd .. +tarball="${tag}.tar" +if [ ! -f "${tarball}" ] && [ ! -f "${tarball}.xz" ] ; then + tar cf "${tarball}" "${replicant_dir}" || rm -f "${tarball}" +fi + +# TODO: Make the tarball reproducible by removing metadata + +xz -9e --verbose "${tarball}" |