Skip to content

Commit c303bc6

Browse files
committed
Implemented: sha256sum checksum checksum checking while downloading a new beta/stable
1 parent 232c5cf commit c303bc6

File tree

5 files changed

+50
-9
lines changed

5 files changed

+50
-9
lines changed

History.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Version 2.0.xxxx (October xxth 2014)
4545
- Updated: WindowsLibraries on server
4646
- Changed: OpenZWave Fibaro RGBW configuration file (had problems with the powerlevel class)
4747
- Changed: OpenZWave code change to fix (ApplicationCommandHandler - Unhandled Command Class 0x2b)
48+
- Implemented: sha256sum checksum checksum checking while downloading a new beta/stable
4849

4950
Version 2.0.2025 (September 28th 2014)
5051
- Implemented: Fibaro Link data pusher

main/mainworker.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,12 @@ void MainWorker::Do_Work()
927927
if (m_bDoDownloadDomoticzUpdate)
928928
{
929929
m_bDoDownloadDomoticzUpdate=false;
930-
std::string outfile = szStartupFolder+"update.tgz";
930+
//First download the checksum file
931+
std::string outfile = szStartupFolder + "update.tgz.sha256sum";
932+
std::string checksumfile = m_szDomoticzUpdateURL + ".sha256sum";
933+
HTTPClient::GETBinaryToFile(checksumfile.c_str(), outfile.c_str());
934+
//Next download the actual update
935+
outfile = szStartupFolder+"update.tgz";
931936
m_bHaveDownloadedDomoticzUpdateSuccessFull=HTTPClient::GETBinaryToFile(m_szDomoticzUpdateURL.c_str(),outfile.c_str());
932937
m_bHaveDownloadedDomoticzUpdate=true;
933938
}

makebeta

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ echo "Working copy at revision $LOCAL_REVISION"
3535
if [ "$SERVER_REVISION" -eq "$LOCAL_REVISION" ]
3636
then
3737
echo "Server is up to date. Nothing to do."
38-
exit 1
38+
# exit 1
3939
fi
4040

4141
echo "Updating to server revision..."
@@ -69,17 +69,29 @@ if [ -f ${archive_file} ];
6969
then
7070
rm ${archive_file}
7171
fi
72+
if [ -f ${archive_file}.sha256sum ];
73+
then
74+
rm ${archive_file}.sha256sum
75+
fi
7276

73-
tar -zcf ${archive_file} domoticz History.txt License.txt svnversion.h domoticz.sh www/ scripts/ Config/
77+
tar -zcf ${archive_file} domoticz History.txt License.txt svnversion.h domoticz.sh --exclude .svn www/ scripts/ Config/
7478
if [ $? -ne 0 ]
7579
then
7680
echo "Error creating archive!";
7781
exit 1
7882
fi
83+
echo "Creating checksum file...";
84+
hash="$(sha256sum ${archive_file} | sed -e 's/\s.*$//') update.tgz";
85+
echo $hash > ${archive_file}.sha256sum
86+
if [ ! -f ${archive_file}.sha256sum ];
87+
then
88+
echo "Error creating archive checksum file!";
89+
exit 1
90+
fi
7991

8092
#################################
8193
echo "Uploading to SourceForge...";
82-
sshpass -p ${SVN_UPLOAD_PASSWORD} scp ${archive_file} ${version_file} ${history_file} ${SVN_UPLOAD_USER}@web.sourceforge.net:/home/project-web/domoticz/htdocs/beta
94+
sshpass -p ${SVN_UPLOAD_PASSWORD} scp ${archive_file} ${archive_file}.sha256sum ${version_file} ${history_file} ${SVN_UPLOAD_USER}@web.sourceforge.net:/home/project-web/domoticz/htdocs/beta
8395
if [ $? -ne 0 ]
8496
then
8597
echo "Error uploading to SourceForge!";

makerelease

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ echo "Working copy at revision $LOCAL_REVISION"
3535
if [ "$SERVER_REVISION" -eq "$LOCAL_REVISION" ]
3636
then
3737
echo "Server is up to date. Nothing to do."
38-
exit 1
38+
# exit 1
3939
fi
4040

4141
echo "Updating to server revision..."
@@ -51,13 +51,13 @@ then
5151
echo "CMake failed!";
5252
exit 1
5353
fi
54-
make -j 2
54+
make -j 1
5555
if [ $? -ne 0 ]
5656
then
5757
echo "Compilation failed!";
5858
exit 1
5959
fi
60-
echo "Success, making release...";
60+
echo "Success, making beta...";
6161

6262
cp -f svnversion.h ${version_file}
6363
cp -f History.txt ${history_file}
@@ -69,17 +69,28 @@ if [ -f ${archive_file} ];
6969
then
7070
rm ${archive_file}
7171
fi
72+
if [ -f ${archive_file}.sha256sum ];
73+
then
74+
rm ${archive_file}.sha256sum
75+
fi
7276

73-
tar -zcf ${archive_file} domoticz History.txt License.txt svnversion.h domoticz.sh www/ scripts/ Config/
77+
tar -zcf ${archive_file} domoticz History.txt License.txt svnversion.h domoticz.sh --exclude .svn www/ scripts/ Config/
7478
if [ $? -ne 0 ]
7579
then
7680
echo "Error creating archive!";
7781
exit 1
7882
fi
83+
echo "Creating checksum file...";
84+
sha256sum ${archive_file} > ${archive_file}.sha256sum
85+
if [ $? -ne 0 ]
86+
then
87+
echo "Error creating archive checksum file!";
88+
exit 1
89+
fi
7990

8091
#################################
8192
echo "Uploading to SourceForge...";
82-
sshpass -p ${SVN_UPLOAD_PASSWORD} scp ${archive_file} ${version_file} ${history_file} ${SVN_UPLOAD_USER}@web.sourceforge.net:/home/project-web/domoticz/htdocs
93+
sshpass -p ${SVN_UPLOAD_PASSWORD} scp ${archive_file} ${archive_file}.sha256sum ${version_file} ${history_file} ${SVN_UPLOAD_USER}@web.sourceforge.net:/home/project-web/domoticz/htdocs
8394
if [ $? -ne 0 ]
8495
then
8596
echo "Error uploading to SourceForge!";

scripts/update_domoticz

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
#!/bin/sh
22
cd $1
3+
if [ -f update.tgz.sha256sum ];
4+
then
5+
#Check archive against checksum!
6+
valid=$(sha256sum -c update.tgz.sha256sum | grep update.tgz | cut -d':' -f2 | tr -d ' ')
7+
if [ $valid != "OK" ]
8+
then
9+
echo "Archive checksum mismatch !";
10+
exit 1;
11+
fi
12+
fi
13+
314
tar xfz update.tgz
415
rm update.tgz
16+
rm update.tgz.sha256sum
517

618
lowercase(){
719
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"

0 commit comments

Comments
 (0)