porting and packaging

I know your suppose to read the porting guide to learn how to create your own ports.
But what do you read to learn how to create pkg (packages)?

DRF

Thank you.
 
Therefore the port is used. The port is the origin of a package. So the answer is still the porting guide.
 
Yep. If your port is good then the package will automatically created. Ports build packages, and it's that resulting package that gets installed.
 
It uses the .txz extension, is that what you mean? It's the LZMA2 compression format rather than GZIP which uses the .tar.gz and .tgz filename extensions. They can be created using tar -xz instead of tar -gz command line parameters. Edited to add: That last part was wrong. I don't know how they're created. man tar says the -z option only uses gzip compression. Maybe it's just an extension but I don't know. I type -czpf, -xzpf, and .tgz so automatically that I hardly ever think about it anymore. Sorry. Where the .txz files are concerned, I let pkg do all the compression and decompression for me.
 
Basicly the internal format of the pkg utility.
I know it uses tar file but what is the structure of the files and directory included in tar.
 
I got curious and investigated a bit. I must first admit that the contents of this post are purely speculation as a result of experimentation and looking at makefile fragments and pkg-create(8). If you need more authoritative information, you're likely going to need to review the C source for ports-mgmt/pkg. The lack of additional documentation is probably because some implementation details are subject to change; perhaps pkg-create(8) will one day switch to TOML or some other file format in the future for example.

A package consists of two JSON files named +COMPACT_MANIFEST and +MANIFEST (in that order), followed by the actual files installed by the package. If you're wondering why there are two manifest files inside a package, consider the fact that some packages install hundreds or even thousands of files; x11-themes/flat-remix-icon-themes has a pkg-plist that is 322236 lines long for example! If using pkg-rquery(8) over a slow network connection, that's potentially a significant waste of time and resources for the server sending unneeded information. That is one possible reason why pkg-rquery(8) cannot fetch a list of files and also why +COMPACT_MANIFEST is written to the archive first, though that is once again mere speculation on my part since I have not reviewed the C source.

Further digging seems to indicate that pkg-create(8) is responsible for creating those manifest files, but they are actually generated from other input files. As confusing as it may be, one of those input files is also named +MANIFEST. It's easier to see an example of that input file than for me to describe it, so below is the one generated by the default config for ports-mgmt/poudriere. Compare the contents with "MANIFEST FILE DETAILS" in pkg-create(8):
Code:
sh$ make -C /usr/ports/ports-mgmt/poudriere 'WRKDIR=/tmp/poudriere-work' create-manifest
sh$ cat /tmp/poudriere-work/.metadir/+MANIFEST
name: "poudriere"
version: "3.3.6"
origin: ports-mgmt/poudriere
comment: <<EOD
Port build and test system
EOD
maintainer: bdrewery@FreeBSD.org
prefix: /usr/local
categories: [ ports-mgmt, ]
licenselogic: single
licenses: [ BSD2CLAUSE, ]
deps: { 
"ca_root_nss": {origin: "security/ca_root_nss", version: "3.63"}
"dialog4ports": {origin: "ports-mgmt/dialog4ports", version: "0.1.6"}
"freebsd-release-manifests": {origin: "misc/freebsd-release-manifests", version: "20210413"}
}
options: {
 BASH: on,
 CERTS: on,
 DIALOG4PORTS: on,
 EXAMPLES: on,
 QEMU: off,
 ZSH: on,
}
You might notice how JSON-like that is already. pkg-create(8) seems to convert that imperfect JSON to valid JSON and combines that with some other information to create the +COMPACT_MANIFEST file; the +MANIFEST file included in the package is essentially the same file as +COMPACT_MANIFEST, except there is some additional information like the list of files installed and installation/deinstallation scripts, and pkg-repository(5) describes another use for +MANIFEST files.
 
I know it uses tar file but what is the structure of the files and directory included in tar.
Just extract one: tar Jxvf package-1.23.txz; You can also use the Midnight Commander (port/package "misc/mc") to enter a package file and see its content like real directories.
Basically there's a directory tree stripped down to the files of a software in it, as well as the license informations and two manifest file with all informations about dependencies, version, its port origin, short summary of the software etc.; But what is that information good for? If you want to create a package, go with the porters handbook.
 
Back
Top