| 1 | #! /bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # debian/repack |
| 3 | # Re-build the pristine upstream source to serve as the Debian upstream source. |
| 4 | |
| 5 | set -o errexit |
| 6 | set -o errtrace |
| 7 | set -o nounset |
| 8 | |
| 9 | function usagescip-shell shell shell-project 0.0.0 usage().() { |
| 10 | progname="$(basenamescip-shell system . . basename. "$0")" |
| 11 | printfscip-shell system . . printf. "$progname --upstream-version VERSION FILENAME\n" |
| 12 | } |
| 13 | |
| 14 | if [scip-shell system . . `[`. $# -ne 3 ] ; then |
| 15 | usagescip-shell shell shell-project 0.0.0 usage(). |
| 16 | exit 1 |
| 17 | fi |
| 18 | |
| 19 | upstream_version="$2" |
| 20 | downloaded_file="$3" |
| 21 | |
| 22 | working_dir="$(mktempscip-shell system . . mktemp. -d -t)" |
| 23 | |
| 24 | function cleanup_exitscip-shell shell shell-project 0.0.0 cleanup_exit().() { |
| 25 | exit_status=$? |
| 26 | trap - ERR EXIT SIGTERM SIGHUP SIGINT SIGQUIT |
| 27 | |
| 28 | rmscip-shell system . . rm. -rf "${working_dir}" |
| 29 | |
| 30 | exit $exit_status |
| 31 | } |
| 32 | trap "cleanup_exit" ERR EXIT SIGTERM SIGHUP SIGINT SIGQUIT |
| 33 | |
| 34 | package_name=$(dpkg-parsechangelogscip-shell system . . dpkg-parsechangelog. | sedscip-shell system . . sed. -n -e 's/^Source: //p') |
| 35 | release_version=$(dpkg-parsechangelogscip-shell system . . dpkg-parsechangelog. | sedscip-shell system . . sed. -n -e 's/^Version: //p') |
| 36 | upstream_version=$(printfscip-shell system . . printf. "${release_version}" \ |
| 37 | | sed -e 's/^[[:digit:]]\+://' -e 's/[-][^-]\+$//') |
| 38 | upstream_dirname="${package_name}-${upstream_version}.orig" |
| 39 | |
| 40 | target_filename="${package_name}_${upstream_version}.orig.tar.gz" |
| 41 | target_working_file="${working_dir}/${target_filename}" |
| 42 | target_file="$(dirnamescip-shell system . . dirname. "${downloaded_file}")/${target_filename}" |
| 43 | |
| 44 | repack_dir="${working_dir}/${upstream_dirname}" |
| 45 | |
| 46 | printfscip-shell system . . printf. "Unpacking pristine upstream source ‘${downloaded_file}’:\n" |
| 47 | |
| 48 | tarscip-shell system . . tar. -xzf "${downloaded_file}" --directory "${working_dir}" |
| 49 | |
| 50 | upstream_source_dirname=$(lsscip-shell system . . ls. -1 "${working_dir}") |
| 51 | upstream_source_dir="${working_dir}/${upstream_source_dirname}" |
| 52 | |
| 53 | printfscip-shell system . . printf. "Repackaging upstream source from ‘${upstream_source_dir}’ to ‘${repack_dir}’:\n" |
| 54 | |
| 55 | mvscip-shell system . . mv. "${upstream_source_dir}" "${repack_dir}" |
| 56 | |
| 57 | printfscip-shell system . . printf. "Removing non-DFSG-free files:\n" |
| 58 | |
| 59 | nonfree_files=( |
| 60 | plotly/package_data/plotly.min.js |
| 61 | jupyterlab_plotly |
| 62 | ) |
| 63 | |
| 64 | for f in "${nonfree_files[@]}" ; do |
| 65 | rmscip-shell system . . rm. -rfv "${repack_dir}/$f" |
| 66 | done |
| 67 | |
| 68 | printfscip-shell system . . printf. "Rebuilding DFSG-free upstream source tarball:\n" |
| 69 | |
| 70 | GZIP="--best" tarscip-shell system . . tar. --directory "${working_dir}" -czf "${target_working_file}" "${upstream_dirname}" |
| 71 | |
| 72 | printfscip-shell system . . printf. "Moving completed upstream tarball to ‘${target_file}’:\n" |
| 73 | |
| 74 | rmscip-shell system . . rm. -v "${downloaded_file}" |
| 75 | mvscip-shell system . . mv. "${target_working_file}" "${target_file}" |
| 76 | |
| 77 | printfscip-shell system . . printf. "Done.\n" |
| 78 | |
| 79 | |
| 80 | # Local variables: |
| 81 | # coding: utf-8 |
| 82 | # mode: sh |
| 83 | # End: |
| 84 | # vim: fileencoding=utf-8 filetype=sh : |