mirror of
https://github.com/sheumann/hush.git
synced 2024-12-26 10:32:02 +00:00
Teach md5sum and sha1sum to work the way other applets do so I don't have to
teach scripts/individual new tricks. And while I'm at it, teach scripts/individual other new tricks. Now builds 198 applets, some of which I should teach it to hardlink together because they're really the same app...
This commit is contained in:
parent
affb7a61a6
commit
236c6755d2
@ -81,12 +81,16 @@ static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
|
|||||||
return hash_value;
|
return hash_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This could become a common function for md5 as well, by using md5_stream */
|
int md5_sha1_sum_main(int argc, char **argv)
|
||||||
static int hash_files(int argc, char **argv, hash_algo_t hash_algo)
|
|
||||||
{
|
{
|
||||||
int return_value = EXIT_SUCCESS;
|
int return_value = EXIT_SUCCESS;
|
||||||
uint8_t *hash_value;
|
uint8_t *hash_value;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
hash_algo_t hash_algo = ENABLE_MD5SUM ?
|
||||||
|
(ENABLE_SHA1SUM ?
|
||||||
|
(**argv=='m' ? HASH_MD5 : HASH_SHA1)
|
||||||
|
: HASH_MD5)
|
||||||
|
: HASH_SHA1;
|
||||||
|
|
||||||
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
|
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
|
||||||
flags = bb_getopt_ulflags(argc, argv, "scw");
|
flags = bb_getopt_ulflags(argc, argv, "scw");
|
||||||
@ -178,17 +182,3 @@ static int hash_files(int argc, char **argv, hash_algo_t hash_algo)
|
|||||||
}
|
}
|
||||||
return (return_value);
|
return (return_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MD5SUM
|
|
||||||
int md5sum_main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
return (hash_files(argc, argv, HASH_MD5));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_SHA1SUM
|
|
||||||
int sha1sum_main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
return (hash_files(argc, argv, HASH_SHA1));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@ -179,7 +179,7 @@ USE_LSATTR(APPLET(lsattr, _BB_DIR_BIN, _BB_SUID_NEVER))
|
|||||||
USE_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_NEVER))
|
USE_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_NEVER))
|
||||||
USE_UNLZMA(APPLET_ODDNAME(lzmacat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lzmacat))
|
USE_UNLZMA(APPLET_ODDNAME(lzmacat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lzmacat))
|
||||||
USE_MAKEDEVS(APPLET(makedevs, _BB_DIR_SBIN, _BB_SUID_NEVER))
|
USE_MAKEDEVS(APPLET(makedevs, _BB_DIR_SBIN, _BB_SUID_NEVER))
|
||||||
USE_MD5SUM(APPLET(md5sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
|
USE_MD5SUM(APPLET_ODDNAME(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, md5sum))
|
||||||
USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER))
|
USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER))
|
||||||
USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
|
USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
|
||||||
USE_MKDIR(APPLET(mkdir, _BB_DIR_BIN, _BB_SUID_NEVER))
|
USE_MKDIR(APPLET(mkdir, _BB_DIR_BIN, _BB_SUID_NEVER))
|
||||||
@ -245,7 +245,7 @@ USE_FEATURE_SH_IS_ASH(APPLET_NOUSAGE(sh, ash, _BB_DIR_BIN, _BB_SUID_NEVER))
|
|||||||
USE_FEATURE_SH_IS_HUSH(APPLET_NOUSAGE(sh, hush, _BB_DIR_BIN, _BB_SUID_NEVER))
|
USE_FEATURE_SH_IS_HUSH(APPLET_NOUSAGE(sh, hush, _BB_DIR_BIN, _BB_SUID_NEVER))
|
||||||
USE_FEATURE_SH_IS_LASH(APPLET_NOUSAGE(sh, lash, _BB_DIR_BIN, _BB_SUID_NEVER))
|
USE_FEATURE_SH_IS_LASH(APPLET_NOUSAGE(sh, lash, _BB_DIR_BIN, _BB_SUID_NEVER))
|
||||||
USE_FEATURE_SH_IS_MSH(APPLET_NOUSAGE(sh, msh, _BB_DIR_BIN, _BB_SUID_NEVER))
|
USE_FEATURE_SH_IS_MSH(APPLET_NOUSAGE(sh, msh, _BB_DIR_BIN, _BB_SUID_NEVER))
|
||||||
USE_SHA1SUM(APPLET(sha1sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
|
USE_SHA1SUM(APPLET_ODDNAME(sha1sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sha1sum))
|
||||||
USE_SLEEP(APPLET(sleep, _BB_DIR_BIN, _BB_SUID_NEVER))
|
USE_SLEEP(APPLET(sleep, _BB_DIR_BIN, _BB_SUID_NEVER))
|
||||||
USE_SORT(APPLET(sort, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
|
USE_SORT(APPLET(sort, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
|
||||||
USE_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, _BB_DIR_SBIN, _BB_SUID_NEVER, start_stop_daemon))
|
USE_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, _BB_DIR_SBIN, _BB_SUID_NEVER, start_stop_daemon))
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Clear out the build directory. (Make clean should do this instead of here.)
|
||||||
|
|
||||||
|
rm -rf build
|
||||||
|
mkdir build
|
||||||
|
|
||||||
# Make our prerequisites.
|
# Make our prerequisites.
|
||||||
|
|
||||||
make busybox.links include/bb_config.h
|
make busybox.links include/bb_config.h
|
||||||
@ -12,15 +17,18 @@ cd libbb
|
|||||||
make
|
make
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
# Same problem.
|
||||||
|
|
||||||
cd archival/libunarchive
|
cd archival/libunarchive
|
||||||
make
|
make
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
# 146 applets build without any extra stuff. The applet is one C file with
|
# About 3/5 of the applets build from one .c file (with the same name as the
|
||||||
# the same name as the corresponding applet, and all it needs to link against
|
# corresponding applet), and all it needs to link against. However, to build
|
||||||
# is libbb.a. However, 104 of them need more than that.
|
# them all we need more than that.
|
||||||
|
|
||||||
|
# Figure out which applets need extra libraries added to their command line.
|
||||||
|
|
||||||
# dpkg_deb gzip
|
|
||||||
function extra_libraries()
|
function extra_libraries()
|
||||||
{
|
{
|
||||||
archival="ar bunzip2 unlzma cpio dpkg gunzip rpm2cpio rpm tar uncompress unzip dpkg_deb gzip "
|
archival="ar bunzip2 unlzma cpio dpkg gunzip rpm2cpio rpm tar uncompress unzip dpkg_deb gzip "
|
||||||
@ -28,34 +36,61 @@ function extra_libraries()
|
|||||||
then
|
then
|
||||||
echo "archival/libunarchive/libunarchive.a"
|
echo "archival/libunarchive/libunarchive.a"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# What needs -libm?
|
||||||
|
|
||||||
|
libm="awk dc "
|
||||||
|
if [ "${libm/$1 //}" != "${libm}" ]
|
||||||
|
then
|
||||||
|
echo "-lm"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Here are a few that build in a standard way. Others are easy to get to
|
# Query applets.h to figure out which need something funky
|
||||||
# build, for example miscutils/dc needs -lm and most of loginutils/* needs
|
|
||||||
# -lcrypt...
|
|
||||||
|
|
||||||
rm -rf build
|
strange_names=`sed -rn -e 's/\#.*//' -e 's/.*APPLET_NOUSAGE\(([^,]*),([^,]*),.*/\1 \2/p' -e 's/.*APPLET_ODDNAME\(([^,]*),([^,]*),.*, *([^)]*).*/\1 \2@\3/p' include/applets.h`
|
||||||
mkdir build
|
|
||||||
|
function bonkname()
|
||||||
|
{
|
||||||
|
while [ $# -gt 0 ]
|
||||||
|
do
|
||||||
|
if [ "$APPLET" == "$1" ]
|
||||||
|
then
|
||||||
|
APPFILT="${2/@*/}"
|
||||||
|
if [ "${APPFILT}" == "$2" ]
|
||||||
|
then
|
||||||
|
HELPNAME='"nousage\n"'
|
||||||
|
else
|
||||||
|
HELPNAME="${2/*@/}"_full_usage
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
shift 2
|
||||||
|
done
|
||||||
|
#echo APPLET=${APPLET} APPFILT=${APPFILT} HELPNAME=${HELPNAME} 2=${2}
|
||||||
|
}
|
||||||
|
|
||||||
for APPLET in `sed 's .*/ ' busybox.links`
|
for APPLET in `sed 's .*/ ' busybox.links`
|
||||||
do
|
do
|
||||||
APPFILT=${APPLET/-/_}
|
export APPLET
|
||||||
j=`find . -name "${APPLET/-/?}.c"` # Because ether-wake.c is broken.
|
export APPFILT=${APPLET}
|
||||||
|
export HELPNAME=${APPLET}_full_usage
|
||||||
|
bonkname $strange_names
|
||||||
|
|
||||||
|
j=`find . -name "${APPFILT}.c"`
|
||||||
if [ -z "$j" ]
|
if [ -z "$j" ]
|
||||||
then
|
then
|
||||||
echo no file for $APPLET
|
echo no file for $APPLET
|
||||||
else
|
else
|
||||||
echo "Building $APPLET..."
|
echo "Building $APPLET"
|
||||||
gcc -Os -o build/$APPLET applets/individual.c $j \
|
gcc -Os -o build/$APPLET applets/individual.c $j \
|
||||||
`extra_libraries $APPFILT` libbb/libbb.a -Iinclude \
|
`extra_libraries $APPFILT` libbb/libbb.a -Iinclude \
|
||||||
-DBUILD_INDIVIDUAL \
|
-DBUILD_INDIVIDUAL \
|
||||||
"-Drun_applet_by_name(...)" "-Dfind_applet_by_name(...) 0" \
|
"-Drun_applet_by_name(...)" "-Dfind_applet_by_name(...) 0" \
|
||||||
-DAPPLET_main=${APPFILT}_main -DAPPLET_full_usage=${APPFILT}_full_usage
|
-DAPPLET_main=${APPFILT}_main -DAPPLET_full_usage=${HELPNAME}
|
||||||
if [ $? -ne 0 ];
|
if [ $? -ne 0 ];
|
||||||
then
|
then
|
||||||
echo "Failed."
|
echo "Failed $APPLET"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user