Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

question about file ordering in pkg_tar

Aperta
#828 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Ambito
build-system

Direzione di ricerca

Inizia dalla riga collegata in pkg/private/pkg_files.bzl e segui il modo in cui pkg_tar elabora srcs e deps negli esempi di BUILD.bazel. Confronta l’ordine dell’archivio generato con il comportamento di tar dalla riga di comando e determina se è previsto preservare l’ordine di srcs. Done dovrebbe stabilire e testare il comportamento di ordinamento supportato oppure documentare chiaramente la limitazione prevista.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature-request p4

I'm wondering about the file order in pkg_tar. When I create a normal tar file via the linux command line the order of files in the tar is like specified on the command line:

touch {a,b}.txt; tar -cvf test.tar {b,a}.txt;  tar -tvf test.tar
# output
-rw-rw-r-- luke/luke         0 2024-03-07 08:29 b.txt
-rw-rw-r-- luke/luke         0 2024-03-07 08:29 a.txt

However if I do something similar with rules_pkg this doesn't apply:

# BUILD.bazel
load("@rules_pkg//:pkg.bzl", "pkg_tar")
pkg_tar(name = "a")
pkg_tar(name = "b")
pkg_tar(
    name = "test",
    srcs = [":b", ":a"],
)

# building and testing:
bazel build //:test; tar -tvf bazel-bin/test.tar
-r-xr-xr-x 0/0           10240 2000-01-01 01:00 a.tar
-r-xr-xr-x 0/0           10240 2000-01-01 01:00 b.tar

Is there any way to make this ordered the same as the srcs are specified?

One workaround I found is to pack a and b into an extra tar and then specify via deps:

pkg_tar(name = "a")
pkg_tar(name = "b")
pkg_tar(name = "a_tar", srcs = ["a"])
pkg_tar(name = "b_tar", srcs = ["b"])
pkg_tar(
    name = "test2",
    deps = [":b_tar", ":a_tar"],
)

# building and testing:
bazel build //:test2; tar -tvf bazel-bin/test2.tar
-r-xr-xr-x 0/0           10240 2000-01-01 01:00 b.tar
-r-xr-xr-x 0/0           10240 2000-01-01 01:00 a.tar

however this seems a bit cumbersome.

I assume the order gets lost here when we assign to the map https://github.com/bazelbuild/rules_pkg/blob/61132feb47add139967476401baa49cf4b7c6b2a/pkg/private/pkg_files.bzl#L493
?

is that the expected/desired behavior?

Lingua principale
Starlark
Stelle
254
Fork
225
Merge medio
2g 4h
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bazelbuild/rules_pkg

Tutte le issue di bazelbuild/rules_pkg

Issue simili

Altre issue su Build System

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.