4 newbie questions about porting process

I am trying to implement steps of quick porting http://www.freebsd.org/doc/en/books/porters-handbook/quick-porting.html
It says "First, get the original tarball and put it into DISTDIR, which defaults to /usr/ports/distfiles."

I have only 2 files in my application:
Code:
/usr/local/bin/vecihibin
/usr/local/etc/vecihi.conf


Question 1)
I created a tar ball of these files and I copied it to /usr/ports/distfiles/vecihi.tar.gz. But I didn't understand where Makefile, pkg-descr, pkg-plist files should be located? In tar ball or?

Makefile:
Code:
# $FreeBSD$

PORTNAME=	vecihi
PORTVERSION=	1.0b
CATEGORIES=	games
MASTER_SITES=	ftp://ftp.vecihi.com/contrib/

MAINTAINER=	vecihi@vecihi.org
COMMENT=	sleepy cat

MAN1=		vecihi.1
MANCOMPRESSED=	yes
USE_IMAKE=	yes

.include <bsd.port.mk>

Quesion 2)
In which folder should I run commands shown as below for testing? Should I define these calls in Makefile?

Code:
make install
make package
make deinstall
pkg_add package-name
make deinstall
make reinstall
make package
make readme

Question3)
How can I generate vecihi.tbz? I don't want to compile custom application with ports. I just want to use pkg_add pkg_delete commands for custom vecihi.tbz package.

Or if I want to install with ports /usr/ports/games/vecihi if I run make install in /usr/ports/games/vecihi; I want to install only 2 files again.

Question4)
if I deinstall it I want to delete 1 file only: vecihibin. vecihi.conf shouldn't be erased. Can I do that?
 
A1) In the port's directory.

A2) In the port's directory.

A3) Using make package in the port's directory.

A4) Yes
 
1. The port files go into /usr/ports/category/portname. For example, rsync(1) is in /usr/ports/net/rsync.

2. Those commands are all executed from within the port directory, as in question 1.

3. Not clear what you're asking, but make package is what creates the package file.

4. If the conf file is standard (unmodified by the user), it should be deinstalled along with the rest. This is an important part of ports, that you can uninstall them without leaving useless files. If you want a per-user config, have the program read and write ~/.vecihi/vecihi.conf. Or see http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/plist-config.html for a way to not delete port config files if they have been modified by the user.
 
Makefile:
Code:
# $FreeBSD$

PORTNAME=       vecihi
PORTVERSION=    1.0b
CATEGORIES=     games
MASTER_SITES=   ftp://192.168.1.40/

MAINTAINER=     vecihi@vecihi.org
COMMENT=        sleepy cat

MAN1=           vecihi.1
MANCOMPRESSED=  yes
USE_IMAKE=      yes

PLIST_FILES=    usr/local/bin/vecihibin \
                usr/local/etc/vecihi.conf


PLIST_DIRS=     usr/local/etc \
                usr/local/bin

.include <bsd.port.mk>


make package
Code:
builder# make package
===>  Building for vecihi-1.0b
make: don't know how to make Makefile. Stop
*** Error code 1

Stop in /usr/ports/games/vecihi.
package-builder# make clean
===>  Cleaning for vecihi-1.0b
package-builder# make package
===>  Extracting for vecihi-1.0b
=> No checksum file (/usr/ports/games/vecihi/distinfo).
===>  Patching for vecihi-1.0b
===>   vecihi-1.0b depends on executable: imake - found
===>  Configuring for vecihi-1.0b
imake -DUseInstalled -I/usr/local/lib/X11/config
imake: No such file or directory
imake: No description file.
  Stop.
===>  Building for vecihi-1.0b
make: don't know how to make Makefile. Stop
*** Error code 1

Stop in /usr/ports/games/vecihi.

what the cause of this error message? it s related with imake but i didn't understand clearly the role of imake ...

i change USE_IMAKE = NO

Result:
Code:
builder# make package
===>  Building for vecihi-1.0b
make: don't know how to make Makefile. Stop
*** Error code 1

Stop in /usr/ports/games/vecihi.
 
I removed USE_IMAKE

Code:
builder# cat /usr/ports/games/vecihi/Makefile
# $FreeBSD$

PORTNAME=       vecihi
PORTVERSION=    1.0b
CATEGORIES=     games
MASTER_SITES=   ftp://192.168.1.40/

MAINTAINER=     vecihi@vecihi.org
COMMENT=        sleepy cat

MAN1=           vecihi.1
MANCOMPRESSED=  yes

PLIST_FILES=    usr/local/bin/vecihibin \
                usr/local/etc/vecihi.conf


PLIST_DIRS=     usr/local/bin \
                usr/local/etc

                vecihi-1.0b/opt/vecihi/sbin
.include <bsd.port.mk>

Code:
builder# cd /usr/ports/games/vecihi/
builder# make
===>  Building for vecihi-1.0b
make: cannot open Makefile.
*** Error code 1

Stop in /usr/ports/games/vecihi.
Question-)
I need another file Makefile. I just want to copy bins to PLIST_DIRS. I don't want to compile anything. In work/vecihi-1.0b/Makefile file should I define install deinstall functions? Or what I need?

Code:
builder# touch work/vecihi-1.0b/Makefile
builder# make
===>  Building for vecihi-1.0b
make: don't know how to make all. Stop
*** Error code 1

Stop in /usr/ports/games/vecihi.
 
I solved it. The problem was space characters.

/usr/ports/games/vecihi/work/vecihi-1.0b/Makefile (I extracted vecihi-1.0b.tar.gz to /usr/ports/games/vecihi/work/vecihi-1.0b manually)
Code:
# A simple Makefile
all:
        echo "test"

it works like a charm...

question:
Why make all command didn't create /usr/ports/games/vecihi/work/vecihi-1.0b folder automatically? (I extracted vecihi-1.0b.tar.gz to /usr/ports/games/vecihi/work/vecihi-1.0b manually)


Code:
builder# cd /usr/ports/games/vecihi/
builder# make all
===>  Extracting for vecihi-1.0b
=> No checksum file (/usr/ports/games/vecihi/distinfo).
===>  Patching for vecihi-1.0b
===>  Configuring for vecihi-1.0b
===>  Building for vecihi-1.0b
cd: can't cd to /usr/ports/games/vecihi/work/vecihi-1.0b
 
solution:
we should have vecihi-1.0b folder in tar ball. actually it automatically extract tar ball to work/ dir...

thank you all for helps
 
Question-1)
make all is successful now. And I will add shell script to Makefile for copying files to required locations. But how can I register port installation to /var/db/pkg/. I want to see installed package (vecihi-1.0b) with pkg_info and I want to create package with make package too.

Question-2) Should I define install: deinstall: package: make calls in /usr/ports/games/vecihi/work/vecihi-1.0b/Makefile?
I read apache22's Makefile for learning more


Information about files that I used:
Code:
cat /usr/ports/games/vecihi/work/vecihi-1.0b/Makefile
# A simple Makefile
all:
        echo "test"


Code:
builder# make all
===>  Extracting for vecihi-1.0b
=> No checksum file ([color="rgb(0, 100, 0)"]/usr/ports/games/vecihi/distinfo[/color]).
===>  Patching for vecihi-1.0b
===>  Configuring for vecihi-1.0b
===>  Building for vecihi-1.0b
echo "test"
test


Code:
builder# make install
===>  Installing for vecihi-1.0b
===>   Generating temporary packing list
===>  Checking if games/vecihi already installed
make: don't know how to make install. Stop
*** Error code 2

Stop in /usr/ports/games/vecihi.

thanks
 
vecihi said:
Question-2) Should I define install: deinstall: package: make calls in /usr/ports/games/vecihi/work/vecihi-1.0b/Makefile?
No, the ports system takes care of those. And you don't need a Makefile for your sources, there's nothing to compile.
 
vecihi said:
Makefile:
Code:
PLIST_FILES=    [color="Red"]usr/local/[/color]bin/vecihibin \
                [color="Red"]usr/local/[/color]etc/vecihi.conf


PLIST_DIRS=     [color="Red"]usr/local/[/color]etc \
                [color="Red"]usr/local/[/color]bin

Do not hardcode paths like that. Use ${PREFIX} instead.

If your program is already compiled, use NO_BUILD= YES.
 
Makefile: (cat /usr/ports/games/vecihi/Makefile)
Code:
# $FreeBSD$

PORTNAME=	vecihi
PORTVERSION=	1.0b
CATEGORIES=	games
MASTER_SITES=	http://192.168.1.40/

MAINTAINER=	vecihi@vecihi.org
COMMENT=	sleepy cat

MAN1=		vecihi.1
MANCOMPRESSED=	yes
[color="DarkGreen"]NO_BUILD=	yes[/color]
PLIST_FILES=    ${PREFIX}/bin/vecihibin \
                ${PREFIX}/etc/vecihi.conf


PLIST_DIRS=     ${PREFIX}/etc \
                ${PREFIX}/bin
.include <bsd.port.mk>

Code:
builder# make clean
===>  Cleaning for vecihi-1.0b

Code:
builder# make 
===>  Extracting for vecihi-1.0b
=> No checksum file (/usr/ports/games/vecihi/distinfo).
===>  Patching for vecihi-1.0b
===>  Configuring for vecihi-1.0b

Code:
builder# make install
===>  Installing for vecihi-1.0b
===>   Generating temporary packing list
===>  Checking if games/vecihi already installed
[color="Red"]make: don't know how to make install. Stop
*** Error code 2[/color]

Stop in /usr/ports/games/vecihi.


if i add
Code:
do-install:
	@${ECHO_MSG} "test"
to " /usr/ports/games/vecihi/Makefile " i got:
Code:
"Makefile", line 52: warning: duplicate script for target "do-install" ignored


Question-)
for installing with make install what changes should be done in Makefile?
 
If I have problems getting a port to do what I need I always try to look at an existing port that does something similar. Have a look at the Makefile of ports-mgmt/portmaster, it's relatively simple and, like your port, doesn't actually build anything.
 
if i set PREFIX to another place than /usr/local
Code:
PREFIX=  /opt
port system creates subfolders in /opt:
Code:
builder# ls [color="DarkGreen"]/opt/[/color]
bin             include         vecihi        libdata         man             share
etc             info            lib             libexec         sbin            www

if i set PREFIX= / (root)... and if port system creates subdirectories in ( / ) it won't be good i think.

how can i prevent this?

i know it s not suitable for freebsd's directory structure but it s not public port, i want to install port to another directory than /usr/local
 
vecihi said:
port system creates subfolders in /opt:
Code:
builder# ls [color="DarkGreen"]/opt/[/color]
bin             include         vecihi        libdata         man             share
etc             info            lib             libexec         sbin            www
During install Mk/bsd.port.mk uses mtree(8) to populate PREFIX with basic subdirectories according to Templates/BSD.local.dist. To avoid this just define NO_MTREE in the port's Makefile.
 
Question)

I'm creating custom vecihi.tbz package with:
Code:
builder# cd /usr/ports/games
builder# make package-recursive
Then, I can see vecihi port installed successfuly with pkg_info on builder machine. And subdirectories (output and logs) created successfuly in /usr/local/vecihi folder. And package (vecihi.tbz) created in /usr/ports/packages/All/ folder.


But if I install package (vecihi.tbz) to another machine with pkg_add, subdirectories (output and logs) are missing...

Makefile:
Code:
# $FreeBSD: ports/security/VECIHI//Makefile $

VECIHIDIR=	[color="SeaGreen"]vecihi[/color]
[color="Red"]VECIHIOUTPUT=	output
VECIHILOGS=	logs[/color]
...

.include <bsd.port.pre.mk>

do-install:
	[color="Green"]${MKDIR} ${PREFIX}/${VECIHIDIR}[/color]
[color="Red"]	${MKDIR} ${PREFIX}/${VECIHIDIR}/${VECIHILOGS}	
	${MKDIR} ${PREFIX}/${VECIHIDIR}/${VECIHIOUTPUT}	[/color]
	@${CHOWN} -R itap ${PREFIX}/${VECIHIDIR}
	(cd ${WRKSRC}${PREFIX}/${VECIHIDIR} && ${COPYTREE_SHARE} \* ${PREFIX}/${VECIHIDIR})
	
...
Red directives are not working correctly with pkg_add.

How can i fix it?
 
Check the pkg-plist file. It's this file that's used for packaging.
 
Actually output/ and log/ directories are defined in Makefile: those directories are empty.

Code:
PLIST_FILES=    usr/local/vecihi/bin/vecihibin \
                usr/local/vecihi/conf/vecihi.conf


PLIST_DIRS=     usr/local/vecihi/conf \
                usr/local/vecihi/bin \
[color="green"]                usr/local/vecihi/output \
                usr/local/vecihi/logs[/color]
I don't want to add those directories to PLIST_DIRS because when i removed package those directories should be there... i don't want to uninstall output/logs.

- Why those empty directories are created successfuly on the builder machine with port installation method (make package-recursive)?

- And why not with pkg_add on another machine?

Thanks
 
Solution:
Empty directories created during port installation need special attention. They will not get created when installing the package, because packages only store the files, and pkg_add creates directories for them as needed. To make sure the empty directory is created when installing the package, add this line to pkg-plist above the corresponding @dirrm line:

Code:
@exec mkdir -p %D/share/foo/templates
http://www.freebsd.org/doc/en/books/porters-handbook/plist-cleaning.html

vecihi said:
Actually output/ and log/ directories are defined in Makefile: those directories are empty.

Code:
PLIST_FILES=    usr/local/vecihi/bin/vecihibin \
                usr/local/vecihi/conf/vecihi.conf


PLIST_DIRS=     usr/local/vecihi/conf \
                usr/local/vecihi/bin \
[color="green"]                usr/local/vecihi/output \
                usr/local/vecihi/logs[/color]
I don't want to add those directories to PLIST_DIRS because when i removed package those directories should be there... i don't want to uninstall output/logs.

- Why those empty directories are created successfuly on the builder machine with port installation method (make package-recursive)?

- And why not with pkg_add on another machine?

Thanks
 
Back
Top