blob: bac18e593a893d4088e559fb687e8e9a1aacddf1 (
plain) (
blame)
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
|
#!/bin/bash
DEST_SYS=/usr/ports/releases/stable
DEST_ARC=/usr/ports/releases/archives
#PACKAGES=/usr/ports/packages
PACKAGES=/usr/ports/archive/packages
#PRT_GET_FLAGS="-fr -if -is"
PRT_GET_FLAGS="-fr"
# Build Name = R1 (System number) D1 (Droid/Machine number)
BUILD_NAME="R1D9"
#echo "Give build NAME;"
#echo "${DEST_ARC}/NAME-0.0.0.targ.gz"
#read BUILD_NAME
#internal
database=${DEST_SYS}/pkg-db.tar.gz
ports=${DEST_SYS}/etc-ports.tar.gz
metadata=${DEST_SYS}/metadata.tar.gz
build=${DEST_SYS}/metadata/build-version
portsver=${DEST_SYS}/metadata/ports-releases
all=${DEST_SYS}/metadata/all-installed
collinst=${DEST_SYS}/metadata/installed
notfound=${DEST_SYS}/metadata/not-found
echo "Give build CRUX_RELEASE.VERSION (3.4.X);"
echo "${DEST_ARC}/${BUILD_NAME}-VERSION.tar.gz"
read BUILD_VERSION
mkdir -p ${DEST_SYS}
mkdir -p ${DEST_ARC}
mkdir -p ${DEST_SYS}/metadata
archive="${DEST_ARC}/${BUILD_NAME}-${BUILD_VERSION}.tar"
echo "Creating $archive ..."
if [ -f ${archive} ]; then
rm ${archive}
fi
backup_collections() {
# backup collection packages
while read COLL_VERSION; do
COLL_NAME=$(echo $COLL_VERSION | cut -d "-" -f 1)
COLL_RELEASE=$(echo $COLL_VERSION | cut -d "-" -f 2)
if [ -f ${DEST_SYS}/${COLL_VERSION}.tar ]; then
rm ${DEST_SYS}/${COLL_VERSION}.tar
fi
while read PORT_NAME; do
# get installed version not version on ports
PACKAGE=$(grep "^${PORT_NAME}#" ${all})
# check if binary package exist
if [ ! -f /usr/ports/packages/${PACKAGE} ]; then
echo "Building package: ${PACKAGE};"
sudo prt-get update ${PRT_GET_FLAGS} ${PORT_NAME}
fi
if [ -f /usr/ports/packages/${PACKAGE} ]; then
echo ${PACKAGE} >> ${DEST_SYS}/metadata/${COLL_NAME}-backup
tar rvf ${DEST_SYS}/${COLL_VERSION}.tar --directory=${PACKAGES} ${PACKAGE}
else
echo "Package ${PACKAGE} from ${PORT_NAME} port not found."
echo ${PACKAGE} >> ${notfound}-${COLL_VERSION}
fi
done < ${collinst}-${COLL_NAME}
tar rvf $archive --directory=${DEST_SYS} ${COLL_VERSION}.tar
done < ${portsver}
}
create_metadata() {
echo "${BUILD_NAME}-${BUILD_VERSION}" > ${build}
# archive pkgutils data
tar --xattrs -zcpf $database --directory=/var/lib/pkg/ db
tar rvf $archive --directory=${DEST_SYS} $(basename ${database})
# archive ports data
tar --xattrs -zcpf $ports --directory=/etc/ports .
tar rvf $archive --directory=${DEST_SYS} $(basename ${ports})
# must be using gwak instead of sed
prt-get listinst -v | sed 's/ /#/g' | sed 's/$/.pkg.tar.gz/g' > ${all}
if [ -f ${portsver} ]; then
rm ${portsver}
fi
for filename in /etc/ports/*.git; do
source $filename
echo "${NAME} port collection release (exp; ${BUILD_VERSION}):"
read RELEASE
echo ${NAME}-${RELEASE} >> ${portsver}
# backup ports collection
echo "Backing up collection: ${NAME}"
tar --xattrs -zcpf ${DEST_SYS}/"ports"-${NAME}-${RELEASE}.tar.gz \
--directory=/usr/ports/${NAME} \
--exclude=.git \
.
tar rvf $archive --directory=${DEST_SYS} "ports"-${NAME}-${RELEASE}.tar.gz
# create list of installed packages
prt-get printf "%i %p %n\n" | grep "yes /usr/ports/${NAME}" | cut -d " " -f 3 > ${collinst}-${NAME}
done
}
create_archive() {
tar --xattrs -zcpf ${metadata} --directory=${DEST_SYS} metadata/
tar rvf $archive --directory=${DEST_SYS} $(basename ${metadata})
}
update_host() {
echo "Creating links to /usr/ports/installed"
rm -r /usr/ports/installed
pkg_installed
echo "Creating ports page"
portspage --title=${BUILD_NAME}-${BUILD_VERSION} /usr/ports/installed > /usr/ports/installed/index.html
}
create_metadata
backup_collections
create_archive
update_host
|