View | Details | Raw Unified | Return to bug 36048
Collapse All | Expand All

(-)a/.gear/rules (+2 lines)
Lines 2-7 tar: grub Link Here
2
tar: grub-extras
2
tar: grub-extras
3
copy: grub2-sysconfig
3
copy: grub2-sysconfig
4
copy: grub*-autoupdate
4
copy: grub*-autoupdate
5
copy: grub-entries
6
copy: grub-entries.8
5
copy: *.patch
7
copy: *.patch
6
copy: alt/*
8
copy: alt/*
7
copy: *.filetrigger
9
copy: *.filetrigger
(-)a/grub-entries (+141 lines)
Line 0 Link Here
1
#!/bin/sh -efu
2
### This file is covered by the GNU General Public License
3
### version 2 or later.
4
###
5
### Copyright (C) 2019  ALT Linux Team
6
### Author: Leonid Krivoshein <klark@altlinux.org>
7
8
numbers_only=0
9
titles_only=0
10
search_item=
11
progname="${0##*/}"
12
grubmenu="/boot/grub/grub.cfg"
13
14
15
show_help() {
16
	cat <<-EOF
17
$progname - Show default or specified grub menu.
18
19
Usage: $progname [options]
20
21
Options:
22
  -f, --config=  Specify path to the grub config.
23
  -n, --numbers  Show only menu item sequence numbers.
24
  -t, --titles   Show only menu item names.
25
  -c, --check=   Specify menu item to validate.
26
  -V, --version  Show script version and exit.
27
  -h, --help     Show this help message and exit.
28
EOF
29
	exit 0
30
}
31
32
show_version() {
33
	cat <<-EOF
34
$progname version 1.0
35
Copyright (C) 2019, ALT Linux Team
36
EOF
37
	exit 0
38
}
39
40
show_usage() {
41
	[ -z "$*" ] || echo "$*" >&2
42
	echo "Try '$progname --help' for more information." >&2
43
	exit 1
44
}
45
46
parse_args() {
47
	local opts="+f:,n,t,c:,V,h"
48
	local longopts="config:,numbers,titles,check:,version,help"
49
50
	opts=$(getopt -n "$progname" -o "$opts" -l "$longopts" -- "$@") ||
51
		show_usage "Invalid command-line arguments."
52
	eval set -- "$opts"
53
	while [ $# -gt 0 ]; do
54
		case "$1" in
55
		-f|--config)	shift; grubmenu="$1";;
56
		-n|--numbers)	numbers_only=1; titles_only=0;;
57
		-t|--titles)	numbers_only=0; titles_only=1;;
58
		-c|--check)	shift; search_item="$1";;
59
		-V|--version)	show_version;;
60
		-h|--help)	show_help;;
61
		--)		shift; break;;
62
		-*)		show_usage "Unrecognized option: '$1'";;
63
		*)		break;;
64
		esac
65
		shift
66
	done
67
	[ $# -eq 0 ] || show_usage "Unrecognized arguments: '$*'"
68
}
69
70
show_menu() {
71
	local mode title number prefix entry=0 itemno=0
72
73
	cat "$grubmenu" | sed \
74
		-re '/^\s*(menuentry\s+|submenu\s+|})/!d' \
75
		-re "s/^\s*menuentry\s+'([^']+)'.*\$/M\t\1/g" \
76
		-re 's/^\s*menuentry\s+"([^"]+)".*$/M\t\1/g' \
77
		-re "s/^\s*submenu\s+'([^']+)'.*\$/S\t\1/g" \
78
		-re 's/^\s*submenu\s+"([^"]+)".*$/S\t\1/g' \
79
		-re "s/^\s*}\s*\$/E\t-/g" |
80
	while read mode title; do
81
		case "$mode" in
82
		M)	if [ $numbers_only -ne 0 ]; then
83
				echo -e "${number}${itemno}"
84
			elif [ $titles_only -ne 0 ]; then
85
				echo -e "${prefix}${title}"
86
			else
87
				echo -e "${number}${itemno}\t${prefix}${title}"
88
			fi
89
			itemno=$(($itemno + 1))
90
			entry=1
91
			;;
92
		S)	number="${number}${itemno}>"
93
			prefix="${prefix}${title}>"
94
			itemno=0
95
			;;
96
		*)	if [ $entry -ne 0 ]; then
97
				entry=0
98
			elif [ -n "$number" ]; then
99
				number="${number%>}"
100
				prefix="${prefix%>}"
101
				case "$number" in
102
				*">"*)	itemno="${number##*>}"
103
					number="${number%>*}>"
104
					prefix="${prefix%>*}>"
105
					itemno=$(($itemno + 1))
106
					;;
107
				*)	itemno=$number
108
					itemno=$(($itemno + 1))
109
					prefix=
110
					number=
111
					;;
112
				esac
113
			fi
114
			;;
115
		esac
116
	done
117
}
118
119
check_item() {
120
	local cnt
121
122
	numbers_only=1; titles_only=0
123
	cnt=$(show_menu | grep -swc "$search_item" ||:)
124
	[ "$cnt" != "1" ] || exit 0
125
126
	numbers_only=0; titles_only=1
127
	cnt=$(show_menu | grep -swc "$search_item" ||:)
128
	[ "$cnt" != "1" ] || exit 0
129
130
	[ -z "$cnt" -o "$cnt" = "0" ] &&
131
		echo "$search_item: menu item not found." >&2 ||
132
		echo "$search_item: duplicate items found." >&2
133
	exit 1
134
}
135
136
137
parse_args "$@"
138
[ -r "$grubmenu" ] || show_usage "$grubmenu: config file not found."
139
[ -z "$search_item" ] || check_item
140
show_menu
141
(-)a/grub-entries.8 (+44 lines)
Line 0 Link Here
1
.\" Copyright 2019 ALT Linux Team
2
.\" Lincensed under GPLv2+
3
.TH GRUB-ENTRIES 8 "Febrary 2019" "grub-entries (ALT Linux Team)"
4
.SH NAME
5
grub-entries \- simple script for show grub menu and check menu items
6
.SH SYNOPSIS
7
.B grub-entries
8
[\fIoptions\fP]
9
10
.SH DESCRIPTION
11
.B grub-entries
12
parse specified or default grub config file, list all grub menu items in the one of the three forms.
13
Also can search specified item in menu and returns 0, if this item exists, otherwise returns non-zero
14
value. By default, \fI/boot/grub/grub.cfg\fP config file used.
15
16
.SH OPTIONS
17
.TP 5
18
.BI \-f "\fR, \fP" \-\-config " filename"
19
Specify path to the grub config.
20
.TP 5
21
.BI \-n "\fR, \fP" \-\-numbers
22
Show only menu item sequence numbers.
23
.TP 5
24
.BI \-t "\fR, \fP" \-\-titles
25
Show only menu item names.
26
.TP 5
27
.BI \-c "\fR, \fP" \-\-check " menuitem"
28
Specify menu item to validate.
29
.TP 5
30
.BI \-V "\fR, \fP" \-\-version
31
Show script version and exit.
32
.TP 5
33
.BI \-h "\fR, \fP" \-\-help
34
Show help message and exit.
35
36
.SH FILES
37
.PD 0
38
.B /boot/grub/grub.cfg
39
.PD
40
.SH AUTHORS
41
Leonid Krivoshein <klark@altlinux.org>
42
.SH "SEE ALSO"
43
.BR grub-reboot (8),
44
.BR grub-set-default (8)
(-)a/grub.spec (+6 lines)
Lines 24-29 Source9: update-grub.8 Link Here
24
Source10: grub-efi-autoupdate
24
Source10: grub-efi-autoupdate
25
Source11: embedded_grub.cfg
25
Source11: embedded_grub.cfg
26
26
27
Source12: grub-entries
28
Source13: grub-entries.8
29
27
Patch0: grub-2.02-os-alt.patch
30
Patch0: grub-2.02-os-alt.patch
28
Patch1: grub-2.00-sysconfig-path-alt.patch
31
Patch1: grub-2.00-sysconfig-path-alt.patch
29
Patch2: grub-2.02-altlinux-theme.patch
32
Patch2: grub-2.02-altlinux-theme.patch
Lines 300-305 mkdir -p %buildroot/boot/grub/fonts Link Here
300
303
301
install -pD -m755 %SOURCE8 %buildroot%_sbindir/
304
install -pD -m755 %SOURCE8 %buildroot%_sbindir/
302
install -pD -m644 %SOURCE9 %buildroot%_man8dir/update-grub.8
305
install -pD -m644 %SOURCE9 %buildroot%_man8dir/update-grub.8
306
install -pD -m644 %SOURCE13 %buildroot%_man8dir/grub-entries.8
303
307
304
# TODO: drop the obsolete one (unifont.pf2)
308
# TODO: drop the obsolete one (unifont.pf2)
305
%buildroot%_bindir/grub-mkfont -o %buildroot/boot/grub/unifont.pf2 %_datadir/fonts/bitmap/misc/8x13.pcf.gz
309
%buildroot%_bindir/grub-mkfont -o %buildroot/boot/grub/unifont.pf2 %_datadir/fonts/bitmap/misc/8x13.pcf.gz
Lines 314-319 sed -i 's,@LOCALEDIR@,%_datadir/locale,g' %buildroot%_sysconfdir/grub.d/* Link Here
314
install -pDm755 %SOURCE4  %buildroot%_rpmlibdir/grub.filetrigger
318
install -pDm755 %SOURCE4  %buildroot%_rpmlibdir/grub.filetrigger
315
install -pDm755 %SOURCE6  %buildroot%_sbindir/grub-autoupdate
319
install -pDm755 %SOURCE6  %buildroot%_sbindir/grub-autoupdate
316
install -pDm755 %SOURCE10 %buildroot%_sbindir/grub-efi-autoupdate
320
install -pDm755 %SOURCE10 %buildroot%_sbindir/grub-efi-autoupdate
321
install -pDm755 %SOURCE12 %buildroot%_sbindir/grub-entries
317
322
318
# Ghost config file
323
# Ghost config file
319
install -d %buildroot/boot/grub
324
install -d %buildroot/boot/grub
Lines 369-374 rm -f %buildroot%_libdir/grub-efi/*/*.h Link Here
369
%_sbindir/grub-reboot
374
%_sbindir/grub-reboot
370
%_sbindir/grub-set-default
375
%_sbindir/grub-set-default
371
%_sbindir/grub-sparc64-setup
376
%_sbindir/grub-sparc64-setup
377
%_sbindir/grub-entries
372
%_sbindir/update-grub
378
%_sbindir/update-grub
373
%_bindir/grub-editenv
379
%_bindir/grub-editenv
374
%_bindir/grub-file
380
%_bindir/grub-file

Return to bug 36048