# This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # sysutils/mkdesktop # sysutils/mkdesktop/Makefile # sysutils/mkdesktop/files # sysutils/mkdesktop/files/mkdesktop # sysutils/mkdesktop/files/stage-definitions # sysutils/mkdesktop/files/mkdesktop.1 # sysutils/mkdesktop/pkg-descr # sysutils/mkdesktop/distinfo # echo c - sysutils/mkdesktop mkdir -p sysutils/mkdesktop > /dev/null 2>&1 echo x - sysutils/mkdesktop/Makefile sed 's/^X//' >sysutils/mkdesktop/Makefile << 'edba6822508738a659ff469244f1df7a' X# $FreeBSD$ X XPORTNAME= mkdesktop XPORTVERSION= 2.0 XCATEGORIES= sysutils XMASTER_SITES= X XMAINTAINER= bourne.identity@hotmail.com XCOMMENT= Powerful, flexible utility to setup a FreeBSD desktop X XNO_BUILD= yes XNO_ARCH= yes X XPLIST_FILES= bin/${PORTNAME} share/${PORTNAME}/${PORTNAME} share/${PORTNAME}/stage-definitions man/man1/${PORTNAME}.1.gz XDISTFILES= X Xdo-install: X ${INSTALL_SCRIPT} ${FILESDIR}/mkdesktop ${STAGEDIR}${PREFIX}/bin/ X ${MKDIR} ${STAGEDIR}${PREFIX}/share/${PORTNAME} X ${INSTALL_DATA} ${FILESDIR}/mkdesktop ${STAGEDIR}${PREFIX}/share/${PORTNAME}/ X ${INSTALL_DATA} ${FILESDIR}/stage-definitions ${STAGEDIR}${PREFIX}/share/${PORTNAME}/ X ${INSTALL_MAN} ${FILESDIR}/mkdesktop.1 ${STAGEDIR}${MANPREFIX}/man/man1 X X.include edba6822508738a659ff469244f1df7a echo c - sysutils/mkdesktop/files mkdir -p sysutils/mkdesktop/files > /dev/null 2>&1 echo x - sysutils/mkdesktop/files/mkdesktop sed 's/^X//' >sysutils/mkdesktop/files/mkdesktop << '496c47bc51067545d7766a2edc7f9cd6' X#!/bin/sh X Xsz_usage="I need 0 (zero) mandatory args : `basename $0` [optional arguments] X XLegend of [optional arguments] :: X X--begin : Use as the beginning stage X( X defaults to 1. But you can specify a higher value as long as it is lower X than or equal to end. You can also specify a begin value of 0 - stage 0 runs X a special initialization procedure to set up your graphics subsystem X) X X--end : Use as the last stage to process X( X defaults to the highest stage value available, as evaluated at runtime. But X you can change that to something lower, as long as it is at least equal to X the begin value X) X X--pkg_list_dir : Use as the package list directory X(defaults to \$HOME/mkdesktop/pkg_list) X X--no-postproc : Disable the postproc function that kicks in automatically upon Xprocessing of regular stages to configure emulation layers and system files X X--dry : in dry mode, special functions (stage 0; post-processor) are Xdisabled and regular stage levels are processed by 'pkg install --dry-run', Xunless you specify --echo too (in which case the --dry argument is silently Xignored). --dry is available to non-root users too. X X--echo : in echo mode, special functions (stage 0; post-processor) are Xdisabled and regular stage levels are processed by 'echo', not 'pkg install'. X--echo takes precedence over --dry, as well as is available to non-root users Xtoo. This is useful for testing what non-automatic packages would get installed Xby this script. X X--append : in append mode, packages mentioned in package list files are Xappended to the stage definition lists, which otherwise would be superseded. X X--help : print the man page. X X--usage : print usage information" X Xlocation=$HOME/mkdesktop Xpkg_list_dir="$location/pkg_list" Xno_postproc=false X Xmode_echo=false Xmode_dry=false Xmode_append=false Xmode_yes=false X Xbegin=1 Xend=-1 X Xarg_begin=false Xarg_end=false X Xdummy=0 X Xdie() X{ X [ $# -eq 0 ] && exit 1 X X [ $# -gt 1 ] && \ X echo "error initiated at line $1 : X $2" 1>&2 || \ X echo "$1" 1>&2 X X exit 1 X} X Xwhile echo "$1" | grep '^--' > /dev/null; do X case "$1" in X --begin) X shift X begin="" X X if [ $# -gt 0 ]; then X if echo $1 | grep '[^[:digit:]]' > /dev/null; then X die "$LINENO" "Bad digital value for begin : $1" X else X begin="$1" X arg_begin=true X shift X fi X fi X ;; X X --end) X shift X end="" X X if [ $# -gt 0 ]; then X if echo $1 | grep '[^[:digit:]]' > /dev/null; then X die "$LINENO" "Bad digital value for end : $1" X else X end="$1" X arg_end=true X shift X fi X fi X ;; X X --pkg_list_dir) X shift X pkg_list_dir="" X X if [ $# -gt 0 ]; then X pkg_list_dir="$1" X shift X fi X ;; X X --no-postproc) X shift X no_postproc=true X ;; X X --dry) X shift X mode_dry=true X ;; X X --echo) X shift X mode_echo=true X ;; X X --append) X shift X mode_append=true X ;; X X --help) X man mkdesktop X exit $? X ;; X X --usage) X echo "$sz_usage" X exit 0 X ;; X X *) X die "$LINENO" "Invalid optional arg : $1" X ;; X esac Xdone X X[ $# -eq 0 ] || { die "$sz_usage"; } X Xstage=0 Xidents="" X Xfor var in location pkg_list_dir; do X eval val='$'$var X [ -z "$val" ] && die "$LINENO" "Empty string for $var" Xdone X Xif ! [ -d "$location" ]; then X cat <<-EOF X This seems to be the first time you are running mkdesktop. X X I can help you with the initial layout for running mkdesktop smoothly. X X If you wish, I can : X X 1) create the directory $HOME/mkdesktop X (which hosts the stage-definitions file) X X 2) create a default $HOME/mkdesktop/stage-definitions X (which should be good enough to get you started) X X Of course, you can always create the above by hand. And you can always X customize your stage-definitions file. You are encouraged to at least read X your stage-definitions file ($HOME/mkdesktop/stage-definitions), just to get X a feel of what lies therein, and perhaps define a custom stage too, so that X you becomes familiar with mkdesktop's working and ensure that everything X works seamlessly end-to-end for you. If you mess up your stage-definitions X file, no probs : just copy out afresh from /usr/local/share/mkdesktop/ X X If you later decide to boost your setup with package list files (read the X manpage for more on this), put them under the directory X $HOME/mkdesktop/pkg_list (which too I will create right now; or else, you X can create yourself later). X X What would you like me to do ? X X I) Initialize the setup X S) Skip initialization X X Press Control-C if you wish to abort. X X Your choice ? (I/S) : X EOF X X read answer X X case "$answer" in X i|I) X set -e X mkdir $HOME/mkdesktop X cp /usr/local/share/mkdesktop/stage-definitions $HOME/mkdesktop/stage-definitions X mkdir $HOME/mkdesktop/pkg_list X X cat <<-EOF X X mkdesktop has been initialized. X X If you wish to alter the stage-definitions or package list files for X this run, you can do still do it from another terminal window. X X When ready, press Enter to continue (or Control-C to abort) X EOF X X read enter X set +e X ;; X X s|S) X ;; X X *) X echo "I could not make sense of your choice : - (" 1>&2 X exit 1 X ;; X esac Xfi X X[ -f "$location"/stage-definitions ] && \ X{ . "$location"/stage-definitions; } || \ X{ echo "Warning : $location/stage-definitions does not exist" 1>&2; } X Xfor var in begin end; do X eval val='$'$var X X [ $var = end ] && [ "$val" = "-1" ] && val=0 X [ -z "$val" ] && die "$LINENO" "Empty string for $var" X X echo "$val" | grep '[^[:digit:]]' > /dev/null && \ X die "$LINENO" "Bad digital value ($var) : ${val}" Xdone X X[ $end -gt $stage ] && \ Xdie "$LINENO" "end must not be greater than the highest stage value ($stage)" X X[ $end -lt 0 ] && end=$stage X Xif [ $begin -gt $end ]; then X [ $end -eq 0 ] && echo "Have you defined at least one stage ?" 1>&2 X die "$LINENO" "begin must not be greater than end" Xfi X Xif [ "$mode_echo" = "false" -a "$mode_dry" = "false" ]; then X dummy=`expr $dummy + 1` X X [ `id -u` -eq 0 ] || die "You need to be root to execute this script" Xfi X Xf_stagezero() X{ X if [ "$mode_echo" = "false" -a "$mode_dry" = "false" ]; then X cat <<-EOF X X This special stage has only one thing to do : X setup any needed kld's for your graphics chipset X X Continue ? (y/n) : X EOF X X read answer X X case "$answer" in X y|Y) X cat <<-EOF X X What is your graphics chipset : X X 1) radeon [ needs radeon.ko; radeonkms.ko : X both shipped by FreeBSD in the base distribution ] X X 2) nvidia [ needs nvidia.ko; nvidia-modeset.ko : X both intalled via nvidia-driver ] X X 3) other [ needs nothing/something I am not aware of ] X X Your choice ? (1/2/3) : X EOF X X read answer X X case "$answer" in X 1) X for k in radeon radeonkms; do X echo "kldstat -qn $k || kldload $k" >> /etc/rc.local X done X X return $? X ;; X X 2) X pkg install nvidia-driver X X [ $? -eq 0 ] || die "$LINENO" "nvidia-driver install failed" X X for k in nvidia nvidia-modeset; do X echo "kldstat -qn $k || kldload $k" >> /etc/rc.local X done X X return $? X ;; X X 3) X return 0 X ;; X X *) X echo "I do not know what to make of that : - (" 1>&2 X return 1 X ;; X X esac X ;; X X n|N) X ;; X X *) X echo "I do not know what to make of that : - (" 1>&2 X return 1 X ;; X esac X fi X} X Xfix_noeol() X{ X [ $# -gt 0 ] || { echo "missing mandatory arg : " 1>&2; return 1; } X [ -f "$1" ] || { echo "$1 is not a regular file" 1>&2; return 1; } X X local r=0 X local f="$1" X X if file "$f" | grep '\' > /dev/null; then X local last="`tail -c1 \"$f\"`" X X if [ -n "$last" ]; then X [ -w "$f" ] || { echo "$f is not writable" 1>&2; return 1; } X X echo >> "$f" X r=$? X fi X fi X X return $r X} X Xf_stage() X{ X [ $# -ne 1 ] && \ X { echo "f_stage() :: I need 1 arg : stage name (ident)" 1>&2; return 1; } X X [ -z "$1" ] && \ X { echo "f_stage() :: I need 1 arg : stage name (ident)" 1>&2; return 1; } X X if ! echo "$idents" | grep -w "$1" > /dev/null; then X echo "f_stage() :: I could not locate $1 among the definitions" 1>&2 X return 1 X fi X X echo -e "\e[4m${1}\e[0m :: \c" X X local nextline="" X local firstchar="" X local lines=0 X local index=0 X X local file="" X eval local arg='$'list_${1} X X local list="`echo $arg | sed 's/:/ /g'`" X X [ -f "$pkg_list_dir"/"$1" ] && file="$pkg_list_dir"/"$1" X X if [ -n "$file" ]; then X fix_noeol "$file" X X [ "$mode_append" = "false" ] && list="" X lines="`cat $file | wc -l | sed 's/^[[:space:]]*//'`" X index=1 X X while [ $index -le $lines ]; do X nextline="`sed -n ${index}p $file`" X X if [ -n "$nextline" ]; then X firstchar="`echo $nextline | cut -c1`" X X if [ "$firstchar" = '#' ]; then X dummy=`expr $dummy + 1` X else X [ -z "$list" ] && list="$nextline" || list="$list $nextline" X fi X fi X X index=`expr $index + 1` X done X fi X X local cmd="pkg install" X X [ "$mode_dry" = "true" ] && \ X { cmd="$cmd --dry-run"; } || \ X { [ "$mode_yes" = "true" ] && cmd="$cmd --yes"; } X X [ "$mode_echo" = true ] && cmd="echo" X X [ -z "$list" ] && echo || { $cmd $list; } X local r=$? X X [ "$mode_dry" = "true" ] && [ $r -eq 1 ] && r=0 X return $r X} X X[ $begin -gt 0 ] || f_stagezero X[ $? -eq 0 ] || die "$LINENO" "stage failure setting up graphics subsystem" X[ $end -eq 0 ] && exit 0 X Xpostproc() X{ X [ "$mode_dry" = "true" ] && return 0 X [ "$mode_echo" = "true" ] && return 0 X [ "$no_postproc" = "true" ] && return 0 X X cat <<-EOF X X Your desktop has been successfully installed : - ) X X I am now going to start post-install processing to set up the following : X X Wine (32-bit/64-bit Windows emulation layer, user-space) X Linuxulator (64-bit Linux emulation layer, kernel-space) X X System files : X /etc/fstab X /etc/devfs.conf X /etc/devfs.rules X /etc/rc.conf X /etc/sysctl.conf X /boot/loader.conf X X I will seek permission from you for each of the above individually : - ) X X Note : If you ask me to configure system files, existing originals will be X saved with .bak extension X EOF X X b_valid=false X X while [ "$b_valid" = "false" ]; do X cat <<-EOF X X Would you like me to kick off post-processing ? X X y) Do it X n) Cancel this [and exit immediately] X X Your choice ? (y/n) : X EOF X X read answer X X case "$answer" in X y|Y) X b_valid=true X ;; X X n|N) X b_valid=true X exit 0 X ;; X X *) X echo "I do not know what to make of that : - (" 1>&2 X ;; X esac X done X X readonly UNITY=1 X readonly WIN32=$(( UNITY<<1 )) X readonly WIN64=$(( UNITY<<2 )) X readonly LINUX=$(( UNITY<<3 )) X X clear && echo "Beginning postproc" X X EMU=0 X X echo && echo "Would you like me to set up Wine (Windows emulation layer) ?" X echo && echo "y/n :" X read answer X X case "$answer" in X y|Y) X cat <<-EOF X X Choose a mode : X X 1) 32-bit X 2) 64-bit (This won't work if your system's CPU is 32-bit) X c) cancel Wine X EOF X X read answer X X case "$answer" in X 1) X EMU=$(( EMU | UNITY | WIN32 )) X ;; X X 2) X EMU=$(( EMU | UNITY | WIN64 )) X ;; X X c|C) X ;; X X *) X echo "I do not know what that means : - (" X echo "Skipping Wine" X ;; X esac X ;; X X n|N) X ;; X X *) X echo "I do not know what that means : - (" X echo "Skipping Wine" X ;; X esac X X echo && echo "Would you like me to set up Linuxulator (Linux emulation layer) ?" X echo && echo "Note : if you choose y, I will factor the Linuxulator into subsequent processing" X echo && echo "y/n :" X X read answer X X case "$answer" in X y|Y) X EMU=$(( EMU | UNITY | LINUX )) X ;; X X n|N) X ;; X X *) X echo "I do not know what that means : - (" X echo "Skipping Linuxulator" X ;; X esac X X my_emu=$(( EMU & UNITY )) X X result_win32=1 X result_win64=1 X result_linux=1 X X if [ $my_emu -ne 0 ]; then X my_emu=$(( EMU & WIN32 )) X X if [ $my_emu -ne 0 ]; then X pkg install --yes i386-wine wine-mono wine-gecko X result_win32=$? X fi X X my_emu=$(( EMU & WIN64 )) X X if [ $my_emu -ne 0 ]; then X pkg install --yes wine wine-mono wine-gecko X result_win64=$? X fi X X my_emu=$(( EMU & LINUX )) X X if [ $my_emu -ne 0 ]; then X if ! kldstat -q -n linux; then X kldload linux X X [ $? -eq 0 ] || \ X die "$LINENO" "Unable to kldload linux" X fi X X if [ "`uname -m`" = "amd64" ]; then X if ! kldstat -q -n linux64; then X kldload linux64 X X [ $? -eq 0 ] || \ X die "$LINENO" "Unable to kldload linux64" X fi X fi X X pkg install --yes linux_base-c7 X result_linux=$? X fi X fi X X flavour_linux=false X X if [ $(( EMU & LINUX )) -ne 0 ]; then X if [ $result_linux -eq 0 ]; then X flavour_linux=true X fi X fi X X set -e X X #block for /etc/fstab X { X f=/etc/fstab X mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'` X X if [ "$flavour_linux" = "false" ]; then X eval mandatory${mangled}="\"\ Xfdescfs /dev/fd fdescfs rw 0 0 Xprocfs /proc procfs rw 0 0\"" X X eval hint${mangled}="\"\ XIf you are going to use the Linuxulator to run Linux applications under XFreeBSD natively, try this/these in $f once you have setup the Linuxulator X(most easily done in a single command with 'pkg install linux-sublime3') :\"" X X eval suggested${mangled}="\"\ Xtmpfs /compat/linux/dev/shm tmpfs rw,mode=1777,size=1g 0 0 Xlinprocfs /compat/linux/proc linprocfs rw 0 0 Xlinsysfs /compat/linux/sys linsysfs rw 0 0\"" X else X eval mandatory${mangled}="\"\ Xfdescfs /dev/fd fdescfs rw 0 0 Xprocfs /proc procfs rw 0 0 Xtmpfs /compat/linux/dev/shm tmpfs rw,mode=1777,size=1g 0 0 Xlinprocfs /compat/linux/proc linprocfs rw 0 0 Xlinsysfs /compat/linux/sys linsysfs rw 0 0\"" X X eval hint${mangled}="" X eval suggested${mangled}="" X fi X } X X #block for /etc/devfs.conf X { X f=/etc/devfs.conf X mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'` X X if [ "$flavour_linux" = "false" ]; then X eval mandatory${mangled}="\"\ Xown /dev/pci root:operator Xperm /dev/pci 0664 Xown /dev/dri/card0 root:operator Xperm /dev/dri/card0 0664 Xown /dev/pass0 root:operator Xperm /dev/pass0 0664 Xown /dev/cd0 root:operator Xperm /dev/cd0 0664 Xown /dev/xpt0 root:operator Xperm /dev/xpt0 0664\"" X X eval hint${mangled}="\"\ XIf you're going to use the Linuxulator to run Linux applications under XFreeBSD natively, try this/these in $f once you have setup the Linuxulator X(most easily done in a single command with 'pkg install linux-sublime3') :\"" X X eval suggested${mangled}="\"\ Xlink /compat/linux/dev/shm shm\"" X else X eval mandatory${mangled}="\"\ Xown /dev/pci root:operator Xperm /dev/pci 0664 Xown /dev/dri/card0 root:operator Xperm /dev/dri/card0 0664 Xown /dev/pass0 root:operator Xperm /dev/pass0 0664 Xown /dev/cd0 root:operator Xperm /dev/cd0 0664 Xown /dev/xpt0 root:operator Xperm /dev/xpt0 0664 Xlink /compat/linux/dev/shm shm\"" X X eval hint${mangled}="" X eval suggested${mangled}="" X fi X } X X #block for /etc/devfs.rules X { X f=/etc/devfs.rules X mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'` X X eval mandatory${mangled}="\"\ X[system=10] Xadd path 'usb/*' mode 0664 group operator Xadd path 'cd*' mode 0664 group operator Xadd path 'da*' mode 0664 group operator Xadd path 'video*' mode 0664 group operator\"" X X eval hint${mangled}="" X eval suggested${mangled}="" X } X X #block for /etc/rc.conf X { X f=/etc/rc.conf X mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'` X X if [ "$flavour_linux" = "false" ]; then X eval mandatory${mangled}="\"\ Xdevfs_system_ruleset=system Xdbus_enable=YES Xhald_enable=YES Xcupsd_enable=YES\"" X X eval hint${mangled}="\"\ XHere's a few more goodies for you to keep in mind for ${f} : X X1) For fuse to be able to mount non-native filesystems like ntfs/ext4 X2) For a decent typing speed on the console X3) For auto-loading linux.ko\"" X X eval suggested${mangled}="\"\ Xfusefs_enable=YES Xkeyrate=fast Xlinux_enable=YES\"" X else X eval mandatory${mangled}="\"\ Xdevfs_system_ruleset=system Xdbus_enable=YES Xhald_enable=YES Xlinux_enable=YES Xcupsd_enable=YES\"" X X eval hint${mangled}="\"\ XHere's a few more goodies for you to keep in mind for ${f} : X X1) For fuse to be able to mount non-native filesystems like ntfs/ext4 X2) For a decent typing speed on the console\"" X X eval suggested${mangled}="\"\ Xfusefs_enable=YES Xkeyrate=fast\"" X fi X } X X #block for /etc/sysctl.conf X { X f=/etc/sysctl.conf X mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'` X X if [ "$flavour_linux" = "false" ]; then X eval mandatory${mangled}="" X X eval hint${mangled}="\"\ XYou might like to keep in mind a few other suggestions for ${f}, all optional. X1 goodie to let normal users mount disks and 2 Linuxulator goodies :\"" X X eval suggested${mangled}="\"\ Xvfs.usermount=1 Xcompat.linux.osrelease=2.6.18 Xkern.ipc.shm_allow_removed=1\"" X else X eval mandatory${mangled}="\"\ Xcompat.linux.osrelease=2.6.18 Xkern.ipc.shm_allow_removed=1\"" X X eval hint${mangled}="\"\ XFor $f, keep in mind a tip to let normal users mount disks :\"" X X eval suggested${mangled}="\"\ Xvfs.usermount=1\"" X fi X } X X #block for /boot/loader.conf X { X f=/boot/loader.conf X mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'` X X eval mandatory${mangled}="\"\ Xkern.vty=vt\"" X X eval hint${mangled}="" X eval suggested${mangled}="" X } X X for f in /etc/fstab; do X echo && echo "Configure $f : (y/n) ?" X read answer X X case "$answer" in X y|Y) X mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'` X eval mandatory='$'mandatory${mangled} X X if [ -f $f ]; then X if [ -n "$mandatory" ]; then X cp $f $f.bak X X maxlines=`echo "$mandatory" | wc -l | sed 's|^[[:space:]]*||'` X index=1 X X while [ $index -le $maxlines ]; do X line="`echo \"$mandatory\" | sed -n ${index}p`" X token1=`echo $line | awk '{print $1}'` X X if ! cat $f | grep --silent "^$token1[[:space:]]"; then X echo $line >> $f X fi X X index=`expr $index + 1` X done X fi X else X echo "$mandatory" > $f X fi X X echo && echo "Done configuring $f" X eval hint='$'hint${mangled} X eval suggested='$'suggested${mangled} X X if [ -n "$suggested" ]; then X echo "$hint" X echo && echo "$suggested" X fi X ;; X X n|N) X ;; X X *) X echo "I do not know what that means : - (" X echo "Skipping $f" X ;; X esac X done X X for f in /etc/devfs.conf; do X echo && echo "Configure $f : (y/n) ?" X read answer X X case "$answer" in X y|Y) X mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'` X eval mandatory='$'mandatory${mangled} X X if [ -f $f ]; then X if [ -n "$mandatory" ]; then X cp $f $f.bak X X maxlines=`echo "$mandatory" | wc -l | sed 's|^[[:space:]]*||'` X index=1 X X while [ $index -le $maxlines ]; do X line="`echo \"$mandatory\" | sed -n ${index}p`" X X if ! cat $f | grep --silent "$line"; then X token1=`echo $line | awk '{print $1}'` X token3=`echo $line | awk '{print $3}'` X X token2=`echo $line | awk '{print $2}'` X token2_alt=`echo $token2 | sed -n 's|^/dev/||p'` X t2_lastchar=`echo $token2 | rev | cut -c1` X X search="^${token1}[[:space:]]+${token2}[[:space:]]" X X if [ -n "$token2_alt" ]; then X search="^${token1}[[:space:]]+(${token2}|${token2_alt})[[:space:]]" X fi X X if [ "$t2_lastchar" = "0" ]; then X lead=`echo $token2 | sed -n 's|^\(.*[^[:digit:]]\)\([[:digit:]]*\)$|\1|p'` X trail=`echo $token2 | sed -n 's|^\(.*[^[:digit:]]\)\([[:digit:]]*\)$|\2|p'` X X while [ -c $token2 ]; do X if ! cat $f | egrep --silent "$search"; then X echo $line >> $f X fi X X trail=`expr $trail + 1` X token2="${lead}${trail}" X token2_alt=`echo $token2 | sed -n 's|^/dev/||p'` X line="$token1 $token2 $token3" X X search="^${token1}[[:space:]]+${token2}[[:space:]]" X X if [ -n "$token2_alt" ]; then X search="^${token1}[[:space:]]+(${token2}|${token2_alt})[[:space:]]" X fi X done X else X if [ -c $token2 ]; then X if ! cat $f | egrep --silent "$search"; then X echo $line >> $f X fi X fi X fi X fi X X index=`expr $index + 1` X done X fi X else X echo "$mandatory" > $f X fi X X echo && echo "Done configuring $f" X eval hint='$'hint${mangled} X eval suggested='$'suggested${mangled} X X if [ -n "$suggested" ]; then X echo "$hint" X echo && echo "$suggested" X fi X ;; X X n|N) X ;; X X *) X echo "I do not know what that means : - (" X echo "Skipping $f" X ;; X esac X done X X for f in /etc/devfs.rules; do X echo && echo "Configure $f : (y/n) ?" X read answer X X case "$answer" in X y|Y) X mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'` X eval mandatory='$'mandatory${mangled} X X if [ -f $f ]; then X if [ -n "$mandatory" ]; then X cp $f $f.bak X X line="`echo \"$mandatory\" | sed -n 1p`" X X if ! cat $f | grep --silent "$line"; then X echo "$mandatory" >> $f X fi X fi X else X echo "$mandatory" > $f X fi X X echo && echo "Done configuring $f" X eval hint='$'hint${mangled} X eval suggested='$'suggested${mangled} X X if [ -n "$suggested" ]; then X echo "$hint" X echo && echo "$suggested" X fi X ;; X X n|N) X ;; X X *) X echo "I do not know what that means : - (" X echo "Skipping $f" X ;; X esac X done X X for f in /etc/rc.conf /etc/sysctl.conf /boot/loader.conf; do X echo && echo "Configure $f : (y/n) ?" X read answer X X case "$answer" in X y|Y) X mangled=`echo $f | sed 's|[^[:alpha:]]|_|g'` X eval mandatory='$'mandatory${mangled} X X if [ -f $f ]; then X if [ -n "$mandatory" ]; then X cp $f $f.bak X X maxlines=`echo "$mandatory" | wc -l | sed 's|^[[:space:]]*||'` X index=1 X X while [ $index -le $maxlines ]; do X line="`echo \"$mandatory\" | sed -n ${index}p`" X X if ! cat $f | grep --silent "$line"; then X token1=`echo $line | awk -F= '{print $1}'` X token2=`echo $line | awk -F= '{print $2}'` X X search="^${token1}=" X X if ! cat $f | egrep --silent "$search"; then X echo $line >> $f X fi X fi X X index=`expr $index + 1` X done X fi X else X echo "$mandatory" > $f X fi X X echo && echo "Done configuring $f" X eval hint='$'hint${mangled} X eval suggested='$'suggested${mangled} X X if [ -n "$suggested" ]; then X echo "$hint" X echo && echo "$suggested" X fi X ;; X X n|N) X ;; X X *) X echo "I do not know what that means : - (" X echo "Skipping $f" X ;; X esac X done X X set +e X echo X X cat <<-EOF X Post-processing done. X If you saw no errors anywhere, your box is raring to go : - ) X A reboot is now needed - you will need to do that yourself. X X Before you reboot, please make a note of one setting that could save you X hours of googling and jostling later on. X X If you plug in a USB device, it usually will be visible to every user X out-of-the-box. But sometimes, it may happen that only the root user is able X to see the device (most commonly happens with printer/scanner). X X If that happens, run usbconfig as root to ensure that the device is showing X up in the output, and make a note of its ugen ID, with . translating X as ..0 (for example, ugen2.4 would correspond to the ugen ID 2.4.0) X X Then run usbconfig again, this time as the normal user. If the ugen ID is X missing, add a line to /etc/devfs.conf (as root, of course) : X X perm usb/ 0664 X X For our example, that would mean : X X perm usb/2.4.0 0664 X X Then, as root, run '/etc/rc.d/devfs restart'. X Your device should now work cleanly for the normal user too. X EOF X} X Xif [ -n "$idents" ]; then X if [ "$mode_echo" = "false" -a "$mode_dry" = "false" ]; then X clear && echo "Here is a preview of what I shall be doing" X echo X echo -e "(\e[4mstage name\e[0m :: package list as per stage definition)" X echo X echo "<<<<----" X echo X X readonly my_mode_echo=$mode_echo X mode_echo=true X previous_level=0 X X for var in $idents; do X eval level='$'$var X X [ -z "$level" ] && \ X die "$LINENO" "level must not evaluate as an empty string" X X echo "$level" | grep '[^[:digit:]]' > /dev/null && \ X die "$LINENO" "level must be numeric" X X if [ $level -le $previous_level ]; then X die "$LINENO" \ X"This level is ${level}; Previous was ${previous_level} XRandom/descending order of stages is not supported" X fi X X [ $begin -gt $level ] || f_stage $var X X [ $? -eq 0 ] && \ X previous_level=$level || \ X die "$LINENO" "stage failure for stage $var" X X [ $end -eq $level ] && { break; } X done X X echo X echo "---->>>>" X echo X X mode_echo=$my_mode_echo X b_valid=false X X while [ "$b_valid" = "false" ]; do X cat <<-EOF X If you like the preview of what is to be done, give me a : X X y) Install the stages X X Y) Install stages non-interactively : passes --yes to 'pkg install' X (If you enter Y, just wait a few minutes/hours, and your entire X desktop will get assembled nicely and I shall bother you only for X the post-processing when the desktop has been put together) X X If you would like to modify the installation, press Control-C to X abort and alter the stage-definitions file and/or package list files X X Your choice ? (y/Y) : X EOF X X read answer X X case "$answer" in X y) X b_valid=true X ;; X X Y) X b_valid=true X mode_yes=true X ;; X X *) X echo "I do not know what to make of that : - (" 1>&2 X ;; X esac X done X fi X X previous_level=0 X X for var in $idents; do X eval level='$'$var X X [ -z "$level" ] && \ X die "$LINENO" "level must not evaluate as an empty string" X X echo "$level" | grep '[^[:digit:]]' > /dev/null && \ X die "$LINENO" "level must be numeric" X X if [ $level -le $previous_level ]; then X die "$LINENO" \ X"This level is ${level}; Previous was ${previous_level} XRandom/descending order of stages is not supported" X fi X X [ $begin -gt $level ] || f_stage $var X X [ $? -eq 0 ] && \ X previous_level=$level || \ X die "$LINENO" "stage failure for stage $var" X X if [ $end -eq $level ]; then X [ "$arg_end" = "true" ] && exit 0 || break X fi X done X X postproc Xfi X Xexit $? 496c47bc51067545d7766a2edc7f9cd6 echo x - sysutils/mkdesktop/files/stage-definitions sed 's/^X//' >sysutils/mkdesktop/files/stage-definitions << 'c369a7501cc6bfb9bcf400d24fce7967' X# Copy (and uncomment once) the following block to establish a new stage. X# You can copy to any location in this file. X# The markup tags are purely for visual assistance. X X#{ X## X# #the first line establishes the stage name X# #must be copied as well as altered to generate a new name X# #name must be a) unique; and b) alphanumeric (with underscores permitted) X X# ident=my_stage1 X## X X## X# #the following lines must never be altered, so copy them as is X X# [ -z "$ident" ] && die "$ident is null" X X# echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident" X X# if echo "$idents" | grep -w "$ident" > /dev/null; then X# die "stage-definitions :: error compiling stage $ident : X# name clash with a stage name already defined" X# fi X X# [ -z "$idents" ] && idents=$ident || idents="$idents $ident" X X# stage=`expr $stage + 1` X# eval $ident=$stage X## X X## X# #the last line must be copied and optionally altered as a X# #colon-separated list of packages X X# eval list_${ident}="" X## X#} X X{ X #stage definition for pre_x : X ident=pre_x X X [ -z "$ident" ] && die "$ident is null" X X echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident" X X if echo "$idents" | grep -w "$ident" > /dev/null; then X die "stage-definitions :: error compiling stage $ident : X name clash with a stage name already defined" X fi X X [ -z "$idents" ] && idents=$ident || idents="$idents $ident" X stage=`expr $stage + 1` X eval $ident=$stage X X eval list_${ident}="" X} X X{ X #stage definition for x X ident=x X X [ -z "$ident" ] && die "$ident is null" X X echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident" X X if echo "$idents" | grep -w "$ident" > /dev/null; then X die "stage-definitions :: error compiling stage $ident : X name clash with a stage name already defined" X fi X X [ -z "$idents" ] && idents=$ident || idents="$idents $ident" X stage=`expr $stage + 1` X eval $ident=$stage X X eval list_${ident}="xorg" X} X X{ X #stage definition for post_x X ident=post_x X X [ -z "$ident" ] && die "$ident is null" X X echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident" X X if echo "$idents" | grep -w "$ident" > /dev/null; then X die "stage-definitions :: error compiling stage $ident : X name clash with a stage name already defined" X fi X X [ -z "$idents" ] && idents=$ident || idents="$idents $ident" X stage=`expr $stage + 1` X eval $ident=$stage X X eval list_${ident}="" X} X X{ X #stage definition for desktop X ident=desktop X X [ -z "$ident" ] && die "$ident is null" X X echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident" X X if echo "$idents" | grep -w "$ident" > /dev/null; then X die "stage-definitions :: error compiling stage $ident : X name clash with a stage name already defined" X fi X X [ -z "$idents" ] && idents=$ident || idents="$idents $ident" X stage=`expr $stage + 1` X eval $ident=$stage X X eval list_${ident}="kde5" X} X X{ X #stage definition for post_desktop X ident=post_desktop X X [ -z "$ident" ] && die "$ident is null" X X echo "$ident" | grep '[^[:alnum:]_]' && die "Bad name : $ident" X X if echo "$idents" | grep -w "$ident" > /dev/null; then X die "stage-definitions :: error compiling stage $ident : X name clash with a stage name already defined" X fi X X [ -z "$idents" ] && idents=$ident || idents="$idents $ident" X stage=`expr $stage + 1` X eval $ident=$stage X X eval list_${ident}="" X} c369a7501cc6bfb9bcf400d24fce7967 echo x - sysutils/mkdesktop/files/mkdesktop.1 sed 's/^X//' >sysutils/mkdesktop/files/mkdesktop.1 << 'e7996b2f615fc5eebdac75cd2861fe84' X.TH man 1 "16 October 2018" "2.0" "mkdesktop man page" X X.SH NAME Xmkdesktop X X.SH SYNOPSIS Xmkdesktop \- configure a FreeBSD desktop in a jiffy. X X.SH DESCRIPTION XIf you install a desktop, for instance KDE, under a new FreeBSD Xinstallation by yourself, you will have to do all of the following : X X1) Install X (xorg) X.br X2) Install KDE (kde5) X.br X3) Configure the system files under /etc and /boot X XIf you use the command mkdesktop, it will do all the above on its own, Xand a bit more if you so desire - it can install (unattended) anything Xelse you need, and then set up any emulation layers (Wine / Linuxulator) Xyou might wish to use. X XIf you wish to use GNOME (gnome3) instead of the default desktop kde5, Xjust launch mkdesktop and wait for it to initialize itself, and Xthen - when prompted - run the command : X Xecho gnome3 > ~/mkdesktop/pkg_list/desktop X XIn any subsequent run, whatever is the list of packages in the file X~/mkdesktop/pkg_list/desktop overrides the default definition of Xdesktop. Package list files are newline-separated. X XAlthough you could lump all packages into a single list, breaking up the Xlist into more stages allows for better, fine-grained control. X XBy default, 5 stages are considered, in order : X Xpre_x -> x -> post_x -> desktop -> post_desktop X X(Remember that stage lists are colon-separated, unlike package lists Xwhich are newline separated) X Xpre_x (level 1) presumes there is no X around. The default definition of Xthis stage is empty, but this is a good place to specify command-line Xutilities - wget:cdrecord:vim-console X Xx (level 2) is the stage for installing the base X system. By default, Xthis installs just the xorg meta-distribution. X Xpost_x (level 3) is suited for X stuff that is not desktop-specific. The Xdefault definition of this stage is empty, but you can pull in a lot of Xstuff - xclip:firefox:virtualbox-ose:libreoffice:smplayer X Xdesktop (level 4) is the stage for the base desktop. If you wish to Xinstall GNOME as the desktop, use gnome3. The default for this stage is XKDE5, which essentially means the meta-package kde5. X X(Like stage x, the stage definition for desktop should preferably be as Xlean as possible). X Xpost_desktop (level 5) is where you get the stuff that is Xdesktop-specific. If you chose gnome3-lite as desktop, you can add some Xapplications at this stage to make your desktop fuller (though the Xdefault setting for this stage is empty) - Xgnome-terminal:gedit:gdm:file-roller X XEach stage can be defined in one/both of the following 2 ways : X X1) list_ is a colon-separated list of packages for the stage. As Xyou would expect, the default implementation has 5 such lists : Xlist_pre_x, list_x, list_post_x, list_desktop, list_post_desktop. These Xlists reside in their respective declarations in the file X~/mkdesktop/stage-definitions (specifically the line list_$ident=) X X2) If a file named exists in the package list directory, it Xsupersedes the definition of list_ (unless you use --append). XSince the default implementation is wired for ~/mkdesktop/pkg_list as Xthe package list directory, this script by default looks for files named Xpre_x, x, post_x, desktop and post_desktop therein. You can change the Xpackage list directory location by passing in "--pkg_list_dir X" X XIf you create a custom stage named mystage in the file X~/mkdesktop/stage-definitions, the script will automatically consider Xthe file ~/mkdesktop/pkg_list/mystage (if such a file exists) as the Xstage definition. If you do not wish to create a package list file for Xmystage, you can specify the stage's package list by preparing the Xcolon-separated list list_mystage in ~/mkdesktop/stage-definitions Xitself (by populating the line list_$ident= in the definition). X XUnlike the colon-separated stage lists, package list files are Xnewline-separated. If the first character on a line is '#' (hash without Xquotes), the line is ignored as a comment. X XIf you create a file named (for example) mydummy in the package list Xdirectory, it comes into consideration only when a stage named mydummy Xhas been declared in the file ~/mkdesktop/stage-definitions. Declaring Xa custom stage in the file stage-definitions is easy : you just need to Xcopy out the sample at the top to a suitable location in the file and Xchange the copy's ident string. Make sure the ident is unique. X Xmkdesktop also bundles in 2 special functions : stagezero and postproc. X Xstagezero has to be explicitly invoked by passing in '--begin 0' and it Xcaters to setting up the graphics environment for Radeon/NVidia Xchipsets, kld's for which are set up to be loaded automatically at Xboot-time via /etc/rc.local. For NVidia, stagezero also pulls in the Xgraphics driver nvidia-driver. X Xpostproc gets automatically invoked when the regular stages have been Xprocessed. It sets up - if the user chooses Yes for each of these - XWine (Windows emulation layer); Linuxulator (Linux emulation layer); Xconfiguration of system files : X XUnder /etc/ : fstab; devfs.conf; devfs.rules; rc.conf; sysctl.conf; X.br XUnder /boot/ : loader.conf. X Xmkdesktop never processes standard input - so you cannot use it at the Xend of a pipeline. Diagnostic messages are always written to standard Xerror. X XIf this script makes FreeBSD desktop installation/configuration easier Xfor you, consider backing up your stage-definitions file and your Xpackage list files. Tip : it might be a bit painful learning how to use Xmkdesktop the first time. But if you regularly install FreeBSD, you will Xsoon appreciate the convenience it becomes. X X.SH OPTIONS X--begin : Use as the beginning stage X(default: 1) X X--end : Use as the last stage X(default: highest available) X X--pkg_list_dir : Use as the package list directory X(default: ~/mkdesktop/pkg_list) X X--no-postproc : Disable the postproc function that kicks in Xautomatically upon processing of regular stages to configure emulation Xlayers and system files X X--dry : Test without making changes to the system. In dry mode, special Xfunctions (stage 0; post-processor) are disabled and regular stage Xlevels are processed by 'pkg install --dry-run', unless you specify X--echo too (in which case the --dry argument is silently ignored). X--dry is available to non-root users too. X X--echo : Just list the packages that would be installed. In echo mode, Xspecial functions (stage 0; post-processor) are disabled and regular Xstage levels are processed by 'echo', not 'pkg install'. --echo takes Xprecedence over --dry, as well as is available to non-root users too. XThis is useful to test what non-automatic packages would get installed Xby this script. X X--append : In append mode, packages mentioned in package list files are Xappended to the stage definition lists, which otherwise would be Xsuperseded. X X--help : Print the man page (same as `man mkdesktop`) X X--usage : Print usage information X X.SH SEE ALSO Xdesktop-installer(1) X X.SH BUGS XNo known bugs. X X.SH AUTHOR XManish Jain (bourne.identity@hotmail.com) e7996b2f615fc5eebdac75cd2861fe84 echo x - sysutils/mkdesktop/pkg-descr sed 's/^X//' >sysutils/mkdesktop/pkg-descr << 'eadb4c768a4d7806f0e88e42584fbb25' XInstalling a FreeBSD desktop from scratch can be messy : you often Xforget the correct steps/packages. The mkdesktop script helps to Xstandardize the process as much as possible per user, with plenty of Xflexibility as well as modularity. The script sets up X & your desktop, Xconfigures emulation layers (Wine / Linuxulator) if so desired, and Xthen configures the essential system files under /etc and /boot. eadb4c768a4d7806f0e88e42584fbb25 echo x - sysutils/mkdesktop/distinfo sed 's/^X//' >sysutils/mkdesktop/distinfo << 'd57c7226fd79bcea96e64bc4ce6e5056' XSHA256 (mkdesktop-2.0.tar.gz) = 294062f8489f499fa7c9209f3d22ba34c1cfe0ef20be4037790554dab1de4da4 XSIZE (mkdesktop-2.0.tar.gz) = 10113 d57c7226fd79bcea96e64bc4ce6e5056 exit