Discussion:
Creating a pkg
Andrew Wood via freebsd-questions
2016-07-28 15:44:05 UTC
Permalink
I'm experimenting with creating a pkg package for a program Ive created
on my system which is a set of Python & shell scripts.

I have a few of questions:

1. Despite following the example +MANIFEST file given on the wiki I am
getting the error pkg: Bad format in manifest for key: version

I am invoking the command like this: pkg create -M ./+MANIFEST
with the current working directory being the one containing the manifest
and all the program scripts.

the line in the manifest is as follows:

version: 0.3

Any idea why it doesnt like this?


2. As my program is Python & shell scripts and is therefore platform
independent can I use arch: all ?

3. When specifying a dependency package and its version, is the version
taken as that version only or will it also be satisfied by a later
version? According to the docs there is no way to specify one or the other.

Many thanks

Andrew
Matthew Seaman
2016-07-28 16:47:50 UTC
Permalink
Post by Andrew Wood via freebsd-questions
I'm experimenting with creating a pkg package for a program Ive created
on my system which is a set of Python & shell scripts.
1. Despite following the example +MANIFEST file given on the wiki I am
getting the error pkg: Bad format in manifest for key: version
You can see the manifest for any package on your system by:

pkg info -R pkgname

If you copy the format there, you shouldn't go far wrong. Note that
pkg(8) will automatically calculate the file checksums and work out any
shared library dependencies for you, so you can leave those bits out of
your manifest

It's written in UCL (https://github.com/vstakhov/libucl) -- that's very
similar to JSON in this case. (UCL can also look like the nginx config
file format, but that's not really relevant here.)
Post by Andrew Wood via freebsd-questions
I am invoking the command like this: pkg create -M ./+MANIFEST
with the current working directory being the one containing the manifest
and all the program scripts.
version: 0.3
Any idea why it doesnt like this?
Try:

version: "0.3";
Post by Andrew Wood via freebsd-questions
2. As my program is Python & shell scripts and is therefore platform
independent can I use arch: all ?
That would be:

abi = "FreeBSD:10:*";
arch = "freebsd:10:*";

(assuming you're running FreeBSD 10.x) You will need both abi and arch
settings, although for a pure Python package they don't really add much
value to the package.
Post by Andrew Wood via freebsd-questions
3. When specifying a dependency package and its version, is the version
taken as that version only or will it also be satisfied by a later
version? According to the docs there is no way to specify one or the other.
No, this is recognised as one of the biggest limitations in pkg(8) at
the moment. Strict dependencies are baked into packages, and the
version matching is exact. This makes a difference at install time --
although it does seem to be possible to update a dependency at a later
date without too much trouble.

Cheers,

Matthew
Andrew Wood via freebsd-questions
2016-07-28 20:02:55 UTC
Permalink
Post by Matthew Seaman
version: "0.3";
Thanks Matthew, quoting the version number works, for some reason it
insists on that even though everything else can be unquoted.
Post by Matthew Seaman
Post by Andrew Wood via freebsd-questions
2. As my program is Python & shell scripts and is therefore platform
independent can I use arch: all ?
abi = "FreeBSD:10:*";
arch = "freebsd:10:*";
(assuming you're running FreeBSD 10.x) You will need both abi and arch
settings, although for a pure Python package they don't really add much
value to the package.
Does that mean I can't create an all architecture package that will work
on FreeBSD 11 when it comes out, I would have to create a separate
package for future versions of FreeBSD?

Can I also clarify how I specify which files to put in the package and
where I want them put on the target system during installation? Can I
package up everything in a directory with dir: {/path: 'sha256hash'}; ?

That only takes one path though, is that the target path or the local
path on my machine? How does the prefix value fit in? What if I want to
put files in several places?

Thanks
Andrew
Matthew Seaman
2016-07-28 21:14:12 UTC
Permalink
Post by Andrew Wood via freebsd-questions
Does that mean I can't create an all architecture package that will work
on FreeBSD 11 when it comes out, I would have to create a separate
package for future versions of FreeBSD?
Yes, you need a separate package for each different FreeBSD major version.
Post by Andrew Wood via freebsd-questions
Can I also clarify how I specify which files to put in the package and
where I want them put on the target system during installation? Can I
package up everything in a directory with dir: {/path: 'sha256hash'}; ?
You need to enumerate each file in your package separately. 'dir'
entries will create a directory -- frequently one that is left empty.
You don't need to list every directory needed to install all the files
in the package. They are created automatically when the file is
installed. You only need a dir entry if the directory wouldn't
otherwise be created.
Post by Andrew Wood via freebsd-questions
That only takes one path though, is that the target path or the local
path on my machine? How does the prefix value fit in? What if I want to
put files in several places?
It's both. The path is where the file will be put after installation.
It's also where pkg(8) looks for the file in order to package it.
Except that when packaging a file you'ld generally create the installed
layout of files relative to some staging directory so you didn't end up
scribbling all over your system. See the '-r' or '--rootdir' option in
pkg-create(8).

Cheers,

Matthew
Andrew Wood via freebsd-questions
2016-07-29 17:33:43 UTC
Permalink
Post by Matthew Seaman
Note that
pkg(8) will automatically calculate the file checksums so you can leave those bits out of
your manifest
What is the syntax for doing this, what would I put in the files {}
section where the hash would normally go?
Post by Matthew Seaman
You need to enumerate each file in your package separately. 'dir'
entries will create a directory -- frequently one that is left empty.
You don't need to list every directory needed to install all the files
in the package. They are created automatically when the file is
installed. You only need a dir entry if the directory wouldn't
otherwise be created.
Will that directory also be deleted automatically when the package
is removed, I dont need to include an rm in a post deinstall
script?

Thanks
Andrew
Andrew Wood via freebsd-questions
2016-08-05 19:16:50 UTC
Permalink
Post by Andrew Wood via freebsd-questions
Post by Matthew Seaman
Note that
pkg(8) will automatically calculate the file checksums so you can leave those bits out of
your manifest
What is the syntax for doing this, what would I put in the files {}
section where the hash would normally go?
OK after trial and error not helped by the fact that different docs
seems to have different syntax, Ive managed to put together a pkg which
will install all the files at the desired location and remove them again
when the pkg is uninstalled. I can also set the file permissions but not
the owner or group owner, which Im doing like this:


files: {
/path/to/file: {uname: 'username', gname: 'groupname',perm: 644};
}

I suspect theres nothing wrong with that, the problem is simply that it
isnt creating the user or group in the first place.

Am I right in assuming that is the purpose of
users: ["username"];
groups: ["groupname", "groupname2"];

If so why is it not making the necessary entries in the /etc/passwd or
/etc/group files?

Thanks
Andrew

Loading...