diff --git a/debian/copyright b/debian/copyright index 4e1eb7ae5..3928b60a2 100644 --- a/debian/copyright +++ b/debian/copyright @@ -327,6 +327,13 @@ Copyright: 2005 Andrew Dolgov Comment: https://git.tt-rss.org/fox/tt-rss/src/master/images/favicon-72px.png License: GPL-3+ +Files: plinth/modules/upgrades/data/usr/share/augeas/lenses/aptsources.aug + plinth/modules/upgrades/data/usr/share/augeas/lenses/tests/test_aptsources.aug +Copyright: 2007-2025 David Lutterkort +Comment: https://github.com/hercules-team/augeas/blob/master/lenses/aptsources.aug + https://github.com/hercules-team/augeas/blob/master/lenses/tests/test_aptsources.aug +License: LGPL-2.1+ + Files: plinth/modules/wordpress/static/icons/wordpress.png plinth/modules/wordpress/static/icons/wordpress.svg Copyright: 2011-2021 WordPress Contributors diff --git a/plinth/modules/upgrades/data/usr/share/augeas/lenses/aptsources.aug b/plinth/modules/upgrades/data/usr/share/augeas/lenses/aptsources.aug new file mode 100644 index 000000000..e8b7f3ab5 --- /dev/null +++ b/plinth/modules/upgrades/data/usr/share/augeas/lenses/aptsources.aug @@ -0,0 +1,72 @@ +(* +Module: Aptsources + Parsing /etc/apt/sources.list +*) + +module Aptsources = + autoload xfm + +(************************************************************************ + * Group: Utility variables/functions + ************************************************************************) + (* View: sep_ws *) + let sep_ws = Sep.space + + (* View: eol *) + let eol = Util.del_str "\n" + + (* View: comment *) + let comment = Util.comment + (* View: empty *) + let empty = Util.empty + + (* View: word *) + let word = /[^][# \n\t]+/ + + (* View: uri *) + let uri = + let protocol = /[a-z+]+:/ + in let path = /\/[^] \t]*/ + in let path_brack = /\[[^]]+\]\/?/ + in protocol? . path + | protocol . path_brack + +(************************************************************************ + * Group: Keywords + ************************************************************************) + (* View: record *) + let record = + let option_key = /[^= \t\r\n]*[^-+= \t\r\n]/ + in let option_sep = [ label "operation" . store /[+-]/]? . Sep.equal + in let option_value = (store /[^] \t\r\n]+/) + in let option = Build.key_value option_key option_sep option_value + in let options = [ label "options" + . Util.del_str "[" . Sep.opt_space + . Build.opt_list option Sep.space + . Sep.opt_space . Util.del_str "]" + . sep_ws ] + in [ Util.indent . seq "source" + . [ label "type" . store word ] . sep_ws + . options? + . [ label "uri" . store uri ] . sep_ws + . [ label "distribution" . store word ] + . [ label "component" . sep_ws . store word ]* + . del /[ \t]*(#.*)?/ "" + . eol ] + +(************************************************************************ + * Group: Lens + ************************************************************************) + (* View: lns *) + let lns = ( comment | empty | record ) * + + (* View: filter *) + let filter = (incl "/etc/apt/sources.list") + . (incl "/etc/apt/sources.list.d/*") + . Util.stdexcl + + let xfm = transform lns filter + +(* Local Variables: *) +(* mode: caml *) +(* End: *) diff --git a/plinth/modules/upgrades/data/usr/share/augeas/lenses/tests/test_aptsources.aug b/plinth/modules/upgrades/data/usr/share/augeas/lenses/tests/test_aptsources.aug new file mode 100644 index 000000000..d72d8fb1f --- /dev/null +++ b/plinth/modules/upgrades/data/usr/share/augeas/lenses/tests/test_aptsources.aug @@ -0,0 +1,110 @@ +module Test_aptsources = + + let simple_source = "deb ftp://mirror.bytemark.co.uk/debian/ etch main\n" + let multi_components = "deb http://security.debian.org/ etch/updates main contrib non-free\n" + + test Aptsources.lns get simple_source = + { "1" + { "type" = "deb" } + { "uri" = "ftp://mirror.bytemark.co.uk/debian/" } + { "distribution" = "etch" } + { "component" = "main" } + } + + test Aptsources.lns get multi_components = + { "1" + { "type" = "deb" } + { "uri" = "http://security.debian.org/" } + { "distribution" = "etch/updates" } + { "component" = "main" } + { "component" = "contrib" } + { "component" = "non-free" } + } + + +let multi_line = "#deb http://www.backports.org/debian/ sarge postfix + # deb http://people.debian.org/~adconrad sarge subversion + +deb ftp://mirror.bytemark.co.uk/debian/ etch main non-free contrib + deb http://security.debian.org/ etch/updates main contrib non-free # security line + deb-src http://mirror.bytemark.co.uk/debian etch main contrib non-free\n" + + test Aptsources.lns get multi_line = + { "#comment" = "deb http://www.backports.org/debian/ sarge postfix" } + { "#comment" = "deb http://people.debian.org/~adconrad sarge subversion" } + {} + { "1" + { "type" = "deb" } + { "uri" = "ftp://mirror.bytemark.co.uk/debian/" } + { "distribution" = "etch" } + { "component" = "main" } + { "component" = "non-free" } + { "component" = "contrib" } + } + { "2" + { "type" = "deb" } + { "uri" = "http://security.debian.org/" } + { "distribution" = "etch/updates" } + { "component" = "main" } + { "component" = "contrib" } + { "component" = "non-free" } + } + { "3" + { "type" = "deb-src" } + { "uri" = "http://mirror.bytemark.co.uk/debian" } + { "distribution" = "etch" } + { "component" = "main" } + { "component" = "contrib" } + { "component" = "non-free" } + } + + let trailing_comment = "deb ftp://server/debian/ etch main # comment\n" + + (* Should be a noop; makes sure that we preserve the trailing comment *) + test Aptsources.lns put trailing_comment after + set "/1/type" "deb" + = trailing_comment + + (* Support options, GH #295 *) + test Aptsources.lns get "deb [arch=amd64] tor+http://ftp.us.debian.org/debian sid main contrib +deb [ arch+=amd64 trusted-=true ] http://ftp.us.debian.org/debian sid main contrib +deb [signed-by=/usr/share/keyrings/debian-archive-trixie-stable.gpg] http://deb.debian.org/debian trixie main\n" = + { "1" + { "type" = "deb" } + { "options" + { "arch" = "amd64" } + } + { "uri" = "tor+http://ftp.us.debian.org/debian" } + { "distribution" = "sid" } + { "component" = "main" } + { "component" = "contrib" } } + { "2" + { "type" = "deb" } + { "options" + { "arch" = "amd64" { "operation" = "+" } } + { "trusted" = "true" { "operation" = "-" } } + } + { "uri" = "http://ftp.us.debian.org/debian" } + { "distribution" = "sid" } + { "component" = "main" } + { "component" = "contrib" } } + { "3" + { "type" = "deb" } + { "options" + { "signed-by" = "/usr/share/keyrings/debian-archive-trixie-stable.gpg" } } + { "uri" = "http://deb.debian.org/debian" } + { "distribution" = "trixie" } + { "component" = "main" } } + + (* cdrom entries may have spaces, GH #296 *) + test Aptsources.lns get "deb cdrom:[Debian GNU/Linux 7.5.0 _Wheezy_ - Official amd64 CD Binary-1 20140426-13:37]/ wheezy main\n" = + { "1" + { "type" = "deb" } + { "uri" = "cdrom:[Debian GNU/Linux 7.5.0 _Wheezy_ - Official amd64 CD Binary-1 20140426-13:37]/" } + { "distribution" = "wheezy" } + { "component" = "main" } } + + +(* Local Variables: *) +(* mode: caml *) +(* End: *)