/* gpt.c */ void usage(void); int main(int argc, char *argv[]); /* version.c */ /* util.c */ void hexdump(FILE *f, uint8_t *data, int s, int l); void utf16_to_ascii(void *_u16, int u16_len, void *_u8, int u8_len); void ascii_to_utf16(void *_u8, int u8_len, void *_u16, int u16_len); /* guid.c */ int guid_cmp(GUID *a, GUID *b); char *guid_to_a(GUID g); int a_to_guid(char *a, GUID *g); GUID guid_random(void); /* crc.c */ uint32_t crc32(uint32_t crc, const void *_buf, int len); /* header.c */ void header_calc_crc(GPT_header *h); GPT_header header_new(GUID disk_guid, uint64_t lbas, int alt); uint32_t header_calc_ent_crc(DISK *d, GPT_header *h); void header_show(DISK *d, GPT_header *h); int header_validate(DISK *d, GPT_header *h); void header_redo_ent_crc(DISK *d, GPT_header *h); void header_write(DISK *d, GPT_header *h); int headers_validate(DISK *d, GPT_headers *h); GPT_headers headers_get(DISK *d); /* disk.c */ DISK *disk_open(char *fn); void disk_read(DISK *d, void *buf, uint64_t lba, int lbas); void disk_write(DISK *d, void *buf, uint64_t lba, int lbas); uint64_t disk_lbas(DISK *d); int disk_reread_kernel_table(DISK *d); /* pmbr.c */ void mbr_entry_show(MBR_entry *e); void mbr_show(MBR *m); MBR mbr_new(uint64_t lbas); void mbr_entry_from_gpt_entry(MBR_entry *m, GPT_header *h, GPT_entry *g, int bootable, uint8_t type); /* show.c */ void show(DISK *d); /* entry.c */ void entry_write(DISK *d, GPT_header *h, int n, GPT_entry *e); GPT_entry entry_read(DISK *d, GPT_header *h, int n); int entry_empty(GPT_entry *e); void entry_show(GPT_entry *e); /* new.c */ void new(DISK *d); /* modify.c */ int modify(DISK *d, int n, char *name, char *type_guid, uint64_t start, uint64_t end); /* sync.c */ void sync_tables(DISK *d); href='/cgit.cgi/openwrt/upstream/?h=v19.07.3'>summaryrefslogtreecommitdiffstats
path: root/scripts/getver.sh
blob: 8bb384bd538fbc4a3a249d666cd8dc216e7fb63d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
export LANG=C
export LC_ALL=C
[ -n "$TOPDIR" ] && cd $TOPDIR

try_version() {
	[ -f version ] || return 1
	REV="$(cat version)"
	[ -n "$REV" ]
}

try_svn() {
	[ -d .svn ] || return 1
	REV="$(svn info | awk '/^Last Changed Rev:/ { print $4 }')"
	REV="${REV:+r$REV}"
	[ -n "$REV" ]
}

try_git() {
	[ -d .git ] || return 1
	REV="$(git log | grep -m 1 git-svn-id | awk '{ gsub(/.*@/, "", $0); print $1 }')"
	REV="${REV:+r$REV}"
	[ -n "$REV" ]
}

try_hg() {
	[ -d .hg ] || return 1
	REV="$(hg log -r-1 --template '{desc}' | awk '{print $2}' | sed 's/\].*//')"
	REV="${REV:+$REV}"
	[ -n "$REV" ]
}

try_version || try_svn || try_git || try_hg || REV="unknown"
echo "$REV"