View | Details | Raw Unified | Return to bug 232326 | Differences between
and this patch

Collapse All | Expand All

(-)mkdesktop/Makefile (-20 / +16 lines)
Lines 1-28 Link Here
1
# $FreeBSD: head/sysutils/mkdesktop/Makefile 470653 2018-05-22 19:22:58Z krion $
1
# $FreeBSD$
2
2
3
PORTNAME=	mkdesktop
3
PORTNAME=		mkdesktop
4
PORTVERSION=	1.8
4
PORTVERSION=		2.0
5
CATEGORIES=	sysutils
5
CATEGORIES=		sysutils
6
MASTER_SITES=
6
7
7
MAINTAINER=	bourne.identity@hotmail.com
8
MAINTAINER=		bourne.identity@hotmail.com
8
COMMENT=	Powerful, flexible utility to setup a FreeBSD desktop
9
COMMENT=		Powerful, flexible utility to setup a FreeBSD desktop
9
10
10
RUN_DEPENDS=	pkg>0:ports-mgmt/pkg
11
NO_BUILD=		yes
12
NO_ARCH=		yes
11
13
12
USE_GITHUB=	yes
14
PLIST_FILES=		bin/${PORTNAME} share/${PORTNAME}/${PORTNAME} share/${PORTNAME}/stage-definitions man/man1/${PORTNAME}.1.gz
13
GH_ACCOUNT=	bourne-again
15
DISTFILES=
14
15
NO_BUILD=	yes
16
NO_ARCH=	yes
17
18
DATA1=		stage-definitions
19
DATA2=		mkdesktop.help
20
PLIST_FILES=	bin/${PORTNAME} ${DATADIR}/${DATA1} ${DATADIR}/${DATA2}
21
16
22
do-install:
17
do-install:
23
		${MKDIR} ${STAGEDIR}${DATADIR}
18
		${INSTALL_SCRIPT} ${FILESDIR}/mkdesktop ${STAGEDIR}${PREFIX}/bin/
24
		${INSTALL_DATA} ${WRKSRC}/${DATA1} ${STAGEDIR}${DATADIR}
19
		${MKDIR} ${STAGEDIR}${PREFIX}/share/${PORTNAME}
25
		${INSTALL_DATA} ${WRKSRC}/${DATA2} ${STAGEDIR}${DATADIR}
20
		${INSTALL_DATA} ${FILESDIR}/mkdesktop ${STAGEDIR}${PREFIX}/share/${PORTNAME}/
26
		${INSTALL_SCRIPT} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin
21
		${INSTALL_DATA} ${FILESDIR}/stage-definitions ${STAGEDIR}${PREFIX}/share/${PORTNAME}/
22
		${INSTALL_MAN} ${FILESDIR}/mkdesktop.1 ${STAGEDIR}${MANPREFIX}/man/man1
27
23
28
.include <bsd.port.mk>
24
.include <bsd.port.mk>
(-)mkdesktop/distinfo (-3 / +2 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1527016876
1
SHA256 (mkdesktop-2.0.tar.gz) = 294062f8489f499fa7c9209f3d22ba34c1cfe0ef20be4037790554dab1de4da4
2
SHA256 (bourne-again-mkdesktop-1.8_GH0.tar.gz) = 79e4d1b4c9466b6052eb6f280e2ec47666c6ce287d16c29b5c8bf854b925e91f
2
SIZE (mkdesktop-2.0.tar.gz) = 10113
3
SIZE (bourne-again-mkdesktop-1.8_GH0.tar.gz) = 9380
(-)mkdesktop/files/mkdesktop (+1179 lines)
Line 0 Link Here
1
#!/bin/sh
2
3
sz_usage="I need 0 (zero) mandatory args : `basename $0` [optional arguments]
4
5
Legend of [optional arguments] ::
6
7
--begin <level> :	Use <level> as the beginning stage
8
(
9
	defaults to 1. But you can specify a higher value as long as it is lower
10
	than or equal to end. You can also specify a begin value of 0 - stage 0 runs
11
	a special initialization procedure to set up your graphics subsystem
12
)
13
14
--end <level> :	Use <level> as the last stage to process
15
(
16
	defaults to the highest stage value available, as evaluated at runtime.	But
17
	you can change that to something lower, as long as it is at least equal to
18
	the begin value
19
)
20
21
--pkg_list_dir <dir> :	Use <dir> as the package list directory
22
(defaults to \$HOME/mkdesktop/pkg_list)
23
24
--no-postproc :	Disable the postproc function that kicks in automatically upon
25
processing of regular stages to configure emulation layers and system files
26
27
--dry :		in dry mode, special functions (stage 0; post-processor) are
28
disabled and regular stage levels are processed by 'pkg install --dry-run',
29
unless you specify --echo too (in which case the --dry argument is silently
30
ignored). --dry is available to non-root users too.
31
32
--echo :	in echo mode, special functions (stage 0; post-processor) are
33
disabled and regular stage levels are processed by 'echo', not 'pkg install'.
34
--echo takes precedence over --dry, as well as is available to non-root users
35
too. This is useful for testing what non-automatic packages would get installed
36
by this script.
37
38
--append :	in append mode, packages mentioned in package list files are
39
appended to the stage definition lists, which otherwise would be superseded.
40
41
--help :	print the man page.
42
43
--usage :	print usage information"
44
45
location=$HOME/mkdesktop
46
pkg_list_dir="$location/pkg_list"
47
no_postproc=false
48
49
mode_echo=false
50
mode_dry=false
51
mode_append=false
52
mode_yes=false
53
54
begin=1
55
end=-1
56
57
arg_begin=false
58
arg_end=false
59
60
dummy=0
61
62
die()
63
{
64
	[ $# -eq 0 ] && exit 1
65
66
	[ $# -gt 1 ] && \
67
	echo "error initiated at line $1 :
68
	$2" 1>&2 || \
69
	echo "$1" 1>&2
70
71
	exit 1
72
}
73
74
while echo "$1" | grep '^--' > /dev/null; do
75
	case "$1" in
76
		--begin)
77
			shift
78
			begin=""
79
80
			if [ $# -gt 0 ]; then
81
				if echo $1 | grep '[^[:digit:]]' > /dev/null; then
82
					die "$LINENO" "Bad digital value for begin : $1"
83
				else
84
					begin="$1"
85
					arg_begin=true
86
					shift
87
				fi
88
			fi
89
		;;
90
91
		--end)
92
			shift
93
			end=""
94
95
			if [ $# -gt 0 ]; then
96
				if echo $1 | grep '[^[:digit:]]' > /dev/null; then
97
					die "$LINENO" "Bad digital value for end : $1"
98
				else
99
					end="$1"
100
					arg_end=true
101
					shift
102
				fi
103
			fi
104
		;;
105
106
		--pkg_list_dir)
107
			shift
108
			pkg_list_dir=""
109
110
			if [ $# -gt 0 ]; then
111
				pkg_list_dir="$1"
112
				shift
113
			fi
114
		;;
115
116
		--no-postproc)
117
			shift
118
			no_postproc=true
119
		;;
120
121
		--dry)
122
			shift
123
			mode_dry=true
124
		;;
125
126
		--echo)
127
			shift
128
			mode_echo=true
129
		;;
130
131
		--append)
132
			shift
133
			mode_append=true
134
		;;
135
136
		--help)
137
			man mkdesktop
138
			exit $?
139
		;;
140
141
		--usage)
142
			echo "$sz_usage"
143
			exit 0
144
		;;
145
146
		*)
147
			die "$LINENO" "Invalid optional arg : $1"
148
		;;
149
	esac
150
done
151
152
[ $# -eq 0 ] || { die "$sz_usage"; }
153
154
stage=0
155
idents=""
156
157
for var in location pkg_list_dir; do
158
	eval val='$'$var
159
	[ -z "$val" ] && die "$LINENO" "Empty string for $var"
160
done
161
162
if ! [ -d "$location" ]; then
163
	cat <<-EOF
164
	This seems to be the first time you are running mkdesktop.
165
166
	I can help you with the initial layout for running mkdesktop smoothly.
167
168
	If you wish, I can :
169
170
	1) 	create the directory $HOME/mkdesktop
171
		(which hosts the stage-definitions file)
172
173
	2) 	create a default $HOME/mkdesktop/stage-definitions
174
		(which should be good enough to get you started)
175
176
	Of course, you can always create the above by hand. And you can always
177
	customize your stage-definitions file. You are encouraged to at least read
178
	your stage-definitions file ($HOME/mkdesktop/stage-definitions), just to get
179
	a feel of what lies therein, and perhaps define a custom stage too, so that
180
	you becomes familiar with mkdesktop's working and ensure that everything
181
	works seamlessly end-to-end for you. If you mess up your stage-definitions
182
	file, no probs : just copy out afresh from /usr/local/share/mkdesktop/
183
184
	If you later decide to boost your setup with package list files (read the
185
	manpage for more on this), put them under the directory
186
	$HOME/mkdesktop/pkg_list (which too I will create right now; or else, you
187
	can create yourself later).
188
189
	What would you like me to do ?
190
191
	I) Initialize the setup
192
	S) Skip initialization
193
194
	Press Control-C if you wish to abort.
195
196
	Your choice ? (I/S) :
197
	EOF
198
199
	read answer
200
201
	case "$answer" in
202
		i|I)
203
			set -e
204
			mkdir $HOME/mkdesktop
205
			cp /usr/local/share/mkdesktop/stage-definitions $HOME/mkdesktop/stage-definitions
206
			mkdir $HOME/mkdesktop/pkg_list
207
208
			cat <<-EOF
209
210
			mkdesktop has been initialized.
211
212
			If you wish to alter the stage-definitions or package list files for
213
			this run, you can do still do it from another terminal window.
214
215
			When ready, press Enter to continue  (or Control-C to abort)
216
			EOF
217
218
			read enter
219
			set +e
220
		;;
221
222
		s|S)
223
		;;
224
225
		*)
226
			echo "I could not make sense of your choice  : - ("  1>&2
227
			exit 1
228
		;;
229
	esac
230
fi
231
232
[ -f "$location"/stage-definitions ] && \
233
{ . "$location"/stage-definitions; } || \
234
{ echo "Warning : $location/stage-definitions does not exist" 1>&2; }
235
236
for var in begin end; do
237
	eval val='$'$var
238
239
	[ $var = end ] && [ "$val" = "-1" ] && val=0
240
	[ -z "$val" ] && die "$LINENO" "Empty string for $var"
241
242
	echo "$val" | grep '[^[:digit:]]' > /dev/null && \
243
	die "$LINENO" "Bad digital value ($var) : ${val}"
244
done
245
246
[ $end -gt $stage ] && \
247
die "$LINENO" "end must not be greater than the highest stage value ($stage)"
248
249
[ $end -lt 0 ] && end=$stage
250
251
if [ $begin -gt $end ]; then
252
	[ $end -eq 0 ] && echo "Have you defined at least one stage ?" 1>&2
253
	die "$LINENO" "begin must not be greater than end"
254
fi
255
256
if [ "$mode_echo" = "false" -a "$mode_dry" = "false" ]; then
257
	dummy=`expr $dummy + 1`
258
259
	[ `id -u` -eq 0 ] || die "You need to be root to execute this script"
260
fi
261
262
f_stagezero()
263
{
264
	if [ "$mode_echo" = "false" -a "$mode_dry" = "false" ]; then
265
		cat <<-EOF
266
267
		This special stage has only one thing to do :
268
		setup any needed kld's for your graphics chipset
269
270
		Continue ?  (y/n) :
271
		EOF
272
273
		read answer
274
275
		case "$answer" in
276
			y|Y)
277
				cat <<-EOF
278
279
				What is your graphics chipset :
280
281
				1) radeon	[ needs radeon.ko; radeonkms.ko :
282
				both shipped by FreeBSD in the base distribution ]
283
284
				2) nvidia	[ needs nvidia.ko; nvidia-modeset.ko :
285
				both intalled via nvidia-driver ]
286
287
				3) other 	[ needs nothing/something I am not aware of ]
288
289
				Your choice  ?  (1/2/3) :
290
				EOF
291
292
				read answer
293
294
				case "$answer" in
295
					1)
296
						for k in radeon radeonkms; do
297
							echo "kldstat -qn $k || kldload $k" >> /etc/rc.local
298
						done
299
300
						return $?
301
					;;
302
303
					2)
304
						pkg install nvidia-driver
305
306
						[ $? -eq 0 ] || die "$LINENO" "nvidia-driver install failed"
307
308
						for k in nvidia nvidia-modeset; do
309
							echo "kldstat -qn $k || kldload $k" >> /etc/rc.local
310
						done
311
312
						return $?
313
					;;
314
315
					3)
316
						return 0
317
					;;
318
319
					*)
320
						echo "I do not know what to make of that  : - (" 1>&2
321
						return 1
322
					;;
323
324
				esac
325
			;;
326
327
			n|N)
328
			;;
329
330
			*)
331
				echo "I do not know what to make of that  : - (" 1>&2
332
				return 1
333
			;;
334
		esac
335
	fi
336
}
337
338
fix_noeol()
339
{
340
	[ $# -gt 0 ] || { echo "missing mandatory arg : <file>" 1>&2; return 1; }
341
	[ -f "$1" ] || { echo "$1 is not a regular file" 1>&2; return 1; }
342
343
	local r=0
344
	local f="$1"
345
346
	if file "$f" | grep '\<ASCII text\>' > /dev/null; then
347
		local last="`tail -c1 \"$f\"`"
348
349
		if [ -n "$last" ]; then
350
			[ -w "$f" ] || { echo "$f is not writable" 1>&2; return 1; }
351
352
		 	echo >> "$f"
353
			r=$?
354
		fi
355
	fi
356
357
	return $r
358
}
359
360
f_stage()
361
{
362
	[ $# -ne 1 ] && \
363
	{ echo "f_stage() :: I need 1 arg : stage name (ident)" 1>&2; return 1; }
364
365
	[ -z "$1" ] && \
366
	{ echo "f_stage() :: I need 1 arg : stage name (ident)" 1>&2; return 1; }
367
	
368
	if ! echo "$idents" | grep -w "$1" > /dev/null; then
369
		echo "f_stage() :: I could not locate $1 among the definitions" 1>&2
370
		return 1
371
	fi
372
373
	echo -e "\e[4m${1}\e[0m :: \c"
374
	
375
	local nextline=""
376
	local firstchar=""
377
	local lines=0
378
	local index=0
379
380
	local file=""
381
	eval local arg='$'list_${1}
382
383
	local list="`echo $arg | sed 's/:/ /g'`"
384
	
385
	[ -f "$pkg_list_dir"/"$1" ] && file="$pkg_list_dir"/"$1"
386
	
387
	if [ -n "$file" ]; then
388
		fix_noeol "$file"
389
		
390
		[ "$mode_append" = "false" ] && list=""
391
		lines="`cat $file | wc -l | sed 's/^[[:space:]]*//'`"
392
		index=1
393
		
394
		while [ $index -le $lines ]; do
395
			nextline="`sed -n ${index}p $file`"
396
			
397
			if [ -n "$nextline" ]; then
398
				firstchar="`echo $nextline | cut -c1`"
399
				
400
				if [ "$firstchar" = '#' ]; then
401
					dummy=`expr $dummy + 1`
402
				else
403
					[ -z "$list" ] && list="$nextline" || list="$list $nextline"
404
				fi
405
			fi
406
			
407
			index=`expr $index + 1`
408
		done
409
	fi
410
	
411
	local cmd="pkg install"
412
	
413
	[ "$mode_dry" = "true" ] && \
414
	{ cmd="$cmd --dry-run"; } || \
415
	{ [ "$mode_yes" = "true" ] && cmd="$cmd --yes"; }
416
	
417
	[ "$mode_echo" = true ] && cmd="echo"
418
419
	[ -z "$list" ] && echo || { $cmd $list; }
420
	local r=$?
421
422
	[ "$mode_dry" = "true" ] && [ $r -eq 1 ] && r=0
423
	return $r
424
}
425
426
[ $begin -gt 0 ] || f_stagezero
427
[ $? -eq 0 ] || die "$LINENO" "stage failure setting up graphics subsystem"
428
[ $end -eq 0 ] && exit 0
429
430
postproc()
431
{
432
	[ "$mode_dry" = "true" ] && return 0
433
	[ "$mode_echo" = "true" ] && return 0
434
	[ "$no_postproc" = "true" ] && return 0
435
436
	cat <<-EOF
437
	
438
	Your desktop has been successfully installed  : - )
439
440
	I am now going to start post-install processing to set up the following :
441
442
	Wine 		(32-bit/64-bit Windows emulation layer, user-space)
443
	Linuxulator	(64-bit Linux emulation layer, kernel-space)
444
445
	System files :
446
	/etc/fstab
447
	/etc/devfs.conf
448
	/etc/devfs.rules
449
	/etc/rc.conf
450
	/etc/sysctl.conf
451
	/boot/loader.conf
452
453
	I will seek permission from you for each of the above individually  : - )
454
455
	Note :	If you ask me to configure system files, existing originals will be
456
			saved with .bak extension
457
	EOF
458
459
	b_valid=false
460
461
	while [ "$b_valid" = "false" ]; do
462
		cat <<-EOF
463
464
		Would you like me to kick off post-processing ?
465
	
466
		y) Do it
467
		n) Cancel this [and exit immediately]
468
		
469
		Your choice  ?  (y/n) :
470
		EOF
471
	
472
		read answer
473
	
474
		case "$answer" in
475
			y|Y)
476
				b_valid=true
477
			;;
478
	
479
			n|N)
480
				b_valid=true
481
				exit 0
482
			;;
483
	
484
			*)
485
				echo "I do not know what to make of that  : - (" 1>&2
486
			;;
487
		esac
488
	done
489
490
	readonly UNITY=1
491
	readonly WIN32=$(( UNITY<<1 ))
492
	readonly WIN64=$(( UNITY<<2 ))
493
	readonly LINUX=$(( UNITY<<3 ))
494
	
495
	clear && echo "Beginning postproc"
496
497
	EMU=0
498
499
	echo && echo "Would you like me to set up Wine (Windows emulation layer) ?"
500
	echo && echo "y/n :"
501
	read answer
502
	
503
	case "$answer" in
504
		y|Y)
505
			cat <<-EOF
506
			
507
			Choose a mode :
508
509
			1) 32-bit
510
			2) 64-bit (This won't work if your system's CPU is 32-bit)
511
			c) cancel Wine
512
			EOF
513
514
			read answer
515
516
			case "$answer" in
517
				1)
518
					EMU=$(( EMU | UNITY | WIN32 ))
519
				;;
520
		
521
				2)
522
					EMU=$(( EMU | UNITY | WIN64 ))
523
				;;
524
	
525
				c|C)
526
				;;
527
	
528
				*)
529
					echo "I do not know what that means  : - ("
530
					echo "Skipping Wine"
531
				;;
532
			esac
533
		;;
534
535
		n|N)
536
		;;
537
538
		*)
539
			echo "I do not know what that means  : - ("
540
			echo "Skipping Wine"
541
		;;
542
	esac
543
	
544
	echo &&	echo "Would you like me to set up Linuxulator (Linux emulation layer) ?"
545
	echo && echo "Note : if you choose y, I will factor the Linuxulator into subsequent processing"
546
	echo && echo "y/n :"
547
548
	read answer
549
550
	case "$answer" in
551
		y|Y)
552
			EMU=$(( EMU | UNITY | LINUX ))
553
		;;
554
	
555
		n|N)
556
		;;
557
	
558
		*)
559
			echo "I do not know what that means  : - ("
560
			echo "Skipping Linuxulator"
561
		;;
562
	esac
563
564
	my_emu=$(( EMU & UNITY ))
565
566
	result_win32=1
567
	result_win64=1
568
	result_linux=1
569
570
	if [ $my_emu -ne 0 ]; then
571
		my_emu=$(( EMU & WIN32 ))
572
573
		if [ $my_emu -ne 0 ]; then
574
			pkg install --yes i386-wine wine-mono wine-gecko
575
			result_win32=$?
576
		fi
577
578
		my_emu=$(( EMU & WIN64 ))
579
580
		if [ $my_emu -ne 0 ]; then
581
			pkg install --yes wine wine-mono wine-gecko
582
			result_win64=$?
583
		fi
584
585
		my_emu=$(( EMU & LINUX ))
586
587
		if [ $my_emu -ne 0 ]; then
588
			if ! kldstat -q -n linux; then
589
				kldload linux
590
591
				[ $? -eq 0 ] || \
592
				die "$LINENO" "Unable to kldload linux"
593
			fi
594
			
595
			if [ "`uname -m`" = "amd64" ]; then
596
				if ! kldstat -q -n linux64; then
597
					kldload linux64
598
599
					[ $? -eq 0 ] || \
600
					die "$LINENO" "Unable to kldload linux64"
601
				fi
602
			fi
603
604
			pkg install --yes linux_base-c7
605
			result_linux=$?
606
		fi
607
	fi
608
609
	flavour_linux=false
610
611
	if [ $(( EMU & LINUX )) -ne 0 ]; then
612
		if [ $result_linux -eq 0 ]; then
613
			flavour_linux=true
614
		fi
615
	fi
616
617
	set -e
618
619
	#block for /etc/fstab
620
	{
621
		f=/etc/fstab
622
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
623
		
624
		if [ "$flavour_linux" = "false" ]; then
625
			eval mandatory${mangled}="\"\
626
fdescfs /dev/fd fdescfs rw 0 0
627
procfs /proc procfs rw 0 0\""
628
629
			eval hint${mangled}="\"\
630
If you are going to use the Linuxulator to run Linux applications under
631
FreeBSD natively, try this/these in $f once you have setup the Linuxulator
632
(most easily done in a single command with 'pkg install linux-sublime3') :\""
633
		
634
			eval suggested${mangled}="\"\
635
tmpfs /compat/linux/dev/shm tmpfs rw,mode=1777,size=1g 0 0
636
linprocfs /compat/linux/proc linprocfs rw 0 0
637
linsysfs /compat/linux/sys linsysfs rw 0 0\""
638
		else
639
			eval mandatory${mangled}="\"\
640
fdescfs /dev/fd fdescfs rw 0 0
641
procfs /proc procfs rw 0 0
642
tmpfs /compat/linux/dev/shm tmpfs rw,mode=1777,size=1g 0 0
643
linprocfs /compat/linux/proc linprocfs rw 0 0
644
linsysfs /compat/linux/sys linsysfs rw 0 0\""
645
646
			eval hint${mangled}=""
647
			eval suggested${mangled}=""
648
		fi
649
	}
650
651
	#block for /etc/devfs.conf
652
	{
653
		f=/etc/devfs.conf
654
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
655
		
656
		if [ "$flavour_linux" = "false" ]; then
657
			eval mandatory${mangled}="\"\
658
own     /dev/pci        root:operator
659
perm    /dev/pci        0664
660
own     /dev/dri/card0  root:operator
661
perm    /dev/dri/card0  0664
662
own     /dev/pass0      root:operator
663
perm    /dev/pass0      0664
664
own     /dev/cd0        root:operator
665
perm    /dev/cd0        0664
666
own     /dev/xpt0       root:operator
667
perm    /dev/xpt0       0664\""
668
669
			eval hint${mangled}="\"\
670
If you're going to use the Linuxulator to run Linux applications under
671
FreeBSD natively, try this/these in $f once you have setup the Linuxulator
672
(most easily done in a single command with 'pkg install linux-sublime3') :\""
673
674
			eval suggested${mangled}="\"\
675
link /compat/linux/dev/shm shm\""
676
		else
677
			eval mandatory${mangled}="\"\
678
own     /dev/pci        root:operator
679
perm    /dev/pci        0664
680
own     /dev/dri/card0  root:operator
681
perm    /dev/dri/card0  0664
682
own     /dev/pass0      root:operator
683
perm    /dev/pass0      0664
684
own     /dev/cd0        root:operator
685
perm    /dev/cd0        0664
686
own     /dev/xpt0       root:operator
687
perm    /dev/xpt0       0664
688
link /compat/linux/dev/shm shm\""
689
690
			eval hint${mangled}=""
691
			eval suggested${mangled}=""
692
		fi
693
	}
694
695
	#block for /etc/devfs.rules
696
	{
697
		f=/etc/devfs.rules
698
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
699
		
700
		eval mandatory${mangled}="\"\
701
[system=10]
702
add path 'usb/*' mode 0664 group operator
703
add path 'cd*' mode 0664 group operator
704
add path 'da*' mode 0664 group operator
705
add path 'video*' mode 0664 group operator\""
706
707
		eval hint${mangled}=""
708
		eval suggested${mangled}=""
709
	}
710
711
	#block for /etc/rc.conf
712
	{
713
		f=/etc/rc.conf
714
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
715
		
716
		if [ "$flavour_linux" = "false" ]; then
717
			eval mandatory${mangled}="\"\
718
devfs_system_ruleset=system
719
dbus_enable=YES
720
hald_enable=YES
721
cupsd_enable=YES\""
722
723
			eval hint${mangled}="\"\
724
Here's a few more goodies for you to keep in mind for ${f} :
725
726
1) For fuse to be able to mount non-native filesystems like ntfs/ext4
727
2) For a decent typing speed on the console
728
3) For auto-loading linux.ko\""
729
730
			eval suggested${mangled}="\"\
731
fusefs_enable=YES
732
keyrate=fast
733
linux_enable=YES\""
734
		else
735
			eval mandatory${mangled}="\"\
736
devfs_system_ruleset=system
737
dbus_enable=YES
738
hald_enable=YES
739
linux_enable=YES
740
cupsd_enable=YES\""
741
742
			eval hint${mangled}="\"\
743
Here's a few more goodies for you to keep in mind for ${f} :
744
745
1) For fuse to be able to mount non-native filesystems like ntfs/ext4
746
2) For a decent typing speed on the console\""
747
748
			eval suggested${mangled}="\"\
749
fusefs_enable=YES
750
keyrate=fast\""
751
		fi
752
	}
753
754
	#block for /etc/sysctl.conf
755
	{
756
		f=/etc/sysctl.conf
757
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
758
		
759
		if [ "$flavour_linux" = "false" ]; then
760
			eval mandatory${mangled}=""
761
762
			eval hint${mangled}="\"\
763
You might like to keep in mind a few other suggestions for ${f}, all optional.
764
1 goodie to let normal users mount disks and 2 Linuxulator goodies :\""
765
766
			eval suggested${mangled}="\"\
767
vfs.usermount=1
768
compat.linux.osrelease=2.6.18
769
kern.ipc.shm_allow_removed=1\""
770
		else
771
			eval mandatory${mangled}="\"\
772
compat.linux.osrelease=2.6.18
773
kern.ipc.shm_allow_removed=1\""
774
775
			eval hint${mangled}="\"\
776
For $f, keep in mind a tip to let normal users mount disks :\""
777
778
			eval suggested${mangled}="\"\
779
vfs.usermount=1\""
780
		fi
781
	}
782
783
	#block for /boot/loader.conf
784
	{
785
		f=/boot/loader.conf
786
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
787
		
788
		eval mandatory${mangled}="\"\
789
kern.vty=vt\""
790
		
791
		eval hint${mangled}=""
792
		eval suggested${mangled}=""
793
	}
794
	
795
	for f in /etc/fstab; do
796
		echo && echo "Configure $f : (y/n) ?"
797
		read answer
798
799
		case "$answer" in
800
			y|Y)
801
				mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
802
				eval mandatory='$'mandatory${mangled}
803
804
				if [ -f $f ]; then
805
					if [ -n "$mandatory" ]; then
806
						cp $f $f.bak
807
						
808
						maxlines=`echo "$mandatory" | wc -l | sed 's|^[[:space:]]*||'`
809
						index=1
810
811
						while [ $index -le $maxlines ]; do
812
							line="`echo \"$mandatory\" | sed -n ${index}p`"
813
							token1=`echo $line | awk '{print $1}'`
814
				
815
							if ! cat $f | grep --silent "^$token1[[:space:]]"; then
816
								echo $line >> $f
817
							fi
818
							
819
							index=`expr $index + 1`
820
						done
821
					fi
822
				else
823
					echo "$mandatory" > $f
824
				fi
825
				
826
				echo && echo "Done configuring $f"
827
				eval hint='$'hint${mangled}
828
				eval suggested='$'suggested${mangled}
829
				
830
				if [ -n "$suggested" ]; then
831
					echo "$hint"
832
					echo && echo "$suggested"
833
				fi
834
			;;
835
836
			n|N)
837
			;;
838
839
			*)
840
				echo "I do not know what that means  : - ("
841
				echo "Skipping $f"
842
			;;
843
		esac
844
	done
845
	
846
	for f in /etc/devfs.conf; do
847
		echo && echo "Configure $f : (y/n) ?"
848
		read answer
849
850
		case "$answer" in
851
			y|Y)
852
				mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
853
				eval mandatory='$'mandatory${mangled}
854
855
				if [ -f $f ]; then
856
					if [ -n "$mandatory" ]; then
857
						cp $f $f.bak
858
						
859
						maxlines=`echo "$mandatory" | wc -l | sed 's|^[[:space:]]*||'`
860
						index=1
861
862
						while [ $index -le $maxlines ]; do
863
							line="`echo \"$mandatory\" | sed -n ${index}p`"
864
								
865
							if ! cat $f | grep --silent "$line"; then
866
								token1=`echo $line | awk '{print $1}'`
867
								token3=`echo $line | awk '{print $3}'`
868
869
								token2=`echo $line | awk '{print $2}'`
870
								token2_alt=`echo $token2 | sed -n 's|^/dev/||p'`
871
								t2_lastchar=`echo $token2 | rev | cut -c1`
872
873
								search="^${token1}[[:space:]]+${token2}[[:space:]]"
874
875
								if [ -n "$token2_alt" ]; then
876
									search="^${token1}[[:space:]]+(${token2}|${token2_alt})[[:space:]]"
877
								fi
878
							
879
								if [ "$t2_lastchar" = "0" ]; then
880
									lead=`echo $token2 		| sed -n 's|^\(.*[^[:digit:]]\)\([[:digit:]]*\)$|\1|p'`
881
									trail=`echo $token2 	| sed -n 's|^\(.*[^[:digit:]]\)\([[:digit:]]*\)$|\2|p'`
882
883
									while [ -c $token2 ]; do
884
										if ! cat $f | egrep --silent "$search"; then
885
											echo $line >> $f
886
										fi
887
888
										trail=`expr $trail + 1`
889
										token2="${lead}${trail}"
890
										token2_alt=`echo $token2 | sed -n 's|^/dev/||p'`
891
										line="$token1 $token2 $token3"
892
893
										search="^${token1}[[:space:]]+${token2}[[:space:]]"
894
895
										if [ -n "$token2_alt" ]; then
896
											search="^${token1}[[:space:]]+(${token2}|${token2_alt})[[:space:]]"
897
										fi
898
									done
899
								else
900
									if [ -c $token2 ]; then
901
										if ! cat $f | egrep --silent "$search"; then
902
											echo $line >> $f
903
										fi
904
									fi					
905
								fi
906
							fi
907
							
908
							index=`expr $index + 1`
909
						done
910
					fi
911
				else
912
					echo "$mandatory" > $f
913
				fi
914
				
915
				echo && echo "Done configuring $f"
916
				eval hint='$'hint${mangled}
917
				eval suggested='$'suggested${mangled}
918
				
919
				if [ -n "$suggested" ]; then
920
					echo "$hint"
921
					echo && echo "$suggested"
922
				fi
923
			;;
924
925
			n|N)
926
			;;
927
928
			*)
929
				echo "I do not know what that means  : - ("
930
				echo "Skipping $f"
931
			;;
932
		esac
933
	done
934
935
	for f in /etc/devfs.rules; do
936
		echo && echo "Configure $f : (y/n) ?"
937
		read answer
938
939
		case "$answer" in
940
			y|Y)
941
				mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
942
				eval mandatory='$'mandatory${mangled}
943
944
				if [ -f $f ]; then
945
					if [ -n "$mandatory" ]; then
946
						cp $f $f.bak
947
						
948
						line="`echo \"$mandatory\" | sed -n 1p`"
949
								
950
						if ! cat $f | grep --silent "$line"; then
951
							echo "$mandatory" >> $f
952
						fi
953
					fi
954
				else
955
					echo "$mandatory" > $f
956
				fi
957
958
				echo && echo "Done configuring $f"
959
				eval hint='$'hint${mangled}
960
				eval suggested='$'suggested${mangled}
961
				
962
				if [ -n "$suggested" ]; then
963
					echo "$hint"
964
					echo && echo "$suggested"
965
				fi
966
			;;
967
968
			n|N)
969
			;;
970
971
			*)
972
				echo "I do not know what that means  : - ("
973
				echo "Skipping $f"
974
			;;
975
		esac
976
	done
977
978
	for f in /etc/rc.conf /etc/sysctl.conf /boot/loader.conf; do
979
		echo && echo "Configure $f : (y/n) ?"
980
		read answer
981
982
		case "$answer" in
983
			y|Y)
984
				mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
985
				eval mandatory='$'mandatory${mangled}
986
987
				if [ -f $f ]; then
988
					if [ -n "$mandatory" ]; then
989
						cp $f $f.bak
990
991
						maxlines=`echo "$mandatory" | wc -l | sed 's|^[[:space:]]*||'`
992
						index=1
993
994
						while [ $index -le $maxlines ]; do
995
							line="`echo \"$mandatory\" | sed -n ${index}p`"
996
								
997
							if ! cat $f | grep --silent "$line"; then
998
								token1=`echo $line | awk -F= '{print $1}'`
999
								token2=`echo $line | awk -F= '{print $2}'`
1000
1001
								search="^${token1}="
1002
								
1003
								if ! cat $f | egrep --silent "$search"; then
1004
									echo $line >> $f
1005
								fi
1006
							fi
1007
							
1008
							index=`expr $index + 1`
1009
						done
1010
					fi
1011
				else
1012
					echo "$mandatory" > $f
1013
				fi
1014
				
1015
				echo && echo "Done configuring $f"
1016
				eval hint='$'hint${mangled}
1017
				eval suggested='$'suggested${mangled}
1018
				
1019
				if [ -n "$suggested" ]; then
1020
					echo "$hint"
1021
					echo && echo "$suggested"
1022
				fi
1023
			;;
1024
1025
			n|N)
1026
			;;
1027
1028
			*)
1029
				echo "I do not know what that means  : - ("
1030
				echo "Skipping $f"
1031
			;;
1032
		esac
1033
	done
1034
1035
	set +e
1036
	echo
1037
1038
	cat <<-EOF
1039
	Post-processing done.
1040
	If you saw no errors anywhere, your box is raring to go  : - )
1041
	A reboot is now needed - you will need to do that yourself.
1042
1043
	Before you reboot, please make a note of one setting that could save you
1044
	hours of googling and jostling later on.
1045
	
1046
	If you plug in a USB device, it usually will be visible to every user
1047
	out-of-the-box. But sometimes, it may happen that only the root user is able
1048
	to see the device (most commonly happens with printer/scanner).
1049
1050
	If that happens, run usbconfig as root to ensure that the device is showing
1051
	up in the output, and make a note of its ugen ID, with <x>.<y> translating
1052
	as <x>.<y>.0 (for example, ugen2.4 would correspond to the ugen ID 2.4.0)
1053
	
1054
	Then run usbconfig again, this time as the normal user. If the ugen ID is
1055
	missing, add a line to /etc/devfs.conf (as root, of course) :
1056
1057
	perm usb/<ugen_ID> 0664
1058
1059
	For our example, that would mean :
1060
1061
	perm usb/2.4.0 0664
1062
1063
	Then, as root, run '/etc/rc.d/devfs restart'.
1064
	Your device should now work	cleanly for the normal user too.
1065
	EOF
1066
}
1067
1068
if [ -n "$idents" ]; then
1069
	if [ "$mode_echo" = "false" -a "$mode_dry" = "false" ]; then
1070
		clear && echo "Here is a preview of what I shall be doing"
1071
		echo
1072
		echo -e "(\e[4mstage name\e[0m :: package list as per stage definition)"
1073
		echo
1074
		echo "<<<<----"
1075
		echo
1076
1077
		readonly my_mode_echo=$mode_echo
1078
		mode_echo=true
1079
		previous_level=0
1080
1081
		for var in $idents; do
1082
			eval level='$'$var
1083
	
1084
			[ -z "$level" ] && \
1085
			die "$LINENO" "level must not evaluate as an empty string"
1086
			
1087
			echo "$level" | grep '[^[:digit:]]' > /dev/null && \
1088
			die "$LINENO" "level must be numeric"
1089
			
1090
			if [ $level -le $previous_level ]; then
1091
				die "$LINENO" \
1092
"This level is ${level}; Previous was ${previous_level}
1093
Random/descending order of stages is not supported"
1094
			fi
1095
			
1096
			[ $begin -gt $level ] || f_stage $var
1097
			
1098
			[ $? -eq 0 ] && \
1099
			previous_level=$level || \
1100
			die "$LINENO" "stage failure for stage $var"
1101
			
1102
			[ $end -eq $level ] && { break; }
1103
		done
1104
1105
		echo
1106
		echo "---->>>>"
1107
		echo
1108
1109
		mode_echo=$my_mode_echo
1110
		b_valid=false
1111
	
1112
		while [ "$b_valid" = "false" ]; do
1113
			cat <<-EOF
1114
			If you like the preview of what is to be done, give me a :
1115
1116
			y) Install the stages
1117
			
1118
			Y) Install stages non-interactively : passes --yes to 'pkg install'
1119
			(If you enter Y, just wait a few minutes/hours, and your entire
1120
			desktop will get assembled nicely and I shall bother you only for
1121
			the post-processing when the desktop has been put together)
1122
			
1123
			If you would like to modify the installation, press Control-C to
1124
			abort and alter the stage-definitions file and/or package list files
1125
1126
			Your choice  ? (y/Y) :
1127
			EOF
1128
		
1129
			read answer
1130
		
1131
			case "$answer" in
1132
				y)
1133
					b_valid=true
1134
				;;
1135
		
1136
				Y)
1137
					b_valid=true
1138
					mode_yes=true
1139
				;;
1140
		
1141
				*)
1142
					echo "I do not know what to make of that  : - (" 1>&2
1143
				;;
1144
			esac
1145
		done
1146
	fi
1147
1148
	previous_level=0
1149
1150
	for var in $idents; do
1151
		eval level='$'$var
1152
1153
		[ -z "$level" ] && \
1154
		die "$LINENO" "level must not evaluate as an empty string"
1155
		
1156
		echo "$level" | grep '[^[:digit:]]' > /dev/null && \
1157
		die "$LINENO" "level must be numeric"
1158
		
1159
		if [ $level -le $previous_level ]; then
1160
			die "$LINENO" \
1161
"This level is ${level}; Previous was ${previous_level}
1162
Random/descending order of stages is not supported"
1163
		fi
1164
		
1165
		[ $begin -gt $level ] || f_stage $var
1166
		
1167
		[ $? -eq 0 ] && \
1168
		previous_level=$level || \
1169
		die "$LINENO" "stage failure for stage $var"
1170
		
1171
		if [ $end -eq $level ]; then
1172
			[ "$arg_end" = "true" ] && exit 0 || break
1173
		fi
1174
	done
1175
1176
	postproc
1177
fi
1178
1179
exit $?
(-)mkdesktop/files/mkdesktop.1 (+172 lines)
Line 0 Link Here
1
.TH man 1 "16 October 2018" "2.0" "mkdesktop man page"
2
3
.SH NAME
4
mkdesktop
5
6
.SH SYNOPSIS
7
mkdesktop \- configure a FreeBSD desktop in a jiffy.
8
9
.SH DESCRIPTION
10
If you install a desktop, for instance KDE, under a new FreeBSD
11
installation by yourself, you will have to do all of the following :
12
13
1) Install X (xorg)
14
.br
15
2) Install KDE (kde5)
16
.br
17
3) Configure the system files under /etc and /boot
18
19
If you use the command mkdesktop, it will do all the above on its own,
20
and a bit more if you so desire - it can install (unattended) anything
21
else you need, and then set up any emulation layers (Wine / Linuxulator)
22
you might wish to use.
23
24
If you wish to use GNOME (gnome3) instead of the default desktop kde5,
25
just launch mkdesktop and wait for it to initialize itself, and
26
then - when prompted - run the command :
27
28
echo gnome3 > ~/mkdesktop/pkg_list/desktop
29
30
In any subsequent run, whatever is the list of packages in the file
31
~/mkdesktop/pkg_list/desktop overrides the default definition of
32
desktop. Package list files are newline-separated.
33
34
Although you could lump all packages into a single list, breaking up the
35
list into more stages allows for better, fine-grained control. 
36
37
By default, 5 stages are considered, in order :
38
39
pre_x -> x -> post_x -> desktop -> post_desktop
40
41
(Remember that stage lists are colon-separated, unlike package lists
42
which are newline separated)
43
44
pre_x (level 1) presumes there is no X around. The default definition of
45
this stage is empty, but this is a good place to specify command-line
46
utilities - wget:cdrecord:vim-console
47
48
x (level 2) is the stage for installing the base X system. By default,
49
this installs just the xorg meta-distribution.
50
51
post_x (level 3) is suited for X stuff that is not desktop-specific. The
52
default definition of this stage is empty, but you can pull in a lot of
53
stuff - xclip:firefox:virtualbox-ose:libreoffice:smplayer
54
55
desktop (level 4) is the stage for the base desktop. If you wish to
56
install GNOME as the desktop, use gnome3. The default for this stage is
57
KDE5, which essentially means the meta-package kde5.
58
59
(Like stage x, the stage definition for desktop should preferably be as
60
lean as possible).
61
62
post_desktop (level 5) is where you get the stuff that is
63
desktop-specific. If you chose gnome3-lite as desktop, you can add some
64
applications at this stage to make your desktop fuller (though the
65
default setting for this stage is empty) -
66
gnome-terminal:gedit:gdm:file-roller
67
68
Each stage can be defined in one/both of the following 2 ways :
69
70
1) list_<stage> is a colon-separated list of packages for the stage. As
71
you would expect, the default implementation has 5 such lists :
72
list_pre_x, list_x, list_post_x, list_desktop, list_post_desktop.  These
73
lists reside in their respective declarations in the file
74
~/mkdesktop/stage-definitions (specifically the line list_$ident=)
75
76
2) If a file named <stage> exists in the package list directory, it
77
supersedes the definition of list_<stage> (unless you use --append).
78
Since the default implementation is wired for ~/mkdesktop/pkg_list as
79
the package list directory, this script by default looks for files named
80
pre_x, x, post_x, desktop and post_desktop therein. You can change the
81
package list directory location by passing in "--pkg_list_dir
82
<location>"
83
84
If you create a custom stage named mystage in the file
85
~/mkdesktop/stage-definitions, the script will automatically consider
86
the file ~/mkdesktop/pkg_list/mystage (if such a file exists) as the
87
stage definition. If you do not wish to create a package list file for
88
mystage, you can specify the stage's package list by preparing the
89
colon-separated list list_mystage in ~/mkdesktop/stage-definitions
90
itself (by populating the line list_$ident= in the definition).
91
92
Unlike the colon-separated stage lists, package list files are
93
newline-separated. If the first character on a line is '#' (hash without
94
quotes), the line is ignored as a comment.
95
96
If you create a file named (for example) mydummy in the package list
97
directory, it comes into consideration only when a stage named mydummy
98
has been declared in the file ~/mkdesktop/stage-definitions. Declaring
99
a custom stage in the file stage-definitions is easy : you just need to
100
copy out the sample at the top to a suitable location in the file and
101
change the copy's ident string. Make sure the ident is unique.
102
103
mkdesktop also bundles in 2 special functions : stagezero and postproc.
104
105
stagezero has to be explicitly invoked by passing in '--begin 0' and it
106
caters to setting up the graphics environment for Radeon/NVidia
107
chipsets, kld's for which are set up to be loaded automatically at
108
boot-time via /etc/rc.local. For NVidia, stagezero also pulls in the
109
graphics driver nvidia-driver.
110
111
postproc gets automatically invoked when the regular stages have been
112
processed.  It sets up - if the user chooses Yes for each of these -
113
Wine (Windows emulation layer); Linuxulator (Linux emulation layer);
114
configuration of system files :
115
116
Under /etc/ : fstab; devfs.conf; devfs.rules; rc.conf; sysctl.conf;
117
.br
118
Under /boot/ : loader.conf.
119
120
mkdesktop never processes standard input - so you cannot use it at the
121
end of a pipeline. Diagnostic messages are always written to standard
122
error.
123
124
If this script makes FreeBSD desktop installation/configuration easier
125
for you, consider backing up your stage-definitions file and your
126
package list files. Tip : it might be a bit painful learning how to use
127
mkdesktop the first time. But if you regularly install FreeBSD, you will
128
soon appreciate the convenience it becomes.
129
130
.SH OPTIONS
131
--begin <level>	: Use <level> as the beginning stage
132
(default: 1)
133
134
--end <level> : Use <level> as the last stage
135
(default: highest available)
136
137
--pkg_list_dir <dir> : Use <dir> as the package list directory
138
(default: ~/mkdesktop/pkg_list)
139
140
--no-postproc : Disable the postproc function that kicks in
141
automatically upon processing of regular stages to configure emulation
142
layers and system files
143
144
--dry : Test without making changes to the system.  In dry mode, special
145
functions (stage 0; post-processor) are disabled and regular stage
146
levels are processed by 'pkg install --dry-run', unless you specify
147
--echo too (in which case the --dry argument is silently ignored).
148
--dry is available to non-root users too.
149
150
--echo : Just list the packages that would be installed.  In echo mode,
151
special functions (stage 0; post-processor) are disabled and regular
152
stage levels are processed by 'echo', not 'pkg install'. --echo takes
153
precedence over --dry, as well as is available to non-root users too.
154
This is useful to test what non-automatic packages would get installed
155
by this script.
156
157
--append : In append mode, packages mentioned in package list files are
158
appended to the stage definition lists, which otherwise would be
159
superseded.
160
161
--help : Print the man page (same as `man mkdesktop`)
162
163
--usage : Print usage information
164
165
.SH SEE ALSO
166
desktop-installer(1)
167
168
.SH BUGS
169
No known bugs.
170
171
.SH AUTHOR
172
Manish Jain (bourne.identity@hotmail.com)
(-)mkdesktop/files/stage-definitions (+138 lines)
Line 0 Link Here
1
# Copy (and uncomment once) the following block to establish a new stage.
2
# You can copy to any location in this file.
3
# The markup tags are purely for visual assistance.
4
5
#{
6
##<mustchange>
7
#	#the first line establishes the stage name
8
#	#must be copied as well as altered to generate a new name
9
#	#name must be a) unique; and b) alphanumeric (with underscores permitted)
10
11
#	ident=my_stage1
12
##</mustchange>
13
14
##<mustnotchange>
15
#	#the following lines must never be altered, so copy them as is
16
17
#	[ -z "$ident" ] && die "$ident is null"
18
19
#	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
20
21
#	if echo "$idents" | grep -w "$ident" > /dev/null; then
22
#		die "stage-definitions :: error compiling stage $ident :
23
#		name clash with a stage name already defined"
24
#	fi
25
26
#	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
27
28
#	stage=`expr $stage + 1`
29
#	eval $ident=$stage
30
##</mustnotchange>
31
32
##<maychange>
33
#	#the last line must be copied and optionally altered as a
34
#	#colon-separated list of packages
35
36
#	eval list_${ident}=""
37
##</maychange>
38
#}
39
40
{
41
	#stage definition for pre_x :
42
	ident=pre_x
43
44
	[ -z "$ident" ] && die "$ident is null"
45
46
	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
47
48
	if echo "$idents" | grep -w "$ident" > /dev/null; then
49
		die "stage-definitions :: error compiling stage $ident :
50
		name clash with a stage name already defined"
51
	fi
52
53
	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
54
	stage=`expr $stage + 1`
55
	eval $ident=$stage
56
57
	eval list_${ident}=""
58
}
59
60
{
61
	#stage definition for x
62
	ident=x
63
64
	[ -z "$ident" ] && die "$ident is null"
65
66
	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
67
68
	if echo "$idents" | grep -w "$ident" > /dev/null; then
69
		die "stage-definitions :: error compiling stage $ident :
70
		name clash with a stage name already defined"
71
	fi
72
73
	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
74
	stage=`expr $stage + 1`
75
	eval $ident=$stage
76
77
	eval list_${ident}="xorg"
78
}
79
80
{
81
	#stage definition for post_x
82
	ident=post_x
83
84
	[ -z "$ident" ] && die "$ident is null"
85
86
	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
87
88
	if echo "$idents" | grep -w "$ident" > /dev/null; then
89
		die "stage-definitions :: error compiling stage $ident :
90
		name clash with a stage name already defined"
91
	fi
92
93
	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
94
	stage=`expr $stage + 1`
95
	eval $ident=$stage
96
97
	eval list_${ident}=""
98
}
99
100
{
101
	#stage definition for desktop
102
	ident=desktop
103
104
	[ -z "$ident" ] && die "$ident is null"
105
106
	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
107
108
	if echo "$idents" | grep -w "$ident" > /dev/null; then
109
		die "stage-definitions :: error compiling stage $ident :
110
		name clash with a stage name already defined"
111
	fi
112
113
	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
114
	stage=`expr $stage + 1`
115
	eval $ident=$stage
116
117
	eval list_${ident}="kde5"
118
}
119
120
{
121
	#stage definition for post_desktop
122
	ident=post_desktop
123
124
	[ -z "$ident" ] && die "$ident is null"
125
126
	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
127
128
	if echo "$idents" | grep -w "$ident" > /dev/null; then
129
		die "stage-definitions :: error compiling stage $ident :
130
		name clash with a stage name already defined"
131
	fi
132
133
	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
134
	stage=`expr $stage + 1`
135
	eval $ident=$stage
136
137
	eval list_${ident}=""
138
}
(-)mkdesktop/mkdesktop-1.8/mkdesktop (-1176 lines)
Lines 1-1176 Link Here
1
#!/bin/sh
2
3
sz_usage="I need 0 (zero) mandatory args : `basename $0` [optional arguments]
4
			
5
Legend of [optional arguments] ::
6
7
--begin <level> :	Use <level> as the beginning stage
8
(
9
	defaults to 1. But you can specify a higher value as long as it is lower
10
	than or equal to end. You can also specify a begin value of 0 - stage 0 runs
11
	a special initialization procedure to set up your graphics subsystem
12
)
13
14
--end <level> :	Use <level> as the last stage to process
15
(
16
	defaults to the highest stage value available, as evaluated at runtime.	But
17
	you can change that to something lower, as long as it is at least equal to
18
	the begin value
19
)					
20
21
--pkg_list_dir <dir> :	Use <dir> as the package list directory
22
(defaults to \$HOME/mkdesktop/pkg_list)
23
24
--no-postproc :	Disable the postproc function that kicks in automatically upon
25
processing of regular stages to configure emulation layers and system files
26
27
--dry :		in dry mode, special functions (stage 0; post-processor) are
28
disabled and regular stage levels are processed by 'pkg install --dry-run',
29
unless you specify --echo too (in which case the --dry argument is silently
30
ignored). --dry is available to non-root users too.
31
32
--echo :	in echo mode, special functions (stage 0; post-processor) are
33
disabled and regular stage levels are processed by 'echo', not 'pkg install'.
34
--echo takes precedence over --dry, as well as is available to non-root users
35
too. This is useful for testing what non-automatic packages would get installed
36
by this script.
37
38
--append :	in append mode, packages mentioned in package list files are
39
appended to the stage definition lists, which otherwise would be superseded.
40
41
--help :	print an introductory manual
42
(this uses \$EDITOR, if set. If not set, rvim or else rjoe or else vi)
43
44
--usage :	print usage information"
45
46
location=$HOME/mkdesktop
47
pkg_list_dir="$location/pkg_list"
48
no_postproc=false
49
50
mode_echo=false
51
mode_dry=false
52
mode_append=false
53
mode_yes=false
54
55
begin=1
56
end=-1
57
58
arg_begin=false
59
arg_end=false
60
61
dummy=0
62
63
die()
64
{
65
	[ $# -eq 0 ] && exit 1
66
	
67
	[ $# -gt 1 ] && \
68
	echo "error initiated at line $1 : 
69
	$2" 1>&2 || \
70
	echo "$1" 1>&2
71
	
72
	exit 1
73
}
74
75
while echo "$1" | grep '^--' > /dev/null; do
76
	case "$1" in
77
		--begin)
78
			shift
79
			begin=""
80
			
81
			if [ $# -gt 0 ]; then
82
				if echo $1 | grep '[^[:digit:]]' > /dev/null; then
83
					die "$LINENO" "Bad digital value for begin : $1"
84
				else
85
					begin="$1"
86
					arg_begin=true
87
					shift
88
				fi
89
			fi
90
		;;
91
92
		--end)
93
			shift
94
			end=""
95
			
96
			if [ $# -gt 0 ]; then
97
				if echo $1 | grep '[^[:digit:]]' > /dev/null; then
98
					die "$LINENO" "Bad digital value for end : $1"
99
				else
100
					end="$1"
101
					arg_end=true
102
					shift
103
				fi
104
			fi
105
		;;
106
107
		--pkg_list_dir)
108
			shift
109
			pkg_list_dir=""
110
			
111
			if [ $# -gt 0 ]; then
112
				pkg_list_dir="$1"
113
				shift
114
			fi
115
		;;
116
				
117
		--no-postproc)
118
			shift
119
			no_postproc=true
120
		;;
121
		
122
		--dry)
123
			shift
124
			mode_dry=true
125
		;;
126
		
127
		--echo)
128
			shift
129
			mode_echo=true
130
		;;
131
132
		--append)
133
			shift
134
			mode_append=true
135
		;;
136
		
137
		--help)
138
			my_editor="$EDITOR"
139
			[ -z "$my_editor" ] && [ -x /usr/local/bin/rvim ] && my_editor=/usr/local/bin/rvim
140
			[ -z "$my_editor" ] && [ -x /usr/local/bin/rjoe ] && my_editor=/usr/local/bin/rjoe
141
			[ -z "$my_editor" ] && my_editor=vi
142
143
			"$my_editor" /usr/local/share/mkdesktop/mkdesktop.help
144
			exit 0
145
		;;
146
		
147
		--usage)
148
			echo "$sz_usage"
149
			exit 0
150
		;;
151
152
		*)
153
			die "$LINENO" "Invalid optional arg : $1"
154
		;;
155
	esac
156
done
157
158
[ $# -eq 0 ] || { die "$sz_usage"; }
159
160
stage=0
161
idents=""
162
163
for var in location pkg_list_dir; do
164
	eval val='$'$var
165
	[ -z "$val" ] && die "$LINENO" "Empty string for $var"
166
done
167
168
if ! [ -d "$location" ]; then
169
	cat <<-EOF
170
	This seems to be the first time you are running mkdesktop.
171
	
172
	I can help you with the initial layout for running mkdesktop smoothly.
173
	
174
	If you wish, I can :
175
	
176
	1) 	create the directory $HOME/mkdesktop
177
		(which hosts the stage-definitions file)
178
179
	2) 	create a default $HOME/mkdesktop/stage-definitions
180
		(which should be good enough to get you started)
181
	
182
	Of course, you can always create the above by hand. And you can always
183
	customize your stage-definitions file. You are encouraged to at least read
184
	your stage-definitions file ($HOME/mkdesktop/stage-definitions), just to get
185
	a feel of what lies therein, and perhaps define a custom stage too, so that
186
	you becomes familiar with mkdesktop's working and ensure that everything
187
	works seamlessly end-to-end for you. If you mess up your stage-definitions
188
	file, no probs : just copy out afresh from /usr/local/share/mkdesktop/
189
190
	If you later decide to boost your setup with package list files (read the
191
	output of --help for this), put them under the directory
192
	$HOME/mkdesktop/pkg_list (which too I can create right now; or else, you can
193
	create yourself later).
194
	
195
	What would you like me to do ?
196
	
197
	I) Initialize the setup
198
	S) Skip initialization
199
	
200
	Press Control-C if you wish to abort.
201
	
202
	Your choice ? (I/S) :
203
	EOF
204
	
205
	read answer
206
	
207
	case "$answer" in
208
		i|I)
209
			set -e
210
			mkdir $HOME/mkdesktop
211
			cp /usr/local/share/mkdesktop/stage-definitions $HOME/mkdesktop/stage-definitions
212
			mkdir $HOME/mkdesktop/pkg_list
213
214
			cat <<-EOF
215
216
			mkdesktop has been initialized.
217
			
218
			If you wish to alter the stage-definitions or package list files for
219
			this run, you can do still do it from another terminal window.
220
221
			When ready, press Enter to continue  (or Control-C to abort)
222
			EOF
223
224
			read enter
225
			set +e
226
		;;
227
		
228
		s|S)
229
		;;
230
		
231
		*)
232
			echo "I could not make sense of your choice  : - ("  1>&2
233
			exit 1
234
		;;
235
	esac
236
fi
237
238
[ -f "$location"/stage-definitions ] && \
239
{ . "$location"/stage-definitions; } || \
240
{ echo "Warning : $location/stage-definitions does not exist" 1>&2; }
241
242
for var in begin end; do 
243
	eval val='$'$var
244
245
	[ $var = end ] && [ "$val" = "-1" ] && val=0
246
	[ -z "$val" ] && die "$LINENO" "Empty string for $var"
247
	
248
	echo "$val" | grep '[^[:digit:]]' > /dev/null && \
249
	die "$LINENO" "Bad digital value ($var) : ${val}"
250
done
251
252
[ $end -gt $stage ] && \
253
die "$LINENO" "end must not be greater than the highest stage value ($stage)"
254
255
[ $end -lt 0 ] && end=$stage
256
257
if [ $begin -gt $end ]; then
258
	[ $end -eq 0 ] && echo "Have you defined at least one stage ?" 1>&2
259
	die "$LINENO" "begin must not be greater than end"
260
fi
261
262
if [ "$mode_echo" = "false" -a "$mode_dry" = "false" ]; then
263
	dummy=`expr $dummy + 1`
264
	
265
	[ `id -u` -eq 0 ] || die "You need to be root to execute this script"
266
fi
267
268
f_stagezero()
269
{
270
	if [ "$mode_echo" = "false" -a "$mode_dry" = "false" ]; then
271
		cat <<-EOF
272
273
		This special stage has only one thing to do :
274
		setup any needed kld's for your graphics chipset
275
	
276
		Continue ?  (y/n) :
277
		EOF
278
279
		read answer
280
	
281
		case "$answer" in
282
			y|Y)
283
				cat <<-EOF
284
				
285
				What is your graphics chipset :
286
	
287
				1) radeon	[ needs radeon.ko; radeonkms.ko :
288
				both shipped by FreeBSD in the base distribution ]
289
				
290
				2) nvidia	[ needs nvidia.ko; nvidia-modeset.ko :
291
				both intalled via nvidia-driver ]
292
293
				3) other 	[ needs nothing/something I am not aware of ]
294
	
295
				Your choice  ?  (1/2/3) : 
296
				EOF
297
	
298
				read answer
299
	
300
				case "$answer" in
301
					1)
302
						for k in radeon radeonkms; do
303
							echo "kldstat -qn $k || kldload $k" >> /etc/rc.local
304
						done
305
	
306
						return $?
307
					;;
308
	
309
					2)
310
						pkg install nvidia-driver
311
						
312
						[ $? -eq 0 ] || die "$LINENO" "nvidia-driver install failed"
313
	
314
						for k in nvidia nvidia-modeset; do
315
							echo "kldstat -qn $k || kldload $k" >> /etc/rc.local
316
						done
317
	
318
						return $?
319
					;;
320
	
321
					3)
322
						return 0
323
					;;
324
	
325
					*)
326
						echo "I do not know what to make of that  : - (" 1>&2
327
						return 1
328
					;;
329
	
330
				esac
331
			;;
332
	
333
			n|N)
334
			;;
335
	
336
			*)
337
				echo "I do not know what to make of that  : - (" 1>&2
338
				return 1
339
			;;
340
		esac
341
	fi
342
}
343
344
fix_noeol()
345
{
346
	[ $# -gt 0 ] || { echo "missing mandatory arg : <file>" 1>&2; return 1; }
347
	[ -f "$1" ] || { echo "$1 is not a regular file" 1>&2; return 1; }
348
349
	local r=0
350
	local f="$1"
351
352
	if file "$f" | grep '\<ASCII text\>' > /dev/null; then
353
		local last="`tail -c1 \"$f\"`"
354
		
355
		if [ -n "$last" ]; then
356
			[ -w "$f" ] || { echo "$f is not writable" 1>&2; return 1; }
357
358
		 	echo >> "$f"
359
			r=$?
360
		fi
361
	fi
362
363
	return $r
364
}
365
366
f_stage()
367
{
368
	[ $# -ne 1 ] && \
369
	{ echo "f_stage() :: I need 1 arg : stage name (ident)" 1>&2; return 1; }
370
371
	[ -z "$1" ] && \
372
	{ echo "f_stage() :: I need 1 arg : stage name (ident)" 1>&2; return 1; }
373
	
374
	if ! echo "$idents" | grep -w "$1" > /dev/null; then
375
		echo "f_stage() :: I could not locate $1 among the definitions" 1>&2
376
		return 1
377
	fi
378
379
	echo -e "\e[4m${1}\e[0m :: \c"
380
	
381
	local nextline=""
382
	local firstchar=""
383
	local lines=0
384
	local index=0
385
386
	local file=""
387
	eval local arg='$'list_${1}
388
389
	local list="`echo $arg | sed 's/:/ /g'`"
390
	
391
	[ -f "$pkg_list_dir"/"$1" ] && file="$pkg_list_dir"/"$1"
392
	
393
	if [ -n "$file" ]; then
394
		fix_noeol "$file"
395
		
396
		[ "$mode_append" = "false" ] && list=""
397
		lines="`cat $file | wc -l | sed 's/^[[:space:]]*//'`"
398
		index=1
399
		
400
		while [ $index -le $lines ]; do
401
			nextline="`sed -n ${index}p $file`"
402
			
403
			if [ -n "$nextline" ]; then
404
				firstchar="`echo $nextline | cut -c1`"
405
				
406
				if [ "$firstchar" = '#' ]; then
407
					dummy=`expr $dummy + 1`
408
				else
409
					[ -z "$list" ] && list="$nextline" || list="$list $nextline"
410
				fi
411
			fi
412
			
413
			index=`expr $index + 1`
414
		done
415
	fi
416
	
417
	local cmd="pkg install"
418
	
419
	[ "$mode_dry" = "true" ] && \
420
	{ cmd="$cmd --dry-run"; } || \
421
	{ [ "$mode_yes" = "true" ] && cmd="$cmd --yes"; }
422
	
423
	[ "$mode_echo" = true ] && cmd="echo"
424
425
	[ -z "$list" ] && echo || { $cmd $list; }
426
	local r=$?
427
428
	[ "$mode_dry" = "true" ] && [ $r -eq 1 ] && r=0
429
	return $r
430
}
431
432
[ $begin -gt 0 ] || f_stagezero
433
[ $? -eq 0 ] || die "$LINENO" "stage failure setting up graphics subsystem"
434
[ $end -eq 0 ] && exit 0
435
436
postproc()
437
{
438
	[ "$mode_dry" = "true" ] && return 0
439
	[ "$mode_echo" = "true" ] && return 0
440
	[ "$no_postproc" = "true" ] && return 0
441
442
	cat <<-EOF
443
	
444
	Your desktop has been successfully installed  : - )
445
446
	I am now going to start post-install processing to set up the following :
447
448
	Wine 		(32-bit/64-bit Windows emulation layer, user-space)
449
	Linuxulator	(64-bit Linux emulation layer, kernel-space)
450
451
	System files :
452
	/etc/fstab
453
	/etc/devfs.conf
454
	/etc/devfs.rules
455
	/etc/rc.conf
456
	/etc/sysctl.conf
457
	/boot/loader.conf
458
459
	I will seek permission from you for each of the above individually  : - )
460
461
	Note :	If you ask me to configure system files, existing originals will be
462
			saved with .bak extension
463
	EOF
464
465
	b_valid=false
466
467
	while [ "$b_valid" = "false" ]; do
468
		cat <<-EOF
469
470
		Would you like me to kick off post-processing ?
471
	
472
		y) Do it
473
		n) Cancel this [and exit immediately]
474
		
475
		Your choice  ?  (y/n) :
476
		EOF
477
	
478
		read answer
479
	
480
		case "$answer" in
481
			y|Y)
482
				b_valid=true
483
			;;
484
	
485
			n|N)
486
				b_valid=true
487
				exit 0
488
			;;
489
	
490
			*)
491
				echo "I do not know what to make of that  : - (" 1>&2
492
			;;
493
		esac
494
	done
495
496
	readonly UNITY=1
497
	readonly WIN32=$(( UNITY<<1 ))
498
	readonly WIN64=$(( UNITY<<2 ))
499
	readonly LINUX=$(( UNITY<<3 ))
500
	
501
	clear && echo "Beginning postproc"
502
503
	EMU=0
504
505
	echo && echo "Would you like me to set up Wine (Windows emulation layer) ?"
506
	echo && echo "y/n :"
507
	read answer
508
	
509
	case "$answer" in
510
		y|Y)
511
			cat <<-EOF
512
			
513
			Choose a mode :
514
515
			1) 32-bit
516
			2) 64-bit (This won't work if your system's CPU is 32-bit)
517
			c) cancel Wine
518
			EOF
519
520
			read answer
521
522
			case "$answer" in
523
				1)
524
					EMU=$(( EMU | UNITY | WIN32 ))
525
				;;
526
		
527
				2)
528
					EMU=$(( EMU | UNITY | WIN64 ))
529
				;;
530
	
531
				c|C)
532
				;;
533
	
534
				*)
535
					echo "I do not know what that means  : - ("
536
					echo "Skipping Wine"
537
				;;
538
			esac
539
		;;
540
541
		n|N)
542
		;;
543
544
		*)
545
			echo "I do not know what that means  : - ("
546
			echo "Skipping Wine"
547
		;;
548
	esac
549
	
550
	echo &&	echo "Would you like me to set up Linuxulator (Linux emulation layer) ?"
551
	echo && echo "Note : if you choose y, I will factor the Linuxulator into subsequent processing"
552
	echo && echo "y/n :"
553
554
	read answer
555
556
	case "$answer" in
557
		y|Y)
558
			EMU=$(( EMU | UNITY | LINUX ))
559
		;;
560
	
561
		n|N)
562
		;;
563
	
564
		*)
565
			echo "I do not know what that means  : - ("
566
			echo "Skipping Linuxulator"
567
		;;
568
	esac
569
570
	my_emu=$(( EMU & UNITY ))
571
572
	result_win32=1
573
	result_win64=1
574
	result_linux=1
575
576
	if [ $my_emu -ne 0 ]; then
577
		my_emu=$(( EMU & WIN32 ))
578
579
		if [ $my_emu -ne 0 ]; then
580
			pkg install --yes i386-wine wine-mono wine-gecko
581
			result_win32=$?
582
		fi
583
584
		my_emu=$(( EMU & WIN64 ))
585
586
		if [ $my_emu -ne 0 ]; then
587
			pkg install --yes wine wine-mono wine-gecko
588
			result_win64=$?
589
		fi
590
591
		my_emu=$(( EMU & LINUX ))
592
593
		if [ $my_emu -ne 0 ]; then
594
			if ! kldstat -q -n linux; then
595
				kldload linux
596
				
597
				[ $? -eq 0 ] || \
598
				die "$LINENO" "Unable to kldload linux"
599
			fi
600
			
601
			pkg install --yes linux_base-c6
602
			result_linux=$?
603
		fi
604
	fi
605
606
	flavour_linux=false
607
608
	if [ $(( EMU & LINUX )) -ne 0 ]; then
609
		if [ $result_linux -eq 0 ]; then
610
			flavour_linux=true
611
		fi
612
	fi
613
614
	set -e
615
616
	#block for /etc/fstab
617
	{
618
		f=/etc/fstab
619
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
620
		
621
		if [ "$flavour_linux" = "false" ]; then
622
			eval mandatory${mangled}="\"\
623
fdescfs /dev/fd fdescfs rw 0 0
624
procfs /proc procfs rw 0 0\""
625
626
			eval hint${mangled}="\"\
627
If you are going to use the Linuxulator to run Linux applications under
628
FreeBSD natively, try this/these in $f once you have setup the Linuxulator
629
(most easily done in a single command with 'pkg install linux-sublime3') :\""
630
		
631
			eval suggested${mangled}="\"\
632
tmpfs /compat/linux/dev/shm tmpfs rw,mode=1777,size=1g 0 0
633
linprocfs /compat/linux/proc linprocfs rw 0 0
634
linsysfs /compat/linux/sys linsysfs rw 0 0\""
635
		else
636
			eval mandatory${mangled}="\"\
637
fdescfs /dev/fd fdescfs rw 0 0
638
procfs /proc procfs rw 0 0
639
tmpfs /compat/linux/dev/shm tmpfs rw,mode=1777,size=1g 0 0
640
linprocfs /compat/linux/proc linprocfs rw 0 0
641
linsysfs /compat/linux/sys linsysfs rw 0 0\""
642
643
			eval hint${mangled}=""
644
			eval suggested${mangled}=""
645
		fi
646
	}
647
648
	#block for /etc/devfs.conf
649
	{
650
		f=/etc/devfs.conf
651
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
652
		
653
		if [ "$flavour_linux" = "false" ]; then
654
			eval mandatory${mangled}="\"\
655
own     /dev/pci        root:operator
656
perm    /dev/pci        0664
657
own     /dev/dri/card0  root:operator
658
perm    /dev/dri/card0  0664
659
own     /dev/pass0      root:operator
660
perm    /dev/pass0      0664
661
own     /dev/cd0        root:operator
662
perm    /dev/cd0        0664
663
own     /dev/xpt0       root:operator
664
perm    /dev/xpt0       0664\""
665
666
			eval hint${mangled}="\"\
667
If you're going to use the Linuxulator to run Linux applications under
668
FreeBSD natively, try this/these in $f once you have setup the Linuxulator
669
(most easily done in a single command with 'pkg install linux-sublime3') :\""
670
671
			eval suggested${mangled}="\"\
672
link /compat/linux/dev/shm shm\""
673
		else
674
			eval mandatory${mangled}="\"\
675
own     /dev/pci        root:operator
676
perm    /dev/pci        0664
677
own     /dev/dri/card0  root:operator
678
perm    /dev/dri/card0  0664
679
own     /dev/pass0      root:operator
680
perm    /dev/pass0      0664
681
own     /dev/cd0        root:operator
682
perm    /dev/cd0        0664
683
own     /dev/xpt0       root:operator
684
perm    /dev/xpt0       0664
685
link /compat/linux/dev/shm shm\""
686
687
			eval hint${mangled}=""
688
			eval suggested${mangled}=""
689
		fi
690
	}
691
692
	#block for /etc/devfs.rules
693
	{
694
		f=/etc/devfs.rules
695
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
696
		
697
		eval mandatory${mangled}="\"\
698
[system=10]
699
add path 'usb/*' mode 0664 group operator
700
add path 'cd*' mode 0664 group operator
701
add path 'da*' mode 0664 group operator
702
add path 'video*' mode 0664 group operator\""
703
704
		eval hint${mangled}=""
705
		eval suggested${mangled}=""
706
	}
707
708
	#block for /etc/rc.conf
709
	{
710
		f=/etc/rc.conf
711
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
712
		
713
		if [ "$flavour_linux" = "false" ]; then
714
			eval mandatory${mangled}="\"\
715
devfs_system_ruleset=system
716
dbus_enable=YES
717
hald_enable=YES
718
cupsd_enable=YES\""
719
720
			eval hint${mangled}="\"\
721
Here's a few more goodies for you to keep in mind for ${f} :
722
723
1) For fuse to be able to mount non-native filesystems like ntfs/ext4
724
2) For a decent typing speed on the console
725
3) For auto-loading linux.ko\""
726
727
			eval suggested${mangled}="\"\
728
fusefs_enable=YES
729
keyrate=fast
730
linux_enable=YES\""
731
		else
732
			eval mandatory${mangled}="\"\
733
devfs_system_ruleset=system
734
dbus_enable=YES
735
hald_enable=YES
736
linux_enable=YES
737
cupsd_enable=YES\""
738
739
			eval hint${mangled}="\"\
740
Here's a few more goodies for you to keep in mind for ${f} :
741
742
1) For fuse to be able to mount non-native filesystems like ntfs/ext4
743
2) For a decent typing speed on the console\""
744
745
			eval suggested${mangled}="\"\
746
fusefs_enable=YES
747
keyrate=fast\""
748
		fi
749
	}
750
751
	#block for /etc/sysctl.conf
752
	{
753
		f=/etc/sysctl.conf
754
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
755
		
756
		if [ "$flavour_linux" = "false" ]; then
757
			eval mandatory${mangled}=""
758
759
			eval hint${mangled}="\"\
760
You might like to keep in mind a few other suggestions for ${f}, all optional.
761
1 goodie to let normal users mount disks and 2 Linuxulator goodies :\""
762
763
			eval suggested${mangled}="\"\
764
vfs.usermount=1
765
compat.linux.osrelease=2.6.18
766
kern.ipc.shm_allow_removed=1\""
767
		else
768
			eval mandatory${mangled}="\"\
769
compat.linux.osrelease=2.6.18
770
kern.ipc.shm_allow_removed=1\""
771
772
			eval hint${mangled}="\"\
773
For $f, keep in mind a tip to let normal users mount disks :\""
774
775
			eval suggested${mangled}="\"\
776
vfs.usermount=1\""
777
		fi
778
	}
779
780
	#block for /boot/loader.conf
781
	{
782
		f=/boot/loader.conf
783
		mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
784
		
785
		eval mandatory${mangled}="\"\
786
kern.vty=vt\""
787
		
788
		eval hint${mangled}=""
789
		eval suggested${mangled}=""
790
	}
791
	
792
	for f in /etc/fstab; do
793
		echo && echo "Configure $f : (y/n) ?"
794
		read answer
795
796
		case "$answer" in
797
			y|Y)
798
				mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
799
				eval mandatory='$'mandatory${mangled}
800
801
				if [ -f $f ]; then
802
					if [ -n "$mandatory" ]; then
803
						cp $f $f.bak
804
						
805
						maxlines=`echo "$mandatory" | wc -l | sed 's|^[[:space:]]*||'`
806
						index=1
807
808
						while [ $index -le $maxlines ]; do
809
							line="`echo \"$mandatory\" | sed -n ${index}p`"
810
							token1=`echo $line | awk '{print $1}'`
811
				
812
							if ! cat $f | grep --silent "^$token1[[:space:]]"; then
813
								echo $line >> $f
814
							fi
815
							
816
							index=`expr $index + 1`
817
						done
818
					fi
819
				else
820
					echo "$mandatory" > $f
821
				fi
822
				
823
				echo && echo "Done configuring $f"
824
				eval hint='$'hint${mangled}
825
				eval suggested='$'suggested${mangled}
826
				
827
				if [ -n "$suggested" ]; then
828
					echo "$hint"
829
					echo && echo "$suggested"
830
				fi
831
			;;
832
833
			n|N)
834
			;;
835
836
			*)
837
				echo "I do not know what that means  : - ("
838
				echo "Skipping $f"
839
			;;
840
		esac
841
	done
842
	
843
	for f in /etc/devfs.conf; do
844
		echo && echo "Configure $f : (y/n) ?"
845
		read answer
846
847
		case "$answer" in
848
			y|Y)
849
				mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
850
				eval mandatory='$'mandatory${mangled}
851
852
				if [ -f $f ]; then
853
					if [ -n "$mandatory" ]; then
854
						cp $f $f.bak
855
						
856
						maxlines=`echo "$mandatory" | wc -l | sed 's|^[[:space:]]*||'`
857
						index=1
858
859
						while [ $index -le $maxlines ]; do
860
							line="`echo \"$mandatory\" | sed -n ${index}p`"
861
								
862
							if ! cat $f | grep --silent "$line"; then
863
								token1=`echo $line | awk '{print $1}'`
864
								token3=`echo $line | awk '{print $3}'`
865
866
								token2=`echo $line | awk '{print $2}'`
867
								token2_alt=`echo $token2 | sed -n 's|^/dev/||p'`
868
								t2_lastchar=`echo $token2 | rev | cut -c1`
869
870
								search="^${token1}[[:space:]]+${token2}[[:space:]]"
871
872
								if [ -n "$token2_alt" ]; then
873
									search="^${token1}[[:space:]]+(${token2}|${token2_alt})[[:space:]]"
874
								fi
875
							
876
								if [ "$t2_lastchar" = "0" ]; then
877
									lead=`echo $token2 		| sed -n 's|^\(.*[^[:digit:]]\)\([[:digit:]]*\)$|\1|p'`
878
									trail=`echo $token2 	| sed -n 's|^\(.*[^[:digit:]]\)\([[:digit:]]*\)$|\2|p'`
879
880
									while [ -c $token2 ]; do
881
										if ! cat $f | egrep --silent "$search"; then
882
											echo $line >> $f
883
										fi
884
885
										trail=`expr $trail + 1`
886
										token2="${lead}${trail}"
887
										token2_alt=`echo $token2 | sed -n 's|^/dev/||p'`
888
										line="$token1 $token2 $token3"
889
890
										search="^${token1}[[:space:]]+${token2}[[:space:]]"
891
892
										if [ -n "$token2_alt" ]; then
893
											search="^${token1}[[:space:]]+(${token2}|${token2_alt})[[:space:]]"
894
										fi
895
									done
896
								else
897
									if [ -c $token2 ]; then
898
										if ! cat $f | egrep --silent "$search"; then
899
											echo $line >> $f
900
										fi
901
									fi					
902
								fi
903
							fi
904
							
905
							index=`expr $index + 1`
906
						done
907
					fi
908
				else
909
					echo "$mandatory" > $f
910
				fi
911
				
912
				echo && echo "Done configuring $f"
913
				eval hint='$'hint${mangled}
914
				eval suggested='$'suggested${mangled}
915
				
916
				if [ -n "$suggested" ]; then
917
					echo "$hint"
918
					echo && echo "$suggested"
919
				fi
920
			;;
921
922
			n|N)
923
			;;
924
925
			*)
926
				echo "I do not know what that means  : - ("
927
				echo "Skipping $f"
928
			;;
929
		esac
930
	done
931
932
	for f in /etc/devfs.rules; do
933
		echo && echo "Configure $f : (y/n) ?"
934
		read answer
935
936
		case "$answer" in
937
			y|Y)
938
				mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
939
				eval mandatory='$'mandatory${mangled}
940
941
				if [ -f $f ]; then
942
					if [ -n "$mandatory" ]; then
943
						cp $f $f.bak
944
						
945
						line="`echo \"$mandatory\" | sed -n 1p`"
946
								
947
						if ! cat $f | grep --silent "$line"; then
948
							echo "$mandatory" >> $f
949
						fi
950
					fi
951
				else
952
					echo "$mandatory" > $f
953
				fi
954
955
				echo && echo "Done configuring $f"
956
				eval hint='$'hint${mangled}
957
				eval suggested='$'suggested${mangled}
958
				
959
				if [ -n "$suggested" ]; then
960
					echo "$hint"
961
					echo && echo "$suggested"
962
				fi
963
			;;
964
965
			n|N)
966
			;;
967
968
			*)
969
				echo "I do not know what that means  : - ("
970
				echo "Skipping $f"
971
			;;
972
		esac
973
	done
974
975
	for f in /etc/rc.conf /etc/sysctl.conf /boot/loader.conf; do
976
		echo && echo "Configure $f : (y/n) ?"
977
		read answer
978
979
		case "$answer" in
980
			y|Y)
981
				mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'`
982
				eval mandatory='$'mandatory${mangled}
983
984
				if [ -f $f ]; then
985
					if [ -n "$mandatory" ]; then
986
						cp $f $f.bak
987
988
						maxlines=`echo "$mandatory" | wc -l | sed 's|^[[:space:]]*||'`
989
						index=1
990
991
						while [ $index -le $maxlines ]; do
992
							line="`echo \"$mandatory\" | sed -n ${index}p`"
993
								
994
							if ! cat $f | grep --silent "$line"; then
995
								token1=`echo $line | awk -F= '{print $1}'`
996
								token2=`echo $line | awk -F= '{print $2}'`
997
998
								search="^${token1}="
999
								
1000
								if ! cat $f | egrep --silent "$search"; then
1001
									echo $line >> $f
1002
								fi
1003
							fi
1004
							
1005
							index=`expr $index + 1`
1006
						done
1007
					fi
1008
				else
1009
					echo "$mandatory" > $f
1010
				fi
1011
				
1012
				echo && echo "Done configuring $f"
1013
				eval hint='$'hint${mangled}
1014
				eval suggested='$'suggested${mangled}
1015
				
1016
				if [ -n "$suggested" ]; then
1017
					echo "$hint"
1018
					echo && echo "$suggested"
1019
				fi
1020
			;;
1021
1022
			n|N)
1023
			;;
1024
1025
			*)
1026
				echo "I do not know what that means  : - ("
1027
				echo "Skipping $f"
1028
			;;
1029
		esac
1030
	done
1031
1032
	set +e
1033
	echo
1034
1035
	cat <<-EOF
1036
	Post-processing done.
1037
	If you saw no errors anywhere, your box is raring to go  : - )
1038
	A reboot is now needed - you will need to do that yourself.
1039
1040
	Before you reboot, please make a note of one setting that could save you
1041
	hours of googling and jostling later on.
1042
	
1043
	If you plug in a USB device, it usually will be visible to every user
1044
	out-of-the-box. But sometimes, it may happen that only the root user is able
1045
	to see the device (most commonly happens with printer/scanner).
1046
1047
	If that happens, run usbconfig as root to ensure that the device is showing
1048
	up in the output, and make a note of its ugen ID, with <x>.<y> translating
1049
	as <x>.<y>.0 (for example, ugen2.4 would correspond to the ugen ID 2.4.0)
1050
	
1051
	Then run usbconfig again, this time as the normal user. If the ugen ID is
1052
	missing, add a line to /etc/devfs.conf (as root, of course) :
1053
1054
	perm usb/<ugen_ID> 0664
1055
1056
	For our example, that would mean :
1057
1058
	perm usb/2.4.0 0664
1059
1060
	Then, as root, run '/etc/rc.d/devfs restart'.
1061
	Your device should now work	cleanly for the normal user too.
1062
	EOF
1063
}
1064
1065
if [ -n "$idents" ]; then
1066
	if [ "$mode_echo" = "false" -a "$mode_dry" = "false" ]; then
1067
		clear && echo "Here is a preview of what I shall be doing"
1068
		echo
1069
		echo -e "(\e[4mstage name\e[0m :: package list as per stage definition)"
1070
		echo
1071
		echo "<<<<----"
1072
		echo
1073
1074
		readonly my_mode_echo=$mode_echo
1075
		mode_echo=true
1076
		previous_level=0
1077
1078
		for var in $idents; do
1079
			eval level='$'$var
1080
	
1081
			[ -z "$level" ] && \
1082
			die "$LINENO" "level must not evaluate as an empty string"
1083
			
1084
			echo "$level" | grep '[^[:digit:]]' > /dev/null && \
1085
			die "$LINENO" "level must be numeric"
1086
			
1087
			if [ $level -le $previous_level ]; then
1088
				die "$LINENO" \
1089
"This level is ${level}; Previous was ${previous_level}
1090
Random/descending order of stages is not supported"
1091
			fi
1092
			
1093
			[ $begin -gt $level ] || f_stage $var
1094
			
1095
			[ $? -eq 0 ] && \
1096
			previous_level=$level || \
1097
			die "$LINENO" "stage failure for stage $var"
1098
			
1099
			[ $end -eq $level ] && { break; }
1100
		done
1101
1102
		echo
1103
		echo "---->>>>"
1104
		echo
1105
1106
		mode_echo=$my_mode_echo
1107
		b_valid=false
1108
	
1109
		while [ "$b_valid" = "false" ]; do
1110
			cat <<-EOF
1111
			If you like the preview of what is to be done, give me a :
1112
1113
			y) Install the stages
1114
			
1115
			Y) Install stages non-interactively : passes --yes to 'pkg install'
1116
			(If you enter Y, just wait a few minutes/hours, and your entire
1117
			desktop will get assembled nicely and I shall bother you only for
1118
			the post-processing when the desktop has been put together)
1119
			
1120
			If you would like to modify the installation, press Control-C to
1121
			abort and alter the stage-definitions file and/or package list files
1122
1123
			Your choice  ? (y/Y) :
1124
			EOF
1125
		
1126
			read answer
1127
		
1128
			case "$answer" in
1129
				y)
1130
					b_valid=true
1131
				;;
1132
		
1133
				Y)
1134
					b_valid=true
1135
					mode_yes=true
1136
				;;
1137
		
1138
				*)
1139
					echo "I do not know what to make of that  : - (" 1>&2
1140
				;;
1141
			esac
1142
		done
1143
	fi
1144
1145
	previous_level=0
1146
1147
	for var in $idents; do
1148
		eval level='$'$var
1149
1150
		[ -z "$level" ] && \
1151
		die "$LINENO" "level must not evaluate as an empty string"
1152
		
1153
		echo "$level" | grep '[^[:digit:]]' > /dev/null && \
1154
		die "$LINENO" "level must be numeric"
1155
		
1156
		if [ $level -le $previous_level ]; then
1157
			die "$LINENO" \
1158
"This level is ${level}; Previous was ${previous_level}
1159
Random/descending order of stages is not supported"
1160
		fi
1161
		
1162
		[ $begin -gt $level ] || f_stage $var
1163
		
1164
		[ $? -eq 0 ] && \
1165
		previous_level=$level || \
1166
		die "$LINENO" "stage failure for stage $var"
1167
		
1168
		if [ $end -eq $level ]; then
1169
			[ "$arg_end" = "true" ] && exit 0 || break
1170
		fi
1171
	done
1172
1173
	postproc
1174
fi
1175
1176
exit $?
(-)mkdesktop/mkdesktop-1.8/mkdesktop.help (-72 lines)
Lines 1-72 Link Here
1
Installing a FreeBSD desktop from scratch can be messy : you often forget the
2
correct steps/packages. This script helps to standardize the process.
3
4
Although you could lump all packages into a single list, breaking up the list
5
into more stages allows for better, fine-grained control.
6
7
By default, 5 stages are considered, in order :
8
9
pre_x -> x -> post_x -> desktop -> post_desktop
10
11
pre_x (level 1) presumes there is no X around. The default definition of this
12
stage is empty, but this is a good place to specify command-line utilities -
13
wget:cdrecord:vim-lite
14
15
x (level 2) is the stage for installing the base X system. By default, this
16
installs just the xorg meta-distribution.
17
18
post_x (level 3) is suited for X stuff that is not desktop-specific. The default
19
definition of this stage is empty, but you can pull in a lot of stuff -
20
xclip:firefox:virtualbox-ose:libreoffice:smplayer
21
22
desktop (level 4) is the stage for the base desktop. If you wish to install
23
GNOME as the desktop, use gnome3. The current default is a lightweight version
24
of KDE4 -
25
kde-baseapps-kde4:kde-runtime-kde4:kde-workspace-kde4:kdelibs-kde4
26
27
Just as with stage x, the stage definition for desktop should preferably be as
28
lean as possible.
29
30
post_desktop (level 5) is where you get the stuff that is desktop-specific. If
31
you chose KDE4 as desktop, you can pull in some additional applications from
32
KDE itself or across other desktop environments -
33
k3b:krita:ksnapshot:thunar:gnome-games
34
35
Each stage can be defined in 2 ways :
36
37
1) list_<stage> is a colon-separated list of packages for the stage.
38
The default implementation has 5 such lists :
39
40
list_pre_x, list_x, list_post_x, list_desktop, list_post_desktop.
41
42
These lists reside in their respective declarations in the file
43
$HOME/mkdesktop/stage-definitions (specifically the line 'eval list_${ident}=')
44
45
2) If a file named <stage> exists in the package list directory, it supersedes
46
the definition of list_<stage>. Since the default implementation is wired for
47
$HOME/mkdesktop/pkg_list as the package list directory, this script by default
48
looks for files named pre_x, x, post_x, desktop and post_desktop therein. You
49
can change the package list directory location by passing in the argument
50
"--pkg_list_dir <location>"
51
52
Unlike the colon-separated lists, package list files are newline-separated. If
53
the first character on a line is '#' (hash without quotes), the line is ignored
54
as a comment.
55
56
mkdesktop also bundles in 2 special functions : stagezero and postproc.
57
58
stagezero has to be explicitly invoked by passing in '--begin 0' and it caters
59
to setting up the graphics environment for Radeon/NVidia chipsets, kld's for
60
which are set up to be loaded automatically at boot-time via /etc/rc.local. For
61
NVidia, stagezero also pulls in the graphics driver nvidia-driver.
62
63
postproc gets automatically invoked when the regular stages have been processed.
64
It sets up - if the user chooses Yes for each of these - Wine (Windows emulation
65
layer); Linuxulator (Linux emulation layer); configuration of system files :
66
{
67
	Under /etc/ 	: fstab; devfs.conf; devfs.rules; rc.conf; sysctl.conf;
68
	Under /boot/	: loader.conf;
69
}
70
71
If you [do not] like this script, consider emailing the author :
72
Manish Jain (bourne.identity@hotmail.com)
(-)mkdesktop/mkdesktop-1.8/stage-definitions (-141 lines)
Lines 1-141 Link Here
1
# Copy (and uncomment once) the following block to establish a new stage.
2
# You can copy to any location in this file : the higher up you copy, the
3
# earlier that stage will be processed. If you copy to the bottom, it will
4
# effectively establish the last stage.
5
# 
6
# The markup tags in the template are purely for visual assistance.
7
8
#{
9
##<mustchange>
10
#	#the first line establishes the stage name
11
#	#must be copied as well as altered to generate a new name
12
#	#name must be a) unique; and b) alphanumeric (with underscores permitted)
13
14
#	ident=my_stage1
15
##</mustchange>
16
17
##<mustnotchange>
18
#	#the following lines must never be altered, so copy them as is
19
20
#	[ -z "$ident" ] && die "$ident is null"
21
22
#	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
23
24
#	if echo "$idents" | grep -w "$ident" > /dev/null; then
25
#		die "stage-definitions :: error compiling stage $ident :
26
#		name clash with a stage name already defined"
27
#	fi
28
	
29
#	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
30
31
#	stage=`expr $stage + 1`
32
#	eval $ident=$stage
33
##</mustnotchange>
34
35
##<maychange>
36
#	#the last line must be copied and optionally altered as a 
37
#	#colon-separated list of packages
38
39
#	eval list_${ident}=""
40
##</maychange>
41
#}
42
43
{
44
	#stage definition for pre_x :
45
	ident=pre_x
46
47
	[ -z "$ident" ] && die "$ident is null"
48
49
	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
50
51
	if echo "$idents" | grep -w "$ident" > /dev/null; then
52
		die "stage-definitions :: error compiling stage $ident :
53
		name clash with a stage name already defined"
54
	fi
55
56
	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
57
	stage=`expr $stage + 1`
58
	eval $ident=$stage
59
60
	eval list_${ident}=""
61
}
62
63
{
64
	#stage definition for x
65
	ident=x
66
67
	[ -z "$ident" ] && die "$ident is null"
68
69
	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
70
71
	if echo "$idents" | grep -w "$ident" > /dev/null; then
72
		die "stage-definitions :: error compiling stage $ident :
73
		name clash with a stage name already defined"
74
	fi
75
76
	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
77
	stage=`expr $stage + 1`
78
	eval $ident=$stage
79
80
	eval list_${ident}="xorg"
81
}
82
83
{
84
	#stage definition for post_x
85
	ident=post_x
86
87
	[ -z "$ident" ] && die "$ident is null"
88
89
	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
90
91
	if echo "$idents" | grep -w "$ident" > /dev/null; then
92
		die "stage-definitions :: error compiling stage $ident :
93
		name clash with a stage name already defined"
94
	fi
95
96
	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
97
	stage=`expr $stage + 1`
98
	eval $ident=$stage
99
100
	eval list_${ident}=""
101
}
102
103
{
104
	#stage definition for desktop
105
	ident=desktop
106
107
	[ -z "$ident" ] && die "$ident is null"
108
109
	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
110
111
	if echo "$idents" | grep -w "$ident" > /dev/null; then
112
		die "stage-definitions :: error compiling stage $ident :
113
		name clash with a stage name already defined"
114
	fi
115
116
	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
117
	stage=`expr $stage + 1`
118
	eval $ident=$stage
119
120
	eval list_${ident}="kde-baseapps-kde4:kde-runtime-kde4:kde-workspace-kde4:kdelibs-kde4"
121
}
122
123
{
124
	#stage definition for post_desktop
125
	ident=post_desktop
126
127
	[ -z "$ident" ] && die "$ident is null"
128
129
	echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident"
130
131
	if echo "$idents" | grep -w "$ident" > /dev/null; then
132
		die "stage-definitions :: error compiling stage $ident :
133
		name clash with a stage name already defined"
134
	fi
135
136
	[ -z "$idents" ] && idents=$ident || idents="$idents $ident"
137
	stage=`expr $stage + 1`
138
	eval $ident=$stage
139
140
	eval list_${ident}=""
141
}
(-)mkdesktop/pkg-descr (-10 / +6 lines)
Lines 1-10 Link Here
1
mkdesktop is a Bourne script that helps to standardize the process of FreeBSD
1
Installing a FreeBSD desktop from scratch can be messy : you often
2
desktop installation as much as possible per user, with plenty of flexibility as
2
forget the correct steps/packages. The mkdesktop script helps to
3
well as modularity. By default, you get 5 distinct stages for defining your
3
standardize the process as much as possible per user, with plenty of
4
desktop environment. But you can always add/subtract/customize the stages as
4
flexibility as well as modularity. The script sets up X & your desktop,
5
much as you wish. Once you start using mkdesktop, you will pretty soon love it -
5
configures emulation layers (Wine / Linuxulator) if so desired, and
6
particularly its post-processor which automatically kicks in once the stages
6
then configures the essential system files under /etc and /boot.
7
have been processed - it sets up emulation layers and configuration of system
8
files, if the user so desires.
9
10
WWW: https://github.com/bourne-again/mkdesktop

Return to bug 232326