engine: resources: Add a tar resource

This makes tar archives from a list of files and/or directories. It
correctly includes empty directories as well. The code structure is
similar to the gzip resource. While this resource is arguably more
useful than gzip, it was invaluable to write the gzip resource first
since that made writing this one much easier.
This commit is contained in:
James Shubin
2024-09-13 20:04:53 -04:00
parent 06cc63fcb6
commit e7b57a32fd
2 changed files with 655 additions and 0 deletions

52
examples/lang/tar.mcl Normal file
View File

@@ -0,0 +1,52 @@
# make a tar archive!
file "/tmp/tar/" {
state => "exists",
}
file ["/tmp/tar/a", "/tmp/tar/bb", "/tmp/tar/cccc",] {
state => "exists",
content => "some file\n",
Before => Tar["/tmp/foo.tar"],
}
file "/tmp/tar/hello" {
state => "exists",
content => "hello world from purpleidea!\n",
Before => Tar["/tmp/foo.tar"],
}
file "/tmp/tar/dir/" {
state => "exists",
}
file "/tmp/tar/dir/deep_file" {
state => "exists",
content => "this is a deeply nested file!\n",
Before => Tar["/tmp/foo.tar"],
}
file "/tmp/standalone" {
state => "exists",
content => "this is some standalone file!\n",
Before => Tar["/tmp/foo.tar"],
}
tar "/tmp/foo.tar" {
inputs => [
"/tmp/tar/",
"/tmp/standalone",
],
format => $const.res.tar.format.gnu,
Depend => File["/tmp/tar/"], # TODO: add autoedges
}
# bonus
gzip "/tmp/foo.tar.gz" {
input => "/tmp/foo.tar",
}