Rebuild installed packages for a certain host in pkgsrc

Submitted by Fekete Zoltán on

You have a machine (a master host) with several idividually installed packages. You want those packages to be rebuilt somewhere else (slave host). Do this:

1. On the master host
# pkg_info -Q PKGPATH -a > pkgs_i_want_to_have
2. Copy the generated file to the slave host, and issue as root:
# cat pkgs_i_want_to_have | (while read pp ; do cd /usr/pkgsrc/$pp ; make && make bin-install ; done)

Simple enough, eh?

Extract one database from mysql/mariadb full dump

Submitted by Fekete Zoltán on

Save this script into an sh file:

#!/usr/bin/env bash

DBNAME=$1
INFILE=$2

SED_FILTER="/^-- Current Database: \`$DBNAME\`/,/^-- Current Database: /p"

sed -n "$SED_FILTER" $INFILE > $DBNAME.sql

echo "Dump is ready: $DBNAME.sql"

exit 0


Run as :

$ sh script_name dbname full_dump_file

If you want to avoid problems during foreign key imports, then insert this line into the newly generated file after the USE <DBNAME>; statement:

SET FOREIGN_KEY_CHECKS=0;