[pacman-dev] [PATCH] repo-add: use more libmakepkg to handle common compression routines
Eli Schwartz
eschwartz at archlinux.org
Tue Mar 12 15:06:51 UTC 2019
On 3/12/19 8:51 AM, Alad Wenter wrote:
> On Tue, 12 Mar 2019 16:32:34 +1000
> Allan McRae <allan at archlinux.org> wrote:
>
>> On 3/8/19 2:32 PM, Eli Schwartz wrote:
>>> Currently the list of supported formats for an archive, is maintained in
>>> two places. And repo-add does not actually get updated. :(
>>>
>>> In the process, remove some of the logical duplication when calling
>>> bsdtar/compress_as.
>>>
>>> Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
>>> ---
>>> scripts/repo-add.sh.in | 27 +++++++++------------------
>>> 1 file changed, 9 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
>>> index 57413df5..0f9628ad 100644
>>> --- a/scripts/repo-add.sh.in
>>> +++ b/scripts/repo-add.sh.in
>>> @@ -44,6 +44,7 @@ CLEAN_LOCK=0
>>> USE_COLOR='y'
>>>
>>> # Import libmakepkg
>>> +source "$LIBRARY"/util/compress.sh
>>> source "$LIBRARY"/util/message.sh
>>>
>>> # ensure we have a sane umask set
>>> @@ -188,21 +189,12 @@ verify_signature() {
>>> }
>>>
>>> verify_repo_extension() {
>>> - local repofile=$1
>>> -
>>> - case $repofile in
>>> - *.db.tar.gz) TAR_OPT="z" ;;
>>> - *.db.tar.bz2) TAR_OPT="j" ;;
>>> - *.db.tar.xz) TAR_OPT="J" ;;
>>> - *.db.tar.zst) TAR_OPT="--zstd" ;;
>>> - *.db.tar.Z) TAR_OPT="Z" ;;
>>> - *.db.tar) TAR_OPT="" ;;
>>> + case $1 in
>>> + *.db.tar.*|*.db.tar) ;;
>>
>> repo-add mydb.tar.badext ...
>>
>> This does no checking at all.
>
> You could use the mime type instead, which also removes the need to hardcode .tar.foo:
>
> local mimetype=$(file --mime-type -b "$1")
>
> case $mimetype in
> application/gzip) TAR_OPT="z" ;;
> application/x-bzip2) TAR_OPT="j" ;;
> application/x-xz) TAR_OPT="J" ;;
> application/x-zstd) TAR_OPT="--zstd" ;;
> application/x-compress) TAR_OPT="Z" ;;
> application/x-tar) TAR_OPT="" ;;
> esac
>
> Ideally this would be done in libmakepkg's compress.sh, and then re-used here. Thoughts?
>
> Alad
The file only exists yet, when updating an existing database, and you
cannot get a mimetype from a nonexistent file.
I see no reason why or how the use of mimetypes vs. file extension
matches would help in this specific case though -- we already have a
list of compression mappings using $implementation and we just want to
figure out under which situations to use it.
I remember in relation to aurutils you have some use case where it is
problematic for you that the .db file itself is not autodetected *on
updates* using mimetypes, but this is not really the same issue at all
and implementing extensionless databases that are just .db would mean
adding a new option to repo-add to express the compression type for the
database.
--
Eli Schwartz
Bug Wrangler and Trusted User
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1601 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20190312/605a2296/attachment.sig>
More information about the pacman-dev
mailing list