-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall
executable file
·147 lines (131 loc) · 4.79 KB
/
install
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
INSTALL_ROOT="$(readlink -f "$1")"
d="$(readlink -f "${0%/*}")"
cd "$d" || exit
. ./var/lib/sorcery/modules/liboscompat
#
# For unknown reasons `$filter=...; find . $filter` doesn't work, so this function
# encapsulates the filters necessary to strip CVS files and EMACS temporary files
install__find_non_volatile() {
find "$@" \( -name CVS -o -name .svn -o -name .arch-id \) -prune -o \
\! -name '.#*' \! -name '*~' \
\! -type d
}
# First clean out all libraries.
echo "Cleaning out all old sorcery libraries..."
SORCERY_LIBS=${INSTALL_ROOT}/var/lib/sorcery/modules
rm -rf $SORCERY_LIBS
SORCERY_INSTALL_LOG=$INSTALL_ROOT/etc/sorcery/install.log
rm -f $SORCERY_INSTALL_LOG
mkdir -p $(dirname $SORCERY_INSTALL_LOG)
echo /etc/sorcery/install.log > $SORCERY_INSTALL_LOG
echo "Installing scripts and libraries"
# Install the executables
install__find_non_volatile etc usr/sbin var/lib usr/lib |
while read src; do
dst="$INSTALL_ROOT/$src" &&
install -o 0 -g 0 -m 755 -p -D "$src" "$dst" &&
echo "$dst"
done >> "$SORCERY_INSTALL_LOG"
# Install the man pages
echo "Installing man pages"
install__find_non_volatile usr/share/man |
while read doc; do
dst="$INSTALL_ROOT/$doc.gz" &&
>"$dst" &&
chown 0:0 "$dst" &&
chmod 644 "$dst" &&
gzip -9 < "$doc" > "$dst" &&
echo "$dst"
done >> "$SORCERY_INSTALL_LOG"
# Install the GNU General Public License
mkdir -p ${INSTALL_ROOT}/usr/share/doc
install -o root -g root -m 644 -p -D "COPYING" "${INSTALL_ROOT}/usr/share/doc/sorcery/COPYING"
echo /usr/share/doc/sorcery/COPYING >> $SORCERY_INSTALL_LOG
# Install the ChangeLog
install -o root -g root -m 644 -p -D "ChangeLog" "${INSTALL_ROOT}/usr/share/doc/sorcery/ChangeLog"
echo /usr/share/doc/sorcery/ChangeLog >> $SORCERY_INSTALL_LOG
# Install the run_compiler script with the same names as gcc
echo "Setting up build symlinks"
BUILD_DIR=${INSTALL_ROOT}/var/lib/sorcery/build
pushd $BUILD_DIR &> /dev/null || exit 1
# optionally put in HOST style compilers
ARCHITECTURE=$(grep ARCHITECTURE /etc/sorcery/local/config | sed 's/[^-]*-\(.*\)}.*/\1/')
HOST_COMPILE=""
if [[ $ARCHITECTURE ]]
then
archspec=$(find /usr/share/archspecs -type f -name $ARCHITECTURE)
if [[ -f $archspec ]]
then
use_gcc() { ! :; } # Take latest GCC only
use_gcc2() { ! :; }
HOST_LIBC=
if ldd --version 2>&1 |grep -q musl; then
HOST_LIBC=musl
fi
HOST=$(. $archspec && printf "%s" "$HOST")
for COMPILER in "c++" "g++" "gcc"
do
HOST_COMPILE="$HOST_COMPILE $HOST-$COMPILER"
done
fi
fi
for COMPILER in clang cc gcc c++ g++ $HOST_COMPILE; do
ln -vsf "run_compiler" "$COMPILER"
echo $BUILD_DIR/$COMPILER >> $SORCERY_INSTALL_LOG
done
popd &>/dev/null
for DIR in "${INSTALL_ROOT}/usr/src" \
"${INSTALL_ROOT}/var/cache/sorcery" \
"${INSTALL_ROOT}/var/spool/sorcery" \
"${INSTALL_ROOT}/var/log/sorcery/compile" \
"${INSTALL_ROOT}/var/log/sorcery/install" \
"${INSTALL_ROOT}/var/log/sorcery/md5sum" \
"${INSTALL_ROOT}/var/log/sorcery/queue" \
"${INSTALL_ROOT}/var/state/sorcery"; do
if ! [[ -d $DIR ]]; then
if [[ -e $DIR ]]; then
echo "$DIR is not a directory, but already exists!"
echo "Please correct this and retry!"
exit 1
fi
mkdir -p "$DIR"
fi
done
# Create other files which should exist, but aren't installed by sorcery
for FILE in \
"${INSTALL_ROOT}/etc/sorcery/local/config" \
"${INSTALL_ROOT}/etc/sorcery/local/compile_config" \
"${INSTALL_ROOT}/var/state/sorcery/packages" \
"${INSTALL_ROOT}/var/state/sorcery/depends" \
"${INSTALL_ROOT}/var/log/sorcery/activity"
do
if ! [[ -x "$FILE" ]]; then
touch "$FILE"
chmod +x "$FILE"
fi
done
# Create the hooks dir since hooks try to check that the files are properly owned
mkdir -p "${INSTALL_ROOT}/etc/sorcery/hooks"
chown 0:0 "${INSTALL_ROOT}/etc/sorcery/hooks"
chmod 0755 "${INSTALL_ROOT}/etc/sorcery/hooks"
#---------------------------------------------------------------------
##=back
##
##=head1 LICENSE
##
## This software is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This software is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this software; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
#---------------------------------------------------------------------