Skip to content

Print error message if no matching PKGBUILD could be found - #100

Merged
Foxboron merged 1 commit into
archlinux:masterfrom
kpcyrd:no-pkgbuild-match
Dec 5, 2021
Merged

Foxboron merged 1 commit into
archlinux:masterfrom
kpcyrd:no-pkgbuild-match

Conversation

@kpcyrd

@kpcyrd kpcyrd commented Jul 19, 2021

Copy link
Copy Markdown
Member

It currently looks like this:

(4/4) Warn about old perl modules
From https://github.com/archlinux/svntogit-community
 * branch            packages/phpvirtualbox -> FETCH_HEAD
 * [new branch]      packages/phpvirtualbox -> community/packages/phpvirtualbox
Cloning into 'phpvirtualbox'...
done.
/phpvirtualbox /
�[1m�[34m  ->�[0m�[1m Delete snapshot for phpvirtualbox_270554...�[0m

With this patch it should look like this:

(4/4) Warn about old perl modules
From https://github.com/archlinux/svntogit-community
 * branch            packages/phpvirtualbox -> FETCH_HEAD
 * [new branch]      packages/phpvirtualbox -> community/packages/phpvirtualbox
Cloning into 'phpvirtualbox'...
done.
/phpvirtualbox /
ERROR: Failed to find commit this was built with (PKGBUILD checksum didn't match any commit)
�[1m�[34m  ->�[0m�[1m Delete snapshot for phpvirtualbox_270554...�[0m

Comment thread repro.in Outdated
@kpcyrd
kpcyrd force-pushed the no-pkgbuild-match branch from fcec8b9 to e34312f Compare July 19, 2021 21:09
Comment thread repro.in
exit 0
fi
done
echo "ERROR: Failed to find commit this was built with (PKGBUILD checksum didn't match any commit)" >&2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    if ! bash <<-__END__
[[snip]]
__END__; then
    error "Failed to find commit this was built with (PKGBUILD checksum didn't match any commit)"
fi

Shouldn't this work? Then we'd get the exit 1 properly caught and a proper error message as rest of repro.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it to work with braces like this:

    if ! (bash <<-__END__
shopt -s globstar
pacman -S asp --noconfirm --needed
asp checkout $pkgbase
pushd $pkgbase
for rev in \$(git rev-list --all -- repos/); do
    pkgbuild_checksum=\$(git show \$rev:trunk/PKGBUILD | sha256sum -b)
    pkgbuild_checksum=\${pkgbuild_checksum%% *}
    if [ \$pkgbuild_checksum = $pkgbuild_sha256sum ]; then
        git checkout \$rev
        mv ./trunk/* /startdir
        exit 0
    fi
done
exit 1
__END__
); then
      echo "ERROR: Failed to find commit this was built with (PKGBUILD checksum didn't match any commit)" >&2
    fi

at first I assumed this would be different because we don't know which command caused the non-zero exit code, but since we don't set -e inside that bash process exit 1 is probably the only one?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative is to capture the exit code and do an "mkinitcpio"-style check?

https://github.com/archlinux/mkinitcpio/blob/master/mkinitcpio#L343-L348

I'm not sure what is the most readable, but I'm a little bit unhappy with the pure echo in the subshell instead of dealing with the bash invocation as a command itself.

@Foxboron
Foxboron merged commit dcb4d63 into archlinux:master Dec 5, 2021
@kpcyrd
kpcyrd deleted the no-pkgbuild-match branch December 5, 2021 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants