File: windows-install.sh

package info (click to toggle)
wit 2.22b-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 7,052 kB
  • ctags: 7,132
  • sloc: ansic: 71,762; sh: 1,914; pascal: 1,823; makefile: 704
file content (131 lines) | stat: -rwxr-xr-x 4,506 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash

    #####################################################################
    ##                 __            __ _ ___________                  ##
    ##                 \ \          / /| |____   ____|                 ##
    ##                  \ \        / / | |    | |                      ##
    ##                   \ \  /\  / /  | |    | |                      ##
    ##                    \ \/  \/ /   | |    | |                      ##
    ##                     \  /\  /    | |    | |                      ##
    ##                      \/  \/     |_|    |_|                      ##
    ##                                                                 ##
    ##                        Wiimms ISO Tools                         ##
    ##                      http://wit.wiimm.de/                       ##
    ##                                                                 ##
    #####################################################################
    ##                                                                 ##
    ##   This file is part of the WIT project.                         ##
    ##   Visit http://wit.wiimm.de/ for project details and sources.   ##
    ##                                                                 ##
    ##   Copyright (c) 2009-2013 by Dirk Clemens <wiimm@wiimm.de>      ##
    ##                                                                 ##
    #####################################################################
    ##                                                                 ##
    ##   This file installs the distribution on a windows system.      ##
    ##                                                                 ##
    #####################################################################


#------------------------------------------------------------------------------
# simple cygwin check

if [[ $1 != --cygwin ]]
then
    echo "Option --cygwin not set => exit" >&2
    exit 1
fi

#------------------------------------------------------------------------------
# pre definitions

BIN_FILES="@@BIN-FILES@@"
WDF_LINKS="@@WDF-LINKS@@"
SHARE_FILES="@@SHARE-FILES@@"
WIN_INSTALL_PATH="@@WIN-INSTALL-PATH@@"

#------------------------------------------------------------------------------
# setup

echo "* setup"

export PATH=".:$PATH"

key="/machine/SOFTWARE/Microsoft/Windows/CurrentVersion/ProgramFilesDir"
if ! WIN_PROG_PATH="$(regtool get "$key")" || [[ $WIN_PROG_PATH = "" ]]
then
    echo "Can't determine Windows program path => abort" >&2
    exit 1
fi
#CYGWIN_PROG_PATH="$( realpath "$WIN_PROG_PATH" )"
CYGWIN_PROG_PATH="${WIN_PROG_PATH//\\//}"

WDEST="$WIN_PROG_PATH\\${WIN_INSTALL_PATH//\//\\}"
CDEST="$CYGWIN_PROG_PATH/$WIN_INSTALL_PATH"

#------------------------------------------------------------------------------
# install files

# mkdir before testing the directory
mkdir -p "$CDEST"

if [[ $(stat -c%d-%i "$PWD") != "$(stat -c%d-%i "$CDEST")" ]]
then
    echo "* install files to $WDEST"
    cp --preserve=time *.bat *.dll *.exe *.sh *.txt "$CDEST"
fi

#------------------------------------------------------------------------------
# define application pathes

for tool in $BIN_FILES $WDF_LINKS
do
    [[ -s "$CDEST/$tool.exe" ]] || continue
    echo "* define application path for '$tool.exe'"
    key="/machine/SOFTWARE/Microsoft/Windows/CurrentVersion/App Paths/$tool.exe"
    regtool add "$key"
    regtool set "$key/" "${WDEST}\\${tool}.exe"
    regtool set "$key/Path" "${WDEST}\\"
done

#------------------------------------------------------------------------------
# add WIT path to environment 'Path'

echo "* add WIT path to environment 'Path'"

function set_path()
{
    local key="$1"

    local p=
    local count=0
    local new_path=

    # split at ';' & substitute ' ' temporary to ';' to be space save
    for p in $( regtool --quiet get "$key" | tr '; ' '\n;' )
    do
	p="${p//;/ }"
	#echo " -> |$p|"
	if [[ "$p" == "$WDEST" ]]
	then
	    ((count++)) || new_path="$new_path;$p"
	    #echo "$count $WDEST"
	elif [[ $p != "" ]]
	then
	    new_path="$new_path;$p"
	fi
    done

    if [[ $new_path != "" ]]
    then
	((count)) || new_path="$new_path;$WDEST"
	#echo "count=$count"
	#echo "new_path=${new_path:1}"
	regtool set "$key" "${new_path:1}"
    fi
}

set_path '/machine/SYSTEM/CurrentControlSet/Control/Session Manager/Environment/Path'
set_path '/user/Environment/Path'

#------------------------------------------------------------------------------