diff options
| author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-08-06 02:13:36 +0000 |
|---|---|---|
| committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-08-06 02:13:36 +0000 |
| commit | 58c1413ed3a9fb98d24efb4fa46902b3c1865295 (patch) | |
| tree | efd52650829e699be220c3932a7f4360f316482e | |
| parent | 65cea7e67e18c28d666503f3c0cb4e7c7b34422b (diff) | |
| download | busybox-w32-58c1413ed3a9fb98d24efb4fa46902b3c1865295.tar.gz busybox-w32-58c1413ed3a9fb98d24efb4fa46902b3c1865295.tar.bz2 busybox-w32-58c1413ed3a9fb98d24efb4fa46902b3c1865295.zip | |
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...
git-svn-id: svn://busybox.net/trunk/busybox@15786 69ca8d6d-28ef-0310-b511-8ec308f3f277
| -rw-r--r-- | coreutils/md5_sha1_sum.c | 22 | ||||
| -rw-r--r-- | include/applets.h | 4 | ||||
| -rwxr-xr-x | scripts/individual | 67 |
3 files changed, 59 insertions, 34 deletions
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 49766a925..6226e0988 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c | |||
| @@ -81,12 +81,16 @@ static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo) | |||
| 81 | return hash_value; | 81 | return hash_value; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | /* This could become a common function for md5 as well, by using md5_stream */ | 84 | int md5_sha1_sum_main(int argc, char **argv) |
| 85 | static int hash_files(int argc, char **argv, hash_algo_t hash_algo) | ||
| 86 | { | 85 | { |
| 87 | int return_value = EXIT_SUCCESS; | 86 | int return_value = EXIT_SUCCESS; |
| 88 | uint8_t *hash_value; | 87 | uint8_t *hash_value; |
| 89 | unsigned int flags; | 88 | unsigned int flags; |
| 89 | hash_algo_t hash_algo = ENABLE_MD5SUM ? | ||
| 90 | (ENABLE_SHA1SUM ? | ||
| 91 | (**argv=='m' ? HASH_MD5 : HASH_SHA1) | ||
| 92 | : HASH_MD5) | ||
| 93 | : HASH_SHA1; | ||
| 90 | 94 | ||
| 91 | if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK) | 95 | if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK) |
| 92 | flags = bb_getopt_ulflags(argc, argv, "scw"); | 96 | flags = bb_getopt_ulflags(argc, argv, "scw"); |
| @@ -178,17 +182,3 @@ static int hash_files(int argc, char **argv, hash_algo_t hash_algo) | |||
| 178 | } | 182 | } |
| 179 | return (return_value); | 183 | return (return_value); |
| 180 | } | 184 | } |
| 181 | |||
| 182 | #ifdef CONFIG_MD5SUM | ||
| 183 | int md5sum_main(int argc, char **argv) | ||
| 184 | { | ||
| 185 | return (hash_files(argc, argv, HASH_MD5)); | ||
| 186 | } | ||
| 187 | #endif | ||
| 188 | |||
| 189 | #ifdef CONFIG_SHA1SUM | ||
| 190 | int sha1sum_main(int argc, char **argv) | ||
| 191 | { | ||
| 192 | return (hash_files(argc, argv, HASH_SHA1)); | ||
| 193 | } | ||
| 194 | #endif | ||
diff --git a/include/applets.h b/include/applets.h index 42758a58f..a8b480b80 100644 --- a/include/applets.h +++ b/include/applets.h | |||
| @@ -179,7 +179,7 @@ USE_LSATTR(APPLET(lsattr, _BB_DIR_BIN, _BB_SUID_NEVER)) | |||
| 179 | USE_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 179 | USE_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
| 180 | USE_UNLZMA(APPLET_ODDNAME(lzmacat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lzmacat)) | 180 | USE_UNLZMA(APPLET_ODDNAME(lzmacat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lzmacat)) |
| 181 | USE_MAKEDEVS(APPLET(makedevs, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 181 | USE_MAKEDEVS(APPLET(makedevs, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
| 182 | USE_MD5SUM(APPLET(md5sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 182 | USE_MD5SUM(APPLET_ODDNAME(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, md5sum)) |
| 183 | USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 183 | USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
| 184 | USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 184 | USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
| 185 | USE_MKDIR(APPLET(mkdir, _BB_DIR_BIN, _BB_SUID_NEVER)) | 185 | 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)) | |||
| 245 | USE_FEATURE_SH_IS_HUSH(APPLET_NOUSAGE(sh, hush, _BB_DIR_BIN, _BB_SUID_NEVER)) | 245 | USE_FEATURE_SH_IS_HUSH(APPLET_NOUSAGE(sh, hush, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 246 | USE_FEATURE_SH_IS_LASH(APPLET_NOUSAGE(sh, lash, _BB_DIR_BIN, _BB_SUID_NEVER)) | 246 | USE_FEATURE_SH_IS_LASH(APPLET_NOUSAGE(sh, lash, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 247 | USE_FEATURE_SH_IS_MSH(APPLET_NOUSAGE(sh, msh, _BB_DIR_BIN, _BB_SUID_NEVER)) | 247 | USE_FEATURE_SH_IS_MSH(APPLET_NOUSAGE(sh, msh, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 248 | USE_SHA1SUM(APPLET(sha1sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 248 | USE_SHA1SUM(APPLET_ODDNAME(sha1sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sha1sum)) |
| 249 | USE_SLEEP(APPLET(sleep, _BB_DIR_BIN, _BB_SUID_NEVER)) | 249 | USE_SLEEP(APPLET(sleep, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 250 | USE_SORT(APPLET(sort, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 250 | USE_SORT(APPLET(sort, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
| 251 | USE_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, _BB_DIR_SBIN, _BB_SUID_NEVER, start_stop_daemon)) | 251 | USE_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, _BB_DIR_SBIN, _BB_SUID_NEVER, start_stop_daemon)) |
diff --git a/scripts/individual b/scripts/individual index 8815e1e14..35c44e87e 100755 --- a/scripts/individual +++ b/scripts/individual | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | # Clear out the build directory. (Make clean should do this instead of here.) | ||
| 4 | |||
| 5 | rm -rf build | ||
| 6 | mkdir build | ||
| 7 | |||
| 3 | # Make our prerequisites. | 8 | # Make our prerequisites. |
| 4 | 9 | ||
| 5 | make busybox.links include/bb_config.h | 10 | make busybox.links include/bb_config.h |
| @@ -12,15 +17,18 @@ cd libbb | |||
| 12 | make | 17 | make |
| 13 | cd .. | 18 | cd .. |
| 14 | 19 | ||
| 20 | # Same problem. | ||
| 21 | |||
| 15 | cd archival/libunarchive | 22 | cd archival/libunarchive |
| 16 | make | 23 | make |
| 17 | cd ../.. | 24 | cd ../.. |
| 18 | 25 | ||
| 19 | # 146 applets build without any extra stuff. The applet is one C file with | 26 | # About 3/5 of the applets build from one .c file (with the same name as the |
| 20 | # the same name as the corresponding applet, and all it needs to link against | 27 | # corresponding applet), and all it needs to link against. However, to build |
| 21 | # is libbb.a. However, 104 of them need more than that. | 28 | # them all we need more than that. |
| 29 | |||
| 30 | # Figure out which applets need extra libraries added to their command line. | ||
| 22 | 31 | ||
| 23 | # dpkg_deb gzip | ||
| 24 | function extra_libraries() | 32 | function extra_libraries() |
| 25 | { | 33 | { |
| 26 | archival="ar bunzip2 unlzma cpio dpkg gunzip rpm2cpio rpm tar uncompress unzip dpkg_deb gzip " | 34 | archival="ar bunzip2 unlzma cpio dpkg gunzip rpm2cpio rpm tar uncompress unzip dpkg_deb gzip " |
| @@ -28,34 +36,61 @@ function extra_libraries() | |||
| 28 | then | 36 | then |
| 29 | echo "archival/libunarchive/libunarchive.a" | 37 | echo "archival/libunarchive/libunarchive.a" |
| 30 | fi | 38 | fi |
| 39 | |||
| 40 | # What needs -libm? | ||
| 41 | |||
| 42 | libm="awk dc " | ||
| 43 | if [ "${libm/$1 //}" != "${libm}" ] | ||
| 44 | then | ||
| 45 | echo "-lm" | ||
| 46 | fi | ||
| 31 | } | 47 | } |
| 32 | |||
| 33 | |||
| 34 | 48 | ||
| 35 | # Here are a few that build in a standard way. Others are easy to get to | 49 | # Query applets.h to figure out which need something funky |
| 36 | # build, for example miscutils/dc needs -lm and most of loginutils/* needs | ||
| 37 | # -lcrypt... | ||
| 38 | 50 | ||
| 39 | rm -rf build | 51 | strange_names=`sed -rn -e 's/\#.*//' -e 's/.*APPLET_NOUSAGE\(([^,]*),([^,]*),.*/\1 \2/p' -e 's/.*APPLET_ODDNAME\(([^,]*),([^,]*),.*, *([^)]*).*/\1 \2@\3/p' include/applets.h` |
| 40 | mkdir build | 52 | |
| 53 | function bonkname() | ||
| 54 | { | ||
| 55 | while [ $# -gt 0 ] | ||
| 56 | do | ||
| 57 | if [ "$APPLET" == "$1" ] | ||
| 58 | then | ||
| 59 | APPFILT="${2/@*/}" | ||
| 60 | if [ "${APPFILT}" == "$2" ] | ||
| 61 | then | ||
| 62 | HELPNAME='"nousage\n"' | ||
| 63 | else | ||
| 64 | HELPNAME="${2/*@/}"_full_usage | ||
| 65 | fi | ||
| 66 | break | ||
| 67 | fi | ||
| 68 | shift 2 | ||
| 69 | done | ||
| 70 | #echo APPLET=${APPLET} APPFILT=${APPFILT} HELPNAME=${HELPNAME} 2=${2} | ||
| 71 | } | ||
| 41 | 72 | ||
| 42 | for APPLET in `sed 's .*/ ' busybox.links` | 73 | for APPLET in `sed 's .*/ ' busybox.links` |
| 43 | do | 74 | do |
| 44 | APPFILT=${APPLET/-/_} | 75 | export APPLET |
| 45 | j=`find . -name "${APPLET/-/?}.c"` # Because ether-wake.c is broken. | 76 | export APPFILT=${APPLET} |
| 77 | export HELPNAME=${APPLET}_full_usage | ||
| 78 | bonkname $strange_names | ||
| 79 | |||
| 80 | j=`find . -name "${APPFILT}.c"` | ||
| 46 | if [ -z "$j" ] | 81 | if [ -z "$j" ] |
| 47 | then | 82 | then |
| 48 | echo no file for $APPLET | 83 | echo no file for $APPLET |
| 49 | else | 84 | else |
| 50 | echo "Building $APPLET..." | 85 | echo "Building $APPLET" |
| 51 | gcc -Os -o build/$APPLET applets/individual.c $j \ | 86 | gcc -Os -o build/$APPLET applets/individual.c $j \ |
| 52 | `extra_libraries $APPFILT` libbb/libbb.a -Iinclude \ | 87 | `extra_libraries $APPFILT` libbb/libbb.a -Iinclude \ |
| 53 | -DBUILD_INDIVIDUAL \ | 88 | -DBUILD_INDIVIDUAL \ |
| 54 | "-Drun_applet_by_name(...)" "-Dfind_applet_by_name(...) 0" \ | 89 | "-Drun_applet_by_name(...)" "-Dfind_applet_by_name(...) 0" \ |
| 55 | -DAPPLET_main=${APPFILT}_main -DAPPLET_full_usage=${APPFILT}_full_usage | 90 | -DAPPLET_main=${APPFILT}_main -DAPPLET_full_usage=${HELPNAME} |
| 56 | if [ $? -ne 0 ]; | 91 | if [ $? -ne 0 ]; |
| 57 | then | 92 | then |
| 58 | echo "Failed." | 93 | echo "Failed $APPLET" |
| 59 | fi | 94 | fi |
| 60 | fi | 95 | fi |
| 61 | done | 96 | done |
