Commit hnyman's changes
[lede.git] / hnscripts / createbuildinfo.sh
1 #!/bin/sh
2 #
3 # createbuildinfo  -  Create info on current config and source code changes
4
5 getGitInfo() {
6 #params: directory patchfile infofile
7  echo "\n######################################################\n" >> $3
8  (cd $1
9   git diff HEAD > $2
10   git remote -v show | grep fetch >> $3
11   git branch --list >> $3
12   git show --format="%cd %h %s" --abbrev=7 --date=short | head -n 1 | cut -b1-60 >> $3
13   git status --porcelain >> $3
14  )
15 }
16
17 BinDir=$PWD/bin/targets/ipq806x/generic
18 Device=R7800
19 Prefix=lede-ipq806x
20 Branch=lede1701
21 #Branch=`basename $PWD`
22
23 VersTime=$Branch-`scripts/getver.sh`-`date +%Y%m%d-%H%M`
24 TFile=$BinDir/$Device-$VersTime
25
26 echo process $Branch...
27
28 # cleanup old binaries & patches
29 rm -f $BinDir/$Device-*
30
31 # remove unnecessary files
32 rm -f $BinDir/*root.img $BinDir/*vmlinux.elf
33
34 # create status info and patches
35 echo "$VersTime" > $TFile-status.txt
36 getGitInfo . $TFile-main.patch $TFile-status.txt
37 getGitInfo feeds/luci $TFile-luci.patch $TFile-status.txt
38 getGitInfo feeds/packages $TFile-packages.patch $TFile-status.txt
39 getGitInfo feeds/routing $TFile-routing.patch $TFile-status.txt
40 sed -i -e 's/$/\r/' $TFile-status.txt
41
42 # collect config info
43 cp .config $TFile.config
44 cp .config.init $TFile.config.init
45 scripts/diffconfig.sh > $TFile.diffconfig 2>/dev/null
46
47 # copy buildroot creation script and patch timestamp info
48 cp hnscripts/newBuildroot.sh $TFile-newBuildroot.sh
49 sed -i "s/^FILESTAMP=.*/FILESTAMP=$Device-$VersTime/" $TFile-newBuildroot.sh
50
51 # cleanup checksum files
52 grep -sh $Device.*-squashfs $BinDir/md5sums $BinDir/sha256sums \
53   | sed -e 's/$/\r/' -e 's/'$Prefix'-//' -e 's/squash/sq/' \
54   > $TFile-checksums.txt
55 rm -f $BinDir/md5sums $BinDir/sha256sums
56
57 # rename manifest and firmware files
58 cd $BinDir
59 mv *.manifest $Device-$VersTime.manifest
60 mv $Prefix-$Device-squashfs-sysupgrade.tar $Device-$VersTime-sqfs-sysupgrade.tar
61 mv $Prefix-$Device-squashfs-factory.img $Device-$VersTime-sqfs-factory.img
62