diff options
author | Renato Botelho <renato@netgate.com> | 2016-04-05 19:50:10 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-04-05 19:50:10 -0300 |
commit | a90f1c9b12c4d31ea845fa04188e599ba28dbaf1 (patch) | |
tree | c7332c7aef82031cac8a9ce8d7dea3d1e5bf9611 /src/etc | |
parent | a35bf546b57558535e3fc1958cf3fb2b4d18ade7 (diff) | |
download | pfsense-a90f1c9b12c4d31ea845fa04188e599ba28dbaf1.zip pfsense-a90f1c9b12c4d31ea845fa04188e599ba28dbaf1.tar.gz |
Rework the way repo packages work
- Distribute only a single pfSense-repo package containing all templates
- Create a symlink pointing to selected repo
- Do not limit it only to pfSense-repo and pfSense-repo-devel
Diffstat (limited to 'src/etc')
-rw-r--r-- | src/etc/inc/pkg-utils.inc | 60 | ||||
-rw-r--r-- | src/etc/pfSense.obsoletedfiles | 1 |
2 files changed, 43 insertions, 18 deletions
diff --git a/src/etc/inc/pkg-utils.inc b/src/etc/inc/pkg-utils.inc index 836e334..48cce82 100644 --- a/src/etc/inc/pkg-utils.inc +++ b/src/etc/inc/pkg-utils.inc @@ -1134,30 +1134,54 @@ function get_system_pkg_version() { ); } -/* Switch between stable and devel repos */ -function pkg_switch_repo($devel = false) { +/* List available repos */ +function pkg_list_repos() { global $g; - $repo_stable = $g['product_name'] . '-repo'; - $repo_devel = $g['product_name'] . '-repo-devel'; + $path = "/usr/local/share/{$g['product_name']}/pkg/repos"; - if ($devel) { - $repo_target = $repo_devel; - } else { - $repo_target = $repo_stable; - } + $default_descr = @file_get_contents($path . "/{$g['product_name']}-repo.descr"); - if (is_pkg_installed($repo_target)) { - /* It's already installed */ - return true; + $default = array( + 'name' => 'Default', + 'path' => $path . "/{$g['product_name']}-repo.conf", + 'descr' => $default_descr + ); + + $result = array($default); + + $conf_files = glob("{$path}/{$g['product_name']}-repo-*.conf"); + foreach ($conf_files as $conf_file) { + $descr_file = preg_replace('/.conf$/', '.descr', $conf_file); + if (file_exists($descr_file)) { + $descr_content = file($descr_file); + $descr = chop($descr_content[0]); + } else { + $descr = 'Unknown'; + } + if (!preg_match('/-repo-(.*).conf/', $conf_file, $matches)) { + continue; + } + $entry = array( + 'name' => ucfirst(strtolower($matches[1])), + 'path' => $conf_file, + 'descr' => $descr + ); + $result[] = $entry; } - /* - * Since both install files in the same place, just - * call pkg_install for target and current one will - * be replaced - */ - return pkg_install($repo_target, true); + return $result; +} + +/* Switch between stable and devel repos */ +function pkg_switch_repo($path) { + global $g; + + safe_mkdir("/usr/local/etc/pkg/repos"); + @unlink("/usr/local/etc/pkg/repos/{$g['product_name']}.conf"); + @symlink($path, "/usr/local/etc/pkg/repos/{$g['product_name']}.conf"); + + return pkg_update(true); } ?> diff --git a/src/etc/pfSense.obsoletedfiles b/src/etc/pfSense.obsoletedfiles index 16854e5..7df07d8 100644 --- a/src/etc/pfSense.obsoletedfiles +++ b/src/etc/pfSense.obsoletedfiles @@ -743,6 +743,7 @@ /usr/local/share/misc /usr/local/share/nls /usr/local/share/pbi-keys +/usr/local/share/pfSense/pfSense-repo-devel.conf /usr/local/share/protocols /usr/local/share/sgml /usr/local/share/skel |