# pkg_create -b



## jlenthe (Dec 6, 2009)

I just discovered `pkg_create -b` today.  I'm very happy because I've been trying to maintain a set of packages for my installed ports by setting PACKAGES and doing `portupgrade -ap` and `make package`.  This approach was OK, but I ended up with a package repository that contained packages for a lot of old versions.  

Enter `pkg_create -b`.  Now I can use the following shell script to obtain a set of package files for all my installed ports:

```
#!/bin/sh

for pkg in `pkg_info -E '*'`
do
  pkg_create -b $pkg
  echo $pkg package complete.
done
```


----------



## DutchDaemon (Dec 6, 2009)

Please don't use fonts; there are specific tags for commands, output and code:
http://forums.freebsd.org/showthread.php?t=8816


----------



## bdrewery@ (Feb 8, 2010)

*Simpler method*

pkg_create(1) accepts regex, so you can just run 1 cmd:


```
pkg_create -vxb '.*'
```


----------



## SirDice (Feb 8, 2010)

Since you have ports-mgmt/portupgrade installed you can clean outdated packages with `# portsclean -P`.


----------

