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
|
#!/usr/bin/env bash
# import gentoo functions
source /lib/gentoo/functions.sh
checkroot () {
if [[ "$(whoami)" != root ]] ; then
eerror "You're not root?...No cookies for you, go away !!!"
exit 1
fi
}
checksystemmode() {
if [[ "$(readlink -f "/etc/portage/make.conf")" = /opt/redcore-build/conf/intel/portage/make.conf.amd64-srcmode ]] ; then
eerror "The system is set to srcmode (full Gentoo mode), cowardly refusing to run!"
exit 1
fi
}
checkportageconfig () {
pushd /opt/redcore-build > /dev/null 2>&1
git remote update > /dev/null 2>&1
export local confhash=$(git rev-parse @)
export local rconfhash=$(git rev-parse @{u})
if [ $confhash != $rconfhash ] ; then
eerror "Portage config is out-of-date, run "sisyphus update" first"
exit 1
fi
popd > /dev/null 2>&1
}
checkportagetree () {
pushd /usr/portage > /dev/null 2>&1
git remote update > /dev/null 2>&1
export local treehash=$(git rev-parse @)
export local rtreehash=$(git rev-parse @{u})
if [ $treehash != $rtreehash ] ; then
eerror "Portage tree is out-of-date, run "sisyphus update" first"
exit 1
fi
popd > /dev/null 2>&1
}
checkredcoreoverlay () {
pushd /var/lib/layman/redcore-desktop > /dev/null 2>&1
git remote update > /dev/null 2>&1
export local overlayhash=$(git rev-parse @)
export local roverlayhash=$(git rev-parse @{u})
if [ $overlayhash != $roverlayhash ] ; then
eerror "Redcore Desktop overlay is out-of-date, run "sisyphus update" first"
exit 1
fi
}
remotedbcsvget () {
if [[ ! -f /var/lib/sisyphus/csv/remote_preinst.csv ]] ; then
pushd /var/lib/sisyphus/csv > /dev/null 2>&1
touch remote_preinst.csv
wget -c http://mirror.math.princeton.edu/pub/redcorelinux/csv/remote_preinst.csv -O remote_postinst.csv > /dev/null 2>&1
popd > /dev/null 2>&1
elif [[ -f /var/lib/sisyphus/csv/remote_preinst.csv ]] ; then
pushd /var/lib/sisyphus/csv > /dev/null 2>&1
wget -c http://mirror.math.princeton.edu/pub/redcorelinux/csv/remote_preinst.csv -O remote_postinst.csv > /dev/null 2>&1
popd > /dev/null 2>&1
fi
}
remotedbcsvcheck () {
if ! cmp /var/lib/sisyphus/csv/remote_preinst.csv /var/lib/sisyphus/csv/remote_postinst.csv > /dev/null 2>&1 ; then
eerror "SisyphusDB : "remote_packages" table is out-of-date, run "sisyphus update" first"
rm -rf /var/lib/sisyphus/csv/remote_postinst.csv
exit 1
elif cmp /var/lib/sisyphus/csv/remote_preinst.csv /var/lib/sisyphus/csv/remote_postinst.csv > /dev/null 2>&1 ; then
rm -rf /var/lib/sisyphus/csv/remote_postinst.csv
fi
}
checkremotedb () {
remotedbcsvget
remotedbcsvcheck
}
checksync () {
checkroot
checkportagetree
checkredcoreoverlay
checkportageconfig
checkremotedb
}
syncrepos () {
emerge --sync
}
syncportageconfig () {
pushd /opt/redcore-build > /dev/null 2>&1
echo ">>> Syncing 'portage config' into '/etc/portage'..."
echo "/usr/bin/git pull"
git pull
echo "=== Sync completed for 'portage config'"
popd > /dev/null 2>&1
}
remotedbcsvsync () {
if ! cmp /var/lib/sisyphus/csv/remote_preinst.csv /var/lib/sisyphus/csv/remote_postinst.csv > /dev/null 2>&1 ; then
echo ">>> Syncing 'SisyphusDB remote_packages' into '/var/lib/sisyphus/db/sisyphus.db'"
echo "/usr/bin/sqlite3 /var/lib/sisyphus/db/sisyphus.db"
pushd /var/lib/sisyphus/db > /dev/null 2>&1
sqlite3 -echo sisyphus.db<<-EXIT_HERE
drop table if exists remote_packages;
create table remote_packages (category TEXT,name TEXT,version TEXT,slot TEXT,description TEXT);
.mode csv
.import /var/lib/sisyphus/csv/remote_postinst.csv remote_packages
EXIT_HERE
popd > /dev/null 2>&1
echo "=== Sync completed for 'SisyphusDB remote_packages'"
elif cmp /var/lib/sisyphus/csv/remote_preinst.csv /var/lib/sisyphus/csv/remote_postinst.csv > /dev/null 2>&1 ; then
echo ">>> Syncing 'SisyphusDB remote_packages' into '/var/lib/sisyphus/db/sisyphus.db'"
echo "/usr/bin/sqlite3 /var/lib/sisyphus/db/sisyphus.db"
echo "Already up-to-date."
echo "=== Sync completed for 'SisyphusDB remote_packages"
fi
mv /var/lib/sisyphus/csv/remote_postinst.csv /var/lib/sisyphus/csv/remote_preinst.csv
}
syncremotedb() {
remotedbcsvget
remotedbcsvsync
}
redcoresync () {
checkroot
syncrepos
syncportageconfig
syncremotedb
}
localdbcsvpre () {
if [[ ! -f /var/lib/sisyphus/csv/local_preinst.csv ]] ; then
for i in $(qlist -ICv); do
pushd /var/db/pkg/$i > /dev/null 2>&1
echo "$(<CATEGORY),$(sed -re "s/-([0-9])/,\1/" <PF),$(<SLOT),$(sed -e "s/\"//g" -e "s/\'//g" -e "s/\,//g" <DESCRIPTION)" >> /var/lib/sisyphus/csv/local_preinst.csv
popd > /dev/null 2>&1
done
fi
}
localdbcsvpost () {
for i in $(qlist -ICv); do
pushd /var/db/pkg/$i > /dev/null 2>&1
echo "$(<CATEGORY),$(sed -re "s/-([0-9])/,\1/" <PF),$(<SLOT),$(sed -e "s/\"//g" -e "s/\'//g" -e "s/\,//g" <DESCRIPTION)" >> /var/lib/sisyphus/csv/local_postinst.csv
popd > /dev/null 2>&1
done
}
localdbcsvsync () {
if cmp /var/lib/sisyphus/csv/local_preinst.csv /var/lib/sisyphus/csv/local_postinst.csv > /dev/null 2>&1 ; then
einfo "PortageDB && SisyphusDB local_packages in sync, nothing to do..."
else
einfo "PortageDB && SisyphusDB local_packages out of sync, syncing..."
echo "/usr/bin/sqlite3 /var/lib/sisyphus/db/sisyphus.db"
pushd /var/lib/sisyphus/db > /dev/null 2>&1
sqlite3 -echo sisyphus.db<<-EXIT_HERE
drop table if exists local_packages;
create table local_packages (category TEXT,name TEXT,version TEXT,slot TEXT,description TEXT);
.mode csv
.import /var/lib/sisyphus/csv/local_postinst.csv local_packages
EXIT_HERE
popd > /dev/null 2>&1
einfo "Sync completed for SisyphusDB local_packages"
fi
mv /var/lib/sisyphus/csv/local_postinst.csv /var/lib/sisyphus/csv/local_preinst.csv
}
updatelocaldb () {
checkroot
localdbcsvpost
localdbcsvsync
}
|