1 | #!/bin/bash
|
---|
2 | # Create a Busybox Patch
|
---|
3 |
|
---|
4 | # Get Version #
|
---|
5 | #
|
---|
6 | VERSION=$1
|
---|
7 |
|
---|
8 | # Check Input
|
---|
9 | #
|
---|
10 | if [ "${VERSION}" = "" ]; then
|
---|
11 | echo "$0 - Busybox_Version"
|
---|
12 | echo "This will Create a Patch for Busybox Busybox_Version"
|
---|
13 | exit 255
|
---|
14 | fi
|
---|
15 |
|
---|
16 | # Get Patch Names
|
---|
17 | #
|
---|
18 | cd /usr/src
|
---|
19 | wget http://busybox.net/downloads/fixes-${VERSION}/ --no-remove-listing
|
---|
20 | FILES=$(cat index.html | grep patch | grep patch | cut -f3 -d'<' | cut -f2 -d'>')
|
---|
21 | rm -f .listing
|
---|
22 | rm -f index.html
|
---|
23 |
|
---|
24 | # Download Busybox Source
|
---|
25 | #
|
---|
26 | if ! [ -e busybox-${VERSION}.tar.bz2 ]; then
|
---|
27 | wget http://busybox.net/downloads/busybox-${VERSION}.tar.bz2
|
---|
28 | fi
|
---|
29 |
|
---|
30 | # Set Patch Number
|
---|
31 | #
|
---|
32 | cd /usr/src
|
---|
33 | wget http://svn.cross-lfs.org/svn/repos/cross-lfs/branches/clfs-embedded/patches/ --no-remove-listing
|
---|
34 | PATCH_NUM=$(cat index.html | grep busybox | grep "${VERSION}" | grep branch_update | cut -f2 -d'"' | cut -f1 -d'"'| cut -f4 -d- | cut -f1 -d. | tail -n 1)
|
---|
35 | PATCH_NUM=$(expr ${PATCH_NUM} + 1)
|
---|
36 | rm -f index.html
|
---|
37 |
|
---|
38 | # Cleanup Directory
|
---|
39 | #
|
---|
40 | rm -rf busybox-${VERSION} busybox-${VERSION}.orig
|
---|
41 | tar xvf busybox-${VERSION}.tar.bz2
|
---|
42 | cp -ar busybox-${VERSION} busybox-${VERSION}.orig
|
---|
43 | cd busybox-${VERSION}
|
---|
44 | CURRENTDIR=$(pwd -P)
|
---|
45 |
|
---|
46 | # Download and Apply Patches
|
---|
47 | #
|
---|
48 | mkdir /tmp/busybox-${VERSION}
|
---|
49 | for file in ${FILES}; do
|
---|
50 | cd /tmp/busybox-${VERSION}
|
---|
51 | echo "Getting Patch ${file}..."
|
---|
52 | wget --quiet http://busybox.net/downloads/fixes-${VERSION}/${file}
|
---|
53 | cd ${CURRENTDIR}
|
---|
54 | patch --dry-run -s -f -Np1 -i /tmp/busybox-${VERSION}/${file}
|
---|
55 | if [ "$?" = "0" ]; then
|
---|
56 | echo "Apply Patch ${file}..."
|
---|
57 | patch -Np1 -i /tmp/busybox-${VERSION}/${file}
|
---|
58 | fi
|
---|
59 | done
|
---|
60 |
|
---|
61 | # Cleanup Directory
|
---|
62 | #
|
---|
63 | for dir in $(find * -type d); do
|
---|
64 | cd /usr/src/busybox-${VERSION}/${dir}
|
---|
65 | for file in $(find . -name '*~'); do
|
---|
66 | rm -f ${file}
|
---|
67 | done
|
---|
68 | for file in $(find . -name '*.orig'); do
|
---|
69 | rm -f ${file}
|
---|
70 | done
|
---|
71 | done
|
---|
72 | cd /usr/src/busybox-${VERSION}
|
---|
73 | rm -f *~ *.orig
|
---|
74 |
|
---|
75 | # Create Patch
|
---|
76 | #
|
---|
77 | cd /usr/src
|
---|
78 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > busybox-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
79 | echo "Date: `date +%m-%d-%Y`" >> busybox-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
80 | echo "Initial Package Version: ${VERSION}" >> busybox-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
81 | echo "Origin: Upstream" >> busybox-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
82 | echo "Upstream Status: Applied" >> busybox-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
83 | echo "Description: This is a branch update for busybox-${VERSION}, and should be" >> busybox-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
84 | echo " rechecked periodically." >> busybox-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
85 | echo "" >> busybox-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
86 | diff -Naur busybox-${VERSION}.orig busybox-${VERSION} >> busybox-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
87 | echo "Created /usr/src/busybox-${VERSION}-branch_update-${PATCH_NUM}.patch."
|
---|