Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg gives the same hash on packages with differing file contents #2276

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion tests/frontend/conflicts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ tests_init \
more_complex_choice \
complex_conflicts \
fileexists_notinpkg \
find_conflicts
find_conflicts \
find_conflicts_digest

# install foo
# foo depends on bar-1.0
Expand Down Expand Up @@ -462,3 +463,63 @@ ${JAILED}[2/2] Extracting test2-1: done
-s exit:0 \
pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" install -y test2-1
}


digest_pkg() {
printf "%s\n" "$1" > a
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_manifest test 1 /
cat << EOF >> +MANIFEST
files: {
${TMPDIR}/a: "",
}
EOF
atf_check \
-o empty \
-e empty \
-s exit:0 \
pkg create -M +MANIFEST -o .

atf_check \
-o inline:"Creating repository in .: done\nPacking files for repository: done\n" \
-e empty \
-s exit:0 \
pkg repo .

rm -rf reposconf
mkdir reposconf
cat << EOF >> reposconf/repo.conf
local: {
url: file:///${TMPDIR},
enabled: true
}
EOF
}


find_conflicts_digest_body() {
digest_pkg a
cp -p test-1.pkg /tmp/t1a.pkg
digest_pkg_a=$(pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" query -F test-1.pkg %X)
# rquery_pkg_a=$(pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" rquery %X test)
atf_check \
-o ignore \
-e ignore \
-s exit:0 \
pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" install -y test-1
query_pkg_a=$(pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" query %X test)

# Same package, different contents, different checksum
digest_pkg b
cp -p test-1.pkg /tmp/t1b.pkg
digest_pkg_b=$(pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" query -F test-1.pkg %X)
# rquery_pkg_b=$(pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" rquery %X test)
atf_check \
-o ignore \
-e ignore \
-s exit:0 \
pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" upgrade -y
query_pkg_b=$(pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" query %X test)
atf_check_equal "${digest_pkg_a}" "${query_pkg_a}"
atf_check_equal "${digest_pkg_b}" "${query_pkg_b}"
atf_check_not_equal "${query_pkg_a}" "${query_pkg_b}"
}