xref: /aosp_15_r20/external/e2fsprogs/util/gen-android-files (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker#!/bin/sh
2*6a54128fSAndroid Build Coastguard Worker
3*6a54128fSAndroid Build Coastguard WorkerANDROID_GENERATED_FILES="lib/ext2fs/ext2_err.c lib/ext2fs/ext2_err.h \
4*6a54128fSAndroid Build Coastguard Worker	lib/ss/ss_err.c lib/ss/ss_err.h lib/support/prof_err.c \
5*6a54128fSAndroid Build Coastguard Worker	lib/support/prof_err.h \
6*6a54128fSAndroid Build Coastguard Worker	lib/blkid/blkid_types.h lib/uuid/uuid_types.h \
7*6a54128fSAndroid Build Coastguard Worker	lib/ext2fs/ext2_types.h lib/config.h lib/blkid/blkid.h \
8*6a54128fSAndroid Build Coastguard Worker	lib/uuid/uuid.h lib/ext2fs/crc32c_table.h misc/default_profile.c \
9*6a54128fSAndroid Build Coastguard Worker	lib/ss/std_rqs.c debugfs/debug_cmds.c debugfs/ro_debug_cmds.c \
10*6a54128fSAndroid Build Coastguard Worker	debugfs/extent_cmds.c debugfs/e2freefrag.c \
11*6a54128fSAndroid Build Coastguard Worker	debugfs/recovery.c debugfs/revoke.c \
12*6a54128fSAndroid Build Coastguard Worker	MODULE_LICENSE_GPL README.version"
13*6a54128fSAndroid Build Coastguard Worker
14*6a54128fSAndroid Build Coastguard WorkerSS_DIR=$(pwd)/lib/ss
15*6a54128fSAndroid Build Coastguard WorkerMK_CMDS=/tmp/mk_cmds$$.sh
16*6a54128fSAndroid Build Coastguard Worker
17*6a54128fSAndroid Build Coastguard Workersed -e "s/@AWK@/awk/" < $SS_DIR/mk_cmds.sh.in \
18*6a54128fSAndroid Build Coastguard Worker    | sed -e "s/@SED@/sed/" > $MK_CMDS
19*6a54128fSAndroid Build Coastguard Worker
20*6a54128fSAndroid Build Coastguard Workersed -e "s/@E2FSPROGS_VERSION@/$(git describe)/" < lib/ext2fs/ext2_err.et.in > lib/ext2fs/ext2_err.et
21*6a54128fSAndroid Build Coastguard Worker
22*6a54128fSAndroid Build Coastguard Workerfor i in lib/ss/ss_err lib/support/prof_err lib/ext2fs/ext2_err
23*6a54128fSAndroid Build Coastguard Workerdo
24*6a54128fSAndroid Build Coastguard Worker   rm -f $i.c $i.h
25*6a54128fSAndroid Build Coastguard Worker   awk -f lib/et/et_c.awk outfile=$i.c outfn=$(basename $i.c) $i.et
26*6a54128fSAndroid Build Coastguard Worker   awk -f lib/et/et_h.awk outfile=$i.h outfn=$(basename $i.h) $i.et
27*6a54128fSAndroid Build Coastguard Workerdone
28*6a54128fSAndroid Build Coastguard Worker
29*6a54128fSAndroid Build Coastguard Workerfor i in lib/ss/std_rqs debugfs/debug_cmds debugfs/ro_debug_cmds \
30*6a54128fSAndroid Build Coastguard Worker			debugfs/extent_cmds
31*6a54128fSAndroid Build Coastguard Workerdo
32*6a54128fSAndroid Build Coastguard Worker    _SS_DIR_OVERRIDE=lib/ss /bin/sh $MK_CMDS $i.ct
33*6a54128fSAndroid Build Coastguard Worker    mv -f $(basename $i).c $i.c
34*6a54128fSAndroid Build Coastguard Workerdone
35*6a54128fSAndroid Build Coastguard Worker
36*6a54128fSAndroid Build Coastguard Workerrm -f $MK_CMDS
37*6a54128fSAndroid Build Coastguard Worker
38*6a54128fSAndroid Build Coastguard Workercp lib/blkid/blkid.h.in lib/blkid/blkid.h
39*6a54128fSAndroid Build Coastguard Workercp lib/uuid/uuid.h.in lib/uuid/uuid.h
40*6a54128fSAndroid Build Coastguard Worker
41*6a54128fSAndroid Build Coastguard Workercp util/android_types.h lib/ext2fs/ext2_types.h
42*6a54128fSAndroid Build Coastguard Workercp util/android_types.h lib/blkid/blkid_types.h
43*6a54128fSAndroid Build Coastguard Workercp util/android_types.h lib/uuid/uuid_types.h
44*6a54128fSAndroid Build Coastguard Worker# Copied header files having exactly same content results in debug output
45*6a54128fSAndroid Build Coastguard Worker# differences on RBE. Hence modify the #define's appropriately.
46*6a54128fSAndroid Build Coastguard Workersed -i 's/#define _LINUX_TYPES_H/#define _BLKID_TYPES_H/g' lib/blkid/blkid_types.h
47*6a54128fSAndroid Build Coastguard Workersed -i 's/#define _LINUX_TYPES_H/#define _EXT2_TYPES_H/g' lib/ext2fs/ext2_types.h
48*6a54128fSAndroid Build Coastguard Workersed -i 's/#define _LINUX_TYPES_H/#define _UUID_TYPES_H/g' lib/uuid/uuid_types.h
49*6a54128fSAndroid Build Coastguard Worker
50*6a54128fSAndroid Build Coastguard Workercp util/android_config.h lib/config.h
51*6a54128fSAndroid Build Coastguard Workercp misc/e2freefrag.c debugfs/
52*6a54128fSAndroid Build Coastguard Workercp e2fsck/recovery.c e2fsck/revoke.c debugfs/
53*6a54128fSAndroid Build Coastguard Worker
54*6a54128fSAndroid Build Coastguard Workergcc -o gen_crc32ctable lib/ext2fs/gen_crc32ctable.c
55*6a54128fSAndroid Build Coastguard Worker./gen_crc32ctable > lib/ext2fs/crc32c_table.h
56*6a54128fSAndroid Build Coastguard Worker
57*6a54128fSAndroid Build Coastguard Workerawk -f misc/profile-to-c.awk < misc/mke2fs.conf.in > misc/default_profile.c
58*6a54128fSAndroid Build Coastguard Worker
59*6a54128fSAndroid Build Coastguard Workerrm -f ./gen_crc32table ./gen_crc32ctable lib/ext2fs/ext2_err.et
60*6a54128fSAndroid Build Coastguard Worker
61*6a54128fSAndroid Build Coastguard Workertouch MODULE_LICENSE_GPL
62*6a54128fSAndroid Build Coastguard Worker
63*6a54128fSAndroid Build Coastguard WorkerE2FSPROGS_VERSION=`grep E2FSPROGS_VERSION version.h  \
64*6a54128fSAndroid Build Coastguard Worker	| awk '{print $3}' | tr \" " " | awk '{print $1}'`
65*6a54128fSAndroid Build Coastguard WorkerDATE=`grep E2FSPROGS_DATE version.h | awk '{print $3}' \
66*6a54128fSAndroid Build Coastguard Worker	| tr \" " "`
67*6a54128fSAndroid Build Coastguard WorkerE2FSPROGS_DAY=$(echo $DATE | awk -F- '{print $1}' | sed -e '/^[1-9]$/s/^/0/')
68*6a54128fSAndroid Build Coastguard WorkerMONTH=`echo $DATE | awk -F- '{print $2}'`
69*6a54128fSAndroid Build Coastguard WorkerYEAR=`echo $DATE | awk -F- '{print $3}'`
70*6a54128fSAndroid Build Coastguard Worker
71*6a54128fSAndroid Build Coastguard Workerif expr $YEAR ">" 1900 > /dev/null ; then
72*6a54128fSAndroid Build Coastguard Worker	E2FSPROGS_YEAR=$YEAR
73*6a54128fSAndroid Build Coastguard Workerelif expr $YEAR ">" 90 >/dev/null ; then
74*6a54128fSAndroid Build Coastguard Worker	E2FSPROGS_YEAR=19$YEAR
75*6a54128fSAndroid Build Coastguard Workerelse
76*6a54128fSAndroid Build Coastguard Worker	E2FSPROGS_YEAR=20$YEAR
77*6a54128fSAndroid Build Coastguard Workerfi
78*6a54128fSAndroid Build Coastguard Worker
79*6a54128fSAndroid Build Coastguard Workercase $MONTH in
80*6a54128fSAndroid Build Coastguard WorkerJan)	MONTH_NUM=01; E2FSPROGS_MONTH="January" ;;
81*6a54128fSAndroid Build Coastguard WorkerFeb)	MONTH_NUM=02; E2FSPROGS_MONTH="February" ;;
82*6a54128fSAndroid Build Coastguard WorkerMar)	MONTH_NUM=03; E2FSPROGS_MONTH="March" ;;
83*6a54128fSAndroid Build Coastguard WorkerApr)	MONTH_NUM=04; E2FSPROGS_MONTH="April" ;;
84*6a54128fSAndroid Build Coastguard WorkerMay)	MONTH_NUM=05; E2FSPROGS_MONTH="May" ;;
85*6a54128fSAndroid Build Coastguard WorkerJun)	MONTH_NUM=06; E2FSPROGS_MONTH="June" ;;
86*6a54128fSAndroid Build Coastguard WorkerJul)	MONTH_NUM=07; E2FSPROGS_MONTH="July" ;;
87*6a54128fSAndroid Build Coastguard WorkerAug)	MONTH_NUM=08; E2FSPROGS_MONTH="August" ;;
88*6a54128fSAndroid Build Coastguard WorkerSep)	MONTH_NUM=09; E2FSPROGS_MONTH="September" ;;
89*6a54128fSAndroid Build Coastguard WorkerOct)	MONTH_NUM=10; E2FSPROGS_MONTH="October" ;;
90*6a54128fSAndroid Build Coastguard WorkerNov)	MONTH_NUM=11; E2FSPROGS_MONTH="November" ;;
91*6a54128fSAndroid Build Coastguard WorkerDec)	MONTH_NUM=12; E2FSPROGS_MONTH="December" ;;
92*6a54128fSAndroid Build Coastguard Worker*)	MONTH_NUM=13; E2FSPROGS_MONTH="UNKNOWN" ;;
93*6a54128fSAndroid Build Coastguard Workeresac
94*6a54128fSAndroid Build Coastguard Worker
95*6a54128fSAndroid Build Coastguard Workerbase_ver=`echo $E2FSPROGS_VERSION | \
96*6a54128fSAndroid Build Coastguard Worker	       sed -e 's/-WIP//' -e 's/pre-//' -e 's/-PLUS//'`
97*6a54128fSAndroid Build Coastguard Worker
98*6a54128fSAndroid Build Coastguard Workerdate_spec=${E2FSPROGS_YEAR}${MONTH_NUM}${E2FSPROGS_DAY}
99*6a54128fSAndroid Build Coastguard Worker
100*6a54128fSAndroid Build Coastguard Workercase $E2FSPROGS_VERSION in
101*6a54128fSAndroid Build Coastguard Worker*-WIP|pre-*)
102*6a54128fSAndroid Build Coastguard Worker	VER="$base_ver-WIP-$date_spec"
103*6a54128fSAndroid Build Coastguard Worker	FN="$base_ver~WIP.$E2FSPROGS_YEAR.$MONTH_NUM.$E2FSPROGS_DAY"
104*6a54128fSAndroid Build Coastguard Worker	;;
105*6a54128fSAndroid Build Coastguard Worker*)
106*6a54128fSAndroid Build Coastguard Worker	VER="$base_ver"
107*6a54128fSAndroid Build Coastguard Worker	FN="$base_ver"
108*6a54128fSAndroid Build Coastguard Worker	;;
109*6a54128fSAndroid Build Coastguard Workeresac
110*6a54128fSAndroid Build Coastguard Worker
111*6a54128fSAndroid Build Coastguard Workersed -e "s/@VER@/$VER/g" -e "s/@FN@/$FN/" < util/android-README.version.in > README.version
112*6a54128fSAndroid Build Coastguard Worker
113*6a54128fSAndroid Build Coastguard Workergit add -f $ANDROID_GENERATED_FILES
114*6a54128fSAndroid Build Coastguard Workerif test -f COPYING
115*6a54128fSAndroid Build Coastguard Workerthen
116*6a54128fSAndroid Build Coastguard Worker   git mv COPYING NOTICE
117*6a54128fSAndroid Build Coastguard Workerfi
118*6a54128fSAndroid Build Coastguard Workergit commit -m "Update generated files for Android"
119