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/usr | |
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/usr')
-rwxr-xr-x | src/usr/local/sbin/pfSense-upgrade | 26 | ||||
-rw-r--r-- | src/usr/local/www/system_update_settings.php | 53 |
2 files changed, 64 insertions, 15 deletions
diff --git a/src/usr/local/sbin/pfSense-upgrade b/src/usr/local/sbin/pfSense-upgrade index e0a0139..de83de1 100755 --- a/src/usr/local/sbin/pfSense-upgrade +++ b/src/usr/local/sbin/pfSense-upgrade @@ -292,11 +292,7 @@ pkg_upgrade() { pkg_update force fi - if is_pkg_installed ${product}-repo-devel; then - local _repo_pkg="${product}-repo-devel" - else - local _repo_pkg="${product}-repo" - fi + local _repo_pkg="${product}-repo" if [ "$(compare_pkg_version ${_repo_pkg})" = "<" ]; then cp /usr/local/etc/pkg/repos/${product}.conf \ @@ -722,6 +718,26 @@ else export HTTP_USER_AGENT="${product}/${product_version}" fi +# Make sure to use default repo conf when it doesn't exist +pkg_repo_conf="/usr/local/etc/pkg/repos/${product}.conf" +default_pkg_repo_conf_path="/usr/local/share/${product}/pkg/repos/${product}-repo.conf" + +pkg_repo_conf_path=$(/usr/local/sbin/read_xml_tag.sh string system/pkg_repo_conf_path \ + ${default_pkg_repo_conf_path}) + +if [ -z "${pkg_repo_conf_path}" -o ! -f "${pkg_repo_conf_path}" ]; then + pkg_repo_conf_path=${default_pkg_repo_conf_path} +fi + +if [ -e "${pkg_repo_conf}" -a ! -L "${pkg_repo_conf}" ]; then + rm -f ${pkg_repo_conf} + ln -sf ${pkg_repo_conf_path} ${pkg_repo_conf} +fi + +if [ "$(readlink ${pkg_repo_conf})" != "${pkg_repo_conf_path}" ]; then + ln -sf ${pkg_repo_conf_path} ${pkg_repo_conf} +fi + # Flags used in _exit export delete_annotation="" export unlock_additional_pkgs="" diff --git a/src/usr/local/www/system_update_settings.php b/src/usr/local/www/system_update_settings.php index d99ea9a..8c7a6f2 100644 --- a/src/usr/local/www/system_update_settings.php +++ b/src/usr/local/www/system_update_settings.php @@ -64,7 +64,10 @@ require("guiconfig.inc"); require("pkg-utils.inc"); +$repos = pkg_list_repos(); + if ($_POST) { + // Set the firmware branch, but only if we are not using it already if ($_POST['fwbranch']) { if (($_POST['fwbranch'] == "development") && !is_pkg_installed($g['product_name'] . "-repo-devel")) { @@ -87,10 +90,21 @@ if ($_POST) { } elseif (isset($config['system']['gitsync']['synconupgrade'])) { unset($config['system']['gitsync']['synconupgrade']); } + $config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl']; $config['system']['gitsync']['branch'] = $_POST['branch']; + foreach ($repos as $repo) { + if ($repo['name'] == $_POST['fwbranch']) { + $config['system']['pkg_repo_conf_path'] = $repo['path']; + pkg_switch_repo($repo['path']); + break; + } + } + write_config(); + + $savemsg = gettext("Changes have been saved successfully"); } $curcfg = $config['system']['firmware']; @@ -103,6 +117,32 @@ if (file_exists("{$g['tmp_path']}/manifest")) { $preset_urls_split = explode("\n", file_get_contents("{$g['tmp_path']}/manifest")); } +// Create an array of repo names and descriptions to populate the "Branch" selector +function build_repo_list() { + global $repos; + + $list = array(); + + foreach ($repos as $repo) { + $list[$repo['name']] = $repo['descr']; + } + + return($list); +} + +function get_repo_name($path) { + global $repos; + + foreach ($repos as $repo) { + if ($repo['path'] == $path) { + return $repo['name']; + } + } + + /* Default */ + return $repos[0]['name']; +} + include("head.inc"); if ($input_errors) { @@ -125,22 +165,15 @@ $section = new Form_Section('Firmware Branch'); $section->addInput(new Form_Select( fwbranch, 'Branch', - (is_pkg_installed($g['product_name'] . "-repo")) ? "stable":"development", - ["stable" => gettext("Stable"), "development" => gettext("Development")] + get_repo_name($config['system']['pkg_repo_conf_path']), + build_repo_list() ))->setHelp('Please select the stable, or the development branch from which to update the system firmware. ' . ' <br />' . 'Use of the development version is at your own risk!'); $form->add($section); $section = new Form_Section('Updates'); -/* -$section->addInput(new Form_Checkbox( - 'allowinvalidsig', - 'Unsigned images', - 'Allow auto-update firmware images with a missing or invalid digital signature to be used', - isset($curcfg['allowinvalidsig']) - )); -*/ + $section->addInput(new Form_Checkbox( 'disablecheck', 'Dashboard check', |