Commit 61fc13b3 authored by Franco Fichtner's avatar Franco Fichtner

firmware: add changelogs tab, pull in index through info action #341

parent dd50e688
......@@ -379,6 +379,14 @@ class FirmwareController extends ApiControllerBase
}
}
/* also pull in changelogs from here */
$changelogs = json_decode(trim($backend->configdRun('firmware changelog list')), true);
if ($changelogs == null) {
$changelogs = array();
}
$response['changelog'] = $changelogs;
return $response;
}
......
......@@ -198,6 +198,7 @@ POSSIBILITY OF SUCH DAMAGE.
ajaxGet('/api/core/firmware/info', {}, function (data, status) {
$('#packageslist').empty();
$('#pluginlist').empty();
$('#changeloglist').empty();
var installed = {};
$("#packageslist").html("<tr><th>{{ lang._('Name') }}</th>" +
......@@ -206,6 +207,8 @@ POSSIBILITY OF SUCH DAMAGE.
$("#pluginlist").html("<tr><th>{{ lang._('Name') }}</th>" +
"<th>{{ lang._('Version') }}</th><th>{{ lang._('Size') }}</th>" +
"<th>{{ lang._('Comment') }}</th><th></th></tr>");
$("#changeloglist").html("<tr><th>{{ lang._('Version') }}</th>" +
"<th>{{ lang._('Date') }}</th><th></th></tr>");
$.each(data['local'], function(index, row) {
$('#packageslist').append(
......@@ -233,6 +236,12 @@ POSSIBILITY OF SUCH DAMAGE.
installed[row['name']] = row;
});
if (!data['local'].length) {
$('#packageslist').append(
'<tr><td colspan=5>{{ lang._('No packages were found on your system. Please call for help.') }}</td></tr>'
);
}
$.each(data['remote'], function(index, row) {
if (!row['name'].match(/^os-/g)) {
return 1;
......@@ -261,6 +270,20 @@ POSSIBILITY OF SUCH DAMAGE.
);
}
$.each(data['changelog'], function(index, row) {
$('#changeloglist').append(
'<tr><td>' + row['version'] + '</td>' +
'<td>' + row['date'] + '</td>' +
'<td>not yet</td></tr>'
);
});
if (!data['changelog'].length) {
$('#changeloglist').append(
'<tr><td colspan=3>{{ lang._('Check for updates to view changelog history.') }}</td></tr>'
);
}
// link buttons to actions
$(".act_reinstall").click(function(event) {
event.preventDefault();
......@@ -402,8 +425,6 @@ POSSIBILITY OF SUCH DAMAGE.
$("#change_mirror_progress").removeClass("fa fa-spinner fa-pulse");
});
});
});
</script>
......@@ -422,6 +443,7 @@ POSSIBILITY OF SUCH DAMAGE.
<li id="settingstab" class="active"><a data-toggle="tab" href="#settings">{{ lang._('Settings') }}</a></li>
<li id="packagestab"><a data-toggle="tab" href="#packages">{{ lang._('Packages') }}</a></li>
<li id="plugintab"><a data-toggle="tab" href="#plugins">{{ lang._('Plugins') }}</a></li>
<li id="changelogtab"><a data-toggle="tab" href="#changelogs">{{ lang._('Changelogs') }}</a></li>
<li id="updatetab"><a data-toggle="tab" href="#updates">{{ lang._('Updates') }}</a></li>
<li id="progresstab"><a data-toggle="tab" href="#progress">{{ lang._('Progress') }}</a></li>
</ul>
......@@ -476,7 +498,7 @@ POSSIBILITY OF SUCH DAMAGE.
<tr>
<td></td>
<td>
<button class="btn btn-primary" id="change_mirror" type="button"><b>{{ lang._('Save') }}</b><i id="change_mirror_progress" class=""></i></button>
<button class="btn btn-primary" id="change_mirror" type="button"><b>{{ lang._('Save') }}</b><i id="change_mirror_progress" class=""></i></button>
</td>
<td></td>
</tr>
......@@ -489,16 +511,16 @@ POSSIBILITY OF SUCH DAMAGE.
</table>
</div>
<div id="packages" class="tab-pane fade in">
<table class="table table-striped table-condensed table-responsive" id="packageslist">
</table>
<table class="table table-striped table-condensed table-responsive" id="packageslist"></table>
</div>
<div id="plugins" class="tab-pane fade in">
<table class="table table-striped table-condensed table-responsive" id="pluginlist">
</table>
<table class="table table-striped table-condensed table-responsive" id="pluginlist"></table>
</div>
<div id="changelogs" class="tab-pane fade in">
<table class="table table-striped table-condensed table-responsive" id="changeloglist"></table>
</div>
<div id="updates" class="tab-pane fade in">
<table class="table table-striped table-condensed table-responsive" id="updatelist">
</table>
<table class="table table-striped table-condensed table-responsive" id="updatelist"></table>
</div>
<div id="progress" class="tab-pane fade in">
<textarea name="output" id="update_status" class="form-control" rows="20" wrap="hard" readonly style="max-width:100%; font-family: monospace;"></textarea>
......
......@@ -27,25 +27,57 @@
set -e
CORE_ABI=$(cat /usr/local/opnsense/version/opnsense.abi 2> /dev/null)
SYS_ABI=$(opnsense-verify -a 2> /dev/null)
URL="https://pkg.opnsense.org"
URL="${URL}/${SYS_ABI}/${CORE_ABI}"
URL="${URL}/sets/changelog.txz"
DESTDIR="/usr/local/opnsense/changelog"
WORKDIR="/tmp/changelog"
FETCH="fetch -aqT 5"
rm -rf ${WORKDIR}
mkdir -p ${WORKDIR}
changelog_remove()
{
rm -rf ${DESTDIR}
mkdir -p ${DESTDIR}
}
changelog_fetch()
{
CORE_ABI=$(cat /usr/local/opnsense/version/opnsense.abi 2> /dev/null)
SYS_ABI=$(opnsense-verify -a 2> /dev/null)
URL="https://pkg.opnsense.org"
URL="${URL}/${SYS_ABI}/${CORE_ABI}"
URL="${URL}/sets/changelog.txz"
rm -rf ${WORKDIR}
mkdir -p ${WORKDIR}
${FETCH} -o ${WORKDIR}/changelog.txz.sig "${URL}.sig"
${FETCH} -o ${WORKDIR}/changelog.txz "${URL}"
opnsense-verify -q ${WORKDIR}/changelog.txz
changelog_remove
tar -C ${DESTDIR} -xJf ${WORKDIR}/changelog.txz
}
changelog_show()
{
FILE="${DESTDIR}/${1}"
${FETCH} -o ${WORKDIR}/changelog.txz.sig "${URL}.sig"
${FETCH} -o ${WORKDIR}/changelog.txz "${URL}"
opnsense-verify -q ${WORKDIR}/changelog.txz
if [ -f "${FILE}" ]; then
cat "${FILE}"
fi
}
rm -rf ${DESTDIR}
mkdir -p ${DESTDIR}
COMMAND=${1}
VERSION=${2}
tar -C ${DESTDIR} -xJf ${WORKDIR}/changelog.txz
if [ "${COMMAND}" = "fetch" ]; then
changelog_fetch
elif [ "${COMMAND}" = "remove" ]; then
changelog_remove
elif [ "${COMMAND}" = "list" ]; then
changelog_show index.json
elif [ "${COMMAND}" = "html" -a -n "${VERSION}" ]; then
changelog_show "$(basename ${VERSION}).htm"
elif [ "${COMMAND}" = "text" -a -n "${VERSION}" ]; then
changelog_show "$(basename ${VERSION}).txt"
fi
......@@ -63,7 +63,7 @@ tmp_pkg_update_file="/tmp/pkg_updates.output"
pkg_running=`ps -x | grep "pkg " | grep -v "grep"`
if [ "$pkg_running" == "" ]; then
# load changelogs first
/usr/local/opnsense/scripts/firmware/changelog.sh
/usr/local/opnsense/scripts/firmware/changelog.sh fetch
# start pkg update
pkg update -f > $tmp_pkg_update_file &
pkg_running="started" # Set running state to arbitrary value
......
......@@ -4,6 +4,24 @@ parameters:
type:script_output
message:retrieve firmware update status
[changelog.list]
command: /usr/local/opnsense/scripts/firmware/changelog.sh list
parameters:
type:script_output
message:Retrieving changelog index
[changelog.html]
command: /usr/local/opnsense/scripts/firmware/changelog.sh html
parameters:%s
type:script_output
message:Viewing changelog for version %s
[changelog.text]
command: /usr/local/opnsense/scripts/firmware/changelog.sh text
parameters:%s
type:script_output
message:Viewing changelog for version %s
[running]
command:/usr/local/opnsense/scripts/firmware/running.sh
parameters:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment