Skip to content

Commit

Permalink
Add APT management plugin
Browse files Browse the repository at this point in the history
Fixes: openmediavault#1774

Signed-off-by: Volker Theile <votdev@gmx.de>
  • Loading branch information
votdev committed Jun 16, 2024
1 parent f530ad2 commit ca0f70f
Show file tree
Hide file tree
Showing 90 changed files with 3,443 additions and 155 deletions.
6 changes: 6 additions & 0 deletions deb/.tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ source_file = openmediavault/usr/share/openmediavault/locale/openmediavault.pot
source_lang = en
type = PO

[o:openmediavault:p:openmediavault:r:openmediavault-apt]
file_filter = openmediavault-apt/usr/share/openmediavault/locale/<lang>/openmediavault-apt.po
source_file = openmediavault-apt/usr/share/openmediavault/locale/openmediavault-apt.pot
source_lang = en
type = PO

[o:openmediavault:p:openmediavault:r:openmediavault-clamav]
file_filter = openmediavault-clamav/usr/share/openmediavault/locale/<lang>/openmediavault-clamav.po
source_file = openmediavault-clamav/usr/share/openmediavault/locale/openmediavault-clamav.pot
Expand Down
8 changes: 8 additions & 0 deletions deb/openmediavault-apt/debian/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/files
/*.debhelper.log
/*.postinst.debhelper
/*.postrm.debhelper
/*.substvars
/*-stamp
/openmediavault-apt/
/.debhelper/
5 changes: 5 additions & 0 deletions deb/openmediavault-apt/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
openmediavault-apt (7.0) stable; urgency=low

* Initial release.

-- Volker Theile <volker.theile@openmediavault.org> Mon, 10 Jun 2024 18:19:58 +0200
1 change: 1 addition & 0 deletions deb/openmediavault-apt/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
15 changes: 15 additions & 0 deletions deb/openmediavault-apt/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Source: openmediavault-apt
Section: admin
XB-Plugin-Section: utilities
Priority: optional
Maintainer: Volker Theile <volker.theile@openmediavault.org>
Build-Depends: debhelper (>= 12), gettext
Standards-Version: 3.9.6
Homepage: https://www.openmediavault.org

Package: openmediavault-apt
Architecture: all
Depends: openmediavault (>= 7.3)
Priority: optional
Description: openmediavault APT management plugin
Manage APT (Advanced Package Tool) repositories easily.
7 changes: 7 additions & 0 deletions deb/openmediavault-apt/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Format: http://dep.debian.net/deps/dep5
Upstream-Contact: Volker Theile <volker.theile@openmediavault.org>
Source: http://www.openmediavault.org

Files: *
Copyright: 2009-2024 Volker Theile <volker.theile@openmediavault.org>
License: GPL-3
2 changes: 2 additions & 0 deletions deb/openmediavault-apt/debian/openmediavault-apt.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
usr/share/openmediavault/* usr/share/openmediavault/
srv/* srv/
53 changes: 53 additions & 0 deletions deb/openmediavault-apt/debian/openmediavault-apt.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env dash
#
# This file is part of OpenMediaVault.
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <volker.theile@openmediavault.org>
# @copyright Copyright (c) 2009-2024 Volker Theile
#
# OpenMediaVault is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# OpenMediaVault is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.

set -e

. /etc/default/openmediavault
. /usr/share/openmediavault/scripts/helper-functions

case "$1" in
configure)
########################################################################
# Activate trigger to rebuild workbench configuration files.
########################################################################
dpkg-trigger update-workbench

########################################################################
# Initialize and migrate configuration database.
########################################################################
echo "Updating configuration database ..."
omv-confdbadm create "conf.system.apt.source"
if [ -n "$2" ]; then
omv-confdbadm migrate "conf.system.apt.source" "${2}"
fi
;;

abort-upgrade|abort-remove|abort-deconfigure)
;;

*)
echo "postinst called with unknown argument '$1'" >&2
exit 1
;;
esac

exit 0
57 changes: 57 additions & 0 deletions deb/openmediavault-apt/debian/openmediavault-apt.postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env dash
#
# This file is part of OpenMediaVault.
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <volker.theile@openmediavault.org>
# @copyright Copyright (c) 2009-2024 Volker Theile
#
# OpenMediaVault is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# OpenMediaVault is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.

set -e

. /etc/default/openmediavault
. /usr/share/openmediavault/scripts/helper-functions

remove_action() {
# Activate trigger to rebuild workbench configuration files.
dpkg-trigger update-workbench
}

case "$1" in
purge)
remove_action
# Remove the configuration data. Sadly we can not use 'omv-confdbadm'
# here because the database model has been removed already in a
# previous stage, see https://wiki.debian.org/MaintainerScripts.
# Because of that we need to use the helper tools to remove the
# configuration.
echo "Cleaning up configuration database ..."
omv_config_delete "/config/system/apt/sources"
;;

remove)
remove_action
;;

upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
;;

*)
echo "postrm called with unknown argument '$1'" >&2
exit 1
;;
esac

exit 0
34 changes: 34 additions & 0 deletions deb/openmediavault-apt/debian/openmediavault-apt.prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env dash
#
# This file is part of OpenMediaVault.
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <volker.theile@openmediavault.org>
# @copyright Copyright (c) 2009-2024 Volker Theile
#
# OpenMediaVault is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# OpenMediaVault is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.

set -e

case "$1" in
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
;;

*)
echo "prerm called with unknown argument '$1'" >&2
exit 1
;;
esac

exit 0
1 change: 1 addition & 0 deletions deb/openmediavault-apt/debian/openmediavault-apt.triggers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
activate restart-engined
9 changes: 9 additions & 0 deletions deb/openmediavault-apt/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include ../openmediavault.mk

%:
dh $@
1 change: 1 addition & 0 deletions deb/openmediavault-apt/debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (native)
47 changes: 47 additions & 0 deletions deb/openmediavault-apt/srv/salt/omv/deploy/apt/20sources.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file is part of OpenMediaVault.
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <volker.theile@openmediavault.org>
# @copyright Copyright (c) 2009-2024 Volker Theile
#
# OpenMediaVault is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# OpenMediaVault is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.

# Documentation/Howto:
# https://repolib.readthedocs.io/en/latest/deb822-format.html#deb822-style-format

{% set sources_prefix = salt['pillar.get']('default:OMV_APT_SOURCES_LIST_DEB822_PREFIX', 'openmediavault-') %}
{% set sources = salt['omv_conf.get']('conf.system.apt.source') %}

cleanup_apt_sources_list_deb822:
module.run:
- file.find:
- path: "/etc/apt/sources.list.d/"
- iname: "{{ sources_prefix }}*.sources"
- delete: "f"

{% for item in sources %}

configure_apt_sources_list_deb822_{{ item.uuid }}:
file.managed:
- name: "/etc/apt/sources.list.d/{{ sources_prefix }}{{ item.uuid }}.sources"
- source:
- salt://{{ tpldir }}/files/etc-apt-sources_list_d-sources.j2
- context:
config: {{ item | json }}
- template: jinja
- user: root
- group: root
- mode: 644

{% endfor %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Enabled: {{ config.enable | to_bool | yesno }}
Types: {{ config.types }}
URIs: {{ config.uris }}
Suites: {{ config.suites }}
Components: {{ config.components }}
{%- if config.signedby | length > 0 %}
Signed-By: {{ config.signedby | indent(1) }}
{%- endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env dash
#
# This file is part of OpenMediaVault.
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <volker.theile@openmediavault.org>
# @copyright Copyright (c) 2009-2024 Volker Theile
#
# OpenMediaVault is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# OpenMediaVault is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.

set -e

. /usr/share/openmediavault/scripts/helper-functions

########################################################################
# Update the configuration.
# See https://repolib.readthedocs.io/en/latest/deb822-format.html#deb822-style-format
# <config>
# <system>
# <apt>
# <sources>
# <!--
# <item>
# <uuid>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</uuid>
# <enable>0|1</enable>
# <types>xxx</types>
# <uris>xxx</uris>
# <suites>xxx</suites>
# <components>xxx</components>
# <signedby>xxx</signedby>
# <comment>xxx</comment>
# </item>
# -->
# </sources>
# </apt>
# </system>
# </config>
########################################################################
if ! omv-confdbadm exists "conf.system.apt.source"; then
omv_config_add_node "/config/system/apt" "sources"
fi

exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"type": "config",
"id": "conf.system.apt.source",
"title": "APT source",
"queryinfo": {
"xpath": "//system/apt/sources/item",
"iterable": true,
"idproperty": "uuid"
},
"properties": {
"uuid": {
"type": "string",
"format": "uuidv4",
"default": ""
},
"enable": {
"type": "boolean",
"default": false
},
"types": {
"type": "string",
"default": ""
},
"uris": {
"type": "string",
"default": ""
},
"suites": {
"type": "string",
"default": ""
},
"components": {
"type": "string",
"default": ""
},
"signedby": {
"type": "string",
"oneOf": [{
"type": "string",
"format": "pgppubkey"
},{
"type": "string",
"maxLength": 0
}],
"default": ""
},
"comment": {
"type": "string",
"default": ""
}
}
}
Loading

0 comments on commit ca0f70f

Please sign in to comment.