Skip to content

Instantly share code, notes, and snippets.

@mietek
Created February 9, 2015 00:49
Show Gist options
  • Save mietek/aff20a4df8694028fef2 to your computer and use it in GitHub Desktop.
Save mietek/aff20a4df8694028fef2 to your computer and use it in GitHub Desktop.
Halcyon post-build hook validating sdist
#!/usr/bin/env bash
source "${HALCYON_DIR}/src.sh"
post_build_hook () {
local tag source_dir build_dir
expect_args tag source_dir build_dir -- "$@"
local label source_hash sdist_dir
label=$( get_tag_label "${tag}" )
source_hash=$( get_tag_source_hash "${tag}" )
sdist_dir=$( get_tmp_dir "cabal-sdist-${label}" ) || return 1
local -a opts_a
opts_a=()
opts_a+=( --output-directory="${sdist_dir}" )
sandboxed_cabal_do "${source_dir}" sdist "${opts_a[@]}" 2>&1 | quote || return 1
local candidate_hash
candidate_hash=$( hash_source "${sdist_dir}" ) || return 1
if [[ "${candidate_hash}" != "${source_hash}" ]]; then
log_error 'Failed to validate sdist'
return 1
fi
}
post_build_hook "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment