Advertisement
rockdrilla

gentoo style @ Debian //early concept

Dec 17th, 2013
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 11.89 KB | None | 0 0
  1. #!/bin/bash
  2. declare -A V
  3. V[zlib]=1.2.8-debian
  4. V[openssl]=1.0.2-20131217
  5.  
  6. source_tree=$(readlink -e "$0" | xargs -r0 dirname)
  7.  
  8. prebuilt_tree=${source_tree}/prebuilt
  9. rm -rf ${prebuilt_tree}; mkdir ${prebuilt_tree}
  10.  
  11. TMPDIR=${source_tree}/gcc_temp
  12. rm -rf ${TMPDIR}; mkdir ${TMPDIR}
  13.  
  14. heavy_task='nice -n +40 chrt -i 0 ionice -c 3'
  15.  
  16. jobs=${JOBS:-1}
  17. make=$(which make)
  18. if [ ${jobs} -gt 1 ]; then
  19.     make="${heavy_task} ${make} -j ${jobs}"
  20. fi
  21.  
  22. Binit() {
  23.     [ -z "${source_tree}" ] && return 1
  24.     [ -z "${name}" ] && return 1
  25.     [ -z "${version}" ] && version=${V[${name}]}
  26.     [ -z "${version}" ] && return 1
  27.  
  28.     cd ${source_tree}/${name}
  29.     [ -e ${version}.tar.xz ] || return 1
  30.     file -i ${version}.tar.xz | cut -d: -f2 | fgrep -qe application/x-xz || return 1
  31.  
  32.     ${heavy_task} find ./ -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} +
  33.     ${heavy_task} xz -dvv < ${version}.tar.xz | ${heavy_task} tar xf -
  34.     prebuilt=${prebuilt_tree}/${name}/${version}
  35.     mkdir -p ${prebuilt}/{,/lib,/include}
  36.     cd ${version}/
  37.     ln -s ${source_tree} source_tree
  38.     ln -s ${prebuilt_tree} prebuilt_tree
  39. }
  40. Bcleanup() {
  41.     gcc_cleanup
  42.  
  43.     [ -z "${source_tree}" ] && return
  44.     [ -z "${name}" ] && return
  45.     [ -z "${version}" ] && return
  46.  
  47.     cd ${source_tree}/
  48.     ${heavy_task} rm -rf ${source_tree}/${name}/${version}/
  49.     unset name version
  50. }
  51. # Source Tree path
  52. # ST {A|R} <name>
  53. ST() {
  54.     local base=
  55.     case "$1" in
  56.     [Aa]) base=${source_tree} ;; # absolute path
  57.     [Rr]) base=source_tree ;;    # relative path
  58.     *)    return 1 ;;
  59.     esac
  60.     [ -z "$2" ] && return 1
  61.     local name=$2
  62.     local version=${V[${name}]}
  63.     [ -z "${version}" ] && return 1
  64.     echo ${base}/${name}/${version}
  65. }
  66. # Prebuild Tree path
  67. # PT {A|R} <name> [path]
  68. PT() {
  69.     local base=
  70.     case "$1" in
  71.     [Aa]) base=${prebuilt_tree} ;; # absolute path
  72.     [Rr]) base=prebuilt_tree ;;    # relative path
  73.     *)    return 1 ;;
  74.     esac
  75.     [ -z "$2" ] && return 1
  76.     local name=$2
  77.     local version=${V[${name}]}
  78.     [ -z "${version}" ] && return 1
  79.     local path=${3:+'/'}$3
  80.     echo ${base}/${name}/${version}${path}
  81. }
  82.  
  83. gcc_cleanup() { ${heavy_task} find ${TMPDIR}/ -mindepth 1 -maxdepth 1 -name 'cc*' -delete; }
  84.  
  85. ### zlib
  86. name=zlib
  87. Binit && {
  88.     cp contrib/amd64/amd64-match.S match.S
  89.     CFLAGS=-DASMV ./configure
  90.     gcc_cleanup
  91.     ${make} OBJA=match.o libz.a
  92.     cp -Lp *.a ${prebuilt}/lib
  93.     cp -Lp *.h ${prebuilt}/include
  94. }
  95. Bcleanup
  96.  
  97. ### openssl
  98. name=openssl
  99. Binit && {
  100.     ./config --prefix=$(PT R ${name}) zlib --with-zlib-lib=$(PT A zlib lib) --with-zlib-include=$(PT A zlib include)
  101.     cp -LpR include/openssl/ ${prebuilt}/include/
  102.     gcc_cleanup
  103.     ${make} depend
  104.     ${make} build_libs
  105.     cp -Lp *.a ${prebuilt}/lib/
  106. }
  107. Bcleanup
  108.  
  109. # krd@amethyst:/tmp/gentoo$ find -mindepth 1 -maxdepth 2 -exec ls -lhdG {} + | sed -e 's# ./# #'
  110. # drwxr-xr-x  2 krd   40 Dec 17 17:30 gcc_temp
  111. # -rw-r--r--  1 krd 2.5K Dec 17 17:30 gentoo.sh
  112. # drwxr-xr-x  2 krd   60 Dec 17 17:32 openssl
  113. # -rw-r--r--  1 krd 3.0M Dec 17 16:39 openssl/1.0.2-20131217.tar.xz
  114. # drwxr-xr-x  4 krd   80 Dec 17 17:30 prebuilt
  115. # drwxr-xr-x  3 krd   60 Dec 17 17:30 prebuilt/openssl
  116. # drwxr-xr-x  3 krd   60 Dec 17 17:30 prebuilt/zlib
  117. # drwxr-xr-x  2 krd   60 Dec 17 17:30 zlib
  118. # -rw-r--r--  1 krd 330K Dec 17 14:45 zlib/1.2.8-debian.tar.xz
  119. #
  120. # krd@amethyst:/tmp/gentoo$ find prebuilt/ -exec ls -lhdG {} +
  121. # drwxr-xr-x 4 krd   80 Dec 17 17:30 prebuilt/
  122. # drwxr-xr-x 3 krd   60 Dec 17 17:30 prebuilt/openssl
  123. # drwxr-xr-x 4 krd   80 Dec 17 17:30 prebuilt/openssl/1.0.2-20131217
  124. # drwxr-xr-x 3 krd   60 Dec 17 17:30 prebuilt/openssl/1.0.2-20131217/include
  125. # drwxr-xr-x 2 krd 1.6K Dec 17 17:30 prebuilt/openssl/1.0.2-20131217/include/openssl
  126. # -rw-r--r-- 1 krd 5.4K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/aes.h
  127. # -rw-r--r-- 1 krd  52K Oct  1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/asn1.h
  128. # -rw-r--r-- 1 krd  19K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/asn1_mac.h
  129. # -rw-r--r-- 1 krd  30K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/asn1t.h
  130. # -rw-r--r-- 1 krd  33K Oct  7 16:00 prebuilt/openssl/1.0.2-20131217/include/openssl/bio.h
  131. # -rw-r--r-- 1 krd 5.1K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/blowfish.h
  132. # -rw-r--r-- 1 krd  35K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/bn.h
  133. # -rw-r--r-- 1 krd 4.6K Oct  1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/buffer.h
  134. # -rw-r--r-- 1 krd 4.9K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/camellia.h
  135. # -rw-r--r-- 1 krd 4.4K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/cast.h
  136. # -rw-r--r-- 1 krd 3.2K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/cmac.h
  137. # -rw-r--r-- 1 krd  22K Nov  9 20:00 prebuilt/openssl/1.0.2-20131217/include/openssl/cms.h
  138. # -rw-r--r-- 1 krd 2.0K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/comp.h
  139. # -rw-r--r-- 1 krd 9.7K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/conf.h
  140. # -rw-r--r-- 1 krd 4.0K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/conf_api.h
  141. # -rw-r--r-- 1 krd  24K Feb  6  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/crypto.h
  142. # -rw-r--r-- 1 krd  11K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/des.h
  143. # -rw-r--r-- 1 krd  18K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/des_old.h
  144. # -rw-r--r-- 1 krd  14K Oct  1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/dh.h
  145. # -rw-r--r-- 1 krd  12K Oct  1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/dsa.h
  146. # -rw-r--r-- 1 krd  18K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/dso.h
  147. # -rw-r--r-- 1 krd 8.0K Sep 18 21:00 prebuilt/openssl/1.0.2-20131217/include/openssl/dtls1.h
  148. # -rw-r--r-- 1 krd  11K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/e_os2.h
  149. # -rw-r--r-- 1 krd  540 Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ebcdic.h
  150. # -rw-r--r-- 1 krd  49K Oct  1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ec.h
  151. # -rw-r--r-- 1 krd 4.8K Oct  1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ecdh.h
  152. # -rw-r--r-- 1 krd  13K Sep 18 21:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ecdsa.h
  153. # -rw-r--r-- 1 krd  40K Dec  2 04:00 prebuilt/openssl/1.0.2-20131217/include/openssl/engine.h
  154. # -rw-r--r-- 1 krd  16K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/err.h
  155. # -rw-r--r-- 1 krd  53K Nov 15 02:00 prebuilt/openssl/1.0.2-20131217/include/openssl/evp.h
  156. # -rw-r--r-- 1 krd 4.4K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/hmac.h
  157. # -rw-r--r-- 1 krd 4.4K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/idea.h
  158. # -rw-r--r-- 1 krd 7.5K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/krb5_asn.h
  159. # -rw-r--r-- 1 krd 6.0K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/kssl.h
  160. # -rw-r--r-- 1 krd 8.9K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/lhash.h
  161. # -rw-r--r-- 1 krd 4.6K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/md4.h
  162. # -rw-r--r-- 1 krd 4.6K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/md5.h
  163. # -rw-r--r-- 1 krd 3.9K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/mdc2.h
  164. # -rw-r--r-- 1 krd 5.8K Oct  1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/modes.h
  165. # -rw-r--r-- 1 krd 138K Oct  1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/obj_mac.h
  166. # -rw-r--r-- 1 krd  36K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/objects.h
  167. # -rw-r--r-- 1 krd  25K Oct  7 16:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ocsp.h
  168. # -rw-r--r-- 1 krd 6.8K Dec 17 17:30 prebuilt/openssl/1.0.2-20131217/include/openssl/opensslconf.h
  169. # -rw-r--r-- 1 krd 3.7K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/opensslv.h
  170. # -rw-r--r-- 1 krd 7.3K Oct  1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ossl_typ.h
  171. # -rw-r--r-- 1 krd  22K Sep 10 21:00 prebuilt/openssl/1.0.2-20131217/include/openssl/pem.h
  172. # -rw-r--r-- 1 krd 2.8K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/pem2.h
  173. # -rw-r--r-- 1 krd  13K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/pkcs12.h
  174. # -rw-r--r-- 1 krd  18K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/pkcs7.h
  175. # -rw-r--r-- 1 krd 3.5K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/pqueue.h
  176. # -rw-r--r-- 1 krd 5.5K Sep 22 22:00 prebuilt/openssl/1.0.2-20131217/include/openssl/rand.h
  177. # -rw-r--r-- 1 krd 4.4K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/rc2.h
  178. # -rw-r--r-- 1 krd 3.8K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/rc4.h
  179. # -rw-r--r-- 1 krd 4.3K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ripemd.h
  180. # -rw-r--r-- 1 krd  25K Oct  1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/rsa.h
  181. # -rw-r--r-- 1 krd 182K Oct  1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/safestack.h
  182. # -rw-r--r-- 1 krd 5.6K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/seed.h
  183. # -rw-r--r-- 1 krd 7.5K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/sha.h
  184. # -rw-r--r-- 1 krd 5.3K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/srp.h
  185. # -rw-r--r-- 1 krd 6.5K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/srtp.h
  186. # -rw-r--r-- 1 krd 120K Dec 13 21:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ssl.h
  187. # -rw-r--r-- 1 krd  11K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ssl2.h
  188. # -rw-r--r-- 1 krd 3.7K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ssl23.h
  189. # -rw-r--r-- 1 krd  29K Oct  6 01:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ssl3.h
  190. # -rw-r--r-- 1 krd 4.4K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/stack.h
  191. # -rw-r--r-- 1 krd  24K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/symhacks.h
  192. # -rw-r--r-- 1 krd  36K Oct  6 01:00 prebuilt/openssl/1.0.2-20131217/include/openssl/tls1.h
  193. # -rw-r--r-- 1 krd  31K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ts.h
  194. # -rw-r--r-- 1 krd 4.4K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/txt_db.h
  195. # -rw-r--r-- 1 krd  17K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ui.h
  196. # -rw-r--r-- 1 krd 3.4K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ui_compat.h
  197. # -rw-r--r-- 1 krd 1019 Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/whrlpool.h
  198. # -rw-r--r-- 1 krd  45K Jan 17  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/x509.h
  199. # -rw-r--r-- 1 krd  24K Dec 13 21:00 prebuilt/openssl/1.0.2-20131217/include/openssl/x509_vfy.h
  200. # -rw-r--r-- 1 krd  33K Jan 11  2013 prebuilt/openssl/1.0.2-20131217/include/openssl/x509v3.h
  201. # drwxr-xr-x 2 krd   80 Dec 17 17:32 prebuilt/openssl/1.0.2-20131217/lib
  202. # -rw-r--r-- 1 krd  15M Dec 17 17:32 prebuilt/openssl/1.0.2-20131217/lib/libcrypto.a
  203. # -rw-r--r-- 1 krd 3.4M Dec 17 17:31 prebuilt/openssl/1.0.2-20131217/lib/libssl.a
  204. # drwxr-xr-x 3 krd   60 Dec 17 17:30 prebuilt/zlib
  205. # drwxr-xr-x 4 krd   80 Dec 17 17:30 prebuilt/zlib/1.2.8-debian
  206. # drwxr-xr-x 2 krd  260 Dec 17 17:30 prebuilt/zlib/1.2.8-debian/include
  207. # -rw-r--r-- 1 krd  30K Apr 30  2012 prebuilt/zlib/1.2.8-debian/include/crc32.h
  208. # -rw-r--r-- 1 krd  13K Jun  2  2012 prebuilt/zlib/1.2.8-debian/include/deflate.h
  209. # -rw-r--r-- 1 krd 6.4K Apr 14  2013 prebuilt/zlib/1.2.8-debian/include/gzguts.h
  210. # -rw-r--r-- 1 krd  427 Apr 19  2010 prebuilt/zlib/1.2.8-debian/include/inffast.h
  211. # -rw-r--r-- 1 krd 6.2K Oct  6  2011 prebuilt/zlib/1.2.8-debian/include/inffixed.h
  212. # -rw-r--r-- 1 krd 6.3K Dec 26  2009 prebuilt/zlib/1.2.8-debian/include/inflate.h
  213. # -rw-r--r-- 1 krd 2.9K Apr 19  2010 prebuilt/zlib/1.2.8-debian/include/inftrees.h
  214. # -rw-r--r-- 1 krd 8.3K Apr 18  2010 prebuilt/zlib/1.2.8-debian/include/trees.h
  215. # -rw-r--r-- 1 krd  16K Dec 17 17:30 prebuilt/zlib/1.2.8-debian/include/zconf.h
  216. # -rw-r--r-- 1 krd  86K Apr 29  2013 prebuilt/zlib/1.2.8-debian/include/zlib.h
  217. # -rw-r--r-- 1 krd 6.7K Mar 25  2013 prebuilt/zlib/1.2.8-debian/include/zutil.h
  218. # drwxr-xr-x 2 krd   60 Dec 17 17:30 prebuilt/zlib/1.2.8-debian/lib
  219. # -rw-r--r-- 1 krd 472K Dec 17 17:30 prebuilt/zlib/1.2.8-debian/lib/libz.a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement