Gentoo Archives: gentoo-commits

From: "Ulrich Mueller (ulm)" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] eselect r508 - in trunk: . man modules
Date: Sun, 26 Apr 2009 17:02:49
Message-Id: E1Ly7kd-00042M-0x@stork.gentoo.org
1 Author: ulm
2 Date: 2009-04-26 17:02:46 +0000 (Sun, 26 Apr 2009)
3 New Revision: 508
4
5 Modified:
6 trunk/NEWS
7 trunk/man/news-tng.eselect.5
8 trunk/modules/news-tng.eselect
9 Log:
10 Fix file permissions. Add option "--raw".
11
12 Modified: trunk/NEWS
13 ===================================================================
14 --- trunk/NEWS 2009-04-25 20:16:18 UTC (rev 507)
15 +++ trunk/NEWS 2009-04-26 17:02:46 UTC (rev 508)
16 @@ -13,6 +13,7 @@
17 - Allow setting system-wide default dictionary.
18 - Treat 'help' and 'version' options as if they were actions.
19 - Modules for the EDITOR, VISUAL, and PAGER environment variables.
20 + - Module news-tng.eselect for reading Gentoo ('GLEP 42') news.
21
22 1.0.12:
23 Bug fixes:
24
25 Modified: trunk/man/news-tng.eselect.5
26 ===================================================================
27 --- trunk/man/news-tng.eselect.5 2009-04-25 20:16:18 UTC (rev 507)
28 +++ trunk/man/news-tng.eselect.5 2009-04-26 17:02:46 UTC (rev 508)
29 @@ -12,6 +12,7 @@
30 .B eselect news-tng list
31 .br
32 .B eselect news-tng read
33 +.RB [ \-\-raw ]
34 .RI [ item ...]
35 .br
36 .B eselect news-tng unread
37 @@ -39,6 +40,7 @@
38 [3] 2009-04-06 (read) Migration to X.org Server 1.5
39 .SH ACTION: READ
40 .B eselect news-tng read
41 +.RB [ \-\-raw ]
42 .RI [ item ...]
43 .br
44 Read news item(s), selected by their
45 @@ -51,6 +53,9 @@
46 .B all
47 select all unread items or all items, respectively.
48 Default is to read all unread news, if no item is specified.
49 +With option
50 +.BR \-\-raw ,
51 +output the item in raw format.
52 .SH ACTION: UNREAD
53 .B eselect news-tng unread
54 .RI [ item ...]
55
56 Modified: trunk/modules/news-tng.eselect
57 ===================================================================
58 --- trunk/modules/news-tng.eselect 2009-04-25 20:16:18 UTC (rev 507)
59 +++ trunk/modules/news-tng.eselect 2009-04-26 17:02:46 UTC (rev 508)
60 @@ -41,14 +41,17 @@
61 [[ ${item%%/*} = ${repo} ]] && update="${update} ${item#*/}"
62 done
63 file="${ROOT}${NEWS_DIR}/news-${repo}.${stat}"
64 - if [[ ! -w ${file} ]]; then
65 + for item in ${update}; do
66 + echo "${item}"
67 + done >"${file}"
68 + if [[ $? -ne 0 ]]; then
69 write_error_msg \
70 "Cannot update list of news items for repository \"${repo}\""
71 return 1
72 fi
73 - for item in ${update}; do
74 - echo "${item}"
75 - done >"${file}" || die "Error writing file ${file}"
76 + # GLEP 42 says the file should be in the portage group and group writable
77 + chgrp portage "${file}" 2>/dev/null && chmod 664 "${file}" 2>/dev/null
78 + return 0
79 }
80
81 # read a given item
82 @@ -159,6 +162,7 @@
83 echo "new : Read unread news items (default)"
84 echo "all : Read all news items"
85 echo "item : Number of item (from 'list' action)"
86 + echo "--raw : Output in raw format"
87 }
88
89 describe_read_parameters() {
90 @@ -168,9 +172,14 @@
91 do_read() {
92 package-manager &>/dev/null # for internal caching
93 local -a items=( $(find_items unread read) ) repos dirs
94 - local n=${#items[@]} item repo stat dir header line i seq repos_upd
95 + local n=${#items[@]} item repo stat dir header line i seq repos_upd raw
96 local ifs_save=${IFS-$' \t\n'}
97
98 + if [[ $1 = --raw ]]; then
99 + raw=1
100 + shift
101 + fi
102 +
103 # expand special values "new" and "all"
104 if [[ $# -eq 0 || $1 = new || $1 = all ]]; then
105 for (( i = 1; i <= n; i++ )); do
106 @@ -190,22 +199,26 @@
107 stat=${item%%/*}; item=${item#*/}
108 repo=${item%%/*}; item=${item#*/}
109 find_repo_dir ${repo}
110 - write_list_start "${item}"
111 - header=$(read_item "${dir}" "${item}" header)
112 - IFS=$'\n'
113 - for line in ${header}; do
114 - case "${line%%: *}" in
115 - Title)
116 - write_kv_list_entry \
117 - "${line%%: *}" "$(highlight "${line#*: }")" ;;
118 - Author|Posted|Revision)
119 - write_kv_list_entry "${line%%: *}" "${line#*: }" ;;
120 - esac
121 - done
122 - IFS=${ifs_save}
123 + if [[ -n ${raw} ]]; then
124 + read_item "${dir}" "${item}"
125 + else
126 + write_list_start "${item}"
127 + header=$(read_item "${dir}" "${item}" header)
128 + IFS=$'\n'
129 + for line in ${header}; do
130 + case "${line%%: *}" in
131 + Title)
132 + write_kv_list_entry \
133 + "${line%%: *}" "$(highlight "${line#*: }")" ;;
134 + Author|Posted|Revision)
135 + write_kv_list_entry "${line%%: *}" "${line#*: }" ;;
136 + esac
137 + done
138 + IFS=${ifs_save}
139 + echo
140 + read_item "${dir}" "${item}" body
141 + fi
142 echo
143 - read_item "${dir}" "${item}" body
144 - echo
145
146 [[ ${stat} = unread ]] || continue
147 # move from "unread" to "read"