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
Backports from Parabola #5
Backports from Parabola #5
Conversation
bb337fd
to
795b654
Compare
Huh, Travis ran slightly faster than my local |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said on the mailing list, I don't see the need to overquote variables everywhere. You want it for the sake of linting (this is a shellcheck thing I actually disagree with) and to reduce the diff against your fork (which is not our design goal).
I'm not sure what to do about it.
cron-jobs/sourceballs
Outdated
# Should this package be skipped? | ||
if grep -Fqx "${pkgbase}" "${dirname}/sourceballs.skip"; then | ||
continue | ||
fi | ||
# Check if the license or .force file does not enforce creating a source package | ||
if ! ([[ -z ${ALLOWED_LICENSES[@]} ]] || chk_license ${pkglicense[@]} || grep -Fqx "${pkgbase}" "${dirname}/sourceballs.force"); then | ||
if ! ([[ ${#ALLOWED_LICENSES[@]} == 0 ]] || chk_license "${pkglicense[@]}" || grep -Fqx "${pkgbase}" "${dirname}/sourceballs.force"); then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of string comparisons why not use shell arithmetic?
db-functions
Outdated
@@ -282,7 +282,7 @@ getpkgfile() { | |||
|
|||
getpkgfiles() { | |||
local f files | |||
if [[ ! -z "$(printf '%s\n' "${@%\.*}" | sort | uniq -D)" ]]; then | |||
if ! printf '%s\n' "${@%\.*}" | awk 'a[$0]++>1{exit 1}'; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not fix this all at once instead of changing the same line multiple times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's two logically distinct changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And so are several other changes you lumped into the first commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're all "this array wasn't quoted, but we can do a better fix than simply quoting it"
db-functions
Outdated
else | ||
return 1 | ||
fi | ||
[[ ${pkgfile##*/} == "${pkgname}-${pkgver}-${pkgarch}"* ]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use ==, use = instead. This is a weird bash extension that literally serves no purpose as it merely aliases =.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[[
is a weird bash extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is a cool bash extension that serves a purpose. You've added the only two examples of using == in the main code, just now, and I dispute Chet Ramey's reasons for adding the == alias to the bash scripting language as it adds no utility to the language while adding compatibility to C as an anti-feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glob/regex matching, but the rest of it is weird. [[ -r $filename ]]
adds nothing to the language, and serves no purpose over [ -r "$filename" ]
At the end of the day, it's just a style choice. And that's fine. But "it's the codebase's style" is the winning argument there, not "it's a bad extension". I hadn't realized that the main codebase was all =
; I'd though it was inconsistent; I hadn't realized that all of the [[ == ]]
uses were in test/
.
indirect="${var}_backup" | ||
if [ -n "${!indirect}" ]; then | ||
eval "${var}=(\${$indirect[@]})" | ||
eval "${var}=(\"\${$indirect[@]}\")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still like to fix this by avoiding the issue entirely and using declare
as I mentioned on the mailing list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- From the ML:
Maybe I should fix the backups as well, but that is a slightly more complicated case there [in makepkg].
Is it? It looks like the exact same case there.
- What about this?
backup_package_variables() {
restore_package_variables=$(declare -p "${splitpkg_overrides[@]}" 2>/dev/null || true)
}
restore_package_variables() {
unset "${splitpkg_overrides[@]}"
eval "$restore_package_variables"
}
test/cases/db-update.bats
Outdated
@@ -222,7 +222,7 @@ load ../lib/common | |||
|
|||
@test "package has to be aregular file" { | |||
local p | |||
local target=$(mktemp -d) | |||
local target=$(mktemp -dt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No TEMPLATE given, this change is extraneous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, you are correct.
I respect that. I'm not sure what I would do about it if I were in your place. If you want me to re-submit this patchset without the quoting commit, let me know. |
795b654
to
5526570
Compare
I've just pushed v3 of the patchset: v3:
I believe it addresses all of Eli's concerns, though it still quotes variables (but not variable-used-as-a-command; we don't have those anymore). I would have never though that quoting variables would be a controversial change. |
fi | ||
done | ||
unset "${splitpkg_overrides[@]}" | ||
eval "$restore_package_variables" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW: https://lists.archlinux.org/pipermail/pacman-dev/2018-March/022406.html
TBH this whole script seems somewhat convoluted. If anything I think I'd rather port check_packages.py
to use pyalpm instead of ctypes, and makepkg --printsrcinfo
+ python-srcinfo rather than parse_pkgbuilds.sh
But then again, I don't think anyone still uses it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree about it being convoluted.
Isn't your solution going to have declare -p
spit things on stderr?
test/lib/common.bash
Outdated
echo "$(bsdtar -xf "${FTP_BASE}/${repo}/os/${tarch}/${repo}${db%.tar.*}" -O)" | grep -qv ${pkgname} | ||
if bsdtar -xf "${FTP_BASE}/${repo}/os/${tarch}/${repo}${db%.tar.*}" -O | grep ${pkgname} &>/dev/null; then | ||
return 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grep -v has been converted to if grep; then return 1
I understand why that has been done here, as AFAICT this used to always return successfully since there was always some line that did not contain ${pkgname} -- even if that line was %NAME%
:D
Which means we weren't actually testing anything with checkRemovedPackageDB as we cannot actually get test failures.
That being said, this does need to be noted in a commit message.
I also think it would make more sense to check for a pkgname using bsdtar -tf whereas in the other change we need to use -xf in order to check a pkgfile. (I'm not positive why we need to check the pkgfile there either.)
testing2x
Outdated
@@ -49,7 +49,7 @@ done | |||
for pkgarch in ${ARCHES[@]}; do | |||
repo_unlock ${TESTING_REPO} ${pkgarch} | |||
done | |||
for repo in ${STABLE_REPOS[@]}; do | |||
for repo in "${STABLE_REPOS[@]}"; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added extra whitespace here, commit message says you are removing whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh. I wonder how I screwed that up. But I did remove whitespace further up in the commit!
db-functions
Outdated
chgrp $group "${filesfile}" || error "Could not change group of %s to %s" "$filesfile" "$group" | ||
chmod g+w "${dbfile}" || error "Could not set write permission for group %s to %s" "$group" "$dbfile" | ||
chmod g+w "${dbfile}" || error "Could not set write permission for group %s to %s" "$group" "$dbfile" | ||
chmod g+w "${filesfile}" || error "Could not set write permission for group %s to %s" "$group" "$filesfile" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You lined up one of these, but the other is still misaligned...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops. That line is 2 characters to the left because $group
is unquoted--it gets quoted in the next commit. I missed that line as being part of lining up when I split it in to 2 commits.
cron-jobs/sourceballs
Outdated
pkgarch=${pkginfo[2]} | ||
pkglicense=(${pkginfo[@]:3}) | ||
|
||
while read -r pkgbase pkgver pkgarch pkglicense; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkglicense is now a string, rather than an array. It would still work as both licenses are in the (unquoted) array element 0, but of course that is now quoted.
So this only works if there is exactly one license in play.
5526570
to
62c3daa
Compare
I've just pushed v4 of the patchset v4:
I believe this addresses each of Eli's comments. I did not switch to using |
62c3daa
to
ca1c034
Compare
I've just pushed v5 of this patchset. It's just rebasing on to v5:
|
(whoops, deleted the wrong branch) |
ca1c034
to
e683a64
Compare
v6:
|
e683a64
to
f5774e4
Compare
v7:
|
Was looking at replacing the whole parse_pkgbuild.sh mess with python-srcinfo and a custom srcinfo generator, but then got sidetracked and had to debug this: https://lists.archlinux.org/pipermail/pacman-dev/2018-March/022428.html yay... |
db-functions
Outdated
} | ||
|
||
getpkgfiles() { | ||
local f files | ||
if [[ ! -z "$(echo ${@%\.*} | sed "s/ /\n/g" | sort | uniq -D)" ]]; then | ||
if ! printf '%s\n' "${@%\.*}" | awk 'a[$0]++>1{exit 1}'; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My initial suggestion did not have >1 in it, and this version does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f5774e4
to
b351f03
Compare
v8:
|
b351f03
to
5a6c4dd
Compare
v9:
I think you should at least pick the |
(Apologies for my initial response to the quoting changes, I did sort of overreact when I saw it breaking things due to excessive quoting. But that appears to be solved now, and it doesn't look like any other regressions are hiding.) The rest look okay, I think. But I'm slightly confused what the test/ commit does, it seems to overlap the test case right above it? Also apologies for the lateness of the response, since I'm now on holiday and somewhat erratically available. |
5a6c4dd
to
eb09efd
Compare
The test above it checks that we detect when a package in v10:
|
…same transaction This is a leftover change from the patch that became 0432cff; v2 of that patch broke db-functions:getpkgfiles, but the testsuite didn't catch it. This patch adds a testcase that catches this type of breakage.
Search for unquoted variables using the command: grep -Prn --exclude-dir=.git '(?<!["=]|\[\[ |\[\[ -[zn] )\$(?!{?#|\(|\? )' and ignore a bunch of false positives. You may verify that the only differences between the lines removed and lines added are double-quotes: diff -u \ <(git show|sed -n 's/^-//p'|grep -v '^-- a/'|sed 's/"//g') \ <(git show|sed -n 's/^+//p'|grep -v '^++ b/'|sed 's/"//g')
This does correct handling of - executing a program by symlink - any weird characters in the full path - I'm sure there's another case I thought about when I originally did this.
eb09efd
to
656fd6d
Compare
v11: remove veverything comments from commit messages |
These are commits from Parabola's dbscripts that I think are
upstreamable. No real theme to them, but because some of them are
wide-sweeping (eg. clean up quoting), they are a good base layer to
apply before backporting other changes.
I've done my best to look over them, but at least one weird thing did
happen while rebasing them, so it's possible I missed something that
rebased weird.
Some of this duplicates (non-backported) changes in the last patchset
I submitted.
This is currently v2 of the patchset. v1 was submitted on the mailing list. I'm submitting v2 here to get a shiny little confirmation from Travis that I didn't break anything; I'm submitting it to the mailing list as well.