Skip to content
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

task #54: Template Directories for Debian package #63

Merged
merged 1 commit into from
Nov 8, 2013
Merged

task #54: Template Directories for Debian package #63

merged 1 commit into from
Nov 8, 2013

Conversation

muuki88
Copy link
Contributor

@muuki88 muuki88 commented Nov 5, 2013

After a second round, I think I managed to get everything working.
This pullrequest could then be closed without merging.

DSL would look like

linuxPackageMappings in Debian += packageTemplateMapping(target.value,
    "/var/log/" + name.value,
    "/etc/" + name.value
)

// Create files and directories
mappings foreach {
case LinuxPackageMapping(paths, perms, zipped) =>
val (dirs, files) = paths.partition(_._1.isDirectory)
Copy link
Member

Choose a reason for hiding this comment

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

Nice. the nesting here is starting to make me want helper functions, but the logic looks excellent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could refactor it, however the logic is so small and almost non redudant. It's a bit more verbose, but easier to read IMHO ;)
Took me a while to get your for loop construction, never used or saw it that way before.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm... Not what I want to hear.... I tend to like that mechanism of for construction :). In any case, the cleanups are nice.

@jsuereth
Copy link
Member

jsuereth commented Nov 6, 2013

Looks great! There's still one nagging issue (it's one I avoided for a bit): the executable bit for directories. I'll comment directly in the code.

files map {
case (file, name) => (file, t / name)
} foreach {
case (source, target) => copyAndFixPerms(source, target, perms, zipped)
Copy link
Member

Choose a reason for hiding this comment

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

So here's something I was being lazy with before and never really fixed, because I wanted the user interface for defining package mappings to have some flexibility and be somewhat lazy.

When we're chmoding things and globbing over files, we were bumping directories to have eveyrone readable + executable permissions (0755). When you glob over a set of files and create mappings (like LinuxPackageMappings(binDir.*** x relativeTo(rootDir)), ...), you're including files + directories with the same set of Permissions. However, directories need the appropriate executable bits set if you're to be able to list files inside them.

SOOOOOO...... What we may want when chmoding directories is to detect "read" permissions for user, group, world and automatically bump in executable permissions on directories.

Again I was too lazy to do this by default. There's also the odd scenario that someone may not want this. So option #2 would be to modify the external functions people use to set up linux package mappings to create two objects, one for directories (with auto-executable permissions) and one with files (without adding executable permissions).

I think I prefer plan A. What are your thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I don't get the point. I ran a few tests with

linuxPackageMappings in Debian += packageTemplateMapping(target.value,
    "/var/log/" + name.value,
    "/etc/" + name.value
)

linuxPackageMappings in Debian += packageTemplateMapping(target.value,
    "/var/log/private"
).withPerms("0644")

linuxPackageMappings in Debian += packageMapping(
    (baseDirectory.value / "conf" / "application.conf") -> "/root/application.conf",
    (baseDirectory.value / "conf" / "application.conf") -> ("/etc/" + name.value + "/application.conf")
).withPerms("0644")

and all permissions were set as they should. If you mean that users may get confused with the directory permissions, then I think it's a matter of documentation. Less magic, is better magic IMHO :)

The LinuxFileMetaData have by default the execution bit so we only have to add magic (Plan A) if this behaviour changes. Right?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, see requests like #69 . I think you're right. We should not do any magic in the "core" api, and we can push helper methods on top to simplify discovering files in directories for users. Your thoughts welcome there!

@jsuereth
Copy link
Member

jsuereth commented Nov 6, 2013

BTW - I plan to merge this regardless. If need, I'll push the executable fix on top of what you have. Great work.

@jsuereth
Copy link
Member

jsuereth commented Nov 8, 2013

Again, thanks much for the work!

jsuereth added a commit that referenced this pull request Nov 8, 2013
task #54: Template Directories for Debian package
@jsuereth jsuereth merged commit 8ed5f55 into sbt:master Nov 8, 2013
@muuki88 muuki88 deleted the wip_template_directories branch November 9, 2013 13:12
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.

2 participants