the_memo.sh 169 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475
  1. #!/bin/bash
  2. #TODO: Add in perl? Maybe?
  3. #TODO: Update deb build numbers as needed
  4. #TODO: Some bins (berkeleydb, readline libs) bitch about not being a vaild file descriptor when attempting to sign them. wtf
  5. MAINTAINER="Maintainer: Kevin Bradley <maintainer@nito.tv>"
  6. VERIFY="true"
  7. ARCH="arm64"
  8. PLATFORM="AppleTVOS"
  9. PLATFORM_LOWER="appletvos"
  10. MIN_VERSION="-mappletvos-version-min=9.0"
  11. CODESIGN_TOOL="jtool"
  12. CLANG_PATH="`xcrun -f clang`"
  13. CLANGPLUS_PATH="`xcrun -f clang++`"
  14. BUILD_ROOT="`pwd`"
  15. ROOT_PREFIX="usr"
  16. SKEL_PREFIX="$BUILD_ROOT/skel"
  17. PKG_NAME="" #The name of our current package being built
  18. PKG_VERSION="-1"
  19. WORKING_DIR="" #This stores the working directory under BUILD_ROOT
  20. BUILD_BASH="false"
  21. set -e
  22. # set trap to help debug any build errors
  23. trap "echo '** ERROR with build:'; pwd" INT TERM EXIT
  24. usage() {
  25. echo "usage: $0 [-c|--codesign-tool] [-b|--build-bash] [-i|--insecure] [-p|--platform] [-s|--sdk-path]"
  26. trap - INT TERM EXIT
  27. exit 0
  28. }
  29. while test $# -gt 0; do
  30. case "$1" in
  31. -h|--help)
  32. usage
  33. ;;
  34. -c|--codesign-tool)
  35. shift
  36. if test $# -gt 0; then
  37. CODESIGN_TOOL="$1"
  38. if [ ! "$CODESIGN_TOOL" == "ldid" ] && [ ! "$CODESIGN_TOOL" == "ldid2" ] && [ ! "$CODESIGN_TOOL" == "jtool" ]; then
  39. echo "Error: Invalid codesigning tool"
  40. trap - INT TERM EXIT
  41. exit 1
  42. fi
  43. else
  44. echo "Error: No codesigning tool given."
  45. echo " Try: ldid, jtool or ldid2"
  46. trap - INT TERM EXIT
  47. exit 1
  48. fi
  49. shift
  50. ;;
  51. -b|--build-bash)
  52. BUILD_BASH="true"
  53. shift
  54. ;;
  55. -i|--insecure|--no-verify)
  56. VERIFY="false"
  57. echo "Working without verifying packages..."
  58. echo "YOU BETTER KNOW WHAT YOU'RE DOING"
  59. sleep 2 #Give them a couple seconds to think about what they're about to do
  60. shift
  61. ;;
  62. -p|--platform)
  63. shift
  64. if test $# -gt 0; then
  65. PLATFORM="$1"
  66. else
  67. echo "No platform given."
  68. trap - INT TERM EXIT
  69. exit 1
  70. fi
  71. shift
  72. ;;
  73. -s|--sdk-path|--sdk)
  74. shift
  75. if test $# -gt 0; then
  76. SDK_PATH="$1"
  77. else
  78. echo "No platform given."
  79. trap - INT TERM EXIT
  80. exit 1
  81. fi
  82. shift
  83. ;;
  84. *)
  85. break
  86. ;;
  87. esac
  88. done
  89. #Check for required programs
  90. command -v cmake -j8 >/dev/null 2>&1 || { echo >&2 "Missing cmake.\nRun: brew install cmake" ; }
  91. command -v gtar >/dev/null 2>&1 || { echo >&2 "Missing gnutar.\nRun: brew install gnu-tar" ; }
  92. command -v dpkg >/dev/null 2>&1 || { echo >&2 "Missing dpkg.\nRun: brew install dpkg" ; }
  93. #jtool
  94. #command -v jtool >/dev/null 2>&1 || { }
  95. #brew
  96. #autoconf
  97. #docbook-xsl
  98. #One of the two is required
  99. command -v md5sum >/dev/null 2>&1 || { command -v md5 >/dev/null 2>&1 || { echo >&2 "Missing md5sum" ; } ; }
  100. if [ "$VERIFY" == "true" ]; then
  101. command -v gpg2 >/dev/null 2>&1 || { echo >&2 "Missing GPG. Cannot verify. Dying."; exit 127 ; }
  102. echo "Importing necessary PGP keys"
  103. gpg2 --recv-key 69184620 7C0135FB088AAF6C66C650B9BB5869F064EA74AB 702353E0F7E48EDB 7FD9FCCB000BEEEE A15B725964A95EE5 D8692123C4065DEA5E0F3AB5249B39D24F25E3B6 031EC2536E580D8EA286A9F22071B08A33BD3F06 9D5EAAF69013B842
  104. fi
  105. #Eventually we'll make -j8 this work for any platform
  106. #For now, this is just scaffolding for the future
  107. #When the time comes, there are several other places which have hardcoded appletvos in them
  108. if [ "$PLATFORM" == "AppleTVOS" ]; then
  109. #Defaults are good
  110. echo ""
  111. elif [ "$PLATFORM" == "WatchOS" ]; then
  112. #Untested
  113. PLATFORM_LOWER="watchos"
  114. MIN_VERSION="-mwatchos-version-min=3.0"
  115. ARCH="armv7k"
  116. else
  117. echo "Unsupported Platform."
  118. trap - INT TERM EXIT
  119. exit 127
  120. fi
  121. if [ -z "$SDK_PATH" ]; then
  122. if [ "$PLATFORM" == "AppleTVOS" ]; then
  123. SDK_PATH="`xcrun --sdk appletvos --show-sdk-path`"
  124. elif [ "$PLATFORM" == "WatchOS" ]; then
  125. SDK_PATH="`xcrun --sdk watchos --show-sdk-path`"
  126. fi
  127. elif [ ${SDK_PATH: -1} == "/" ]; then
  128. # Some of our sed's require SDK_PATH *not* end with /
  129. SDK_PATH="`echo $SDK_PATH | sed 's/\/$//g'`"
  130. fi
  131. #================
  132. #Helper Functions
  133. #----------------
  134. initDebStructure() {
  135. rm -rf deb
  136. mkdir -p deb/DEBIAN
  137. rm -rf deb-doc
  138. mkdir -p deb-doc/DEBIAN
  139. rm -rf deb-dev
  140. mkdir -p deb-dev/DEBIAN
  141. }
  142. prepSDK() {
  143. #Availability.h patches
  144. #grep -R "#define __TVOS_UNAVAILABLE " "$SDK_PATH/usr/include/Availability.h"
  145. #grep -R "#define __TVOS_PROHIBITED " "$SDK_PATH/usr/include/Availability.h"
  146. #sudo sed -i -- "s|#define __TVOS_UNAVAILABLE __OS_AVAILABILITY(tvos,unavailable)|#define __TVOS_UNAVAILABLE_NOTQUITE __OS_AVAILABILITY(tvos,unavailable)|" /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/Availability.h
  147. #sudo sed -i -- "s|#define __TVOS_PROHIBITED __OS_AVAILABILITY(tvos,unavailable)|#define __TVOS_PROHIBITED_NOTQUITE __OS_AVAILABILITY(tvos,unavailable)|" /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/Availability.h
  148. #Fix for ncurses
  149. if [ ! -e "$SDK_PATH/usr/include/sys/ttydev.h" ]; then
  150. echo "Missing <sys/ttydev.h>. Moving it in from MacOSX SDK (with sudo)"
  151. sudo cp "`xcrun --sdk macosx --show-sdk-path`/usr/include/sys/ttydev.h" "$SDK_PATH/usr/include/sys/ttydev.h"
  152. fi
  153. #I forget.. Readline perhaps?
  154. #IOKit
  155. #~/Library/Developer/Xcode/tvOS\ DeviceSupport
  156. #9.0 (13T396)
  157. #9.0.1 (13T402)
  158. #10.1 (14U593)
  159. #10.1.1 (14U712a)
  160. #10.2.1 (14W585a)
  161. #10.2.2 (14W756)
  162. #11.1 (15J582)
  163. #/Users/kevinbradley/Library/Developer/Xcode/tvOS\ DeviceSupport/11.1\ \(15J582\)/Symbols/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
  164. }
  165. # this needs to be modified to have the proper spacing, if the spacing is absolutely perfect you can't ever use jtool to change the entitlements without building from scratch
  166. createEntitlements() {
  167. if [ ! -e "$BUILD_ROOT/ent.plist" ]; then
  168. echo "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" >> "$BUILD_ROOT/ent.plist"
  169. echo "<plist version=\"1.0\">" >> "$BUILD_ROOT/ent.plist"
  170. echo "<dict>" >> "$BUILD_ROOT/ent.plist"
  171. echo " <key>platform-application</key>" >> "$BUILD_ROOT/ent.plist"
  172. echo " <true/>" >> "$BUILD_ROOT/ent.plist"
  173. echo " <key>com.apple.private.skip-library-validation</key>" >> "$BUILD_ROOT/ent.plist"
  174. echo " <true/>" >> "$BUILD_ROOT/ent.plist"
  175. echo "</dict>" >> "$BUILD_ROOT/ent.plist"
  176. echo "</plist>" >> "$BUILD_ROOT/ent.plist"
  177. fi
  178. }
  179. # for some reason the files signed this way don't run on tvOS 9 anymore
  180. codesign() {
  181. #local var=$(ldid -S "$1");
  182. if [ "$CODESIGN_TOOL" == "jtool" ]; then
  183. createEntitlements
  184. jtool --sign platform --ent "$BUILD_ROOT/ent.plist" "$1"
  185. sudo cp -X out.bin "$1"
  186. elif [ "$CODESIGN_TOOL" == "ldid" ]; then
  187. ldid -S "$1"
  188. elif [ "$CODESIGN_TOOL" == "ldid2" ]; then
  189. ldid2 -S "$1"
  190. fi
  191. }
  192. notifyProgress() {
  193. echo "$1"
  194. #say "$1"
  195. }
  196. createListFile() {
  197. if [ ! -d "$SKEL_PREFIX/var/lib/dpkg/info/" ]; then
  198. mkdir -p "$SKEL_PREFIX/var/lib/dpkg/info/"
  199. fi
  200. #md5 -r == md5sum
  201. MD5="md5sum"
  202. command -v md5sum >/dev/null 2>&1 || { MD5="md5 -r" ; }
  203. find "$BUILD_ROOT/$WORKING_DIR/deb" -type f -not -path "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/*" -exec $MD5 {} \; | awk '{ print $1 " " $2 }' | sed "s|$BUILD_ROOT/$WORKING_DIR/deb/||g" >> "$SKEL_PREFIX/var/lib/dpkg/info/$PKG_NAME.md5sums"
  204. find "$BUILD_ROOT/$WORKING_DIR/deb" -type f -not -path "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/*" | sed "s|$BUILD_ROOT/$WORKING_DIR/deb||g" >> "$SKEL_PREFIX/var/lib/dpkg/info/$PKG_NAME.list"
  205. FILES="$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/*"
  206. for f in $FILES; do
  207. file=${f##*/}
  208. if [ "$file" != "control" ]; then
  209. echo "Processing $file in $PKG_NAME..";
  210. cp "$f" "$SKEL_PREFIX/var/lib/dpkg/info/$PKG_NAME.$file"
  211. fi
  212. done
  213. }
  214. #warning: this will process ANY deb file you have in your $BUILD_ROOT
  215. createStatusFile() {
  216. cd "$BUILD_ROOT"
  217. rm -rf status
  218. rm -rf available
  219. for f in *.deb; do
  220. echo "Processing $f..";
  221. dpkg-deb -f "$f" >> status
  222. dpkg-deb -f "$f" >> available
  223. echo "Status: install ok installed" >> status
  224. echo "" >> status
  225. echo "" >> available
  226. done
  227. mv status "$SKEL_PREFIX/var/lib/dpkg/status"
  228. mv available "$SKEL_PREFIX/var/lib/dpkg/available"
  229. }
  230. checkPGPSig() {
  231. if [ "$VERIFY" == "true" ]; then
  232. SIGFILE="$1"
  233. FILE="$2"
  234. local VERIFY_TEST="`gpg --verify $SIGFILE $FILE 2>&1 | grep 'Good signature'`"
  235. if [ "$VERIFY_TEST" == "" ]; then
  236. echo "Failed to validate PGP signature for $FILE"
  237. trap - INT TERM EXIT
  238. exit 127
  239. fi
  240. echo "*** VALID SIGNATURE"
  241. fi
  242. }
  243. checkSHA256() {
  244. if [ "$VERIFY" == "true" ]; then
  245. FILE="$1"
  246. VALID_SHA="$2"
  247. VERIFY_TEST="`shasum -a 256 $FILE | cut -c 1-64`"
  248. if [ "$VERIFY_TEST" != "$VALID_SHA" ]; then
  249. echo "Failed to validate SHA256 signature for $FILE"
  250. trap - INT TERM EXIT
  251. exit 127
  252. fi
  253. echo "*** VALID SIGNATURE"
  254. fi
  255. }
  256. #=====================
  257. #OSGT10.1
  258. #---------------------
  259. #Download readline
  260. downloadReadline() {
  261. #http://gnu.askapache.com/readline/readline-7.0.tar.gz
  262. if [ ! -e readline-7.0.tar.gz ]; then
  263. echo "Downloading readline-7.0.tar.gz"
  264. curl -LO http://gnu.askapache.com/readline/readline-7.0.tar.gz
  265. curl -LO http://gnu.askapache.com/readline/readline-7.0.tar.gz.sig
  266. checkPGPSig readline-7.0.tar.gz.sig readline-7.0.tar.gz
  267. else
  268. echo "Using existing readline"
  269. fi
  270. rm -rf readline-7.0
  271. tar xzvf readline-7.0.tar.gz
  272. WORKING_DIR="readline-7.0"
  273. PKG_NAME="readline"
  274. PKG_VERSION="7.0-1"
  275. cd "$WORKING_DIR"
  276. }
  277. #readline
  278. #Notes:
  279. # Doesn't like to build with ncurses.a in any of its linker paths (read: rm -rf skel)
  280. buildReadline() {
  281. downloadReadline
  282. if [ "$ARCH" == "arm64" ]; then
  283. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=aarch64-apple-darwin
  284. else
  285. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=arm-apple-darwin
  286. fi
  287. #make
  288. make -j8 DESTDIR="$SKEL_PREFIX" install
  289. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libhistory.7.0.dylib"
  290. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libreadline.7.0.dylib"
  291. initDebStructure
  292. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  293. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libhistory.7.0.dylib"
  294. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libreadline.7.0.dylib"
  295. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  296. echo "Priority: required" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  297. echo "Section: Development" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  298. #echo "Installed-Size: 724" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  299. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  300. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  301. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  302. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  303. #echo "Depends: bash, sed" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  304. echo "Description: command-line history management" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  305. echo "Homepage: https://tiswww.cwru.edu/php/chet/readline/rltop.html" >> deb/DEBIAN/control
  306. #Build the doc deb
  307. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  308. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  309. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  310. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  311. #Build the dev deb
  312. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  313. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  314. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  315. rmdir "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin"
  316. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  317. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  318. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  319. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  320. dpkg -b deb
  321. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  322. dpkg -b deb-doc
  323. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  324. dpkg -b deb-dev
  325. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  326. createListFile
  327. cd "$BUILD_ROOT"
  328. }
  329. #Download ncurses
  330. downloadNcurses() {
  331. if [ ! -e ncurses-6.0.tar.gz ]; then
  332. echo "Downlading ncurses-6.0.tar.gz"
  333. curl -LO http://gnu.mirror.constant.com/ncurses/ncurses-6.0.tar.gz
  334. curl -LO http://gnu.mirror.constant.com/ncurses/ncurses-6.0.tar.gz.sig
  335. checkPGPSig ncurses-6.0.tar.gz.sig ncurses-6.0.tar.gz
  336. else
  337. echo "Using existing ncurses-6.0"
  338. fi
  339. rm -rf ncurses-6.0
  340. tar xzvf ncurses-6.0.tar.gz
  341. WORKING_DIR="ncurses-6.0"
  342. PKG_NAME="ncurses"
  343. PKG_VERSION="6.0-1"
  344. cd "$WORKING_DIR"
  345. }
  346. patchNcurses() {
  347. if [ "$PLATFORM" == "AppleTVOS" ]; then
  348. if [ "$PKG_VERSION" == "6.0-1" ]; then
  349. # LEFT ERROR ON environ)' no ;
  350. # For some reason, building never fails on the error...
  351. # But still, tput is in /usr/bin... so.... ??
  352. cat progs/tput.c | head -n 55 > tput.patched.c
  353. echo "#include <stdint.h>" >> tput.patched.c
  354. echo "#include <stdio.h>" >> tput.patched.c
  355. echo "#include <stdlib.h>" >> tput.patched.c
  356. echo "#include <spawn.h>" >> tput.patched.c
  357. echo "#include <sys/wait.h>" >> tput.patched.c
  358. echo "" >> tput.patched.c
  359. echo "extern char **environ;" >> tput.patched.c
  360. echo "" >> tput.patched.c
  361. cat progs/tput.c | tail -n 350 | head -n 50 >> tput.patched.c
  362. echo "int RunCmd(const char *cmd) {" >> tput.patched.c
  363. echo " pid_t pid;" >> tput.patched.c
  364. echo ' char *argv[] = {"sh", "-c", (char*)cmd, NULL};' >> tput.patched.c
  365. echo ' int status;' >> tput.patched.c
  366. echo ' status = posix_spawn(&pid, "/bin/sh", NULL, NULL, argv, environ)' >> tput.patched.c
  367. echo ' if (status == 0) {' >> tput.patched.c
  368. echo ' if (waitpid(pid, &status, 0) != -1) {' >> tput.patched.c
  369. echo ' printf("Child exted in ATV Patched RunCmd with status %i\n", status);' >> tput.patched.c
  370. echo ' } else {' >> tput.patched.c
  371. echo ' perror("waitpid");' >> tput.patched.c
  372. echo ' }' >> tput.patched.c
  373. echo ' } else {' >> tput.patched.c
  374. echo ' printf("posix_spawn: %s\n", strerror(status));' >> tput.patched.c
  375. echo ' }' >> tput.patched.c
  376. echo ' return status;' >> tput.patched.c
  377. echo '}' >> tput.patched.c
  378. echo "" >> tput.patched.c
  379. cat progs/tput.c | tail -n 301 | sed 's/system(init_prog)/RunCmd(init_prog)/g' >> tput.patched.c
  380. cp tput.patched.c progs/tput.c
  381. fi
  382. fi
  383. }
  384. #ncurses
  385. #Notes:
  386. # Needs DESTDIR in make -j8 to not attempt to build test files (which fail to link)
  387. # May need the make clean in between to keep out artifacts from the old DESTDIR
  388. buildNcurses() {
  389. downloadNcurses
  390. if [ "$ARCH" == "arm64" ]; then
  391. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=aarch64-apple-darwin
  392. else
  393. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=arm-apple-darwin
  394. fi
  395. make -j8 DESTDIR="$SKEL_PREFIX/" install
  396. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/clear"
  397. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/infocmp"
  398. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tabs"
  399. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tic"
  400. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/toe"
  401. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tput"
  402. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tset"
  403. make clean
  404. initDebStructure
  405. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  406. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/clear"
  407. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/infocmp"
  408. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/tabs"
  409. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/tic"
  410. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/toe"
  411. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/tput"
  412. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/tset"
  413. echo "Package: $PKG_NAME" > "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  414. echo "Priority: required" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  415. echo "Section: System" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  416. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  417. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  418. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  419. echo "Description: feature-complete terminal library" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  420. echo "Name: New Curses" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  421. echo "Homepage: https://www.gnu.org/software/ncurses/ncurses.html" >> deb/DEBIAN/control
  422. #Build the doc deb
  423. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  424. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share"
  425. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/man" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/"
  426. #Build the dev deb
  427. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  428. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/bin"
  429. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  430. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/ncurses6-config" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/bin/"
  431. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  432. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  433. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  434. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  435. dpkg -b deb
  436. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  437. dpkg -b deb-doc
  438. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  439. dpkg -b deb-dev
  440. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  441. createListFile
  442. cd "$BUILD_ROOT"
  443. }
  444. #Download bash
  445. downloadBash() {
  446. #http://gnu.askapache.com/bash/bash-4.4.12.tar.gz
  447. if [ ! -e bash-4.4.12.tar.gz ]; then
  448. echo "Downloading bash-4.4.12.tar.gz"
  449. curl -LO http://gnu.askapache.com/bash/bash-4.4.12.tar.gz
  450. curl -LO http://gnu.askapache.com/bash/bash-4.4.12.tar.gz.sig
  451. checkPGPSig bash-4.4.12.tar.gz.sig bash-4.4.12.tar.gz
  452. else
  453. echo "Using existing bash"
  454. fi
  455. rm -rf bash-4.4.12
  456. tar xzvf bash-4.4.12.tar.gz
  457. WORKING_DIR="bash-4.4.12"
  458. PKG_NAME="bash"
  459. PKG_VERSION="4.4.12-1"
  460. cd "$WORKING_DIR"
  461. }
  462. patchBash() {
  463. if [ "$PLATFORM" == "AppleTVOS" ]; then
  464. sed -i -- 's|^#undef HAVE_SYS_SIGLIST$|#define HAVE_SYS_SIGLIST 1|' config.h.in
  465. fi
  466. }
  467. #bash
  468. #Notes:
  469. # Requires autoconf
  470. buildBash() {
  471. downloadBash
  472. patchBash
  473. if [ "$ARCH" == "arm64" ]; then
  474. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=aarch64-apple-darwin --disable-nls --with-installed-readline --disable-largefile bash_cv_dev_fd=absent bash_cv_sys_named_pipes=present bash_cv_job_control_missing=present bash_cv_func_sigsetjmp=present bash_cv_func_ctype_nonascii=no bash_cv_must_reinstall_sighandlers=no bash_cv_func_strcoll_broken=yes ac_cv_c_stack_direction=-1 ac_cv_func_mmap_fixed_mapped=yes gt_cv_int_divbyzero_sigfpe=no ac_cv_func_setvbuf_reversed=no ac_cv_func_strcoll_works=yes ac_cv_func_working_mktime=yes ac_cv_type_getgroups=gid_t bash_cv_dup2_broken=no ac_cv_prog_cc_g=no ac_cv_rl_version=6.0
  475. else
  476. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=arm-apple-darwin --disable-nls --with-installed-readline --disable-largefile bash_cv_dev_fd=absent bash_cv_sys_named_pipes=present bash_cv_job_control_missing=present bash_cv_func_sigsetjmp=present bash_cv_func_ctype_nonascii=no bash_cv_must_reinstall_sighandlers=no bash_cv_func_strcoll_broken=yes ac_cv_c_stack_direction=-1 ac_cv_func_mmap_fixed_mapped=yes gt_cv_int_divbyzero_sigfpe=no ac_cv_func_setvbuf_reversed=no ac_cv_func_strcoll_works=yes ac_cv_func_working_mktime=yes ac_cv_type_getgroups=gid_t bash_cv_dup2_broken=no ac_cv_prog_cc_g=no ac_cv_rl_version=6.0
  477. fi
  478. #make
  479. make -j8 DESTDIR="$SKEL_PREFIX" install
  480. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bash"
  481. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/basename"
  482. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/dirname"
  483. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/finfo"
  484. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/head"
  485. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/id"
  486. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/ln"
  487. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/logname"
  488. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/mkdir"
  489. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/mypid"
  490. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/pathchk"
  491. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/print"
  492. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/printenv"
  493. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/push"
  494. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/realpath"
  495. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/rmdir"
  496. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/setpgid"
  497. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/sleep"
  498. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/strftime"
  499. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/sync"
  500. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/tee"
  501. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/truefalse"
  502. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/tty"
  503. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/uname"
  504. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/unlink"
  505. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/whoami"
  506. #Get rid of cross-compile artifacts
  507. sed -i -- "s|$SKEL_PREFIX||g" "$SKEL_PREFIX/$ROOT_PREFIX/bin/bashbug"
  508. sed -i -- "s|$SKEL_PREFIX||g" "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/Makefile.inc"
  509. sed -i -- "s|BUILD_DIR = $BUILD_ROOT/$WORKING_DIR|BUILD_DIR = /usr/src/usr.bin/$WORKING_DIR|g" "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/Makefile.inc"
  510. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/bashbug--"
  511. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/Makefile.inc--"
  512. initDebStructure
  513. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  514. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/bash"
  515. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/basename"
  516. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/dirname"
  517. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/finfo"
  518. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/head"
  519. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/id"
  520. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/ln"
  521. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/logname"
  522. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/mkdir"
  523. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/mypid"
  524. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/pathchk"
  525. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/print"
  526. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/printenv"
  527. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/push"
  528. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/realpath"
  529. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/rmdir"
  530. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/setpgid"
  531. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/sleep"
  532. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/strftime"
  533. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/sync"
  534. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/tee"
  535. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/truefalse"
  536. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/tty"
  537. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/uname"
  538. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/unlink"
  539. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/whoami"
  540. #Get rid of cross-compile artifacts
  541. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/bashbug"
  542. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/Makefile.inc"
  543. sed -i -- "s|BUILD_DIR = $BUILD_ROOT/$WORKING_DIR|BUILD_DIR = /usr/src/usr.bin/$WORKING_DIR|g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/Makefile.inc"
  544. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/bashbug--"
  545. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/bash/Makefile.inc--"
  546. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  547. echo "Priority: required" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  548. echo "Section: Terminal_Support" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  549. #echo "Installed-Size: 724" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  550. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  551. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  552. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  553. if [ "$PLATFORM" == "AppleTVOS" ]; then
  554. echo "Pre-Depends: dpkg (>= 1.14.25-8), cy+model.appletv" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  555. echo "Depends: grep, readline (>= 6.0-7), sed, firmware (>= 10.2.2)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  556. else
  557. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  558. echo "Depends: grep, readline (>= 6.0-7), sed" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  559. fi
  560. echo "Description: the best shell ever written by Brian Fox" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  561. echo "Name: Bourne-Again SHell" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  562. echo "Homepage: http://www.gnu.org/software/bash/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  563. #Build the doc deb
  564. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  565. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  566. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  567. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  568. #Build the dev deb
  569. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  570. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  571. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  572. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/pkgconfig" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  573. #FIXME: Make a $PKG_NAME-staticlibs.deb
  574. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  575. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  576. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  577. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  578. dpkg -b deb
  579. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  580. dpkg -b deb-doc
  581. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  582. dpkg -b deb-dev
  583. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  584. createListFile
  585. cd "$BUILD_ROOT"
  586. }
  587. # DONT USE UNLESS YOU ARE ON 11+; OVERWRITE BASH (or any other apple-signed file, for that matter), LEAD TO BRICK
  588. # 10.2 and up
  589. buildBashAndFriends() {
  590. notifyProgress "Building readline"
  591. buildReadline
  592. notifyProgress "Building ncurses"
  593. buildNcurses
  594. notifyProgress "Building bash"
  595. buildBash
  596. }
  597. #=====================
  598. #Basic Utils
  599. #---------------------
  600. #Download sed
  601. downloadSed() {
  602. if [ ! -e sed-4.4.tar.xz ]; then
  603. echo "Downloading sed-4.4.tar.xz"
  604. curl -LO https://ftp.gnu.org/gnu/sed/sed-4.4.tar.xz
  605. curl -LO https://ftp.gnu.org/gnu/sed/sed-4.4.tar.xz.sig
  606. checkPGPSig sed-4.4.tar.xz.sig sed-4.4.tar.xz
  607. else
  608. echo "Using existing sed"
  609. fi
  610. rm -rf sed-4.4/
  611. tar xJvf sed-4.4.tar.xz
  612. WORKING_DIR="sed-4.4"
  613. PKG_NAME="sed"
  614. PKG_VERSION="4.4-1"
  615. cd "$WORKING_DIR"
  616. }
  617. #sed
  618. buildSed() {
  619. downloadSed
  620. if [ "$ARCH" == "arm64" ]; then
  621. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=aarch64-apple-darwin
  622. else
  623. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=arm-apple-darwin
  624. fi
  625. make -j8 DESTDIR="$SKEL_PREFIX/" install
  626. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sed"
  627. initDebStructure
  628. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb/" install
  629. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sed"
  630. echo "Package: $PKG_NAME" > "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  631. echo "Priority: important" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  632. echo "Section: Utilities" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  633. #echo "Installed-Size: 396" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  634. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  635. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  636. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  637. echo "Description: edits streams of text using patterns" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  638. echo "Homepage: http://www.gnu.org/software/sed/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  639. #Build the doc deb
  640. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  641. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  642. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  643. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  644. #Build the dev deb
  645. #No files
  646. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  647. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  648. dpkg -b deb
  649. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  650. dpkg -b deb-doc
  651. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  652. createListFile
  653. cd "$BUILD_ROOT"
  654. }
  655. #Download grep
  656. downloadGrep() {
  657. if [ ! -e grep-3.0.tar.xz ]; then
  658. echo "Downloading grep-3.0.tar.xz"
  659. curl -LO https://ftp.gnu.org/gnu/grep/grep-3.0.tar.xz
  660. curl -LO https://ftp.gnu.org/gnu/grep/grep-3.0.tar.xz.sig
  661. checkPGPSig grep-3.0.tar.xz.sig grep-3.0.tar.xz
  662. else
  663. echo "Using existing grep"
  664. fi
  665. rm -rf grep-3.0/
  666. tar xJvf grep-3.0.tar.xz
  667. WORKING_DIR="grep-3.0"
  668. PKG_NAME="grep"
  669. PKG_VERSION="3.0-1"
  670. cd "$WORKING_DIR"
  671. }
  672. #grep
  673. buildGrep() {
  674. downloadGrep
  675. if [ "$ARCH" == "arm64" ]; then
  676. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=aarch64-apple-darwin --without-libiconv-prefix
  677. else
  678. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=arm-apple-darwin --without-libiconv-prefix
  679. fi
  680. #make
  681. make -j8 DESTDIR="$SKEL_PREFIX" install
  682. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/grep"
  683. initDebStructure
  684. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  685. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/grep"
  686. echo "Package: $PKG_NAME" > "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  687. echo "Priority: important" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  688. echo "Section: Utilities" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  689. #echo "Installed-Size: 396" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  690. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  691. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  692. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  693. echo "Description: searches files for regular expressions" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  694. echo "Homepage: http://www.gnu.org/software/grep/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  695. #Build the doc deb
  696. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  697. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  698. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  699. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  700. #Build the dev deb
  701. #No files
  702. #rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/info"
  703. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  704. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  705. dpkg -b deb
  706. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  707. dpkg -b deb-doc
  708. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  709. createListFile
  710. cd "$BUILD_ROOT"
  711. }
  712. #Download coreutils
  713. downloadCoreutils() {
  714. if [ ! -e coreutils-8.9.tar.xz ]; then
  715. echo "Downloading coreutils-8.9.tar.xz"
  716. curl -LO http://gnu.mirror.constant.com/coreutils/coreutils-8.9.tar.xz
  717. curl -LO http://gnu.mirror.constant.com/coreutils/coreutils-8.9.tar.xz.sig
  718. checkPGPSig coreutils-8.9.tar.xz.sig coreutils-8.9.tar.xz
  719. else
  720. echo "Using existing coreutils"
  721. fi
  722. rm -rf coreutils-8.9
  723. tar xJvf coreutils-8.9.tar.xz
  724. WORKING_DIR="coreutils-8.9"
  725. PKG_NAME="coreutils"
  726. PKG_VERSION="8.9-1"
  727. cd "$WORKING_DIR"
  728. }
  729. patchCoreutils() {
  730. if [ "$PLATFORM" == "AppleTVOS" ]; then
  731. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' lib/config.hin
  732. sed -i -- 's|#undef HAVE_CLOCK_SETTIME||' lib/config.hin
  733. sed -i -- 's|#undef HAVE_FDATASYNC||' lib/config.hin
  734. sed -i -- 's|# define __stpncpy stpncpy||' lib/stpncpy.c
  735. if [ ! -d "$SKEL_PREFIX/$ROOT_PREFIX/include" ]; then
  736. mkdir -p "$SKEL_PREFIX/$ROOT_PREFIX/include"
  737. fi
  738. if [ ! -e "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h" ]; then
  739. echo "#include <sys/cdefs.h>" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  740. echo "" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  741. echo "__BEGIN_DECLS" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  742. echo "extern char ***_NSGetArgv(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  743. echo "extern int *_NSGetArgc(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  744. echo "extern char ***_NSGetEnviron(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  745. echo "extern char **_NSGetProgname(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  746. echo "extern struct mach_header *_NSGetMachExecuteHeader(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  747. echo "__END_DECLS" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  748. fi
  749. fi
  750. }
  751. #coreutils
  752. buildCoreutils() {
  753. downloadCoreutils
  754. patchCoreutils
  755. # Only builds with arm-apple-darwin, not aarch64
  756. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=arm-apple-darwin
  757. #make
  758. make -j8 DESTDIR="$SKEL_PREFIX" install
  759. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/["
  760. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/base64"
  761. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/basename"
  762. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cat"
  763. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chcon"
  764. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chgrp"
  765. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chmod"
  766. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chown"
  767. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chroot"
  768. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cksum"
  769. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/comm"
  770. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cp"
  771. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/csplit"
  772. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cut"
  773. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/date"
  774. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dd"
  775. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/df"
  776. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dir"
  777. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dircolors"
  778. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dirname"
  779. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/du"
  780. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/echo"
  781. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/env"
  782. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/expand"
  783. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/expr"
  784. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/factor"
  785. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/false"
  786. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/fmt"
  787. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/fold"
  788. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/groups"
  789. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/head"
  790. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/hostid"
  791. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/id"
  792. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/install"
  793. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/join"
  794. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/kill"
  795. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/link"
  796. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/ln"
  797. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/logname"
  798. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/ls"
  799. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/md5sum"
  800. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mkdir"
  801. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mkfifo"
  802. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mknod"
  803. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mktemp"
  804. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mv"
  805. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nice"
  806. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nl"
  807. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nohup"
  808. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nproc"
  809. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/od"
  810. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/paste"
  811. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pathchk"
  812. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pinky"
  813. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pr"
  814. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/printenv"
  815. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/printf"
  816. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/ptx"
  817. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pwd"
  818. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/readlink"
  819. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/rm"
  820. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/rmdir"
  821. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/runcon"
  822. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/seq"
  823. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha1sum"
  824. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha224sum"
  825. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha256sum"
  826. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha384sum"
  827. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha512sum"
  828. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/shred"
  829. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/shuf"
  830. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sleep"
  831. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sort"
  832. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/split"
  833. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/stat"
  834. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/stty"
  835. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sum"
  836. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sync"
  837. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tac"
  838. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tail"
  839. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tee"
  840. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/test"
  841. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/timeout"
  842. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/touch"
  843. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tr"
  844. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/true"
  845. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/truncate"
  846. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tsort"
  847. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tty"
  848. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/uname"
  849. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/unexpand"
  850. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/uniq"
  851. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/unlink"
  852. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/uptime"
  853. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/users"
  854. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/vdir"
  855. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/wc"
  856. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/who"
  857. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/whoami"
  858. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/yes"
  859. initDebStructure
  860. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  861. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/["
  862. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/base64"
  863. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/basename"
  864. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/cat"
  865. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/chcon"
  866. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/chgrp"
  867. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/chmod"
  868. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/chown"
  869. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/chroot"
  870. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/cksum"
  871. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/comm"
  872. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/cp"
  873. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/csplit"
  874. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/cut"
  875. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/date"
  876. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/dd"
  877. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/df"
  878. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/dir"
  879. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/dircolors"
  880. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/dirname"
  881. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/du"
  882. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/echo"
  883. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/env"
  884. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/expand"
  885. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/expr"
  886. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/factor"
  887. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/false"
  888. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/fmt"
  889. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/fold"
  890. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/groups"
  891. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/head"
  892. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/hostid"
  893. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/id"
  894. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/install"
  895. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/join"
  896. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/kill"
  897. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/link"
  898. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/ln"
  899. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/logname"
  900. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/ls"
  901. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/md5sum"
  902. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/mkdir"
  903. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/mkfifo"
  904. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/mknod"
  905. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/mktemp"
  906. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/mv"
  907. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/nice"
  908. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/nl"
  909. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/nohup"
  910. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/nproc"
  911. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/od"
  912. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/paste"
  913. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/pathchk"
  914. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/pinky"
  915. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/pr"
  916. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/printenv"
  917. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/printf"
  918. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/ptx"
  919. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/pwd"
  920. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/readlink"
  921. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/rm"
  922. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/rmdir"
  923. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/runcon"
  924. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/seq"
  925. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sha1sum"
  926. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sha224sum"
  927. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sha256sum"
  928. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sha384sum"
  929. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sha512sum"
  930. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/shred"
  931. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/shuf"
  932. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sleep"
  933. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sort"
  934. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/split"
  935. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/stat"
  936. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/stty"
  937. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sum"
  938. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sync"
  939. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/tac"
  940. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/tail"
  941. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/tee"
  942. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/test"
  943. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/timeout"
  944. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/touch"
  945. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/tr"
  946. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/true"
  947. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/truncate"
  948. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/tsort"
  949. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/tty"
  950. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/uname"
  951. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/unexpand"
  952. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/uniq"
  953. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/unlink"
  954. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/uptime"
  955. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/users"
  956. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/vdir"
  957. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/wc"
  958. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/who"
  959. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/whoami"
  960. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/yes"
  961. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  962. echo "Priority: standard" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  963. echo "Section: Utilities" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  964. echo "Provides: md5sum, sha1sum" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  965. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  966. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  967. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  968. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  969. echo "Depends: grep, sed" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  970. echo "Description: core set of Unix shell utilities from GNU" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  971. echo "Name: Core Utilities" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  972. echo "Homepage: http://www.gnu.org/software/coreutils/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  973. #Build the doc deb
  974. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  975. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  976. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  977. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  978. #Build the dev deb
  979. #No files
  980. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  981. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib"
  982. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  983. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  984. dpkg -b deb
  985. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  986. dpkg -b deb-doc
  987. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  988. createListFile
  989. cd "$BUILD_ROOT"
  990. }
  991. #Download findutils
  992. downloadFindUtils() {
  993. if [ ! -e findutils-4.6.0.tar.gz ]; then
  994. echo "Downloading findutils-4.6.0.tar.gz "
  995. curl -LO http://mirror.keystealth.org/gnu/findutils/findutils-4.6.0.tar.gz
  996. curl -LO http://mirror.keystealth.org/gnu/findutils/findutils-4.6.0.tar.gz.sig
  997. # NOT WORKING FOR SOME REASON, we have the signature but it still says theres no public sig, really weird
  998. #checkPGPSig findutils-4.6.0.tar.gz.sig findutils-4.6.0.tar.gz
  999. checkSHA256 findutils-4.6.0.tar.gz ded4c9f73731cd48fec3b6bdaccce896473b6d8e337e9612e16cf1431bb1169d
  1000. else
  1001. echo "Using existing findutils"
  1002. fi
  1003. rm -rf findutils-4.6.0
  1004. tar xzvf findutils-4.6.0.tar.gz
  1005. WORKING_DIR="findutils-4.6.0"
  1006. PKG_NAME="findutils"
  1007. PKG_VERSION="4.6.0-1"
  1008. cd "$WORKING_DIR"
  1009. }
  1010. #findutils
  1011. buildFindUtils() {
  1012. downloadFindUtils
  1013. if [ "$ARCH" == "arm64" ]; then
  1014. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=aarch64-apple-darwin
  1015. else
  1016. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=arm-apple-darwin
  1017. fi
  1018. make -j8 DESTDIR="$SKEL_PREFIX" install
  1019. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/find"
  1020. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/locate"
  1021. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/xargs"
  1022. initDebStructure
  1023. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  1024. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1025. echo "Priority: important" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1026. echo "Section: Utilities" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1027. #echo "Installed-Size: 724" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1028. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1029. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1030. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1031. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1032. #echo "Depends: bash, sed" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1033. echo "Description: indexes and searches filesystems" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1034. echo "Name: Find Utilities" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1035. echo "Homepage: https://www.gnu.org/software/findutils/" >> deb/DEBIAN/control
  1036. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/find"
  1037. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/locate"
  1038. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/xargs"
  1039. rmdir "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/var"
  1040. #Build the doc deb
  1041. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  1042. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1043. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  1044. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  1045. #Build the dev deb
  1046. #No files
  1047. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  1048. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1049. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1050. dpkg -b deb
  1051. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1052. dpkg -b deb-doc
  1053. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1054. createListFile
  1055. cd "$BUILD_ROOT"
  1056. }
  1057. #Download diffutils
  1058. downloadDiffUtils() {
  1059. if [ ! -e diffutils-3.6.tar.xz ]; then
  1060. echo "Downloading diffutils-3.6.tar.xz"
  1061. curl -LO http://ftp.gnu.org/gnu/diffutils/diffutils-3.6.tar.xz
  1062. curl -LO http://ftp.gnu.org/gnu/diffutils/diffutils-3.6.tar.xz.sig
  1063. checkPGPSig diffutils-3.6.tar.xz.sig diffutils-3.6.tar.xz
  1064. else
  1065. echo "Using existing diffutils"
  1066. fi
  1067. rm -rf diffutils-3.6
  1068. tar xJvf diffutils-3.6.tar.xz
  1069. WORKING_DIR="diffutils-3.6"
  1070. PKG_NAME="diffutils"
  1071. PKG_VERSION="3.6-1"
  1072. cd "$WORKING_DIR"
  1073. }
  1074. #diffutils
  1075. buildDiffUtils() {
  1076. downloadDiffUtils
  1077. if [ "$ARCH" == "arm64" ]; then
  1078. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=aarch64-apple-darwin
  1079. else
  1080. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=arm-apple-darwin
  1081. fi
  1082. #make
  1083. make -j8 DESTDIR="$SKEL_PREFIX" install
  1084. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cmp"
  1085. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/diff"
  1086. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/diff3"
  1087. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sdiff"
  1088. initDebStructure
  1089. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  1090. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/cmp"
  1091. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/diff"
  1092. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/diff3"
  1093. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sdiff"
  1094. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1095. echo "Priority: important" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1096. echo "Section: Development" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1097. #echo "Installed-Size: 724" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1098. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1099. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1100. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1101. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1102. #echo "Depends: bash, sed" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1103. echo "Description: compare two files for differences" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1104. echo "Name: Diff Utilities" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1105. echo "Homepage: http://www.gnu.org/software/diffutils/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1106. #Build the doc deb
  1107. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  1108. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1109. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  1110. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  1111. #Build the dev deb
  1112. #No files for this
  1113. #FIXME
  1114. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  1115. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1116. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1117. dpkg -b deb
  1118. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1119. dpkg -b deb-doc
  1120. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1121. createListFile
  1122. cd "$BUILD_ROOT"
  1123. }
  1124. #Download darwintools
  1125. downloadDarwinTools() {
  1126. if [ ! -d DarwinToolsARM ]; then
  1127. echo "Fetching DarwinTools"
  1128. mkdir -p DarwinToolsARM
  1129. cd DarwinToolsARM
  1130. curl -LO https://opensource.apple.com/source/DarwinTools/DarwinTools-1/sw_vers.c
  1131. #Not built yet
  1132. curl -LO https://opensource.apple.com/source/launchd/launchd-842.92.1/support/launchctl.c
  1133. #sw_vers.c
  1134. checkSHA256 sw_vers.c 55aab510b465f7687b8ebe23f0e51926606fd5316da138778838b2dac3e7c7e0
  1135. else
  1136. echo "Using existing DarwinTools"
  1137. cd DarwinToolsARM
  1138. fi
  1139. WORKING_DIR="DarwinToolsARM"
  1140. PKG_NAME="darwintools"
  1141. PKG_VERSION="1.0-1"
  1142. }
  1143. patchDarwinTools() {
  1144. if [ "$PLATFORM" == "AppleTVOS" ]; then
  1145. sed -i -- 's|#include <CoreFoundation/CFPriv.h>|extern CFDictionaryRef _CFCopySystemVersionDictionary(void);\
  1146. extern CFDictionaryRef _CFCopyServerVersionDictionary(void);|' sw_vers.c
  1147. sed -i -- 's|_kCFSystemVersionProductNameKey|CFSTR(\"ProductName\")|g' sw_vers.c
  1148. sed -i -- 's|_kCFSystemVersionProductVersionKey|CFSTR(\"ProductVersion\")|g' sw_vers.c
  1149. sed -i -- 's|_kCFSystemVersionBuildVersionKey|CFSTR(\"ProductBuildVersion\")|g' sw_vers.c
  1150. fi
  1151. }
  1152. #darwintools
  1153. #Notes:
  1154. # This only builds a striped down version of the one on iOS
  1155. # If you're building for a non-appletv platform, you may need to fix things here.
  1156. buildDarwinTools() {
  1157. downloadDarwinTools
  1158. patchDarwinTools
  1159. "$CLANG_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -framework CoreFoundation "$MIN_VERSION" -o "sw_vers" sw_vers.c
  1160. codesign "$BUILD_ROOT/$WORKING_DIR/sw_vers"
  1161. cp sw_vers "$SKEL_PREFIX/$ROOT_PREFIX/bin/"
  1162. initDebStructure
  1163. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/"
  1164. cp sw_vers "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/"
  1165. echo "Package: $PKG_NAME" > "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1166. echo "Priority: required" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1167. echo "Section: Administration" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1168. echo "Maintainer: $MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1169. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1170. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1171. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1172. echo "Description: sw_vers" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1173. echo "Name: Darwin Tools" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1174. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete #Not that there are any...
  1175. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1176. dpkg -b deb
  1177. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1178. cd "$BUILD_ROOT"
  1179. }
  1180. #Download uikittools
  1181. downloadUIKitTools() {
  1182. if [ ! -d uikittools ]; then
  1183. echo "Fetching uikittools"
  1184. git clone git://git.saurik.com/uikittools.git
  1185. else
  1186. echo "Using existing uikittools"
  1187. fi
  1188. WORKING_DIR="uikittools"
  1189. PKG_NAME="uikittools"
  1190. PKG_VERSION="1.1.12-1"
  1191. cd "$WORKING_DIR"
  1192. git checkout tags/v1.1.12
  1193. }
  1194. #uikittools
  1195. #Notes:
  1196. # This only builds a striped down version of the one on iOS
  1197. # If you're building for a non-appletv platform, you may need to fix things here.
  1198. buildUIKitTools() {
  1199. downloadUIKitTools
  1200. "$CLANGPLUS_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -Os -Werror -framework CoreFoundation -framework Foundation "$MIN_VERSION" -o cfversion cfversion.mm
  1201. "$CLANGPLUS_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -Os -Werror -framework CoreFoundation -framework Foundation "$MIN_VERSION" -o gssc gssc.mm
  1202. "$CLANGPLUS_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -Os -Werror -framework CoreFoundation -framework Foundation -framework UIKit "$MIN_VERSION" -o uiduid uiduid.mm
  1203. codesign "$BUILD_ROOT/$WORKING_DIR/cfversion"
  1204. codesign "$BUILD_ROOT/$WORKING_DIR/gssc"
  1205. codesign "$BUILD_ROOT/$WORKING_DIR/uiduid"
  1206. cp gssc cfversion uiduid "$SKEL_PREFIX/$ROOT_PREFIX/bin/"
  1207. initDebStructure
  1208. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/"
  1209. cp gssc cfversion uiduid "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/"
  1210. echo "Package: $PKG_NAME" > "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1211. echo "Priority: required" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1212. echo "Section: Utilities" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1213. echo "Maintainer: $MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1214. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1215. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1216. echo "Description: UIKit/GraphicsServices command line access" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1217. echo "Name: UIKit Tools" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1218. echo "Author: Jay Freeman (saurik) <saurik@saurik.com>" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1219. echo "Depiction: http://cydia.saurik.com/info/uikittools/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1220. if [ "$PLATFORM" == "AppleTVOS" ]; then
  1221. echo "Pre-Depends: cy+model.appletv" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1222. echo "Depends: coreutils, firmware (>= 9.0)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1223. else
  1224. #FIXME: If you're building for some other platform, you should address this.
  1225. echo "Depends: coreutils" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1226. fi
  1227. echo "Tag: purpose::console, role::hacker" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1228. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete #Not that there are any...
  1229. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1230. dpkg -b deb
  1231. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1232. cd "$BUILD_ROOT"
  1233. }
  1234. buildBasicUtils() {
  1235. notifyProgress "Building sed"
  1236. buildSed
  1237. notifyProgress "Building grep"
  1238. buildGrep
  1239. notifyProgress "Building coreutils"
  1240. buildCoreutils
  1241. notifyProgress "Building findutils"
  1242. buildFindUtils
  1243. notifyProgress "Building diffutils"
  1244. buildDiffUtils
  1245. notifyProgress "Building DarwinTools"
  1246. buildDarwinTools
  1247. notifyProgress "Building UIKitTools"
  1248. buildUIKitTools
  1249. }
  1250. #=====================
  1251. #DPKG and Dependencies
  1252. #---------------------
  1253. #Download zlib
  1254. downloadZLib() {
  1255. #Download zlib
  1256. if [ ! -d zlib ]; then
  1257. echo "Downloading zlib git"
  1258. git clone https://github.com/madler/zlib.git
  1259. else
  1260. echo "Using existing zlib"
  1261. fi
  1262. WORKING_DIR="zlib"
  1263. PKG_NAME="zlib"
  1264. PKG_VERSION="1.2.11-1"
  1265. cd "$WORKING_DIR"
  1266. git checkout tags/v1.2.11
  1267. rm -rf build
  1268. mkdir build
  1269. cd build
  1270. WORKING_DIR="$WORKING_DIR/build"
  1271. }
  1272. #zlib
  1273. buildZLib() {
  1274. downloadZLib
  1275. cmake -j8 -DCMAKE_INSTALL_NAME_DIR="/$ROOT_PREFIX/lib" -DCMAKE_OSX_SYSROOT="$SDK_PATH/" -DCMAKE_C_FLAGS="-arch $ARCH" -DCMAKE_INSTALL_PREFIX="/$ROOT_PREFIX" ..
  1276. #make
  1277. make -j8 DESTDIR="$SKEL_PREFIX" install
  1278. initDebStructure
  1279. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb/" install
  1280. export COPYFILE_DISABLE
  1281. export COPY_EXTENDED_ATTRIBUTES_DISABLE
  1282. echo "Package: $PKG_NAME" > "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1283. echo "Priority: important" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1284. echo "Section: Archiving" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1285. #echo "Installed-Size: 396" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1286. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1287. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1288. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1289. echo "Description: Massively spiffy yet delicately unobtrusive compression library" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1290. echo "Name: zlib" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1291. echo "Homepage: http://zlib.net/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1292. #Build the doc deb
  1293. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  1294. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share"
  1295. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/man" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/"
  1296. #Build the dev deb
  1297. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  1298. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share"
  1299. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  1300. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/pkgconfig" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share/"
  1301. rmdir "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share"
  1302. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  1303. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1304. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  1305. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1306. dpkg -b deb
  1307. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1308. dpkg -b deb-doc
  1309. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1310. dpkg -b deb-dev
  1311. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1312. createListFile
  1313. cd "$BUILD_ROOT"
  1314. }
  1315. #Download xz
  1316. downloadXZ() {
  1317. if [ ! -e xz-5.2.3.tar.gz ]; then
  1318. echo "Downloading xz-5.2.3.tar.gz"
  1319. curl -LO http://tukaani.org/xz/xz-5.2.3.tar.gz
  1320. curl -LO http://tukaani.org/xz/xz-5.2.3.tar.gz.sig
  1321. checkPGPSig xz-5.2.3.tar.gz.sig xz-5.2.3.tar.gz
  1322. else
  1323. echo "Using xz-5.2.3.tar.gz"
  1324. fi
  1325. rm -rf xz-5.2.3
  1326. tar xzvf xz-5.2.3.tar.gz
  1327. WORKING_DIR="xz-5.2.3"
  1328. PKG_NAME="xz"
  1329. PKG_VERSION="5.2.3-1"
  1330. cd "$WORKING_DIR"
  1331. }
  1332. patchXZ() {
  1333. if [ "$PLATFORM" == "AppleTVOS" ]; then
  1334. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' config.h.in
  1335. fi
  1336. }
  1337. #xz
  1338. buildXZ() {
  1339. downloadXZ
  1340. patchXZ
  1341. if [ "$ARCH" == "arm64" ]; then
  1342. ./configure CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CXXFLAGS="$MIN_VERSION -isysroot $SDK_PATH -arch $ARCH" CFLAGS="$MIN_VERSION -isysroot $SDK_PATH -arch $ARCH" LIBS="$MIN_VERSION -isysroot $SDK_PATH -arch $ARCH" --prefix="/$ROOT_PREFIX" --host=aarch64-apple-darwin
  1343. else
  1344. ./configure CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CXXFLAGS="$MIN_VERSION -isysroot $SDK_PATH -arch $ARCH" CFLAGS="$MIN_VERSION -isysroot $SDK_PATH -arch $ARCH" LIBS="$MIN_VERSION -isysroot $SDK_PATH -arch $ARCH" --prefix="/$ROOT_PREFIX" --host=arm-apple-darwin
  1345. fi
  1346. make DESTDIR="$SKEL_PREFIX" install
  1347. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lzmadec"
  1348. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lzmainfo"
  1349. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/xz"
  1350. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/xzdec"
  1351. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/liblzma.5.dylib"
  1352. if [ ! -e "$SKEL_PREFIX/$ROOT_PREFIX/local/lib/liblzma.5.dylib" ]; then
  1353. mkdir -p "$SKEL_PREFIX/$ROOT_PREFIX/local/lib"
  1354. #cp "$SKEL_PREFIX/$ROOT_PREFIX/lib/liblzma.5.dylib" "$SKEL_PREFIX/$ROOT_PREFIX/local/lib/liblzma.5.dylib"
  1355. ln -s /usr/lib/liblzma.5.dylib "$SKEL_PREFIX/$ROOT_PREFIX/local/lib/liblzma.5.dylib"
  1356. fi
  1357. initDebStructure
  1358. make DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  1359. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/lzmadec"
  1360. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/lzmainfo"
  1361. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/xz"
  1362. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/xzdec"
  1363. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/liblzma.5.dylib"
  1364. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/local/lib"
  1365. ln -s /usr/lib/liblzma.5.dylib "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/local/lib/liblzma.5.dylib"
  1366. echo "Package: $PKG_NAME" > "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1367. echo "Priority: important" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1368. echo "Section: Archiving" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1369. #echo "Installed-Size: 396" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1370. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1371. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1372. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1373. echo "Depends: grep, sed" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1374. echo "Description: XZ Utils are the successor to LZMA Utils" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1375. echo "Name: XZ Utils" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1376. echo "Homepage: http://tukaani.org/xz/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1377. #Build the doc deb
  1378. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  1379. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1380. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  1381. #Build the dev deb
  1382. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  1383. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  1384. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  1385. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/pkgconfig" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  1386. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/liblzma.la" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  1387. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  1388. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1389. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  1390. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1391. dpkg -b deb
  1392. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1393. dpkg -b deb-doc
  1394. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1395. dpkg -b deb-dev
  1396. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1397. createListFile
  1398. cd "$BUILD_ROOT"
  1399. }
  1400. #Download bzip2
  1401. downloadBZip2() {
  1402. if [ ! -e bzip2-1.0.6.tar.gz ]; then
  1403. echo "Downloading bzip2-1.0.6.tar.gz"
  1404. curl -LO http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz
  1405. checkSHA256 bzip2-1.0.6.tar.gz a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd
  1406. else
  1407. echo "Using bzip2-1.0.6.tar.gz"
  1408. fi
  1409. rm -rf bzip2-1.0.6
  1410. tar xzvf bzip2-1.0.6.tar.gz
  1411. WORKING_DIR="bzip2-1.0.6"
  1412. PKG_NAME="bzip2"
  1413. PKG_VERSION="1.0.6-1"
  1414. cd "$WORKING_DIR"
  1415. }
  1416. patchBZip2() {
  1417. if [ "$PLATFORM" == "AppleTVOS" ]; then
  1418. #fix up our makefile...
  1419. sed -i -- 's|CC=gcc|CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang|' Makefile
  1420. sed -i -- 's|AR=ar|AR=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar|' Makefile
  1421. sed -i -- 's|RANLIB=ranlib|RANLIB=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib|' Makefile
  1422. sed -i -- "s|LDFLAGS=|LDFLAGS=$MIN_VERSION -isysroot \"$SDK_PATH\" -arch $ARCH|" Makefile
  1423. sed -i -- "s|CFLAGS=|CFLAGS=$MIN_VERSION -isysroot \"$SDK_PATH\" -arch $ARCH |" Makefile
  1424. sed -i -- 's|all:\(.*\) test$|all: \1|' Makefile
  1425. sed -i -- 's|ln -s -f \$(PREFIX)/bin/|ln -s -f |g' Makefile
  1426. fi
  1427. }
  1428. #bzip2
  1429. buildBZip2() {
  1430. downloadBZip2
  1431. patchBZip2
  1432. make -j8 install PREFIX="$SKEL_PREFIX/$ROOT_PREFIX"
  1433. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bunzip2"
  1434. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bzcat"
  1435. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bzip2"
  1436. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bzip2recover"
  1437. initDebStructure
  1438. make -j8 install PREFIX="$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1439. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/bunzip2"
  1440. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/bzcat"
  1441. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/bzip2"
  1442. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/bzip2recover"
  1443. export COPYFILE_DISABLE
  1444. export COPY_EXTENDED_ATTRIBUTES_DISABLE
  1445. echo "Package: $PKG_NAME" > "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1446. echo "Priority: important" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1447. echo "Section: Archiving" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1448. #echo "Installed-Size: 148" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1449. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1450. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1451. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1452. echo "Depends: grep, sed" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1453. echo "Description: compression that's slightly better than gzip" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1454. echo "Homepage: http://www.bzip.org/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1455. #Build the doc deb
  1456. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  1457. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1458. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/man" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  1459. #Build the dev deb
  1460. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  1461. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  1462. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  1463. #FIXME: Make a $PKG_NAME-staticlibs.deb
  1464. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  1465. rmdir "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib"
  1466. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1467. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  1468. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1469. dpkg -b deb
  1470. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1471. dpkg -b deb-doc
  1472. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1473. dpkg -b deb-dev
  1474. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1475. createListFile
  1476. cd "$BUILD_ROOT"
  1477. }
  1478. #Download lz4
  1479. downloadLZ4() {
  1480. if [ ! -e lz4-v1.7.5.tar.gz ]; then
  1481. #echo "Cloning lz4.git"
  1482. #git clone https://github.com/lz4/lz4.git
  1483. #Master = v1.7.5
  1484. curl -LO https://github.com/lz4/lz4/archive/v1.7.5.tar.gz
  1485. mv v1.7.5.tar.gz lz4-v1.7.5.tar.gz
  1486. checkSHA256 lz4-v1.7.5.tar.gz 0190cacd63022ccb86f44fa5041dc6c3804407ad61550ca21c382827319e7e7e
  1487. else
  1488. echo "Using existing lz4"
  1489. fi
  1490. rm -rf lz4-1.7.5/
  1491. tar xzvf lz4-v1.7.5.tar.gz
  1492. WORKING_DIR="lz4-1.7.5/contrib/cmake_unofficial/"
  1493. PKG_NAME="lz4"
  1494. PKG_VERSION="1.7.5-1"
  1495. cd "$WORKING_DIR"
  1496. rm -rf build
  1497. mkdir build
  1498. cd build
  1499. WORKING_DIR="$WORKING_DIR/build"
  1500. }
  1501. #lz4
  1502. buildLZ4() {
  1503. downloadLZ4
  1504. initDebStructure
  1505. cmake -j8 -DCMAKE_INSTALL_NAME_DIR="/$ROOT_PREFIX/lib" -DCMAKE_OSX_SYSROOT="$SDK_PATH/" -DCMAKE_C_FLAGS="-arch $ARCH" -DCMAKE_INSTALL_PREFIX="/$ROOT_PREFIX" ..
  1506. make -j8
  1507. make -j8 DESTDIR="$SKEL_PREFIX" install
  1508. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lz4"
  1509. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lz4c"
  1510. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/liblz4.1.7.5.dylib"
  1511. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb/" install
  1512. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/lz4"
  1513. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/lz4c"
  1514. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/liblz4.1.7.5.dylib"
  1515. export COPYFILE_DISABLE
  1516. export COPY_EXTENDED_ATTRIBUTES_DISABLE
  1517. echo "Package: $PKG_NAME" > "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1518. echo "Priority: important" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1519. echo "Section: Archiving" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1520. #echo "Installed-Size: 396" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1521. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1522. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1523. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1524. echo "Description: Extremely Fast Compression algorithm" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1525. echo "Name: lz4" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1526. echo "Homepage: http://www.lz4.org" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1527. #Build the doc deb
  1528. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  1529. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1530. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1531. #Build the dev deb
  1532. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  1533. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  1534. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  1535. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/pkgconfig" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  1536. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1537. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  1538. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1539. dpkg -b deb
  1540. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1541. dpkg -b deb-doc
  1542. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1543. dpkg -b deb-dev
  1544. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1545. createListFile
  1546. cd "$BUILD_ROOT"
  1547. }
  1548. #Download openssl
  1549. downloadOpenSSL() {
  1550. if [ ! -d openssl ]; then
  1551. git clone -b OpenSSL_1_1_0-stable https://github.com/openssl/openssl.git
  1552. else
  1553. echo "Using existing openssl repo"
  1554. fi
  1555. WORKING_DIR="openssl"
  1556. PKG_NAME="openssl"
  1557. PKG_VERSION="1.1.0-1"
  1558. cd "$WORKING_DIR"
  1559. }
  1560. patchOpenSSL() {
  1561. #if [ "$PLATFORM" == "AppleTVOS" ]; then
  1562. sed -i -- "s|-arch $ARCH -mios-version-min=7.0.0|-arch $ARCH $MIN_VERSION|" Configurations/10-main.conf
  1563. #fi
  1564. }
  1565. #openssl
  1566. buildOpenSSL() {
  1567. downloadOpenSSL
  1568. patchOpenSSL
  1569. export PLATFORM="$PLATFORM"
  1570. export BUILD_TOOLS="`xcode-select --print-path`"
  1571. export CC="clang -fembed-bitcode"
  1572. export CROSS_COMPILE="`xcode-select --print-path`/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
  1573. export CROSS_TOP="`xcode-select --print-path`/Platforms/$PLATFORM.platform/Developer"
  1574. export CROSS_SDK="`echo $SDK_PATH | sed 's/.*\///g'`"
  1575. #export PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:$PATH"
  1576. ./Configure ios64-cross no-shared no-dso no-hw no-engine --prefix="/$ROOT_PREFIX"
  1577. #make
  1578. make DESTDIR="$SKEL_PREFIX" install
  1579. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/openssl"
  1580. initDebStructure
  1581. make DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  1582. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/openssl"
  1583. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1584. echo "Priority: standard" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1585. echo "Section: Security" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1586. #echo "Installed-Size: 6164" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1587. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1588. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1589. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1590. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1591. echo "Description: SSL library and cryptographic tools" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1592. echo "Name: OpenSSL" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1593. echo "Homepage: https://www.openssl.org" >> deb/DEBIAN/control
  1594. #Build the doc deb
  1595. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  1596. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1597. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  1598. #Build the dev deb
  1599. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  1600. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  1601. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  1602. #mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/pkgconfig" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  1603. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  1604. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1605. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  1606. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1607. dpkg -b deb
  1608. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1609. dpkg -b deb-doc
  1610. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1611. dpkg -b deb-dev
  1612. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1613. createListFile
  1614. cd "$BUILD_ROOT"
  1615. }
  1616. #Download Curl
  1617. downloadCurl() {
  1618. if [ ! -e curl-7.50.1.tar.gz ]; then
  1619. echo "Downloading curl-7.50.1.tar.gz"
  1620. curl -LO https://curl.haxx.se/download/curl-7.50.1.tar.gz
  1621. checkSHA256 curl-7.50.1.tar.gz 3e392cf600822b817be82d9080b377fcbab70538d5a8bf525a1cd66e157b99ea
  1622. else
  1623. echo "Using curl-7.50.1.tar.gz"
  1624. fi
  1625. rm -rf curl-7.50.1
  1626. echo "Unpacking curl"
  1627. tar xzvf "curl-7.50.1.tar.gz"
  1628. WORKING_DIR="curl-7.50.1"
  1629. PKG_NAME="curl"
  1630. PKG_VERSION="7.50.1-1"
  1631. cd "$WORKING_DIR"
  1632. }
  1633. patchCurl() {
  1634. if [ "$PLATFORM" == "AppleTVOS" ]; then
  1635. #(Forcibly) Remove that dirty clock_gettime
  1636. #TODO: Determine if this is the best way
  1637. sed -i -- 's|#undef HAVE_CLOCK_GETTIME_MONOTONIC||' lib/curl_config.h.in
  1638. fi
  1639. }
  1640. #curl
  1641. buildCurl() {
  1642. downloadCurl
  1643. patchCurl
  1644. export PLATFORM="$PLATFORM"
  1645. export BUILD_TOOLS="`xcode-select --print-path`"
  1646. export CC="clang"
  1647. export CROSS_COMPILE="`xcode-select --print-path`/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
  1648. export CROSS_TOP="`xcode-select --print-path`/Platforms/$PLATFORM.platform/Developer"
  1649. export CROSS_SDK="`echo $SDK_PATH | sed 's/.*\///g'`"
  1650. export CFLAGS="-arch $ARCH -pipe -Os -gdwarf-2 -isysroot $SDK_PATH $MIN_VERSION -fembed-bitcode -I$SKEL_PREFIX/$ROOT_PREFIX/include/ "
  1651. export LDFLAGS="-arch $ARCH -isysroot $SDK_PATH -L${SKEL_PREFIX}/$ROOT_PREFIX/lib"
  1652. ./configure --prefix="/$ROOT_PREFIX" --host="arm-apple-darwin" --with-zlib="$SKEL_PREFIX/$ROOT_PREFIX/lib" -with-random=/dev/urandom --disable-ntlm-wb --with-ssl="$SKEL_PREFIX/$ROOT_PREFIX/lib"
  1653. make -j8 DESTDIR="$SKEL_PREFIX" install
  1654. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/curl"
  1655. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libcurl.4.dylib"
  1656. make clean
  1657. initDebStructure
  1658. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb/" install
  1659. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/curl"
  1660. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libcurl.4.dylib"
  1661. #Get rid of cross-compile artifacts
  1662. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libcurl.la"
  1663. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/curl-config"
  1664. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libcurl.la--"
  1665. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/curl-config--"
  1666. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1667. echo "Priority: standard" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1668. echo "Section: Networking" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1669. #echo "Installed-Size: 724" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1670. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1671. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1672. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1673. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1674. echo "Depends: openssl" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1675. echo "Description: flexible multi-protocol file transfers" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1676. echo "Name: cURL" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1677. echo "Homepage: http://curl.haxx.se/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1678. #Build the doc deb
  1679. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  1680. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share"
  1681. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/man" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/"
  1682. #Build the dev deb
  1683. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  1684. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/bin"
  1685. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  1686. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share"
  1687. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/curl-config" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/bin/"
  1688. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  1689. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/pkgconfig" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  1690. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libcurl.la" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  1691. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/aclocal" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share/"
  1692. rmdir "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share"
  1693. #FIXME
  1694. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  1695. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1696. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  1697. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1698. dpkg -b deb
  1699. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1700. dpkg -b deb-doc
  1701. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1702. dpkg -b deb-dev
  1703. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1704. createListFile
  1705. cd "$BUILD_ROOT"
  1706. }
  1707. #Download berkeleydb
  1708. downloadBerkeleyDB() {
  1709. if [ ! -e db-6.2.23.tar.gz ]; then
  1710. echo "Downlading db-6.2.23.tar.gz"
  1711. curl -LO http://download.oracle.com/berkeley-db/db-6.2.23.tar.gz
  1712. checkSHA256 db-6.2.23.tar.gz 47612c8991aa9ac2f6be721267c8d3cdccf5ac83105df8e50809daea24e95dc7
  1713. else
  1714. echo "Using existing db-6.2.23"
  1715. fi
  1716. rm -rf db-6.2.23
  1717. tar xzvf db-6.2.23.tar.gz
  1718. WORKING_DIR="db-6.2.23/build_unix/"
  1719. PKG_NAME="berkeleydb"
  1720. PKG_VERSION="6.2.23-1"
  1721. cd "$WORKING_DIR"
  1722. }
  1723. patchBerkeleyDB() {
  1724. if [ "$PLATFORM" == "AppleTVOS" ]; then
  1725. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' ../dist/config.hin
  1726. if [ "$PKG_VERSION" == "6.2.23-1" ]; then
  1727. cat ../lang/sql/sqlite/src/shell.c | head -n 14 > shell.patched.c
  1728. echo "#include <stdint.h>" >> shell.patched.c
  1729. echo "#include <stdio.h>" >> shell.patched.c
  1730. echo "#include <stdlib.h>" >> shell.patched.c
  1731. echo "#include <spawn.h>" >> shell.patched.c
  1732. echo "#include <sys/wait.h>" >> shell.patched.c
  1733. echo "" >> shell.patched.c
  1734. echo "extern char **environ;" >> shell.patched.c
  1735. echo "" >> shell.patched.c
  1736. cat ../lang/sql/sqlite/src/shell.c | tail -n 4847 | head -n 2622 >> shell.patched.c
  1737. echo "int RunCmd(const char *cmd) {" >> shell.patched.c
  1738. echo " pid_t pid;" >> shell.patched.c
  1739. echo ' char *argv[] = {"sh", "-c", (char*)cmd, NULL};' >> shell.patched.c
  1740. echo ' int status;' >> shell.patched.c
  1741. echo ' status = posix_spawn(&pid, "/bin/sh", NULL, NULL, argv, environ);' >> shell.patched.c
  1742. echo ' if (status == 0) {' >> shell.patched.c
  1743. echo ' if (waitpid(pid, &status, 0) != -1) {' >> shell.patched.c
  1744. echo ' printf("Child exted in ATV Patched RunCmd with status %i\n", status);' >> shell.patched.c
  1745. echo ' } else {' >> shell.patched.c
  1746. echo ' perror("waitpid");' >> shell.patched.c
  1747. echo ' }' >> shell.patched.c
  1748. echo ' } else {' >> shell.patched.c
  1749. echo ' printf("posix_spawn: %s\n", strerror(status));' >> shell.patched.c
  1750. echo ' }' >> shell.patched.c
  1751. echo ' return status;' >> shell.patched.c
  1752. echo '}' >> shell.patched.c
  1753. echo "" >> shell.patched.c
  1754. cat ../lang/sql/sqlite/src/shell.c | tail -n 2226 | sed 's/system(zCmd)/RunCmd(zCmd)/g' >> shell.patched.c
  1755. cp shell.patched.c ../lang/sql/sqlite/src/shell.c
  1756. fi
  1757. fi
  1758. }
  1759. #berkeleydb
  1760. buildBerkeleyDB() {
  1761. downloadBerkeleyDB
  1762. patchBerkeleyDB
  1763. #Not sure which all we need...
  1764. export PLATFORM="$PLATFORM" #TODO: Maybe necessary? Need to test.
  1765. export BUILD_TOOLS="`xcode-select --print-path`"
  1766. export CC="clang"
  1767. export CROSS_COMPILE="`xcode-select --print-path`/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
  1768. export CROSS_TOP="`xcode-select --print-path`/Platforms/$PLATFORM.platform/Developer"
  1769. export CROSS_SDK="`echo $SDK_PATH | sed 's/.*\///g'`"
  1770. export CFLAGS="-arch $ARCH -pipe -Os -gdwarf-2 -isysroot $SDK_PATH $MIN_VERSION"
  1771. export CXXFLAGS="-arch $ARCH -pipe -Os -gdwarf-2 -isysroot $SDK_PATH $MIN_VERSION"
  1772. export LDFLAGS="-arch $ARCH -isysroot $SDK_PATH" # -L${SKEL_PREFIX}/lib"
  1773. #Only builds with arm-apple-darwin, not aarch64
  1774. ../dist/configure --disable-debug --disable-test --disable-atomicsupport --enable-cxx--enable-compact185 --enable-sql --enable-sql_codegen --enable-dbm --enable-slt --disable-java --host=arm-apple-darwin --prefix="/$ROOT_PREFIX"
  1775. make DESTDIR="$SKEL_PREFIX" install
  1776. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_archive"
  1777. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_checkpoint"
  1778. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_deadlock"
  1779. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_dump"
  1780. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_hotbackup"
  1781. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_load"
  1782. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_log_verify"
  1783. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_printlog"
  1784. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_recover"
  1785. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_replicate"
  1786. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_sql_codegen"
  1787. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_stat"
  1788. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_tuner"
  1789. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_upgrade"
  1790. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_verify"
  1791. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dbsql"
  1792. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libdb_sql-6.2.dylib"
  1793. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libdb-6.2.dylib"
  1794. initDebStructure
  1795. make DESTDIR="$BUILD_ROOT/db-6.2.23/build_unix/deb/" install
  1796. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_archive"
  1797. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_checkpoint"
  1798. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_deadlock"
  1799. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_dump"
  1800. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_hotbackup"
  1801. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_load"
  1802. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_log_verify"
  1803. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_printlog"
  1804. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_recover"
  1805. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_replicate"
  1806. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_sql_codegen"
  1807. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_stat"
  1808. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_tuner"
  1809. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_upgrade"
  1810. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/db_verify"
  1811. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/dbsql"
  1812. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libdb_sql-6.2.dylib"
  1813. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libdb-6.2.dylib"
  1814. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1815. echo "Priority: important" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1816. echo "Section: Data_Storage" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1817. #echo "Installed-Size: 1644" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1818. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1819. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1820. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1821. echo "Description: Oracle's embeddable database engine" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1822. echo "Name: Berkeley DB" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1823. echo "Homepage: http://www.oracle.com/technology/products/berkeley-db/index.html" >> deb/DEBIAN/control
  1824. #Build the doc deb
  1825. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  1826. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1827. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/docs" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  1828. #Build the dev deb
  1829. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  1830. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  1831. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  1832. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libdb-6.2.la" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  1833. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libdb_sql-6.2.la" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  1834. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  1835. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1836. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  1837. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1838. dpkg -b deb
  1839. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1840. dpkg -b deb-doc
  1841. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1842. dpkg -b deb-dev
  1843. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1844. createListFile
  1845. cd "$BUILD_ROOT"
  1846. }
  1847. #Download tar
  1848. downloadTar() {
  1849. if [ ! -e tar-1.30.tar.xz ]; then
  1850. echo "Downloading tar-1.30.tar.xz"
  1851. curl -LO http://ftp.gnu.org/gnu/tar/tar-1.30.tar.xz
  1852. checkSHA256 tar-1.30.tar.xz f1bf92dbb1e1ab27911a861ea8dde8208ee774866c46c0bb6ead41f4d1f4d2d3
  1853. else
  1854. echo "Using existing tar"
  1855. fi
  1856. rm -rf tar-1.30
  1857. tar xJvf tar-1.30.tar.xz
  1858. WORKING_DIR="tar-1.30"
  1859. PKG_NAME="tar"
  1860. PKG_VERSION="1.30-1"
  1861. cd "$WORKING_DIR"
  1862. }
  1863. patchTar() {
  1864. if [ "$PLATFORM" == "AppleTVOS" ]; then
  1865. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' config.h.in
  1866. fi
  1867. }
  1868. #tar
  1869. buildTar() {
  1870. downloadTar
  1871. patchTar
  1872. if [ "$ARCH" == "arm64" ]; then
  1873. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=aarch64-apple-darwin
  1874. else
  1875. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=arm-apple-darwin
  1876. fi
  1877. make -j8 DESTDIR="$SKEL_PREFIX" install
  1878. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tar"
  1879. initDebStructure
  1880. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  1881. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/tar"
  1882. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1883. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1884. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1885. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1886. echo "Depends: bzip2, xz" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1887. echo "Section: Archiving" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1888. echo "Priority: required" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1889. echo "Homepage: http://www.gnu.org/software/tar/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1890. echo "Description: tool for making tape archives" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1891. echo "Name: Tape Archive" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1892. echo "Tag: purpose::console, role::hacker" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1893. #Build the doc deb
  1894. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  1895. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1896. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1897. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  1898. #Build the dev deb
  1899. #No files
  1900. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  1901. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1902. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  1903. dpkg -b deb
  1904. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1905. dpkg -b deb-doc
  1906. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  1907. createListFile
  1908. cd "$BUILD_ROOT"
  1909. }
  1910. #Download dpkg
  1911. downloadDpkg() {
  1912. if [ ! -d dpkg ]; then
  1913. echo "Downlading dpkg"
  1914. git clone https://git.nito.tv/NitoTV/dpkg.git
  1915. else
  1916. echo "Using existing dpkg"
  1917. fi
  1918. WORKING_DIR="dpkg"
  1919. PKG_NAME="dpkg"
  1920. PKG_VERSION="1.18.23-1" #FIXME
  1921. cd "$WORKING_DIR"
  1922. }
  1923. patchDpkg() {
  1924. if [ "$PLATFORM" == "AppleTVOS" ]; then
  1925. sed -i -- "s|#define ARCHITECTURE \"darwin-arm\"|#define ARCHITECTURE \"$PLATFORM_LOWER-$ARCH\"|" config.h
  1926. sed -i -- 's|gtar|tar|' config.h
  1927. fi
  1928. }
  1929. #dpkg
  1930. buildDpkg() {
  1931. downloadDpkg
  1932. local dont_die_here=$(./autogen.sh)
  1933. if [ "$ARCH" == "arm64" ]; then
  1934. LZMA_LIBS="$SKEL_PREFIX/$ROOT_PREFIX/lib/liblzma.dylib" CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" CPPFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --disable-start-stop-daemon --host=aarch64-apple-darwin PERL_LIBDIR='$(prefix)/lib/' --disable-dselect --localstatedir="/var/" --sysconfdir="/etc"
  1935. else
  1936. LZMA_LIBS="$SKEL_PREFIX/$ROOT_PREFIX/lib/liblzma.dylib" CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" CPPFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --disable-start-stop-daemon --host=arm-apple-darwin PERL_LIBDIR='$(prefix)/lib/' --disable-dselect --localstatedir="/var/" --sysconfdir="/etc"
  1937. fi
  1938. patchDpkg #Must be after configure for now. I'll deal with this later
  1939. make -j8 DESTDIR="$SKEL_PREFIX" install
  1940. #lzma conflicts with built in libraries when running in certian conditions.
  1941. #we make -j8 a symlink our version of lzma in the xz build process
  1942. #here we change dpkg-deb to look for this version instead
  1943. #if we do not do this, apt-get/dpkg* will fail from our setuid tool
  1944. install_name_tool -change /usr/lib/liblzma.5.dylib /usr/local/lib/liblzma.5.dylib "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-deb"
  1945. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg"
  1946. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-deb"
  1947. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-divert"
  1948. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-query"
  1949. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-split"
  1950. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-trigger"
  1951. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-statoverride"
  1952. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/update-alternatives"
  1953. echo "appletvos-arm64" >> "$SKEL_PREFIX/var/lib/dpkg/arch"
  1954. echo "darwin-arm64" >> "$SKEL_PREFIX/var/lib/dpkg/arch"
  1955. initDebStructure
  1956. make -j8 install DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb/"
  1957. install_name_tool -change /usr/lib/liblzma.5.dylib /usr/local/lib/liblzma.5.dylib "$BUILD_ROOT/dpkg/deb/$ROOT_PREFIX/bin/dpkg-deb"
  1958. codesign "$BUILD_ROOT/dpkg/deb/$ROOT_PREFIX/bin/dpkg"
  1959. codesign "$BUILD_ROOT/dpkg/deb/$ROOT_PREFIX/bin/dpkg-deb"
  1960. codesign "$BUILD_ROOT/dpkg/deb/$ROOT_PREFIX/bin/dpkg-divert"
  1961. codesign "$BUILD_ROOT/dpkg/deb/$ROOT_PREFIX/bin/dpkg-query"
  1962. codesign "$BUILD_ROOT/dpkg/deb/$ROOT_PREFIX/bin/dpkg-split"
  1963. codesign "$BUILD_ROOT/dpkg/deb/$ROOT_PREFIX/bin/dpkg-trigger"
  1964. codesign "$BUILD_ROOT/dpkg/deb/$ROOT_PREFIX/bin/dpkg-statoverride"
  1965. codesign "$BUILD_ROOT/dpkg/deb/$ROOT_PREFIX/bin/update-alternatives"
  1966. echo "appletvos-arm64" >> "$BUILD_ROOT/dpkg/deb/var/lib/dpkg/arch"
  1967. echo "darwin-arm64" >> "$BUILD_ROOT/dpkg/deb/var/lib/dpkg/arch"
  1968. #Get rid of cross-compile artifacts
  1969. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libdpkg.la"
  1970. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/pkgconfig/libdpkg.pc"
  1971. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libdpkg.la--"
  1972. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/pkgconfig/libdpkg.pc--"
  1973. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1974. echo "Priority: required" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1975. echo "Section: Packaging" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1976. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1977. #echo "Depends: bash, bzip2, coreutils-bin, diffutils, findutils, gzip, lzma, ncurses, tar" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1978. echo "Depends: bzip2, coreutils, diffutils, findutils, xz, tar" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1979. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1980. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1981. echo "Description: package maintainance tools from Debian" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1982. echo "Name: Debian Packager" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  1983. echo "Homepage: http://wiki.debian.org/Teams/Dpkg" >> deb/DEBIAN/control
  1984. #Build the doc deb
  1985. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  1986. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share"
  1987. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/man" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/"
  1988. #Build the dev deb
  1989. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  1990. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  1991. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  1992. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libdpkg.la" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  1993. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/pkgconfig" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  1994. #FIXME
  1995. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  1996. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  1997. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/etc"
  1998. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/var"
  1999. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  2000. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  2001. dpkg -b deb
  2002. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2003. dpkg -b deb-doc
  2004. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2005. dpkg -b deb-dev
  2006. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2007. createListFile
  2008. cd "$BUILD_ROOT"
  2009. }
  2010. buildDPKGAndDependencies() {
  2011. notifyProgress "Building zlib"
  2012. buildZLib
  2013. notifyProgress "Building xz"
  2014. buildXZ
  2015. notifyProgress "Building bzip2"
  2016. buildBZip2
  2017. notifyProgress "Building lz4"
  2018. buildLZ4
  2019. notifyProgress "Building openSSL"
  2020. buildOpenSSL
  2021. notifyProgress "Building curl"
  2022. buildCurl
  2023. notifyProgress "Building BerkeleyDB"
  2024. buildBerkeleyDB
  2025. notifyProgress "Building tar"
  2026. buildTar
  2027. notifyProgress "Building dpkg"
  2028. buildDpkg
  2029. }
  2030. #====================
  2031. #APT and Dependencies
  2032. #--------------------
  2033. #Download libgpg-error
  2034. downloadGpgError() {
  2035. if [ ! -e libgpg-error-1.27.tar.bz2 ]; then
  2036. echo "Downloading libgpg-error-1.27.tar.bz2"
  2037. curl -LO https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2
  2038. curl -LO https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2.sig
  2039. checkPGPSig libgpg-error-1.27.tar.bz2.sig libgpg-error-1.27.tar.bz2
  2040. else
  2041. echo "Using existing libgpg-error"
  2042. fi
  2043. rm -rf libgpg-error-1.27
  2044. tar xjvf libgpg-error-1.27.tar.bz2
  2045. WORKING_DIR="libgpg-error-1.27"
  2046. PKG_NAME="libgpg-error"
  2047. PKG_VERSION="1.27-1"
  2048. cd "$WORKING_DIR"
  2049. }
  2050. patchGpgError() {
  2051. if [ "$PLATFORM" == "AppleTVOS" ]; then
  2052. echo ""
  2053. #sed -i -- 's|assert (!"lock ABI version");|//assert (!"lock ABI version");|' config.h
  2054. #sed -i -- 's|assert (!"lock ABI version");|//assert (!"lock ABI version");|' config.h
  2055. fi
  2056. }
  2057. #libgpg-error
  2058. buildGpgError() {
  2059. downloadGpgError
  2060. if [ "$ARCH" == "arm64" ]; then
  2061. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix=/$ROOT_PREFIX --host=aarch64-apple-darwin --disable-tests --enable-threads=posix
  2062. else
  2063. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix=/$ROOT_PREFIX --host=arm-apple-darwin --disable-tests --enable-threads=posix
  2064. fi
  2065. make -j8 DESTDIR="$SKEL_PREFIX" install
  2066. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libgpg-error.0.dylib"
  2067. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-error"
  2068. initDebStructure
  2069. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  2070. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libgpg-error.0.dylib"
  2071. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/gpg-error"
  2072. #Get rid of cross-compile artifacts
  2073. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libgpg-error.la"
  2074. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libgpg-error.la--"
  2075. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2076. echo "Priority: optional" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2077. echo "Section: Security" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2078. #echo "Installed-Size: 724" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2079. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2080. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2081. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2082. echo "Description: GnuPG's error management library" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2083. echo "Name: GnuPG Errors" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2084. echo "Homepage: https://www.gnupg.org/related_software/libgpg-error/index.en.html" >> deb/DEBIAN/control
  2085. #Build the doc deb
  2086. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  2087. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share"
  2088. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/info" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/"
  2089. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/man" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/"
  2090. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/libgpg-error" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/"
  2091. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  2092. #Build the dev deb
  2093. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  2094. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share"
  2095. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/bin"
  2096. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  2097. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/gpg-error-config" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/bin/"
  2098. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/aclocal" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share/"
  2099. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/common-lisp" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share/"
  2100. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2101. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libgpg-error.la" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  2102. rmdir "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share"
  2103. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  2104. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  2105. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  2106. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  2107. dpkg -b deb
  2108. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2109. dpkg -b deb-doc
  2110. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2111. dpkg -b deb-dev
  2112. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2113. createListFile
  2114. cd "$BUILD_ROOT"
  2115. }
  2116. #Download gcrypt
  2117. downloadGcrypt() {
  2118. if [ ! -e libgcrypt-1.8.2.tar.bz2 ]; then
  2119. echo "Downloading libgcrypt-1.8.2.tar.bz2"
  2120. curl -LO https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.8.2.tar.bz2
  2121. curl -LO https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.8.2.tar.bz2.sig
  2122. checkPGPSig libgcrypt-1.8.2.tar.bz2.sig libgcrypt-1.8.2.tar.bz2
  2123. else
  2124. echo "Using existing gcrypt"
  2125. fi
  2126. rm -rf libgcrypt-1.8.2
  2127. tar xjvf libgcrypt-1.8.2.tar.bz2
  2128. WORKING_DIR="libgcrypt-1.8.2"
  2129. PKG_NAME="libgcrypt"
  2130. PKG_VERSION="1.8.2-1"
  2131. cd "$WORKING_DIR"
  2132. }
  2133. patchGcrypt() {
  2134. if [ "$PLATFORM" == "AppleTVOS" ]; then
  2135. if [ "$PKG_VERSION" == "1.8.2-1" ]; then
  2136. cat tests/random.c | head -n 39 > random.patched.c
  2137. echo "#include <stdint.h>" >> random.patched.c
  2138. echo "#include <stdio.h>" >> random.patched.c
  2139. echo "#include <stdlib.h>" >> random.patched.c
  2140. echo "#include <spawn.h>" >> random.patched.c
  2141. echo "#include <sys/wait.h>" >> random.patched.c
  2142. echo "" >> random.patched.c
  2143. echo "extern char **environ;" >> random.patched.c
  2144. echo "" >> random.patched.c
  2145. echo "int RunCmd(const char *cmd) {" >> random.patched.c
  2146. echo " pid_t pid;" >> random.patched.c
  2147. echo ' char *argv[] = {"sh", "-c", (char*)cmd, NULL};' >> random.patched.c
  2148. echo ' int status;' >> random.patched.c
  2149. echo ' status = posix_spawn(&pid, "/bin/sh", NULL, NULL, argv, environ);' >> random.patched.c
  2150. echo ' if (status == 0) {' >> random.patched.c
  2151. echo ' if (waitpid(pid, &status, 0) != -1) {' >> random.patched.c
  2152. echo ' printf("Child exted in ATV Patched RunCmd with status %i\n", status);' >> random.patched.c
  2153. echo ' } else {' >> random.patched.c
  2154. echo ' perror("waitpid");' >> random.patched.c
  2155. echo ' }' >> random.patched.c
  2156. echo ' } else {' >> random.patched.c
  2157. echo ' printf("posix_spawn: %s\n", strerror(status));' >> random.patched.c
  2158. echo ' }' >> random.patched.c
  2159. echo ' return status;' >> random.patched.c
  2160. echo '}' >> random.patched.c
  2161. echo "" >> random.patched.c
  2162. cat tests/random.c | tail -n 727 | sed 's/system (cmdline)/RunCmd(cmdline)/g' >> random.patched.c
  2163. cp random.patched.c tests/random.c
  2164. fi
  2165. fi
  2166. }
  2167. #gcrypt
  2168. buildGcrypt() {
  2169. downloadGcrypt
  2170. patchGcrypt
  2171. #TODO: Doesn't like aarch64-apple-darwin, but may build with it with minor changes.
  2172. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=arm-apple-darwin --with-libgpg-error-prefix="$SKEL_PREFIX/$ROOT_PREFIX/"
  2173. make -j8 DESTDIR="$SKEL_PREFIX" install
  2174. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dumpsexp"
  2175. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/hmac256"
  2176. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mpicalc"
  2177. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libgcrypt.20.dylib"
  2178. #make clean
  2179. initDebStructure
  2180. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  2181. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/dumpsexp"
  2182. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/hmac256"
  2183. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/mpicalc"
  2184. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libgcrypt.20.dylib"
  2185. #Get rid of cross-compile artifacts
  2186. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libgcrypt.la"
  2187. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libgcrypt.la--"
  2188. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2189. echo "Priority: optional" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2190. echo "Section: Security" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2191. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2192. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2193. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2194. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2195. echo "Depends: libgpg-error" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2196. echo "Description: LGPL cryptographic algorithm library" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2197. echo "Name: GNU Cryptography" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2198. echo "Homepage: https://www.gnupg.org/related_software/libgcrypt/" >> deb/DEBIAN/control
  2199. #Build the doc deb
  2200. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  2201. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share"
  2202. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/info" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/"
  2203. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/man" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/"
  2204. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  2205. #Build the dev deb
  2206. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  2207. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share"
  2208. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/bin"
  2209. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  2210. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/libgcrypt-config" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/bin/"
  2211. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/aclocal" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share/"
  2212. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2213. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libgcrypt.la" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  2214. rmdir "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share"
  2215. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  2216. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  2217. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  2218. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  2219. dpkg -b deb
  2220. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2221. dpkg -b deb-doc
  2222. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2223. dpkg -b deb-dev
  2224. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2225. createListFile
  2226. cd "$BUILD_ROOT"
  2227. }
  2228. #Download libkbsa
  2229. downloadKSBA() {
  2230. if [ ! -e libksba-1.3.5.tar.bz2 ]; then
  2231. echo "Downloading libksba-1.3.5.tar.bz2"
  2232. curl -LO https://www.gnupg.org/ftp/gcrypt/libksba/libksba-1.3.5.tar.bz2
  2233. curl -LO https://www.gnupg.org/ftp/gcrypt/libksba/libksba-1.3.5.tar.bz2.sig
  2234. checkPGPSig libksba-1.3.5.tar.bz2.sig libksba-1.3.5.tar.bz2
  2235. else
  2236. echo "Using existing libksba"
  2237. fi
  2238. rm -rf libksba-1.3.5
  2239. tar xjvf libksba-1.3.5.tar.bz2
  2240. WORKING_DIR="libksba-1.3.5"
  2241. PKG_NAME="libksba"
  2242. PKG_VERSION="1.3.5-1"
  2243. cd "$WORKING_DIR"
  2244. }
  2245. #libkbsa
  2246. buildKSBA() {
  2247. downloadKSBA
  2248. if [ "$ARCH" == "arm64" ]; then
  2249. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=aarch64-apple-darwin --with-libgpg-error-prefix="$SKEL_PREFIX/$ROOT_PREFIX"
  2250. else
  2251. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=arm-apple-darwin --with-libgpg-error-prefix="$SKEL_PREFIX/$ROOT_PREFIX"
  2252. fi
  2253. make -j8 DESTDIR="$SKEL_PREFIX" install
  2254. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libksba.8.dylib"
  2255. initDebStructure
  2256. make -j8 DESTDIR="$BUILD_ROOT/libksba-1.3.5/deb" install
  2257. codesign "deb/$ROOT_PREFIX/lib/libksba.8.dylib"
  2258. #Get rid of cross-compile artifacts
  2259. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libksba.la"
  2260. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libksba.la--"
  2261. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2262. echo "Priority: optional" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2263. echo "Section: Security" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2264. #echo "Installed-Size: 724" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2265. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2266. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2267. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2268. #echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2269. echo "Depends: libgpg-error" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2270. echo "Description: GnuPG's certification management library" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2271. echo "Name: KSBA" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2272. echo "Homepage: https://www.gnupg.org/related_software/libksba/" >> deb/DEBIAN/control
  2273. #Build the doc deb
  2274. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  2275. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share"
  2276. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/info" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/"
  2277. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  2278. #Build the dev deb
  2279. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  2280. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share"
  2281. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  2282. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2283. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2284. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/aclocal" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share/"
  2285. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libksba.la" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  2286. rmdir "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share"
  2287. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  2288. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  2289. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  2290. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  2291. dpkg -b deb
  2292. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2293. dpkg -b deb-doc
  2294. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2295. dpkg -b deb-dev
  2296. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2297. createListFile
  2298. cd "$BUILD_ROOT"
  2299. }
  2300. #Download npth
  2301. downloadNpth() {
  2302. if [ ! -e npth-1.5.tar.bz2 ]; then
  2303. echo "Downloading npth-1.5.tar.bz2"
  2304. curl -LO https://www.gnupg.org/ftp/gcrypt/npth/npth-1.5.tar.bz2
  2305. curl -LO https://www.gnupg.org/ftp/gcrypt/npth/npth-1.5.tar.bz2.sig
  2306. checkPGPSig npth-1.5.tar.bz2.sig npth-1.5.tar.bz2
  2307. else
  2308. echo "Using existing npth"
  2309. fi
  2310. rm -rf npth-1.5
  2311. tar xjvf npth-1.5.tar.bz2
  2312. WORKING_DIR="npth-1.5"
  2313. PKG_NAME="libnpth"
  2314. PKG_VERSION="1.5-1"
  2315. cd "$WORKING_DIR"
  2316. }
  2317. patchNpth() {
  2318. if [ "$PLATFORM" == "AppleTVOS" ]; then
  2319. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' config.h.in
  2320. if [ "$PKG_VERSION" == "1.5-1" ]; then
  2321. cat src/npth.c | head -n 19 > npth.patched.c
  2322. echo "#include <stdint.h>" >> npth.patched.c
  2323. echo "#include <stdio.h>" >> npth.patched.c
  2324. echo "#include <stdlib.h>" >> npth.patched.c
  2325. echo "#include <spawn.h>" >> npth.patched.c
  2326. echo "#include <sys/wait.h>" >> npth.patched.c
  2327. echo "" >> npth.patched.c
  2328. echo "extern char **environ;" >> npth.patched.c
  2329. echo "" >> npth.patched.c
  2330. cat src/npth.c | tail -n 757 | head -n 537 >> npth.patched.c
  2331. echo "int RunCmd(const char *cmd) {" >> npth.patched.c
  2332. echo " pid_t pid;" >> npth.patched.c
  2333. echo ' char *argv[] = {"sh", "-c", (char*)cmd, NULL};' >> npth.patched.c
  2334. echo ' int status;' >> npth.patched.c
  2335. echo ' status = posix_spawn(&pid, "/bin/sh", NULL, NULL, argv, environ);' >> npth.patched.c
  2336. echo ' if (status == 0) {' >> npth.patched.c
  2337. echo ' if (waitpid(pid, &status, 0) != -1) {' >> npth.patched.c
  2338. echo ' printf("Child exted in ATV Patched RunCmd with status %i\n", status);' >> npth.patched.c
  2339. echo ' } else {' >> npth.patched.c
  2340. echo ' perror("waitpid");' >> npth.patched.c
  2341. echo ' }' >> npth.patched.c
  2342. echo ' } else {' >> npth.patched.c
  2343. echo ' printf("posix_spawn: %s\n", strerror(status));' >> npth.patched.c
  2344. echo ' }' >> npth.patched.c
  2345. echo ' return status;' >> npth.patched.c
  2346. echo '}' >> npth.patched.c
  2347. echo "" >> npth.patched.c
  2348. cat src/npth.c | tail -n 220 | sed 's/system(cmd)/RunCmd(cmd)/g' >> npth.patched.c
  2349. cp npth.patched.c src/npth.c
  2350. fi
  2351. fi
  2352. }
  2353. #npth
  2354. buildNpth() {
  2355. downloadNpth
  2356. patchNpth
  2357. if [ "$ARCH" == "arm64" ]; then
  2358. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=aarch64-apple-darwin
  2359. else
  2360. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=arm-apple-darwin
  2361. fi
  2362. make -j8 DESTDIR="$SKEL_PREFIX" install
  2363. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libnpth.0.dylib"
  2364. initDebStructure
  2365. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  2366. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libnpth.0.dylib"
  2367. #Get rid of cross-compile artifacts
  2368. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libnpth.la"
  2369. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libnpth.la--"
  2370. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2371. echo "Priority: optional" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2372. echo "Section: Development" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2373. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2374. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2375. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2376. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2377. #echo "Depends: grep, sed" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2378. echo "Description: portable threading library used by X" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2379. echo "Name: The New GNU Portable Threads Library" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2380. echo "Homepage: https://www.gnupg.org/software/npth" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2381. #Build the doc deb
  2382. #No files
  2383. #Build the dev deb
  2384. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  2385. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  2386. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2387. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2388. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2389. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libnpth.la" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  2390. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  2391. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  2392. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  2393. dpkg -b deb
  2394. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2395. dpkg -b deb-dev
  2396. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2397. createListFile
  2398. cd "$BUILD_ROOT"
  2399. }
  2400. #Download libassuan
  2401. downloadAssuan() {
  2402. if [ ! -e libassuan-2.5.1.tar.bz2 ]; then
  2403. echo "Downloading libassuan-2.5.1.tar.bz2"
  2404. curl -LO https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-2.5.1.tar.bz2
  2405. curl -LO https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-2.5.1.tar.bz2.sig
  2406. checkPGPSig libassuan-2.5.1.tar.bz2.sig libassuan-2.5.1.tar.bz2
  2407. else
  2408. echo "Using existing libassuan"
  2409. fi
  2410. rm -rf libassuan-2.5.1
  2411. tar xjvf libassuan-2.5.1.tar.bz2
  2412. WORKING_DIR="libassuan-2.5.1"
  2413. PKG_NAME="libassuan"
  2414. PKG_VERSION="2.5.1-1"
  2415. cd "$WORKING_DIR"
  2416. }
  2417. #libassuan
  2418. buildAssuan() {
  2419. downloadAssuan
  2420. if [ "$ARCH" == "arm64" ]; then
  2421. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=aarch64-apple-darwin --with-gpg-error-prefix="$SKEL_PREFIX/$ROOT_PREFIX/"
  2422. else
  2423. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=arm-apple-darwin --with-gpg-error-prefix="$SKEL_PREFIX/$ROOT_PREFIX/"
  2424. fi
  2425. make -j8 DESTDIR="$SKEL_PREFIX" install
  2426. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libassuan.0.dylib"
  2427. #Get rid of cross-compile artifacts
  2428. sed -i -- "s|$SKEL_PREFIX||g" "$SKEL_PREFIX/$ROOT_PREFIX/lib/libassuan.la"
  2429. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/lib/libassuan.la--"
  2430. initDebStructure
  2431. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  2432. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libassuan.0.dylib"
  2433. #Get rid of cross-compile artifacts
  2434. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libassuan.la"
  2435. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libassuan.la--"
  2436. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2437. echo "Priority: optional" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2438. echo "Section: Development" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2439. #echo "Installed-Size: 724" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2440. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2441. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2442. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2443. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2444. echo "Depends: gnupth" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2445. echo "Description: GnuPG's inter-process communication" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2446. echo "Name: Assuan" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2447. echo "Homepage: https://www.gnupg.org/related_software/libassuan/index.en.html" >> deb/DEBIAN/control
  2448. #Build the doc deb
  2449. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  2450. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share"
  2451. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/info" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/"
  2452. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  2453. #Build the dev deb
  2454. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  2455. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share"
  2456. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  2457. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2458. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2459. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/aclocal" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/share/"
  2460. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libassuan.la" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  2461. rmdir "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share"
  2462. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  2463. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  2464. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  2465. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  2466. dpkg -b deb
  2467. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2468. dpkg -b deb-doc
  2469. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2470. dpkg -b deb-dev
  2471. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2472. createListFile
  2473. cd "$BUILD_ROOT"
  2474. }
  2475. #Download ntbtls
  2476. downloadNtbtls() {
  2477. if [ ! -e ntbtls-0.1.2.tar.bz2 ]; then
  2478. echo "Downloading ntbtls-0.1.2.tar.bz2"
  2479. curl -LO https://www.gnupg.org/ftp/gcrypt/ntbtls/ntbtls-0.1.2.tar.bz2
  2480. curl -LO https://www.gnupg.org/ftp/gcrypt/ntbtls/ntbtls-0.1.2.tar.bz2.sig
  2481. checkPGPSig ntbtls-0.1.2.tar.bz2.sig ntbtls-0.1.2.tar.bz2
  2482. else
  2483. echo "Using existing ntbtls"
  2484. fi
  2485. rm -rf ntbtls-0.1.2
  2486. tar xjvf ntbtls-0.1.2.tar.bz2
  2487. WORKING_DIR="ntbtls-0.1.2"
  2488. PKG_NAME="libntbtls"
  2489. PKG_VERSION="0.1.2-1"
  2490. cd "$WORKING_DIR"
  2491. }
  2492. patchNtbtls() {
  2493. if [ "$PLATFORM" == "AppleTVOS" ]; then
  2494. # this is required because prior dependencies write /$ROOT_PREFIX/lib/libgpg-error.la as a dependency in the .la file
  2495. sed -i -- "s|/$ROOT_PREFIX/lib/libgpg-error.la|$SKEL_PREFIX/$ROOT_PREFIX/lib/libgpg-error.la|g" "$SKEL_PREFIX/$ROOT_PREFIX/lib/libgcrypt.la"
  2496. sed -i -- "s|/$ROOT_PREFIX/lib/libgpg-error.la|$SKEL_PREFIX/$ROOT_PREFIX/lib/libgpg-error.la|g" "$SKEL_PREFIX/$ROOT_PREFIX/lib/libksba.la"
  2497. rm -f "$SKEL_PREFIX/$ROOT_PREFIX/lib/libgcrypt.la--"
  2498. rm -f "$SKEL_PREFIX/$ROOT_PREFIX/lib/libksba.la--"
  2499. fi
  2500. }
  2501. #ntbtls
  2502. buildNtbtls() {
  2503. downloadNtbtls
  2504. patchNtbtls
  2505. if [ "$ARCH" == "arm64" ]; then
  2506. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=aarch64-apple-darwin --with-libgpg-error-prefix="$SKEL_PREFIX/$ROOT_PREFIX" --with-libgcrypt-prefix="$SKEL_PREFIX/$ROOT_PREFIX" --with-ksba-prefix="$SKEL_PREFIX/$ROOT_PREFIX"
  2507. else
  2508. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX" --host=arm-apple-darwin --with-libgpg-error-prefix="$SKEL_PREFIX/$ROOT_PREFIX" --with-libgcrypt-prefix="$SKEL_PREFIX/$ROOT_PREFIX" --with-ksba-prefix="$SKEL_PREFIX/$ROOT_PREFIX"
  2509. fi
  2510. make -j8 DESTDIR="$SKEL_PREFIX" install
  2511. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libntbtls.0.dylib"
  2512. initDebStructure
  2513. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb/" install
  2514. codesign "deb/$ROOT_PREFIX/lib/libntbtls.0.dylib"
  2515. #Get rid of cross-compile artifacts
  2516. sed -i -- "s|$SKEL_PREFIX||g" "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libntbtls.la"
  2517. rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libntbtls.la--"
  2518. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2519. echo "Priority: optional" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2520. echo "Section: Security" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2521. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2522. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2523. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2524. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2525. echo "Depends: gcrypt, libksba" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2526. echo "Description: a tiny TLS 1.2 only implementation designed to be used with Libgcrypt and LibKSBA" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2527. echo "Name: The Not Too Bad TLS Library" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2528. echo "Homepage: https://www.gnupg.org/related_software/ntbtls/index.en.html" >> deb/DEBIAN/control
  2529. #Build the doc deb
  2530. #No files
  2531. #Build the dev deb
  2532. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  2533. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib"
  2534. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2535. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2536. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2537. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libntbtls.la" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/lib/"
  2538. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  2539. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  2540. dpkg -b deb
  2541. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2542. dpkg -b deb-dev
  2543. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2544. createListFile
  2545. cd "$BUILD_ROOT"
  2546. }
  2547. #Download gpg
  2548. downloadGpg() {
  2549. if [ ! -e gnupg-2.2.3.tar.bz2 ]; then
  2550. echo "Downloading gnupg-2.2.3.tar.bz2"
  2551. curl -LO https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.2.3.tar.bz2
  2552. curl -LO https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.2.3.tar.bz2.sig
  2553. checkPGPSig gnupg-2.2.3.tar.bz2.sig gnupg-2.2.3.tar.bz2
  2554. else
  2555. echo "Using existing gpg"
  2556. fi
  2557. rm -rf gnupg-2.2.3
  2558. tar xjvf gnupg-2.2.3.tar.bz2
  2559. WORKING_DIR="gnupg-2.2.3"
  2560. PKG_NAME="gnupg"
  2561. PKG_VERSION="2.2.3-1"
  2562. cd "$WORKING_DIR"
  2563. }
  2564. patchGpg() {
  2565. if [ "$PLATFORM" == "AppleTVOS" ]; then
  2566. if [ "$PKG_VERSION" == "2.2.3-1" ]; then
  2567. cat "g10/exec.c" | head -n 54 > "exec.patched.c"
  2568. echo "#include <stdint.h>" >> "exec.patched.c"
  2569. echo "#include <stdio.h>" >> "exec.patched.c"
  2570. echo "#include <stdlib.h>" >> "exec.patched.c"
  2571. echo "#include <spawn.h>" >> "exec.patched.c"
  2572. echo "#include <sys/wait.h>" >> "exec.patched.c"
  2573. echo "" >> "exec.patched.c"
  2574. echo "extern char **environ;" >> "exec.patched.c"
  2575. echo "" >> "exec.patched.c"
  2576. cat "g10/exec.c" | head -n 111 | tail -n 57 >> "exec.patched.c"
  2577. echo "int RunCmd(const char *cmd) {" >> "exec.patched.c"
  2578. echo " pid_t pid;" >> "exec.patched.c"
  2579. echo ' char *argv[] = {"sh", "-c", (char*)cmd, NULL};' >> "exec.patched.c"
  2580. echo ' int status;' >> "exec.patched.c"
  2581. echo ' status = posix_spawn(&pid, "/bin/sh", NULL, NULL, argv, environ);' >> "exec.patched.c"
  2582. echo ' if (status == 0) {' >> "exec.patched.c"
  2583. echo ' if (waitpid(pid, &status, 0) != -1) {' >> "exec.patched.c"
  2584. echo ' printf("Child exted in ATV Patched RunCmd with status %i\n", status);' >> "exec.patched.c"
  2585. echo ' } else {' >> "exec.patched.c"
  2586. echo ' perror("waitpid");' >> "exec.patched.c"
  2587. echo ' }' >> "exec.patched.c"
  2588. echo ' } else {' >> "exec.patched.c"
  2589. echo ' printf("posix_spawn: %s\n", strerror(status));' >> "exec.patched.c"
  2590. echo ' }' >> "exec.patched.c"
  2591. echo ' return status;' >> "exec.patched.c"
  2592. echo '}' >> "exec.patched.c"
  2593. echo "" >> "exec.patched.c"
  2594. cat "g10/exec.c" | tail -n 524 | sed 's/=system(info->command)/=RunCmd(info->command)/g' >> "exec.patched.c"
  2595. cp "exec.patched.c" "g10/exec.c"
  2596. fi
  2597. fi
  2598. }
  2599. #gpg
  2600. buildGpg() {
  2601. downloadGpg
  2602. patchGpg
  2603. if [ "$ARCH" == "arm64" ]; then
  2604. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=aarch64-apple-darwin --with-libgpg-error-prefix="$SKEL_PREFIX/$ROOT_PREFIX/" --with-libgcrypt-prefix="$SKEL_PREFIX/$ROOT_PREFIX/" --with-libassuan-prefix="$SKEL_PREFIX/$ROOT_PREFIX/" --with-ksba-prefix="$SKEL_PREFIX/$ROOT_PREFIX/" --with-npth-prefix="$SKEL_PREFIX/$ROOT_PREFIX/" --with-ntbtls-prefix="$SKEL_PREFIX/$ROOT_PREFIX/"
  2605. else
  2606. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix="/$ROOT_PREFIX/" --host=arm-apple-darwin --with-libgpg-error-prefix="$SKEL_PREFIX/$ROOT_PREFIX/" --with-libgcrypt-prefix="$SKEL_PREFIX/$ROOT_PREFIX/" --with-libassuan-prefix="$SKEL_PREFIX/$ROOT_PREFIX/" --with-ksba-prefix="$SKEL_PREFIX/$ROOT_PREFIX/" --with-npth-prefix="$SKEL_PREFIX/$ROOT_PREFIX/" --with-ntbtls-prefix="$SKEL_PREFIX/$ROOT_PREFIX/"
  2607. fi
  2608. make -j8 DESTDIR="$SKEL_PREFIX" install
  2609. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dirmngr"
  2610. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dirmngr-client"
  2611. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg"
  2612. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-agent"
  2613. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-connect-agent"
  2614. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgconf"
  2615. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgparsemail"
  2616. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgscm"
  2617. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgsm"
  2618. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgtar"
  2619. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgv"
  2620. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/kbxutil"
  2621. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/watchgnupg"
  2622. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-check-pattern"
  2623. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-preset-passphrase"
  2624. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-protect-tool"
  2625. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-wks-client"
  2626. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/scdaemon"
  2627. initDebStructure
  2628. make -j8 install DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb/"
  2629. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/dirmngr"
  2630. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/dirmngr-client"
  2631. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/gpg"
  2632. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/gpg-agent"
  2633. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/gpg-connect-agent"
  2634. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/gpgconf"
  2635. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/gpgparsemail"
  2636. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/gpgscm"
  2637. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/gpgsm"
  2638. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/gpgtar"
  2639. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/gpgv"
  2640. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/kbxutil"
  2641. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/watchgnupg"
  2642. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/gpg-check-pattern"
  2643. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/gpg-preset-passphrase"
  2644. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/gpg-protect-tool"
  2645. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/gpg-wks-client"
  2646. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/scdaemon"
  2647. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2648. echo "Priority: required" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2649. echo "Section: Archiving" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2650. #echo "Installed-Size: 724" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2651. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2652. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2653. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2654. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2655. echo "Depends: gcrypt, gnupth, libassuan, libksba, gnutbtls" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2656. echo "Description: newer encryption compatible with OpenPGP" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2657. echo "Name: GNU Privacy Guard" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2658. echo "Homepage: http://www.gnupg.org/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2659. #Build the doc deb
  2660. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-doc|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-doc/DEBIAN/control"
  2661. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  2662. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share" "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/"
  2663. rm "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX/share/info/dir"
  2664. #Build the dev deb
  2665. #No files
  2666. #rm -rf "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/share/info"
  2667. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  2668. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  2669. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-doc/$ROOT_PREFIX"
  2670. dpkg -b deb
  2671. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2672. dpkg -b deb-doc
  2673. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2674. createListFile
  2675. cd "$BUILD_ROOT"
  2676. }
  2677. #Download apt
  2678. downloadApt() {
  2679. if [ ! -d apt ]; then
  2680. echo "Downlading apt"
  2681. git clone https://git.nito.tv/NitoTV/apt.git
  2682. else
  2683. echo "Using existing apt"
  2684. fi
  2685. WORKING_DIR="apt"
  2686. PKG_NAME="apt7"
  2687. PKG_VERSION="0.7.25.3-1"
  2688. cd "$WORKING_DIR"
  2689. rm -rf build
  2690. mkdir build
  2691. cd build
  2692. WORKING_DIR="$WORKING_DIR/build"
  2693. }
  2694. patchAPT() {
  2695. if [ "$PLATFORM" == "AppleTVOS" ]; then
  2696. sed -i -- '/^INCLUDE_DIRECTORIES/d' ../CMakeLists.txt
  2697. sed -i -- '/^LINK_DIRECTORIES/d' ../CMakeLists.txt
  2698. cat ../CMakeLists.txt | head -n 15 > newCmakeLists.txt
  2699. echo "INCLUDE_DIRECTORIES($SKEL_PREFIX/$ROOT_PREFIX/include)" >> newCmakeLists.txt
  2700. echo "LINK_DIRECTORIES($SKEL_PREFIX/$ROOT_PREFIX/lib)" >> newCmakeLists.txt
  2701. echo "" >> newCmakeLists.txt
  2702. cat ../CMakeLists.txt | tail -n 217 >> newCmakeLists.txt
  2703. mv newCmakeLists.txt ../CmakeLists.txt
  2704. #sed -i -- "s|/Users/jaywalker/RnD/ATV/packages/test/skel/|$SKEL_PREFIX/|g" ../CMakeLists.txt
  2705. fi
  2706. }
  2707. #apt
  2708. buildAPT() {
  2709. downloadApt
  2710. patchAPT
  2711. cmake -j8 -DCMAKE_LOCALSTATEDIR="/private/var" -DCMAKE_INSTALL_NAME_DIR="/$ROOT_PREFIX/lib" -DCMAKE_INSTALL_RPATH="/$ROOT_PREFIX/" -DCMAKE_OSX_SYSROOT="$SDK_PATH" -DCMAKE_CXX_FLAGS="-arch $ARCH" -DCMAKE_C_FLAGS="-arch $ARCH" -DCMAKE_INSTALL_PREFIX="/$ROOT_PREFIX/" -DCMAKE_SHARED_LINKER_FLAGS="-lresolv -L$SKEL_PREFIX/$ROOT_PREFIX/lib/" -DCURL_INCLUDE_DIR="$SKEL_PREFIX/$ROOT_PREFIX/include" -DCURL_LIBRARIES="$SKEL_PREFIX/$ROOT_PREFIX/lib/libcurl.4.dylib" -DLZ4_INCLUDE_DIRS="$SKEL_PREFIX/$ROOT_PREFIX/include/" -DLZ4_LIBRARIES="$SKEL_PREFIX/$ROOT_PREFIX/lib/liblz4.dylib" -DLZMA_INCLUDE_DIRS="$SKEL_PREFIX/$ROOT_PREFIX/include/" -DLZMA_LIBRARIES="$SKEL_PREFIX/$ROOT_PREFIX/lib/liblzma.dylib" -DCURRENT_VENDOR=debian -DUSE_NLS=0 -DWITH_DOC=0 -DBERKELEY_DB_INCLUDE_DIRS="$SKEL_PREFIX/$ROOT_PREFIX/include" -DBERKELEY_DB_LIBRARIES="$SKEL_PREFIX/$ROOT_PREFIX/lib/libdb.dylib" -DCMAKE_FIND_ROOT_PATH="$SKEL_PREFIX" ..
  2712. #FIXME: Use our platform-arch vars
  2713. sed -i -- 's|#define COMMON_ARCH "darwin-amd64"|#define COMMON_ARCH "darwin-arm64"|' include/config.h
  2714. make -j8 DESTDIR="$SKEL_PREFIX" install
  2715. #lzma conflicts with built in libraries we make -j8 an extra copy of our version of lzma in the xz build process
  2716. #here we change libapt-pkg*.dylib to look for this version instead
  2717. #if we do not do this, apt-get will fail from our helper tool
  2718. install_name_tool -change /usr/lib/liblzma.5.dylib /usr/local/lib/liblzma.5.dylib $SKEL_PREFIX/$ROOT_PREFIX/lib/libapt-pkg.5.0.1.dylib
  2719. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt"
  2720. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-cache"
  2721. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-cdrom"
  2722. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-config"
  2723. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-ftparchive"
  2724. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-get"
  2725. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-mark"
  2726. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-sortpkgs"
  2727. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libapt-inst.2.0.0.dylib"
  2728. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libapt-pkg.5.0.1.dylib"
  2729. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libapt-private.0.0.0.dylib"
  2730. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/apt-helper"
  2731. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/cdrom"
  2732. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/copy"
  2733. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/file"
  2734. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/ftp"
  2735. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/gpgv"
  2736. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/http"
  2737. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/https"
  2738. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/mirror"
  2739. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/rred"
  2740. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/rsh"
  2741. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/store"
  2742. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/planners/apt"
  2743. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/solvers/apt"
  2744. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/solvers/dump"
  2745. initDebStructure
  2746. make -j8 DESTDIR="$BUILD_ROOT/$WORKING_DIR/deb" install
  2747. #lzma conflicts with built in libraries we make -j8 an extra copy of our version of lzma in the xz build process
  2748. #here we change libapt-pkg*.dylib to look for this version instead
  2749. #if we do not do this, apt-get will fail from our helper tool
  2750. install_name_tool -change /usr/lib/liblzma.5.dylib /usr/local/lib/liblzma.5.dylib deb/$ROOT_PREFIX/lib/libapt-pkg.5.0.1.dylib
  2751. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/apt"
  2752. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/apt-cache"
  2753. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/apt-cdrom"
  2754. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/apt-config"
  2755. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/apt-ftparchive"
  2756. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/apt-get"
  2757. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/apt-mark"
  2758. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/apt-sortpkgs"
  2759. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libapt-inst.2.0.0.dylib"
  2760. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libapt-pkg.5.0.1.dylib"
  2761. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/lib/libapt-private.0.0.0.dylib"
  2762. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/apt-helper"
  2763. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/methods/cdrom"
  2764. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/methods/copy"
  2765. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/methods/file"
  2766. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/methods/ftp"
  2767. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/methods/gpgv"
  2768. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/methods/http"
  2769. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/methods/https"
  2770. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/methods/mirror"
  2771. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/methods/rred"
  2772. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/methods/rsh"
  2773. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/methods/store"
  2774. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/planners/apt"
  2775. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/solvers/apt"
  2776. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/libexec/apt/solvers/dump"
  2777. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2778. echo "Priority: standard" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2779. echo "Section: Packaging" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2780. #echo "Installed-Size: 724" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2781. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2782. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2783. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2784. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2785. echo "Depends: sed" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2786. echo "Description: the advanced packaging tool from Debian" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2787. echo "Name: APT 0.7 Strict" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2788. echo "Homepage: https://wiki.debian.org/Apt" >> deb/DEBIAN/control
  2789. #Build the dev deb
  2790. cat "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control" | sed "s|^Package: $PKG_NAME|Package: $PKG_NAME-dev|" | sed 's|^Priority: .*|Priority: optional|' | sed "s|^Depends: .*|Depends: $PKG_NAME|" | sed '/^Pre-Depends: /d' | sed 's|^Section: .*|Section: Development|' >> "$BUILD_ROOT/$WORKING_DIR/deb-dev/DEBIAN/control"
  2791. mkdir -p "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2792. mv "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/include" "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX/"
  2793. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  2794. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/etc"
  2795. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX"
  2796. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb/var"
  2797. sudo chown -R root:wheel "$BUILD_ROOT/$WORKING_DIR/deb-dev/$ROOT_PREFIX"
  2798. dpkg -b deb
  2799. mv deb.deb "$BUILD_ROOT/${PKG_NAME}_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2800. dpkg -b deb-dev
  2801. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2802. createListFile
  2803. cd "$BUILD_ROOT"
  2804. }
  2805. buildAPTAndDependencies() {
  2806. notifyProgress "Building gpg-error"
  2807. buildGpgError
  2808. notifyProgress "Building gcrypt"
  2809. buildGcrypt
  2810. notifyProgress "Building KSBA"
  2811. buildKSBA
  2812. notifyProgress "Building npth"
  2813. buildNpth
  2814. notifyProgress "Building Assuan"
  2815. buildAssuan
  2816. notifyProgress "Building ntbtls"
  2817. buildNtbtls
  2818. notifyProgress "Building gpg"
  2819. buildGpg
  2820. notifyProgress "Building apt"
  2821. buildAPT
  2822. }
  2823. #===============
  2824. #Dead Packages
  2825. #---------------
  2826. downloadGnuTLS() {
  2827. #http://gnu.mirrors.pair.com/gnutls/gnutls-3.1.5.tar.xz
  2828. if [ ! -e gnutls-3.1.5.tar.xz ]; then
  2829. echo "Downloading gnutls-3.1.5.tar.xz"
  2830. curl -LO http://gnu.mirrors.pair.com/gnutls/gnutls-3.1.5.tar.xz
  2831. curl -LO http://gnu.mirrors.pair.com/gnutls/gnutls-3.1.5.tar.xz.sig
  2832. checkPGPSig gnutls-3.1.5.tar.xz.sig gnutls-3.1.5.tar.xz
  2833. else
  2834. echo "Using existing gnutls"
  2835. fi
  2836. rm -rf gnutls-3.1.5
  2837. tar xJvf gnutls-3.1.5.tar.xz
  2838. }
  2839. buildGnuTLS() {
  2840. pthname="gnutls-3.1.5"
  2841. downloadGnuTLS
  2842. cd $pthname
  2843. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix=/$ROOT_PREFIX/ --host=arm-apple-darwin
  2844. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' config.h.in
  2845. make clean
  2846. make -j8 DESTDIR="$SKEL_PREFIX" install
  2847. make clean
  2848. mkdir deb
  2849. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix=/$ROOT_PREFIX/ --host=arm-apple-darwin
  2850. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' config.h.in
  2851. make -j8 DESTDIR="$BUILD_ROOT/$pthname/deb" install
  2852. mkdir -p deb/DEBIAN
  2853. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2854. echo "Priority: optional" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2855. echo "Section: Development" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2856. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2857. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2858. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2859. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2860. #echo "Depends: grep, sed" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2861. echo "Description: portable threading library used by X" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2862. echo "Name: The New GNU Portable Threads Library" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2863. echo "Homepage: https://www.gnupg.org/software/npth" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2864. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  2865. dpkg -b deb
  2866. mv deb.deb "$BUILD_ROOT/gnutls-3.5.1-1_${PLATFORM_LOWER}-$ARCH.deb"
  2867. dpkg -b deb-doc
  2868. mv deb-doc.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-doc_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2869. dpkg -b deb-dev
  2870. mv deb-dev.deb "$BUILD_ROOT/extra_pkg/${PKG_NAME}-dev_${PKG_VERSION}_${PLATFORM_LOWER}-$ARCH.deb"
  2871. cd ..
  2872. }
  2873. downloadGzip() {
  2874. if [ ! -e gzip-1.8.tar.xz]; then
  2875. echo "Downloading gzip-1.8.tar.xz"
  2876. curl -LO http://mirror.keystealth.org/gnu/gzip/gzip-1.8.tar.xz
  2877. curl -LO http://mirror.keystealth.org/gnu/gzip/gzip-1.8.tar.xz.sig
  2878. checkPGPSig gzip-1.8.tar.xz.sig gzip-1.8.tar.xz
  2879. else
  2880. echo "Using existing gzip"
  2881. fi
  2882. rm -rf gzip-1.8
  2883. tar xJvf gzip-1.8.tar.xz
  2884. }
  2885. buildGzip() {
  2886. downloadGzip
  2887. cd gzip-1.8
  2888. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix=/$ROOT_PREFIX/ --host=arm-apple-darwin
  2889. make -j8 DESTDIR=$SKEL_PREFIX install
  2890. initDebStructure
  2891. CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH" LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH" ./configure --prefix=/$ROOT_PREFIX --host=arm-apple-darwin
  2892. make -j8 DESTDIR=$BUILD_ROOT/gzip-1.8/deb install
  2893. mkdir -p deb/DEBIAN
  2894. echo "Package: $PKG_NAME" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2895. echo "Priority: required" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2896. echo "Section: Archiving" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2897. #echo "Installed-Size: 724" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2898. echo "$MAINTAINER" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2899. echo "Architecture: $PLATFORM_LOWER-$ARCH" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2900. echo "Version: $PKG_VERSION" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2901. echo "Pre-Depends: dpkg (>= 1.14.25-8)" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2902. #echo "Depends: grep, sed" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2903. echo "Description: the standard Unix compression algorithm" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2904. #echo "Name: Diff Utilities" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2905. echo "Homepage: http://www.gzip.org/" >> "$BUILD_ROOT/$WORKING_DIR/deb/DEBIAN/control"
  2906. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/cmp"
  2907. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/diff"
  2908. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/diff3"
  2909. codesign "$BUILD_ROOT/$WORKING_DIR/deb/$ROOT_PREFIX/bin/sdiff"
  2910. find "$BUILD_ROOT/$WORKING_DIR/deb/" -type f -name '*.a' -delete
  2911. dpkg -b deb
  2912. mv deb.deb "$BUILD_ROOT/gzip-1.8-1_${PLATFORM_LOWER}-$ARCH.deb"
  2913. createListFile
  2914. cd "$BUILD_ROOT"
  2915. }
  2916. ######################################################################################
  2917. # can download and repackage substrate (mostly, still may need a modified extrainst_ script)
  2918. installSubstrate() {
  2919. if [ ! -e mobilesubstrate_0.9.6301_iphoneos-arm.deb ]; then
  2920. curl -LO http://apt.saurik.com/debs/com.saurik.substrate.safemode_0.9.6001_iphoneos-arm.deb
  2921. checkSHA256 com.saurik.substrate.safemode_0.9.6001_iphoneos-arm.deb 86515cb9f6832247dbeae8427b996099dc8759bb1ef1d719c293123f2f531ee1
  2922. curl -LO http://apt.saurik.com/debs/mobilesubstrate_0.9.6301_iphoneos-arm.deb
  2923. checkSHA256 mobilesubstrate_0.9.6301_iphoneos-arm.deb 8dc91a066f088632409fecf65613831b8d6802e3b799f2dc87563c3ea2ed06ca
  2924. fi
  2925. initDebStructure
  2926. dpkg-deb -e mobilesubstrate_0.9.6301_iphoneos-arm.deb deb/DEBIAN
  2927. dpkg-deb -x mobilesubstrate_0.9.6301_iphoneos-arm.deb deb
  2928. sed -i -- "s|iphoneos-arm|${PLATFORM_LOWER}-$ARCH|" deb/DEBIAN/control
  2929. createListFile mobilesubstrate
  2930. dpkg -b deb
  2931. mv deb.deb "mobilesubstrate_0.9.6301_${PLATFORM_LOWER}-$ARCH.deb"
  2932. dpkg-deb -e com.saurik.substrate.safemode_0.9.6001_iphoneos-arm.deb deb/DEBIAN
  2933. initDebStructure
  2934. dpkg-deb -x com.saurik.substrate.safemode_0.9.6001_iphoneos-arm.deb deb
  2935. sed -i -- "s|iphoneos-arm|${PLATFORM_LOWER}-$ARCH|" deb/DEBIAN/control
  2936. createListFile com.saurik.substrate.safemode
  2937. dpkg -b deb
  2938. mv deb.deb "com.saurik.substrate.safemode_0.9.6001_${PLATFORM_LOWER}-$ARCH.deb"
  2939. rm mobilesubstrate_0.9.6301_iphoneos-arm.deb com.saurik.substrate.safemode_0.9.6001_iphoneos-arm.deb
  2940. dpkg-deb -x "com.saurik.substrate.safemode_0.9.6001_${PLATFORM_LOWER}-$ARCH.deb" "$SKEL_PREFIX/"
  2941. dpkg-deb -x "mobilesubstrate_0.9.6301_${PLATFORM_LOWER}-$ARCH.deb" "$SKEL_PREFIX/"
  2942. #dpkg-deb -x com.saurik.substrate.safemode_0.9.6001_iphoneos-arm.deb
  2943. }
  2944. #main functions
  2945. #main
  2946. #Entry Point
  2947. echo "Cleaning the slate"
  2948. rm -rf skel extra_pkg
  2949. mkdir -p skel/etc
  2950. mkdir extra_pkg
  2951. # Ensure our SDK has all the required "extras" installed/setup
  2952. prepSDK
  2953. #Begin Building
  2954. #DO NOT BUILD THE 11 UTILS IN UNTIL YOU ARE BUILDING EXPLICITLY FOR 11+
  2955. #/bin/bash exists on 9 and 10 and if overwritten without unthether will likely brick.
  2956. if [ "$BUILD_BASH" == "true" ]; then
  2957. buildBashAndFriends
  2958. fi
  2959. buildBasicUtils
  2960. buildDPKGAndDependencies
  2961. buildAPTAndDependencies
  2962. #installSubstrate
  2963. #rm -rf deb
  2964. #mkdir -p deb/DEBIAN
  2965. #dpkg-deb -x nitoTVLatest.deb deb
  2966. #dpkg-deb -e nitoTVLatest.deb deb/DEBIAN
  2967. #createListFile "com.nito.nitoTV4"
  2968. #dpkg-deb -x nitoTVLatest.deb "$SKEL_PREFIX"
  2969. createStatusFile
  2970. #clean out frivolous stuff to slim skel down to a reasonable size
  2971. find "$SKEL_PREFIX" -type f -name .DS_Store -delete
  2972. mkdir -p "$SKEL_PREFIX/private"
  2973. mv "$SKEL_PREFIX/etc" "$SKEL_PREFIX/private/"
  2974. mv "$SKEL_PREFIX/var" "$SKEL_PREFIX/private/"
  2975. #clean out symbolic links that you don't want to overwrite
  2976. unlink "$SKEL_PREFIX/$ROOT_PREFIX/lib/liblzma.dylib"
  2977. unlink "$SKEL_PREFIX/$ROOT_PREFIX/lib/libz.1.dylib"
  2978. unlink "$SKEL_PREFIX/$ROOT_PREFIX/lib/libz.dylib"
  2979. rm "$SKEL_PREFIX/$ROOT_PREFIX/lib/libz.1.2.11.dylib"
  2980. # Get rid of the docs
  2981. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/docs"
  2982. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/doc"
  2983. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/info"
  2984. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/man"
  2985. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/man"
  2986. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/gnupg" #TODO: See if the keys in this folder are needed
  2987. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/readline"
  2988. # Get rid of dev stuff
  2989. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/include"
  2990. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/aclocal"
  2991. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/pkgconfig"
  2992. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/common-lisp"
  2993. # remove all the static and libtool libraries from the bootstrap, they take up a LOT of space
  2994. cd "$SKEL_PREFIX/$ROOT_PREFIX/lib"
  2995. rm *.a
  2996. rm *.la
  2997. rmdir "$SKEL_PREFIX/$ROOT_PREFIX/var"
  2998. #Get rid of non-skel packages which were needed to compile
  2999. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-error-config"
  3000. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/libgcrypt-config"
  3001. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/lib/pkgconfig"
  3002. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/curl-config"
  3003. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/ncurses6-config"
  3004. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/npth-config"
  3005. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/ntbtls-config"
  3006. # for getting permissions right, try to mimic them as closely as possible to the default ones
  3007. # Still need to do this for debs, but oh well. We just won't use the yet :P
  3008. sudo chown -R root:wheel "$SKEL_PREFIX/$ROOT_PREFIX"
  3009. sudo chown root:admin "$SKEL_PREFIX/private"
  3010. #sudo chown root:admin "$SKEL_PREFIX/Applications"
  3011. #sudo chown -R root:wheel "$SKEL_PREFIX/Library"
  3012. sudo chown -R root:wheel "$SKEL_PREFIX/private/etc"
  3013. sudo chown -R root:wheel "$SKEL_PREFIX/private/var"
  3014. #sudo chmod 6755 "$SKEL_PREFIX/usr/bin/nitoHelper"
  3015. #sudo chmod 6755 "$SKEL_PREFIX/usr/bin/nitoUpdate"
  3016. rm -rf skel.tgz
  3017. cd "$SKEL_PREFIX"
  3018. #sudo tar cpz -P --exclude .DS_Store -f ../skel.tgz Applications usr private Library
  3019. sudo tar cpz -P --exclude .DS_Store -f ../skel.tgz usr private
  3020. cd "$BUILD_ROOT"
  3021. #reset trap
  3022. trap - INT TERM EXIT
  3023. ls *.deb
  3024. echo "Done"