Ensure that variables are defined before they are used

When pkg_info is nil, don't generate the following error:
```
NameError: undefined local variable or method `pkg_action'
```