File: repack

package info (click to toggle)
inform6-library 6.12.2%2Bdfsg.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 628 kB
  • sloc: ansic: 11,806; sh: 68; makefile: 2
file content (91 lines) | stat: -rwxr-xr-x 2,546 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#! /bin/bash
#
# debian/repack
# Part of the Debian package ‘inform6-library’.
#
# This is free software, and you are welcome to redistribute it under
# certain conditions; see the end of this file for copyright
# information, grant of license, and disclaimer of warranty.

# Convert the pristine upstream source to the Debian upstream source.
#
# This program is designed for use with the ‘uscan(1)’ tool, as the
# “action” parameter for the ‘debian/watch’ configuration file.

set -o errexit
set -o errtrace
set -o pipefail
set -o nounset

program_dir="$(dirname "$(realpath --strip "$0")")"
source "${program_dir}"/source_package_build.bash

function usage() {
    local progname=$(basename $0)
    printf "$progname --upstream-version VERSION FILENAME\n"
}

if [ $# -ne 3 ] ; then
    usage
    exit 1
fi

upstream_version="$2"
downloaded_file="$3"

target_filename="${upstream_tarball_basename}.tar.gz"
target_working_file="${working_dir}/${target_filename}"
target_file="$(dirname "${downloaded_file}")/${target_filename}"

repack_dir="${working_dir}/${upstream_dirname}"

printf "Unpacking pristine upstream source ‘%s’:\n" "${downloaded_file}"

extract_tarball_to_working_dir "${downloaded_file}"

upstream_source_dirname=$(ls -1 "${working_dir}")
upstream_source_dir="${working_dir}/${upstream_source_dirname}"

printf "Repackaging upstream source from ‘%s’ to ‘%s’:\n" \
       "${upstream_source_dir}" "${repack_dir}"

mv "${upstream_source_dir}" "${repack_dir}"

printf "Removing non-source files:\n"

nonsource_files=(
        # Generated files without corresponding source form.
        infglk.h

        )

for f in "${nonsource_files[@]}" ; do
    rm -f -v "${repack_dir}"/$f
done

printf "Rebuilding DFSG-free upstream source tarball:\n"

archive_working_dir_to_tarball "${upstream_dirname}" "${target_working_file}"

printf "Moving completed upstream tarball to ‘%s’:\n" "${target_file}"

rm -v "${downloaded_file}"
mv "${target_working_file}" "${target_file}"

printf "Done.\n"


# Copyright © 2010–2019 Ben Finney <bignose@debian.org>
#
# This is free software; you may copy, modify, and/or distribute this
# work under the terms of the GNU General Public License as published
# by the Free Software Foundation; version 3 of that License or later.
# No warranty expressed or implied.
# See the file ‘/usr/share/common-licenses/GPL-3’ for details.

# Local variables:
# coding: utf-8
# mode: shell-script
# indent-tabs-mode: nil
# End:
# vim: fileencoding=utf-8 filetype=bash expandtab :