cbednarski / mkdeb Goto Github PK
View Code? Open in Web Editor NEWGo library for creating Debian packages (.deb)
License: MIT License
Go library for creating Debian packages (.deb)
License: MIT License
I was just using the Files map to add in extra files..
...Files = map[string]string{
"somefile":"/usr/share/doc/someproject/somefile",
}
This fails because the directory /usr/share/doc/someproject/
isn't explicitly
added to the archive.
Files should probably also support directories which would be added recursively.
The mapping in the Files map should be inverted to support copying one source
file to multiple destination files. The current Files map map[src]dst
makes
it impossible to reuse src
multiple times.
I had an actual use case for this today when I tried to put a default
configuration file both in /etc and in the documentation folder.
A backwards compatible solution is keep the Files struct field (map[src]dst
)
and add a new field Include
which probably is some functionality to properly
handle sources and destinations. It opens up for .Exclude
or .Filters
fields. I will work on a suggestion.
A worse solution is to change Files from map[src]dst
to map[src][]dst
which
breaks the current API so that any current users have to change.
The worst solution is to just silently change map[src]dst
to map[dst]src
which will cause errors without breaking compilation.
I haven't looked at the details of the deb file creation so I might have missed
something but it seems like the whole process just use io.writer's writing
directly to the .deb-archive instead of writing it out to multiple files first?
new suggestion: create intermediate files concurrently in goroutines
lintian
shoes that packages built using mkdeb
have incorrect UNIX permissions on the control file:
$ lintian quickmkdeb-1.0-amd64.deb
.... some output snipped...
E: quickmkdeb: control-file-has-bad-permissions conffiles 0600 != 0644
E: quickmkdeb: control-file-has-bad-permissions md5sums 0600 != 0644
It's a good idea to vendor all dependencies locally for building the executable to ensure reproducible builds and not fail if something external changes.
Currently it is only possible to install a .deb
generated by mkdeb if the filesystem image only includes directories which already exist, as intermediate directory headers are not included in the data archive (likely because of the ListFiles()
method).
A reproducible example:
cat > mkdeb.json <<EOF
{
"package": "quickmkdeb",
"architecture": "amd64",
"maintainer": "Your Name \[email protected]\u003e",
"description": "quickmkdeb is an awsome project for...",
"depends": [],
"section": "default",
"priority": "extra",
"homepage": "https://www.example.com/project",
"preinst": "",
"postinst": "",
"prerm": "",
"postrm": "",
"autoPath": "deb-pkg"
}
EOF
mkdir -p deb-pkg/usr/bin/
touch deb-pkg/usr/bin/testscript.sh
mkdir -p deb-pkg/zzz/i/dont/exist
touch deb-pkg/zzz/i/dont/exist/test.txt
mkdeb build -version=1.0 mkdeb.json
This results in a package which when installed on Ubuntu 16.04 gives the following results:
sudo dpkg -i quickmkdeb-1.0-amd64.deb
Selecting previously unselected package quickmkdeb.
(Reading database ... 59450 files and directories currently installed.)
Preparing to unpack quickmkdeb-1.0-amd64.deb ...
Unpacking quickmkdeb (1.0) ...
dpkg: error processing archive quickmkdeb-1.0-amd64.deb (--install):
unable to create '/zzz/i/dont/exist/test.txt.dpkg-new' (while processing 'zzz/i/dont/exist/test.txt'): No such file or directory
Errors were encountered while processing:
quickmkdeb-1.0-amd64.deb
Lintian shows the following relevant lint errors (among some others representing different bugs for which I will open separate issues):
W: quickmkdeb: missing-intermediate-directory usr/
W: quickmkdeb: missing-intermediate-directory usr/bin/
W: quickmkdeb: script-with-language-extension usr/bin/quickmkdeb.sh
E: quickmkdeb: non-standard-toplevel-dir zzz/
W: quickmkdeb: missing-intermediate-directory zzz/
W: quickmkdeb: missing-intermediate-directory ... use --no-tag-display-limit to see all (or pipe to a file/program)
The solution is to include directory header information for each intermediate directory irrespective of whether it already exists, but this requires some rearchitecture to avoid building the data archive from a slice of strings and towards building it directly in the filepath walk.
$ dpkg --contents testpackage-0.0.1-amd64.deb
-rwxrwxr-x root/root 4028490 2017-06-11 14:39 usr/bin/drone-deb
$ dpkg --info testpackage-0.0.1-amd64.deb
new debian package, version 2.0.
size 1435764 bytes: control archive=366 bytes.
1 bytes, 0 lines conffiles
181 bytes, 9 lines control
52 bytes, 1 lines md5sums
Package: testpackage
Version: 0.0.1
Architecture: amd64
Maintainer: Foo Bar<[email protected]>
Installed-Size: 0
Section: default
Priority: extra
Homepage:
Description: Test package
It's some times needed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.