the_memo.sh 171 KB

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