forked from puppylinux-woof-CE/woof-CE
-
Notifications
You must be signed in to change notification settings - Fork 2
/
merge2out
executable file
·197 lines (179 loc) · 6.65 KB
/
merge2out
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/bash
#BK nov. 2011
if [ "`whoami`" != "root" ] ; then
echo "Must be root"
exit 1
fi
[ -d ./woof-code ] || [ -d ./woof-distro ] || exit
if [ "$1" != "" ]; then
if [ -f ${1}/DISTRO_SPECS ]; then
COMPATVERSION_DIR=${1%/}
. ${COMPATVERSION_DIR}/DISTRO_SPECS
TARGETARCH=${DISTRO_TARGETARCH}
COMPATDISTRO=${DISTRO_BINARY_COMPAT}
COMPATVERSION=${DISTRO_COMPAT_VERSION}
else
echo "Missing configuration directory: $1"
DIR="$1"
while [ -n "$DIR" ]; do
if [ -d "$DIR" ]; then
echo -e "\nAvailable under $DIR:"
ls -1 "$DIR" | grep -v -e ^DISTRO_
break
fi
PREV="$DIR"
DIR="${DIR%/*}"
[ "$DIR" = "$PREV" ] && break
done
exit 1
fi
fi
echo
echo 'This script merges woof-code
woof-distro, kernel-kit and initrd-progs to ../woof-out_*.
See README.md
'
# autodetect HOSTARCH - how hard can it be?
case `uname -m` in
i?86)HOSTARCH=x86 ;;
x86_64|amd64)HOSTARCH=x86_64 ;;
*) echo "Error detecting host architecture, exiting..." ; exit 1 ;;
esac
echo "-----------------"
echo "Host arch: $HOSTARCH (The host is the machine you are running Woof on)"
echo "-----------------"
echo
echo "Please choose the target architecture.. (the target
is the machine in which the Puppy that you build is going to run):"
while [ "$TARGETARCH" = "" ] ; do
echo
CNT=1
for ONEARCH in `find woof-distro -mindepth 1 -maxdepth 1 -type d | sed -e 's%^woof-distro/%%' | sort | tr '\n' ' '`
do
echo "$CNT $ONEARCH"
CNT=$(($CNT + 1))
done
echo -n 'Type number of target architecture: '
read nTARGETARCH
TARGETARCH="`find woof-distro -mindepth 1 -maxdepth 1 -type d | sed -e 's%^woof-distro/%%' | sort | head -n $nTARGETARCH 2>/dev/null | tail -n 1`"
done
echo "...ok, $TARGETARCH"
echo
echo 'Woof builds a Puppy based on the binary packages from another distro.
We sometimes refer to this as the "compat-distro".'
while [ "$COMPATDISTRO" = "" ] ; do
echo
CNT=1
taPTN="s%^woof-distro/${TARGETARCH}/%%"
for ONEDISTRO in `find woof-distro/${TARGETARCH} -mindepth 1 -maxdepth 1 -type d | sed -e "${taPTN}" | sort | tr '\n' ' '`
do
echo "$CNT $ONEDISTRO"
CNT=$(($CNT + 1))
done
echo -n 'Type number of compat-distro: '
read nCOMPATDISTRO
COMPATDISTRO="`find woof-distro/${TARGETARCH} -mindepth 1 -maxdepth 1 -type d | sed -e "${taPTN}" | sort | head -n $nCOMPATDISTRO 2>/dev/null | tail -n 1`"
done
echo "...ok, $COMPATDISTRO"
echo
echo 'The compat-distro usually has release versions
Choose which release you want to obtain the binary packages from.'
while [ "$COMPATVERSION" = "" ] ; do
echo
CNT=1
for ONECOMPAT in `find woof-distro/${TARGETARCH}/${COMPATDISTRO} -maxdepth 1 -mindepth 1 -type d | rev | cut -f 1 -d '/' | rev | sort | tr '\n' ' '`
do
echo "$CNT $ONECOMPAT"
CNT=$(($CNT + 1))
done
if [ $CNT -eq 1 ];then
echo -e "\nSorry, there are no release directories inside woof-distro/${COMPATDISTRO}."
exit
fi
if [ $CNT -eq 2 ];then
COMPATVERSION="`find woof-distro/${TARGETARCH}/${COMPATDISTRO} -maxdepth 1 -mindepth 1 -type d | rev | cut -f 1 -d '/' | rev | sort | head -n 1 2>/dev/null | tail -n 1`"
continue
fi
echo -n 'Type number of release: '
read nCOMPATVERSION
COMPATVERSION="`find woof-distro/${TARGETARCH}/${COMPATDISTRO} -maxdepth 1 -mindepth 1 -type d | rev | cut -f 1 -d '/' | rev | sort | head -n $nCOMPATVERSION 2>/dev/null | tail -n 1`"
done
echo "...ok, $COMPATVERSION"
echo
echo 'Choices:'
echo "Host architecture: $HOSTARCH"
echo "Target architecture: $TARGETARCH"
echo "Compatible-distro: $COMPATDISTRO"
echo "Compat-distro version: $COMPATVERSION"
echo
echo -n "If these are ok, press ENTER, other CTRL-C to quit: "
read waitforit
#-------
if [ "$COMPATVERSION_DIR" = "" ]; then
COMPATVERSION_DIR=woof-distro/${TARGETARCH}/${COMPATDISTRO}/${COMPATVERSION}
WOOF_OUT=woof-out_${HOSTARCH}_${TARGETARCH}_${COMPATDISTRO}_${COMPATVERSION}
else
WOOF_OUT=woof-out_${HOSTARCH}_${TARGETARCH}_${COMPATDISTRO}_${COMPATVERSION_DIR##*/}
fi
#-------
mkdir -p ../${WOOF_OUT}
echo
echo "Directory '${WOOF_OUT}'
has been created, if it didn't exist, and the contents of 'woof-code' will
be copied into it. Then, these will also be copied into it:
woof-distro/${TARGETARCH}/${COMPATDISTRO} (files all levels)
${COMPATVERSION_DIR}"
echo
echo "Any existing files in '${WOOF_OUT}' will be over-ridden."
echo "(Also, all files in folders 'boot', 'packages-templates',
'rootfs-skeleton', 'rootfs-packages', 'support',
'kernel-kit' and 'initrd-progs' will be deleted.)"
echo
echo -n 'Press ENTER to continue: '
read goforit
echo
echo "Copying woof-code/*..."
cp -a -f --remove-destination woof-code/* ../${WOOF_OUT}/
echo "Copying kernel-kit, initrd-progs..."
cp -a -f --remove-destination kernel-kit ../${WOOF_OUT}/
cp -a -f --remove-destination initrd-progs ../${WOOF_OUT}/
echo
echo "Copying woof-distro/${TARGETARCH}/${COMPATDISTRO}/*... (files all levels)"
echo "Copying ${COMPATVERSION_DIR}/*..."
#copy any top-level files, going down...
for ONETOP in \
`find woof-distro -mindepth 1 -maxdepth 1 -type f | tr '\n' ' '` \
`find woof-distro/${TARGETARCH} -mindepth 1 -maxdepth 1 -type f | tr '\n' ' '` \
`find woof-distro/${TARGETARCH}/${COMPATDISTRO} -mindepth 1 -maxdepth 1 -type f | tr '\n' ' '` \
`find -L ${COMPATVERSION_DIR} -mindepth 1 -maxdepth 1 -type f | tr '\n' ' '`
do
cp -a -f -L --remove-destination $ONETOP ../${WOOF_OUT}/
done
echo
install -m 644 LICENSE ../${WOOF_OUT}/LICENSE
install -m 644 LICENSE ../${WOOF_OUT}/rootfs-skeleton/usr/local/share/doc/puppy/LICENSE
ln -s rootfs-skeleton/usr/local/share/doc/puppy/woof-CE.md ../${WOOF_OUT}/README.md
chown -R root:root ../${WOOF_OUT}
echo -e "\nUndoing VCS-friendly stuff..."
find ../${WOOF_OUT} -type f -name .gitignore -delete
#record target architecture in DISTRO_SPECS (will end up in /etc/ in Puppy build)...
sed -i '/DISTRO_TARGETARCH=/d' ../${WOOF_OUT}/DISTRO_SPECS
echo "DISTRO_TARGETARCH='${TARGETARCH}'" >> ../${WOOF_OUT}/DISTRO_SPECS
#record the woof state we build from
sed -i '/BUILD_FROM_WOOF=/d' ../${WOOF_OUT}/DISTRO_SPECS
if which git &>/dev/null && [ "`git log -n 1`" != "" ]; then
GITBRANCH=$(git rev-parse --abbrev-ref HEAD)
GITHEAD=$(git log -n 1 --pretty=format:"%h;%ci") # git rev-parse HEAD
echo "BUILD_FROM_WOOF='${GITBRANCH};${GITHEAD}'" >> ../${WOOF_OUT}/DISTRO_SPECS
else
echo "BUILD_FROM_WOOF=\"No woof-CE-git info available\"" >> ../${WOOF_OUT}/DISTRO_SPECS
fi
tar -C .. -c ${WOOF_OUT} | xz -9 > ../${WOOF_OUT}.tar.xz
mkdir -p ../${WOOF_OUT}/rootfs-skeleton/usr/local/share/woof-CE
mv -f ../${WOOF_OUT}.tar.xz ../${WOOF_OUT}/rootfs-skeleton/usr/local/share/woof-CE/${WOOF_OUT}.tar.xz
echo
echo "Directory '${WOOF_OUT}'
is now normal (the workarounds have been removed). Note,
../local-repositories has been created (if not already),
to be used as a common binary package download place."
### END ###