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

binary control files #220

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

binary control files #220

wants to merge 1 commit into from

Conversation

mlhartme
Copy link

I need to add binary control files to a package (actually a jar file, that I use in my maintainer scripts).

Can you please consider to merge something like this?

Best regards

Michael

@@ -187,7 +187,7 @@
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<settingsFile>src/it/settings.xml</settingsFile>
<!-- settingsFile>src/it/settings.xml</settingsFile -->
<goals>
Copy link
Owner

Choose a reason for hiding this comment

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

Why did you remove this?

Copy link
Author

Choose a reason for hiding this comment

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

Just to make the tests work in my environment. Quick hack for me, Do not merge this, sorry.

Copy link
Author

Choose a reason for hiding this comment

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

But probably hard to implement. I think you detect variables withing string - and have to encode them for saving the resulting file.

Another approach would be a configurable method you call before closing the tar file. I'd add my binary file in this method. And make my method availabe to your Code by adding a dependency to the Plugin config in my pom.

@tcurdt
Copy link
Owner

tcurdt commented Oct 10, 2015

Hey Michael,
thanks for the contribution. Can you elaborate a bit on this?
Frankly speaking I am not even sure what "binary control files" are.
Is this just to ship the jar so you can call it from your maintainer scripts?

@mlhartme
Copy link
Author

Yes, it want to ship a jar file that I can access from my maintainer script.
Because I'm sick of writing shell scripts - I want to have one generic maintainer shell script that just dispatches into Java.

The only way (I found ...) to do this is to append the jar file to the postrm script.

You can see this in action here: https://github.com/mlhartme/stool/blob/master/setup/pom.xml

if (CONFIGURATION_FILENAMES.contains(file.getName()) || MAINTAINER_SCRIPTS.contains(file.getName())) {
FilteredFile configurationFile = new FilteredFile(new FileInputStream(file), resolver);
configurationFile.setOpenToken(openReplaceToken);
configurationFile.setCloseToken(closeReplaceToken);
addControlEntry(file.getName(), configurationFile.toString(), outputStream);

} else if (file.getName().endsWith(".bin")) {
Copy link
Owner

Choose a reason for hiding this comment

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

Frankly speaking I am not such a fan of adding some new rule about the file name. Maybe we should just make this work with https://github.com/mlhartme/jdeb/blob/binanry_control/src/main/java/org/vafer/jdeb/ControlBuilder.java#L120 instead.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed. I though about that too, but i didn't see a reliable way to detect binary files. In my case, the file is a shell script with a jar file appended.

Copy link
Owner

Choose a reason for hiding this comment

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

I guess the proper way to fix this is expanding https://github.com/tcurdt/jdeb/blob/master/src/main/java/org/vafer/jdeb/utils/InformationInputStream.java

Right now we are only checking for the BOM and the shebang. We could also also try to detect a binary there.

Copy link
Author

Choose a reason for hiding this comment

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

How can you properly check for a binary there? Character codes >= 128?

And by the way: what about shell scripts with "here documents" http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04. Maybe they have a similar problem.

Copy link
Owner

Choose a reason for hiding this comment

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

If we don't use BOM and Shebang but plain heuristics we indeed run into those problems with "here documents", too.

I am wondering if we should take a step back here. Right now we have 2 types

  • shell - where we apply variable expansion
  • other - which we just copy without applying variable expansion

Introducing a 3rd type is a bit sneaky as we would want to have variable expansion on only the shell part of the combined file.

So question is whether there is another way to ship the jar but appending it to the shell script or having some kind of convention/marker that tells jdeb where to apply the variable expansion and what to copy as binary.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not aware of an alternative place for the jar: is has to be present when postrm is executed. And at this point dpkg has removed all other files of the package. Even e.g. prerm.

Is there a way to define a variables with my binary content?

Copy link
Owner

Choose a reason for hiding this comment

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

Not binary variables yet - but that's actually a very (!) interesting line of thinking to solve this.

@tcurdt tcurdt modified the milestones: 1.6, 1.5 Jan 16, 2016
@tcurdt tcurdt modified the milestones: 1.6, 1.9 Aug 20, 2019
@tcurdt tcurdt removed this from the 1.9 milestone Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants