1#!/bin/sh 2 3ANDROID_GENERATED_FILES="lib/ext2fs/ext2_err.c lib/ext2fs/ext2_err.h \ 4 lib/ss/ss_err.c lib/ss/ss_err.h lib/support/prof_err.c \ 5 lib/support/prof_err.h \ 6 lib/blkid/blkid_types.h lib/uuid/uuid_types.h \ 7 lib/ext2fs/ext2_types.h lib/config.h lib/blkid/blkid.h \ 8 lib/uuid/uuid.h lib/ext2fs/crc32c_table.h misc/default_profile.c \ 9 lib/ss/std_rqs.c debugfs/debug_cmds.c debugfs/ro_debug_cmds.c \ 10 debugfs/extent_cmds.c debugfs/e2freefrag.c \ 11 debugfs/recovery.c debugfs/revoke.c \ 12 MODULE_LICENSE_GPL README.version" 13 14SS_DIR=$(pwd)/lib/ss 15MK_CMDS=/tmp/mk_cmds$$.sh 16 17sed -e "s/@AWK@/awk/" < $SS_DIR/mk_cmds.sh.in \ 18 | sed -e "s/@SED@/sed/" > $MK_CMDS 19 20sed -e "s/@E2FSPROGS_VERSION@/$(git describe)/" < lib/ext2fs/ext2_err.et.in > lib/ext2fs/ext2_err.et 21 22for i in lib/ss/ss_err lib/support/prof_err lib/ext2fs/ext2_err 23do 24 rm -f $i.c $i.h 25 awk -f lib/et/et_c.awk outfile=$i.c outfn=$(basename $i.c) $i.et 26 awk -f lib/et/et_h.awk outfile=$i.h outfn=$(basename $i.h) $i.et 27done 28 29for i in lib/ss/std_rqs debugfs/debug_cmds debugfs/ro_debug_cmds \ 30 debugfs/extent_cmds 31do 32 _SS_DIR_OVERRIDE=lib/ss /bin/sh $MK_CMDS $i.ct 33 mv -f $(basename $i).c $i.c 34done 35 36rm -f $MK_CMDS 37 38cp lib/blkid/blkid.h.in lib/blkid/blkid.h 39cp lib/uuid/uuid.h.in lib/uuid/uuid.h 40cp util/android_types.h lib/ext2fs/ext2_types.h 41cp util/android_types.h lib/blkid/blkid_types.h 42cp util/android_types.h lib/uuid/uuid_types.h 43cp util/android_config.h lib/config.h 44cp misc/e2freefrag.c debugfs/ 45cp e2fsck/recovery.c e2fsck/revoke.c debugfs/ 46 47gcc -o gen_crc32ctable lib/ext2fs/gen_crc32ctable.c 48./gen_crc32ctable > lib/ext2fs/crc32c_table.h 49 50awk -f misc/profile-to-c.awk < misc/mke2fs.conf.in > misc/default_profile.c 51 52rm -f ./gen_crc32table ./gen_crc32ctable lib/ext2fs/ext2_err.et 53 54touch MODULE_LICENSE_GPL 55 56E2FSPROGS_VERSION=`grep E2FSPROGS_VERSION version.h \ 57 | awk '{print $3}' | tr \" " " | awk '{print $1}'` 58DATE=`grep E2FSPROGS_DATE version.h | awk '{print $3}' \ 59 | tr \" " "` 60E2FSPROGS_DAY=$(echo $DATE | awk -F- '{print $1}' | sed -e '/^[1-9]$/s/^/0/') 61MONTH=`echo $DATE | awk -F- '{print $2}'` 62YEAR=`echo $DATE | awk -F- '{print $3}'` 63 64if expr $YEAR ">" 1900 > /dev/null ; then 65 E2FSPROGS_YEAR=$YEAR 66elif expr $YEAR ">" 90 >/dev/null ; then 67 E2FSPROGS_YEAR=19$YEAR 68else 69 E2FSPROGS_YEAR=20$YEAR 70fi 71 72case $MONTH in 73Jan) MONTH_NUM=01; E2FSPROGS_MONTH="January" ;; 74Feb) MONTH_NUM=02; E2FSPROGS_MONTH="February" ;; 75Mar) MONTH_NUM=03; E2FSPROGS_MONTH="March" ;; 76Apr) MONTH_NUM=04; E2FSPROGS_MONTH="April" ;; 77May) MONTH_NUM=05; E2FSPROGS_MONTH="May" ;; 78Jun) MONTH_NUM=06; E2FSPROGS_MONTH="June" ;; 79Jul) MONTH_NUM=07; E2FSPROGS_MONTH="July" ;; 80Aug) MONTH_NUM=08; E2FSPROGS_MONTH="August" ;; 81Sep) MONTH_NUM=09; E2FSPROGS_MONTH="September" ;; 82Oct) MONTH_NUM=10; E2FSPROGS_MONTH="October" ;; 83Nov) MONTH_NUM=11; E2FSPROGS_MONTH="November" ;; 84Dec) MONTH_NUM=12; E2FSPROGS_MONTH="December" ;; 85*) MONTH_NUM=13; E2FSPROGS_MONTH="UNKNOWN" ;; 86esac 87 88base_ver=`echo $E2FSPROGS_VERSION | \ 89 sed -e 's/-WIP//' -e 's/pre-//' -e 's/-PLUS//'` 90 91date_spec=${E2FSPROGS_YEAR}${MONTH_NUM}${E2FSPROGS_DAY} 92 93case $E2FSPROGS_VERSION in 94*-WIP|pre-*) 95 VER="$base_ver-WIP-$date_spec" 96 FN="$base_ver~WIP.$E2FSPROGS_YEAR.$MONTH_NUM.$E2FSPROGS_DAY" 97 ;; 98*) 99 VER="$base_ver" 100 FN="$base_ver" 101 ;; 102esac 103 104sed -e "s/@VER@/$VER/g" -e "s/@FN@/$FN/" < util/android-README.version.in > README.version 105 106git add -f $ANDROID_GENERATED_FILES 107if test -f COPYING 108then 109 git mv COPYING NOTICE 110fi 111git commit -m "Update generated files for Android" 112