Fix build error and pkg -d behavior

- Fixes build error (debug_level undefined)
- Attempts to implement behavior described in man pkg.conf / man pkg. The debug flag of pkg is passed down to pkg_ini to override debug_level. Alternatively, one could make debug_level an extern that pkg also uses. I can be convinced to go both ways.

Pkg now works as documented:

**** SCENARIO ****

/* no debugging set */

[12:49:32 rbarabas@freebsd10:~/src/pkg.mod]                                                                                                                                      % sudo ./src/pkg install expect
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 1 packages will be affected (of 0 checked):

New packages to be INSTALLED:
	expect: 5.45_1

The process will require 382 KB more space.
168 KB to be downloaded.

Proceed with this action? [y/N]: 
                      
          
**** SCENARIO ****

/* DEBUG_LEVEL not set, -d increases debug_level to 2 */

[12:40:20 rbarabas@freebsd10:~/src/pkg.mod]                                                                                                                                      % sudo ./src/pkg -d -d install expect
DBG(1)[48803]> pkg initialized
DBG(1)[48803]> PkgConfig: loading repositories in /etc/pkg/
DBG(1)[48803]> PKgConfig: loading /etc/pkg/FreeBSD.conf
DBG(1)[48803]> PkgConfig: parsing key 'FreeBSD'
DBG(1)[48803]> PkgConfig: parsing repository object FreeBSD
DBG(1)[48803]> PkgConfig: loading repositories in /usr/local/etc/pkg/repos/
Updating FreeBSD repository catalogue...
DBG(1)[48803]> PkgRepo: verifying update for FreeBSD
DBG(1)[48803]> Pkgrepo, begin update of '/var/db/pkg/repo-FreeBSD.sqlite'
DBG(1)[48803]> Fetch: fetching from: http://pkgmir.pkg.freebsd.org/FreeBSD:10:amd64/latest/meta.txz with opts "i"
DBG(1)[48803]> Fetch: fetching from: http://pkgmir.pkg.freebsd.org/FreeBSD:10:amd64/latest/packagesite.txz with opts "i"
FreeBSD repository is up-to-date.
All repositories are up-to-date.
DBG(1)[48803]> want to get an advisory lock on a database
...
DBG(2)[48803]> solver: ignoring package sessreg(2$0$bgrb5swmreo8nrnizzcnekotx8n8mh9hakt55n1t7m4tn3maim3b) as its state has not been changed
DBG(2)[48803]> solver: ignoring package xextproto(2$0$hotkhwdcbyn99izh8f5unypfmxh1ys9qn6wuwjtdp7fdysr8hdiy) as its state has not been changed
DBG(2)[48803]> solver: ignoring package libvdpau(2$0$z448qmijxegr8mb48zi7xyc5g7tpoisksc314q6jypxr9wf3b1bb) as its state has not been changed
DBG(2)[48803]> solver: ignoring package tktable(2$0$yfb1zdofdwhqo7e1pcpzfipn3fjyp9bmzt5gxp4eyhdgbyndi4cy) as its state has not been changed
DBG(1)[48803]> Binary> loading /var/cache/pkg/expect-5.45_1-78300222ed.txz
The following 1 packages will be affected (of 0 checked):

New packages to be INSTALLED:
	expect: 5.45_1

The process will require 382 KB more space.
168 KB to be downloaded.

Proceed with this action? [y/N]: 
DBG(1)[48803]> release an advisory lock on a database


**** SCENARIO ****

/* DEBUG_LEVEL is set in pkg.conf to 3 */

[12:48:07 rbarabas@freebsd10:~/src/pkg.mod]                                                                                                                                      % sudo ./src/pkg install expect
DBG(1)[48925]> PkgConfig: loading repositories in /etc/pkg/
DBG(1)[48925]> PKgConfig: loading /etc/pkg/FreeBSD.conf
DBG(1)[48925]> PkgConfig: parsing key 'FreeBSD'
DBG(1)[48925]> PkgConfig: parsing repository object FreeBSD
DBG(1)[48925]> PkgConfig: loading repositories in /usr/local/etc/pkg/repos/
Updating FreeBSD repository catalogue...
DBG(1)[48925]> PkgRepo: verifying update for FreeBSD
DBG(1)[48925]> Pkgrepo, begin update of '/var/db/pkg/repo-FreeBSD.sqlite'
DBG(1)[48925]> Fetch: fetching from: http://pkgmir.pkg.freebsd.org/FreeBSD:10:amd64/latest/meta.txz with opts "i"
DBG(1)[48925]> Fetch: fetching from: http://pkgmir.pkg.freebsd.org/FreeBSD:10:amd64/latest/packagesite.txz with opts "i"
FreeBSD repository is up-to-date.
All repositories are up-to-date.
DBG(1)[48925]> want to get an advisory lock on a database
DBG(3)[48925]> added shlib provide pkg for ports-mgmt/pkg
DBG(3)[48925]> added shlib provide pkg for ports-mgmt/pkg
DBG(2)[48925]> universe: add new local pkg: pkg, (pkg-1.4.0:2$0$twuks45irpy9yjh5u4utdmxaeakx17osb3fcpoykgak4zg8ytxgy)
DBG(3)[48925]> Pkg: add a new dependency origin: lang/tcl86, name: tcl86, version: 8.6.3
DBG(3)[48925]> added shlib deps for expect on libtcl86.so.1
DBG(3)[48925]> added shlib provide expect for lang/expect
DBG(3)[48925]> Pkg: add a new dependency origin: lang/tcl86, name: tcl86, version: 8.6.3
DBG(3)[48925]> added shlib deps for expect on libtcl86.so.1
DBG(3)[48925]> added shlib provide expect for lang/expect
DBG(2)[48925]> universe: add new remote pkg: expect, (expect-5.45_1:2$0$frdzcyejzcfcd5b5fhte4wcp4ztzridh4ne644tqfph1dk9uremb)
DBG(3)[48925]> Pkg: add a new reverse dependency origin: x11-toolkits/tk86, name: tk86, version: 8.6.3
DBG(3)[48925]> Pkg: add a new reverse dependency origin: editors/vim, name: vim, version: 7.4.542
DBG(2)[48925]> Pkg> adding options: MODULES = on
DBG(2)[48925]> Pkg> adding options: TCLMAN = off
DBG(2)[48925]> Pkg> adding options: THREADS = on
DBG(2)[48925]> Pkg> adding options: TZDATA = off
...
DBG(2)[48910]> solver: ignoring package setxkbmap(2$0$p7brzazj5sop8i1gyru7jqc4krb3fxun81uywwgsmyqpna8g166y) as its state has not been changed
DBG(2)[48910]> solver: ignoring package sessreg(2$0$bgrb5swmreo8nrnizzcnekotx8n8mh9hakt55n1t7m4tn3maim3b) as its state has not been changed
DBG(2)[48910]> solver: ignoring package xextproto(2$0$hotkhwdcbyn99izh8f5unypfmxh1ys9qn6wuwjtdp7fdysr8hdiy) as its state has not been changed
DBG(2)[48910]> solver: ignoring package libvdpau(2$0$z448qmijxegr8mb48zi7xyc5g7tpoisksc314q6jypxr9wf3b1bb) as its state has not been changed
DBG(2)[48910]> solver: ignoring package tktable(2$0$yfb1zdofdwhqo7e1pcpzfipn3fjyp9bmzt5gxp4eyhdgbyndi4cy) as its state has not been changed
DBG(1)[48910]> Binary> loading /var/cache/pkg/expect-5.45_1-78300222ed.txz
The following 1 packages will be affected (of 0 checked):

New packages to be INSTALLED:
	expect: 5.45_1

The process will require 382 KB more space.
168 KB to be downloaded.

Proceed with this action? [y/N]: 

*** SCENARIO ***

/* DEBUG_LEVEL set to 3, -d overrides debug_level to 1 */

[12:42:12 rbarabas@freebsd10:~/src/pkg.mod]                                                                                                                                      % grep ^DEBUG_LEVEL /usr/local/etc/pkg.conf
DEBUG_LEVEL = 3;
                                                                                                                                                                                 [12:42:21 rbarabas@freebsd10:~/src/pkg.mod]                                                                                                                                      % sudo ./src/pkg -d install expect
DBG(1)[48837]> pkg initialized
DBG(1)[48837]> PkgConfig: loading repositories in /etc/pkg/
DBG(1)[48837]> PKgConfig: loading /etc/pkg/FreeBSD.conf
DBG(1)[48837]> PkgConfig: parsing key 'FreeBSD'
DBG(1)[48837]> PkgConfig: parsing repository object FreeBSD
DBG(1)[48837]> PkgConfig: loading repositories in /usr/local/etc/pkg/repos/
Updating FreeBSD repository catalogue...
DBG(1)[48837]> PkgRepo: verifying update for FreeBSD
DBG(1)[48837]> Pkgrepo, begin update of '/var/db/pkg/repo-FreeBSD.sqlite'
DBG(1)[48837]> Fetch: fetching from: http://pkgmir.pkg.freebsd.org/FreeBSD:10:amd64/latest/meta.txz with opts "i"
DBG(1)[48837]> Fetch: fetching from: http://pkgmir.pkg.freebsd.org/FreeBSD:10:amd64/latest/packagesite.txz with opts "i"
FreeBSD repository is up-to-date.
All repositories are up-to-date.
DBG(1)[48837]> want to get an advisory lock on a database
DBG(1)[48837]> Binary> loading /var/cache/pkg/expect-5.45_1-78300222ed.txz
The following 1 packages will be affected (of 0 checked):

New packages to be INSTALLED:
	expect: 5.45_1

The process will require 382 KB more space.
168 KB to be downloaded.

Proceed with this action? [y/N]: