| 1 | #!/bin/bash | 
|---|
| 2 | # Written By: Joe Ciccone <jciccone at gmail dot com> | 
|---|
| 3 |  | 
|---|
| 4 | # Usage, glibc.sh [cvs-tag] [tarball-version] | 
|---|
| 5 | # An example of a CVS tag would be HEAD or glibc-2_9 | 
|---|
| 6 | # An example of a tarball version would be say the date, or 2.9, it will be | 
|---|
| 7 | #   inserted into the output tarball filename, | 
|---|
| 8 | #   eg, glibc-[tarball-version].tar.bz2 | 
|---|
| 9 |  | 
|---|
| 10 | CVStag=${1-HEAD} | 
|---|
| 11 | TARver=${2-$(date +%Y%m%d)} | 
|---|
| 12 |  | 
|---|
| 13 | echo "Creating glibc-${TARver}.tar.bz2 and glibc-ports-${TARver}.tar.bz2 from the ${CVStag} CVS Tag." | 
|---|
| 14 |  | 
|---|
| 15 | tmpdir="$(mktemp -d)" | 
|---|
| 16 | if test ! -d "${tmpdir}"; then | 
|---|
| 17 | tmpdir="/tmp/glibc-XXXX" | 
|---|
| 18 | mkdir -pv "${tmpdir}" | 
|---|
| 19 | fi | 
|---|
| 20 |  | 
|---|
| 21 | if test ! -d "${tmpdir}"; then | 
|---|
| 22 | echo "Failed to create temp directory: ${tmpdir}" | 
|---|
| 23 | exit 1 | 
|---|
| 24 | fi | 
|---|
| 25 |  | 
|---|
| 26 | echo "Use \"anoncvs\" for the password." | 
|---|
| 27 | cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/glibc login | 
|---|
| 28 | if test $? -ne 0; then | 
|---|
| 29 | echo "Failed to login to glibc cvs server." | 
|---|
| 30 | rm -rf "${tmpdir}" | 
|---|
| 31 | exit 1 | 
|---|
| 32 | fi | 
|---|
| 33 |  | 
|---|
| 34 | pushd "${tmpdir}" | 
|---|
| 35 |  | 
|---|
| 36 | # Checkout from the cvs glibc | 
|---|
| 37 | cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/glibc co -r "${CVStag}" libc | 
|---|
| 38 | mv libc "glibc-${TARver}" | 
|---|
| 39 | if test $? -ne 0; then | 
|---|
| 40 | echo "Failed to check out libc, Leaving temp files in ${tmpdir}." | 
|---|
| 41 | exit 1 | 
|---|
| 42 | fi | 
|---|
| 43 |  | 
|---|
| 44 | # Checkout from the cvs glibc | 
|---|
| 45 | cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/glibc co -r "${CVStag}" ports | 
|---|
| 46 | mv ports "glibc-ports-${TARver}" | 
|---|
| 47 | if test $? -ne 0; then | 
|---|
| 48 | echo "Failed to check out libc, Leaving temp files in ${tmpdir}." | 
|---|
| 49 | exit 1 | 
|---|
| 50 | fi | 
|---|
| 51 |  | 
|---|
| 52 | # If the timestamp of configure.in is newer than configure glibc will try to | 
|---|
| 53 | # reconfigure itself, this can cause some errors while cross-compiling. | 
|---|
| 54 | find "glibc-${TARver}" "glibc-ports-${TARver}" -name configure | xargs touch | 
|---|
| 55 |  | 
|---|
| 56 | # Clean out CVS Files | 
|---|
| 57 | find "glibc-${TARver}" "glibc-ports-${TARver}" -name CVS -type d | xargs rm -rf | 
|---|
| 58 | find "glibc-${TARver}" "glibc-ports-${TARver}" -name .cvsignore | xargs rm -rf | 
|---|
| 59 |  | 
|---|
| 60 | # Add a custom version string | 
|---|
| 61 | DATE_STAMP=$(date +%Y%m%d) | 
|---|
| 62 | echo "#define DL_DATE \"${DATE_STAMP}\"" >> libc/version.h | 
|---|
| 63 | sed -i "s@Compiled by GNU CC version@Built for Cross-LFS.\\\\n\\\\\nRetrieved on \"DL_DATE\".\\\\n\\\\\\nCompiled by GNU CC version@" libc/csu/version.c | 
|---|
| 64 | sed -i "s@static const char __libc_release@static const char __libc_dl_date[] = DL_DATE;\nstatic const char __libc_release@" libc/csu/version.c | 
|---|
| 65 |  | 
|---|
| 66 | # Create tarballs | 
|---|
| 67 | echo "Creating Tarballs" | 
|---|
| 68 | tar cvjf "glibc-${TARver}.tar.bz2" "glibc-${TARver}" | 
|---|
| 69 | tar cvjf "glibc-ports-${TARver}.tar.bz2" "glibc-ports-${TARver}" | 
|---|
| 70 |  | 
|---|
| 71 | # echo Pop back to the orig working directory and mv the tarballs over | 
|---|
| 72 |  | 
|---|
| 73 | popd | 
|---|
| 74 | mv "${tmpdir}/glibc-${TARver}.tar.bz2" . | 
|---|
| 75 | mv "${tmpdir}/glibc-ports-${TARver}.tar.bz2" . | 
|---|
| 76 |  | 
|---|
| 77 | rm -rf "${tmpdir}" | 
|---|