Remove python dependency

This commit is contained in:
lw-everestlinux 2022-12-09 10:41:22 -05:00
parent a2b3ad34d4
commit fa1162a88c
5 changed files with 82 additions and 19 deletions

View File

@ -23,6 +23,12 @@ case $1 in
mv -v $SRC_DIR/glacier $PREFIX
printf "directory $PREFIX/bin does not exist, moving to $PREFIX instead\n"
fi
CC $SRC_DIR/int-check/main.c -o glacier-integrity-check
mv -v $SRC_DIR/int-check/glacier-integrity-check $PREFIX/bin
if [ "$?" != 0 ]; then
mv -v $SRC_DIR/int-check/glacier-integrity-check $PREFIX
printf "directory $PREFIX/bin does not exist, moving to $PREFIX instead.\n"
fi
printf "installing configuration files\n"
mv -v $SRC_DIR/glacier.conf $CONFDIR
if [ "$?" != 0 ]; then

View File

@ -8,3 +8,6 @@ PREFIX="/usr"
# System config directory
# On almost all systems, this should be /etc
CONFDIR="/etc"
# C Compiler to use
CC="gcc"

View File

@ -27,7 +27,9 @@ get_pkg() {
int_check() {
if [ "$GLACIER_DO_INT_CHECK" = "true" ]; then
printf "$blue[ i ]$reset Checking package integrity...\n"
/usr/bin/glacier-integrity-check
mv *.checksum local_sum
sha256sum *.tar.gz > pkg_sum
/usr/bin/glacier-integrity-check local_sum pkg_sum
if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Integrity check failed.\n"
exit 1

View File

@ -1,18 +0,0 @@
#!/usr/bin/python3
import sys
import os
LOCAL_SUM=os.system("cat *.checksum")
PKG_SUM=os.system("sha256sum *.tar.gz")
if LOCAL_SUM == PKG_SUM:
print("checksums match\n")
sys.exit(0)
elif LOCAL_SUM != PKG_SUM:
print("checksums do not match\n")
sys.exit(1)
else:
print("an error occured\n")
sys.exit(1)
print("=======================================")

70
src/int-check/main.c Normal file
View File

@ -0,0 +1,70 @@
//Write a program to compare two file.
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
FILE *fp1 ;
FILE *fp2 ;
int cnt1 = 0;
int cnt2 = 0;
int flg = 0;
if( argc < 3 )
{
printf("Insufficient Arguments!!!\n");
printf("Please use \"program-name file-name1 file-name2\" format.\n");
return -1;
}
fp1 = fopen(argv[1],"r");
if( fp1 == NULL )
{
printf("\n%s File can not be opened : \n",argv[1]);
return -1;
}
// move file pointer to end and get total number of bytes
fseek(fp1,0,SEEK_END);
cnt1 = ftell(fp1);
fp2 = fopen(argv[2],"r");
if( fp2 == NULL )
{
printf("\n%s File can not be opened : \n",argv[2]);
return -1;
}
// move file pointer to end and get total number of bytes
fseek(fp2,0,SEEK_END);
cnt2 = ftell(fp2);
fseek(fp1,0,SEEK_SET);
fseek(fp2,0,SEEK_SET);
// check for the total number of bytes
if( cnt1 != cnt2 ){
return 1;
}
else
{
while( ! feof(fp1) )
{
if( fgetc(fp1) != fgetc(fp2) )
{
flg = 1;
break;
}
}
if( flg ) return 1;
else return 0;
}
fclose(fp1);
fclose(fp2);
return 0;
}