the_memo2.sh 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865
  1. #!/bin/bash
  2. BUILD_ROOT="$(pwd)"
  3. ROOT_LOG_FOLDER="$BUILD_ROOT/Logs"
  4. VERIFY="false"
  5. PLATFORM="AppleTVOS"
  6. PLATFORM_LOWER="appletvos"
  7. SDK_VERSION="$(xcrun --show-sdk-version --sdk $PLATFORM_LOWER)"
  8. ROOT_PREFIX="fs/jb/usr"
  9. SKEL_PREFIX="$BUILD_ROOT/skel"
  10. ALREADY_BUILT="$BUILD_ROOT/tracked"
  11. CLANG_PATH="$(xcrun -f clang)"
  12. CLANGPLUS_PATH="$(xcrun -f clang++)"
  13. MIN_VERSION="-mappletvos-version-min=13.0"
  14. ARCH="arm64"
  15. SDK_PATH="$(xcrun --sdk $PLATFORM_LOWER --show-sdk-path)"
  16. SPEAK="false"
  17. EXTRA_LD_FLAGS=""
  18. HOST="aarch64"
  19. FORCE="false"
  20. LOG_VERBOSE=""
  21. OPEN_LOG="false"
  22. TRIM="false"
  23. CREATE_STATUS="false"
  24. usage() {
  25. echo "usage: $0 [-s|--speak-updates] [-V|--verify] [-v|--verbose] [-f|--force] [-o|--open-active-log] [-t|--trim-bootstrap] [-c|--create-status]"
  26. trap - INT TERM EXIT
  27. exit 0
  28. }
  29. while test $# -gt 0; do
  30. case "$1" in
  31. -h|--help)
  32. usage
  33. ;;
  34. -v|--verbose)
  35. LOG_VERBOSE="verbose"
  36. shift
  37. ;;
  38. -V|--verify)
  39. VERIFY="true"
  40. #echo "Working without verifying packages..."
  41. #echo "YOU BETTER KNOW WHAT YOU'RE DOING"
  42. #sleep 2 #Give them a couple seconds to think about what they're about to do
  43. shift
  44. ;;
  45. -f|--force)
  46. FORCE="true"
  47. shift
  48. ;;
  49. -s|--speak-updates|--speak)
  50. SPEAK="true"
  51. shift
  52. ;;
  53. -t|--trim-bootstrap|--trim)
  54. TRIM="true"
  55. shift
  56. ;;
  57. -o|--open-log|--open)
  58. OPEN_LOG="true"
  59. shift
  60. ;;
  61. -c|--create-status|--create)
  62. CREATE_STATUS="true"
  63. shift
  64. ;;
  65. *)
  66. break
  67. ;;
  68. esac
  69. done
  70. patchAvailability() {
  71. PATCH_FILE=$1
  72. sed -i -- "s|__TVOS_PROHIBITED||" "$PATCH_FILE"
  73. }
  74. # for some reason the files signed this way don't run on tvOS 9 anymore
  75. codesign() {
  76. BIN=$1
  77. ENT=$2
  78. if [[ ! -z $ENT ]]; then
  79. ldid -S$ENT $BIN
  80. else
  81. ldid -S $BIN
  82. fi
  83. }
  84. printPreprocessor() {
  85. $(xcrun --sdk $PLATFORM_LOWER --find clang) -E - - -dM < /dev/null
  86. }
  87. sayIfVerbal() {
  88. if [[ $SPEAK == "true" ]]; then
  89. say $1
  90. fi
  91. }
  92. splitName() {
  93. IN=$1
  94. i=0
  95. while [ "$IN" != "$iter" ] ;do
  96. # extract the substring from start of string up to delimiter.
  97. iter=${IN%%-*}
  98. # delete this first "element" AND next separator, from $IN.
  99. IN="${IN#$iter-}"
  100. ((i=i+1))
  101. if [[ $i == 1 ]]; then
  102. echo "set RAW_NAME var to $iter"
  103. RAW_NAME=$iter
  104. elif [[ $i == 2 ]]; then
  105. VERSION=$iter
  106. echo "set VERSION var to $iter"
  107. fi
  108. #echo $iter at $i
  109. done
  110. }
  111. spinner() {
  112. local pid=$!
  113. local delay=0.75
  114. local spinstr='|/-\'
  115. while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
  116. local temp=${spinstr#?}
  117. printf " [%c]" "$spinstr"
  118. local spinstr=$temp${spinstr%"$temp"}
  119. sleep $delay
  120. printf "\b\b\b\b\b"
  121. done
  122. wait $pid
  123. return $?
  124. }
  125. setBuilt() {
  126. DIRECTORY_NAME=$1
  127. FULL=$ALREADY_BUILT/$DIRECTORY_NAME
  128. touch "$FULL"
  129. }
  130. checkStatus() {
  131. PKG=$1
  132. STATUS=$2
  133. FINISHED=$3
  134. if [[ $STATUS != 0 ]]; then
  135. echo "configure or make $PKG returned with non zero: $STATUS check $LOG_FILE for errors!"
  136. sayIfVerbal "configure or make of $PKG returned with non zero: $STATUS"
  137. open $LOG_FILE
  138. #printPreprocessor
  139. #/bin/bash ./finish.sh
  140. exit $STATUS
  141. else
  142. #echo "make returned with zero"
  143. if [[ $FINISHED == "true" ]]; then
  144. setBuilt $PKG
  145. fi
  146. fi
  147. }
  148. checkBuilt() {
  149. if [[ "$FORCE" == "true" ]]; then
  150. return 0
  151. fi
  152. DIRECTORY_NAME=$1
  153. FULL=$ALREADY_BUILT/$DIRECTORY_NAME
  154. if [[ ! -f $FULL ]]; then
  155. return 0
  156. fi
  157. return 1
  158. }
  159. notifyProgress() {
  160. echo "$1"
  161. sayIfVerbal "$1"
  162. }
  163. checkSHA256() {
  164. if [[ "$VERIFY" == "true" ]]; then
  165. FILE="$1"
  166. VALID_SHA="$2"
  167. VERIFY_TEST="`shasum -a 256 $FILE | cut -c 1-64`"
  168. if [[ "$VERIFY_TEST" != "$VALID_SHA" ]]; then
  169. echo "Failed to validate SHA256 signature for $FILE"
  170. trap - INT TERM EXIT
  171. exit 127
  172. fi
  173. echo "*** VALID SIGNATURE"
  174. fi
  175. }
  176. checkPGPSig() {
  177. if [[ "$VERIFY" == "true" ]]; then
  178. SIGFILE="$1"
  179. FILE="$2"
  180. local VERIFY_TEST="`gpg --verify $SIGFILE $FILE 2>&1 | grep 'Good signature'`"
  181. if [[ "$VERIFY_TEST" == "" ]]; then
  182. echo "Failed to validate PGP signature for $FILE"
  183. trap - INT TERM EXIT
  184. exit 127
  185. fi
  186. echo "*** VALID SIGNATURE"
  187. fi
  188. }
  189. exportBuildScript() {
  190. EXPORT_FILE="$1"
  191. echo -e "#!/bin/bash" > $EXPORT_FILE
  192. echo -e "\nexport CC=$(xcrun --sdk $PLATFORM_LOWER --find clang)" >> $EXPORT_FILE
  193. echo -e "export CXX=$(xcrun --sdk $PLATFORM_LOWER --find clang++)" >> $EXPORT_FILE
  194. echo -e "export LD=$(xcrun --sdk $PLATFORM_LOWER --find ld)" >> $EXPORT_FILE
  195. echo -e "export AR=$(xcrun --sdk $PLATFORM_LOWER --find ar)" >> $EXPORT_FILE
  196. echo -e "export 'CPP=$(xcrun --sdk $PLATFORM_LOWER -f clang) -E -D__arm__ -I$SDKROOT/usr/include' " >> $EXPORT_FILE
  197. echo -e "export 'CXXCPP=$(xcrun --sdk $PLATFORM_LOWER -f clang++) -E -D__arm__ -I$SDKROOT/usr/include' " >> $EXPORT_FILE
  198. echo -e "export RANLIB=$(xcrun --sdk $PLATFORM_LOWER --find ranlib)" >> $EXPORT_FILE
  199. echo -e "export LIBTOOL=$(xcrun --sdk $PLATFORM_LOWER --find libtool)" >> $EXPORT_FILE
  200. echo -e "export STRIP=$(xcrun --sdk $PLATFORM_LOWER --find strip)" >> $EXPORT_FILE
  201. echo -e "export 'CFLAGS=-arch arm64 -isysroot $SDKROOT -m$PLATFORM_LOWER-version-min=$VER_MIN -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -DARM -DARM64 -D__arm64__ -Wno-unused-command-line-argument'" >> $EXPORT_FILE
  202. echo -e "export 'CXXFLAGS=-arch arm64 -isysroot $SDKROOT -m$PLATFORM_LOWER-version-min=$VER_MIN -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -DARM -DARM64 -D__arm64__ -Wno-unused-command-line-argument'" >> $EXPORT_FILE
  203. echo -e "export 'LDFLAGS=-arch arm64 -isysroot $SDKROOT -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ $EXTRA_LD_FLAGS'" >> $EXPORT_FILE
  204. echo -e "./configure --prefix=/$ROOT_PREFIX --host=$HOST-apple-darwin --target=$HOST-apple-darwin --disable-dependency-tracking --without-manpages --disable-tests $EXTRA_CFG" >> $EXPORT_FILE
  205. echo -e "make -j8 DESTDIR="$SKEL_PREFIX" install" >> $EXPORT_FILE
  206. chmod +x $EXPORT_FILE
  207. }
  208. buildProduct() {
  209. PKG_NAME=$1
  210. EXTRA_CFG=$2
  211. LOG_FILE="$ROOT_LOG_FOLDER/$PKG_NAME.log"
  212. #exit 2
  213. touch $LOG_FILE
  214. echo $PKG_NAME
  215. echo "build output going to: " $LOG_FILE
  216. echo $EXTRA_CFG
  217. local SDKROOT=$(xcrun --sdk $PLATFORM_LOWER --show-sdk-path)
  218. local VER_MIN=13.0
  219. export CC=$(xcrun --sdk $PLATFORM_LOWER --find clang)
  220. export CXX=$(xcrun --sdk $PLATFORM_LOWER --find clang++)
  221. export LD=$(xcrun --sdk $PLATFORM_LOWER --find ld)
  222. export AR=$(xcrun --sdk $PLATFORM_LOWER --find ar)
  223. #export CPP="$(xcrun --sdk $PLATFORM_LOWER -f clang) -E -D__arm__ -D__arm64__ -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -I$SDKROOT/usr/include -arch arm64"
  224. #export CXXCPP="$(xcrun --sdk $PLATFORM_LOWER -f clang++) -E -D__arm__ -D__arm64__ -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -I$SDKROOT/usr/include -arch arm64"
  225. export CPP="$(xcrun --sdk $PLATFORM_LOWER -f clang) -E -D__arm__ -I$SDKROOT/usr/include"
  226. export CXXCPP="$(xcrun --sdk $PLATFORM_LOWER -f clang++) -E -D__arm__ -I$SDKROOT/usr/include"
  227. export RANLIB=$(xcrun --sdk $PLATFORM_LOWER --find ranlib)
  228. export LIBTOOL=$(xcrun --sdk $PLATFORM_LOWER --find libtool)
  229. export STRIP=$(xcrun --sdk $PLATFORM_LOWER --find strip)
  230. export CFLAGS="-arch arm64 -isysroot $SDKROOT -m$PLATFORM_LOWER-version-min=$VER_MIN -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -DARM -DARM64 -D__arm64__ -Wno-unused-command-line-argument"
  231. export CXXFLAGS=$CFLAGS
  232. export LDFLAGS="-arch arm64 -isysroot $SDKROOT -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ $EXTRA_LD_FLAGS"
  233. exportBuildScript "finish.sh"
  234. notifyProgress "configuring $PKG_NAME"
  235. if [[ $LOG_VERBOSE == "verbose"* ]]; then
  236. ./configure --prefix=/$ROOT_PREFIX --host=$HOST-apple-darwin --target=$HOST-apple-darwin --disable-dependency-tracking --without-manpages --disable-tests $EXTRA_CFG | tee "${LOG_FILE}"
  237. EC=$(grep "configure: error:" -i "${LOG_FILE}" -c)
  238. checkStatus $PKG_NAME $EC "false"
  239. else
  240. (./configure --prefix=/$ROOT_PREFIX --host=$HOST-apple-darwin --target=$HOST-apple-darwin --disable-dependency-tracking --without-manpages --disable-tests $EXTRA_CFG > "${LOG_FILE}" 2>&1)
  241. checkStatus $PKG_NAME $? "false"
  242. if [[ $OPEN_LOG == "true" ]]; then
  243. open "${LOG_FILE}"
  244. fi
  245. fi
  246. notifyProgress "making $PKG_NAME"
  247. echo -e "\n\nPOST CONFIGURE\n\n" >> "$LOG_FILE"
  248. if [[ $LOG_VERBOSE == "verbose"* ]]; then
  249. make -j8 DESTDIR="$SKEL_PREFIX" install | tee -a "${LOG_FILE}"
  250. EC=$(grep "fatal error:" -i "${LOG_FILE}" -c)
  251. checkStatus $PKG_NAME $EC "true"
  252. else
  253. (make -j8 DESTDIR="$SKEL_PREFIX" install >> "${LOG_FILE}" 2>&1) #& spinner
  254. checkStatus $PKG_NAME $? "true"
  255. fi
  256. cd "$BUILD_ROOT"
  257. }
  258. downloadProduct() {
  259. cd "$BUILD_ROOT"
  260. DOWNLOAD_LINK=$1
  261. FILENAME=$(basename $DOWNLOAD_LINK)
  262. SIG_DOWNLOAD=$2
  263. RAW_NAME=$3
  264. VERSION=$4
  265. FILE_EXTENSION="${FILENAME##*.}"
  266. DIRECTORY_NAME="$RAW_NAME-$VERSION"
  267. SIG_FILE=$(basename $SIG_DOWNLOAD)
  268. if [[ ! -e $FILENAME ]]; then
  269. echo "Downloading $FILENAME"
  270. curl -LO $DOWNLOAD_LINK
  271. if [[ ! $SIG_FILE == "-" ]]; then
  272. curl -LO $SIG_DOWNLOAD
  273. checkPGPSig $SIG_FILE $FILENAME
  274. fi
  275. else
  276. echo "Using existing $FILENAME"
  277. fi
  278. rm -rf $DIRECTORY_NAME
  279. if [[ $FILE_EXTENSION == "gz" ]]; then
  280. echo "is gz file!"
  281. tar xzvf $FILENAME
  282. fi
  283. if [[ $FILE_EXTENSION == "xz" ]]; then
  284. echo "is lzma file!"
  285. tar xJvf $FILENAME
  286. fi
  287. if [[ $FILE_EXTENSION == "bz2" ]]; then
  288. echo "is bzip2 file!"
  289. tar xjvf $FILENAME
  290. fi
  291. WORKING_DIR=$DIRECTORY_NAME
  292. PKG_VERSION=$VERSION-1
  293. cd "$WORKING_DIR"
  294. #buildProduct
  295. }
  296. patchBash() {
  297. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  298. sed -i -- 's|^#undef HAVE_SYS_SIGLIST$|#define HAVE_SYS_SIGLIST 1|' config.h.in
  299. fi
  300. }
  301. patchDpkg() {
  302. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  303. sed -i -- "s|#define ARCHITECTURE \"darwin-arm64\"|#define ARCHITECTURE \"$PLATFORM_LOWER-$ARCH\"|" config.h
  304. sed -i -- "s|#define ARCHITECTURE_OS \"darwin\"|#define ARCHITECTURE_OS \"$PLATFORM_LOWER\"|" config.h
  305. sed -i -- 's|gtar|tar|' config.h
  306. fi
  307. }
  308. # DONT USE UNLESS YOU ARE ON 11+; OVERWRITE BASH (or any other apple-signed file, for that matter), LEAD TO BRICK
  309. # 10.2 and up
  310. buildBashAndFriends() {
  311. notifyProgress "Building readline"
  312. buildReadline
  313. notifyProgress "Building ncurses"
  314. buildNcurses
  315. notifyProgress "Building bash"
  316. buildBash
  317. }
  318. buildReadline() {
  319. PKG_NAME="readline-7.0"
  320. checkBuilt $PKG_NAME
  321. if [[ $? != 0 ]]; then
  322. echo "$PKG_NAME already exists, skipping!"
  323. else
  324. echo "building $PKG_NAME..."
  325. splitName $PKG_NAME
  326. downloadProduct http://gnu.askapache.com/readline/readline-7.0.tar.gz http://gnu.askapache.com/readline/readline-7.0.tar.gz.sig $RAW_NAME $VERSION
  327. buildProduct $PKG_NAME
  328. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libhistory.7.0.dylib"
  329. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libreadline.7.0.dylib"
  330. fi
  331. }
  332. fixSystem() {
  333. FILE="$1"
  334. echo '#define PROC_PIDPATHINFO_MAXSIZE (1024)' >> "$FILE"
  335. echo 'static int file_exist(const char *filename) {' >> "$FILE"
  336. echo ' struct stat buffer;' >> "$FILE"
  337. echo ' int r = stat(filename, &buffer);' >> "$FILE"
  338. echo ' return (r == 0);' >> "$FILE"
  339. echo '}' >> "$FILE"
  340. echo '' >> "$FILE"
  341. echo 'static char *searchpath(const char *binaryname){' >> "$FILE"
  342. echo ' if (strstr(binaryname, "/") != NULL){' >> "$FILE"
  343. echo ' if (file_exist(binaryname)){' >> "$FILE"
  344. echo ' char *foundpath = malloc((strlen(binaryname) + 1) * (sizeof(char)));' >> "$FILE"
  345. echo ' strcpy(foundpath, binaryname);' >> "$FILE"
  346. echo ' return foundpath;' >> "$FILE"
  347. echo ' } else {' >> "$FILE"
  348. echo ' return NULL;' >> "$FILE"
  349. echo ' }' >> "$FILE"
  350. echo ' }' >> "$FILE"
  351. echo ' ' >> "$FILE"
  352. echo ' char *pathvar = getenv("PATH");' >> "$FILE"
  353. echo ' ' >> "$FILE"
  354. echo ' char *dir = strtok(pathvar,":");' >> "$FILE"
  355. echo ' while (dir != NULL){' >> "$FILE"
  356. echo ' char searchpth[PROC_PIDPATHINFO_MAXSIZE];' >> "$FILE"
  357. echo ' strcpy(searchpth, dir);' >> "$FILE"
  358. echo ' strcat(searchpth, "/");' >> "$FILE"
  359. echo ' strcat(searchpth, binaryname);' >> "$FILE"
  360. echo ' ' >> "$FILE"
  361. echo ' if (file_exist(searchpth)){' >> "$FILE"
  362. echo ' char *foundpath = malloc((strlen(searchpth) + 1) * (sizeof(char)));' >> "$FILE"
  363. echo ' strcpy(foundpath, searchpth);' >> "$FILE"
  364. echo ' return foundpath;' >> "$FILE"
  365. echo ' }' >> "$FILE"
  366. echo ' ' >> "$FILE"
  367. echo ' dir = strtok(NULL, ":");' >> "$FILE"
  368. echo ' }' >> "$FILE"
  369. echo ' return NULL;' >> "$FILE"
  370. echo '}' >> "$FILE"
  371. echo '' >> "$FILE"
  372. echo 'static int isShellScript(const char *path){' >> "$FILE"
  373. echo ' FILE *file = fopen(path, "r");' >> "$FILE"
  374. echo ' uint8_t header[2];' >> "$FILE"
  375. echo ' if (fread(header, sizeof(uint8_t), 2, file) == 2){' >> "$FILE"
  376. echo " if (header[0] == '#' && header[1] == '!'){" >> "$FILE"
  377. echo ' fclose(file);' >> "$FILE"
  378. echo ' return 1;' >> "$FILE"
  379. echo ' }' >> "$FILE"
  380. echo ' }' >> "$FILE"
  381. echo ' fclose(file);' >> "$FILE"
  382. echo ' return -1;' >> "$FILE"
  383. echo '}' >> "$FILE"
  384. echo '' >> "$FILE"
  385. echo 'static char *getInterpreter(char *path){' >> "$FILE"
  386. echo ' FILE *file = fopen(path, "r");' >> "$FILE"
  387. echo ' char *interpreterLine = NULL;' >> "$FILE"
  388. echo ' unsigned long lineSize = 0;' >> "$FILE"
  389. echo ' getline(&interpreterLine, &lineSize, file);' >> "$FILE"
  390. echo ' ' >> "$FILE"
  391. echo ' char *rawInterpreter = (interpreterLine+2);' >> "$FILE"
  392. echo ' rawInterpreter = strtok(rawInterpreter, " ");' >> "$FILE"
  393. echo ' rawInterpreter = strtok(rawInterpreter, "\n");' >> "$FILE"
  394. echo ' ' >> "$FILE"
  395. echo ' char *interpreter = malloc((strlen(rawInterpreter)+1) * sizeof(char));' >> "$FILE"
  396. echo ' strcpy(interpreter, rawInterpreter);' >> "$FILE"
  397. echo ' ' >> "$FILE"
  398. echo ' free(interpreterLine);' >> "$FILE"
  399. echo ' fclose(file);' >> "$FILE"
  400. echo ' return interpreter;' >> "$FILE"
  401. echo '}' >> "$FILE"
  402. echo '' >> "$FILE"
  403. echo 'static char *fixedCmd(const char *cmdStr){' >> "$FILE"
  404. echo ' char *cmdCpy = malloc((strlen(cmdStr)+1) * sizeof(char));' >> "$FILE"
  405. echo ' strcpy(cmdCpy, cmdStr);' >> "$FILE"
  406. echo ' ' >> "$FILE"
  407. echo ' char *cmd = strtok(cmdCpy, " ");' >> "$FILE"
  408. echo ' ' >> "$FILE"
  409. echo ' uint8_t size = strlen(cmd) + 1;' >> "$FILE"
  410. echo ' ' >> "$FILE"
  411. echo ' char *args = cmdCpy + size;' >> "$FILE"
  412. echo ' if ((strlen(cmdStr) - strlen(cmd)) == 0)' >> "$FILE"
  413. echo ' args = NULL;' >> "$FILE"
  414. echo ' ' >> "$FILE"
  415. echo ' char *abs_path = searchpath(cmd);' >> "$FILE"
  416. echo ' if (abs_path){' >> "$FILE"
  417. echo ' int isScript = isShellScript(abs_path);' >> "$FILE"
  418. echo ' if (isScript == 1){' >> "$FILE"
  419. echo ' char *interpreter = getInterpreter(abs_path);' >> "$FILE"
  420. echo ' ' >> "$FILE"
  421. echo ' uint8_t commandSize = strlen(interpreter) + 1 + strlen(abs_path);' >> "$FILE"
  422. echo ' ' >> "$FILE"
  423. echo ' if (args){' >> "$FILE"
  424. echo ' commandSize += 1 + strlen(args);' >> "$FILE"
  425. echo ' }' >> "$FILE"
  426. echo ' ' >> "$FILE"
  427. echo ' char *rawCommand = malloc(sizeof(char) * (commandSize + 1));' >> "$FILE"
  428. echo ' strcpy(rawCommand, interpreter);' >> "$FILE"
  429. echo ' strcat(rawCommand, " ");' >> "$FILE"
  430. echo ' strcat(rawCommand, abs_path);' >> "$FILE"
  431. echo ' ' >> "$FILE"
  432. echo ' if (args){' >> "$FILE"
  433. echo ' strcat(rawCommand, " ");' >> "$FILE"
  434. echo ' strcat(rawCommand, args);' >> "$FILE"
  435. echo ' }' >> "$FILE"
  436. echo ' rawCommand[(commandSize)+1] = "\0";' >> "$FILE"
  437. echo ' ' >> "$FILE"
  438. echo ' free(interpreter);' >> "$FILE"
  439. echo ' free(abs_path);' >> "$FILE"
  440. echo ' free(cmdCpy);' >> "$FILE"
  441. echo ' ' >> "$FILE"
  442. echo ' return rawCommand;' >> "$FILE"
  443. echo ' } else {' >> "$FILE"
  444. echo ' uint8_t commandSize = strlen(abs_path);' >> "$FILE"
  445. echo ' ' >> "$FILE"
  446. echo ' if (args){' >> "$FILE"
  447. echo ' commandSize += 1 + strlen(args);' >> "$FILE"
  448. echo ' }' >> "$FILE"
  449. echo ' ' >> "$FILE"
  450. echo ' char *rawCommand = malloc(sizeof(char) * (commandSize + 1));' >> "$FILE"
  451. echo ' strcat(rawCommand, abs_path);' >> "$FILE"
  452. echo ' ' >> "$FILE"
  453. echo ' if (args){' >> "$FILE"
  454. echo ' strcat(rawCommand, " ");' >> "$FILE"
  455. echo ' strcat(rawCommand, args);' >> "$FILE"
  456. echo ' }' >> "$FILE"
  457. echo ' rawCommand[(commandSize)+1] = "\0";' >> "$FILE"
  458. echo ' ' >> "$FILE"
  459. echo ' free(abs_path);' >> "$FILE"
  460. echo ' free(cmdCpy);' >> "$FILE"
  461. echo ' ' >> "$FILE"
  462. echo ' return rawCommand;' >> "$FILE"
  463. echo ' }' >> "$FILE"
  464. echo ' }' >> "$FILE"
  465. echo ' return cmdCpy;' >> "$FILE"
  466. echo '}' >> "$FILE"
  467. echo '' >> "$FILE"
  468. echo 'int RunCmd(const char *cmd) {' >> "$FILE"
  469. echo ' pid_t pid;' >> "$FILE"
  470. echo ' char *rawCmd = fixedCmd(cmd);' >> "$FILE"
  471. echo ' char *argv[] = {"sh", "-c", (char*)rawCmd, NULL};' >> "$FILE"
  472. echo ' int status;' >> "$FILE"
  473. echo ' status = posix_spawn(&pid, "/fs/jb/bin/sh", NULL, NULL, argv, environ);' >> "$FILE"
  474. echo ' if (status == 0) {' >> "$FILE"
  475. echo ' if (waitpid(pid, &status, 0) == -1) {' >> "$FILE"
  476. echo ' perror("waitpid");' >> "$FILE"
  477. echo ' }' >> "$FILE"
  478. echo ' } else {' >> "$FILE"
  479. echo ' printf("posix_spawn: %s\n", strerror(status));' >> "$FILE"
  480. echo ' }' >> "$FILE"
  481. echo ' free(rawCmd);' >> "$FILE"
  482. echo ' return status;' >> "$FILE"
  483. echo '}' >> "$FILE"
  484. }
  485. patchNcurses() {
  486. PKG_NAME=$1
  487. echo "patchNCurses PKG_NAME: $PKG_NAME"
  488. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  489. if [[ "$PKG_VERSION" == "6.0-1" ]]; then
  490. # LEFT ERROR ON environ)' no ;
  491. # For some reason, building never fails on the error...
  492. # But still, tput is in /usr/bin... so.... ??
  493. cat progs/tput.c | head -n 55 > tput.patched.c
  494. echo "#include <stdint.h>" >> tput.patched.c
  495. echo "#include <stdio.h>" >> tput.patched.c
  496. echo "#include <stdlib.h>" >> tput.patched.c
  497. echo "#include <spawn.h>" >> tput.patched.c
  498. echo "#include <sys/wait.h>" >> tput.patched.c
  499. echo "" >> tput.patched.c
  500. echo "extern char **environ;" >> tput.patched.c
  501. echo "" >> tput.patched.c
  502. cat progs/tput.c | tail -n 350 | head -n 50 >> tput.patched.c
  503. fixSystem "tput.patched.c"
  504. cat progs/tput.c | tail -n 301 | sed 's/system(init_prog)/RunCmd(init_prog)/g' >> tput.patched.c
  505. cp tput.patched.c progs/tput.c
  506. fi
  507. fi
  508. #sed -i -- 's|#include <stdlib.h>|\n#if !defined(__arm64__)\n#define __arm64__\n#endif\n\n#include <stdlib.h>|' ncurses/build.priv.h
  509. # CURSES_PRIV="$SKEL_PREFIX/$ROOT_PREFIX/include/curses.priv.h"
  510. # FIFO="$SKEL_PREFIX/$ROOT_PREFIX/include/fifo_defs.h"
  511. # BUILD_P="$SKEL_PREFIX/$ROOT_PREFIX/include/build.priv.h"
  512. # if [[ ! -f "$CURSES_PRIV" ]]; then
  513. # cp $BUILD_ROOT/$1/ncurses/*.h "$SKEL_PREFIX/$ROOT_PREFIX/include/"
  514. #cp "$BUILD_ROOT/$1/ncurses/fifo_defs.h" "$FIFO"
  515. #cp "$BUILD_ROOT/$1/ncurses/build.priv.h" "$BUILD_P"
  516. # fi
  517. }
  518. #http://gnu.mirror.constant.com/ncurses/ncurses-6.0.tar.gz
  519. #https://git.elucubratus.com/elucubratus/elucubratus/-/raw/master/data/ncurses/ncurses_6.1+20181013.orig.tar.gz
  520. buildNcurses() {
  521. PKG_NAME="ncurses-6.1-20181013"
  522. checkBuilt $PKG_NAME
  523. if [[ $? != 0 ]]; then
  524. echo "$PKG_NAME already exists, skipping!"
  525. else
  526. echo "building $PKG_NAME..."
  527. #splitName $PKG_NAME
  528. downloadProduct https://git.elucubratus.com/elucubratus/elucubratus/-/raw/master/data/ncurses/ncurses_6.1+20181013.orig.tar.gz - ncurses 6.1-20181013
  529. patchNcurses $PKG_NAME
  530. export HOST="arm"
  531. buildProduct $PKG_NAME
  532. export HOST="aarch64"
  533. mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-captoinfo" "$SKEL_PREFIX/$ROOT_PREFIX/bin/captoinfo"
  534. mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-clear" "$SKEL_PREFIX/$ROOT_PREFIX/bin/clear"
  535. mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-infocmp" "$SKEL_PREFIX/$ROOT_PREFIX/bin/infocmp"
  536. mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-infotocap" "$SKEL_PREFIX/$ROOT_PREFIX/bin/infotocap"
  537. mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-reset" "$SKEL_PREFIX/$ROOT_PREFIX/bin/reset"
  538. mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-tabs" "$SKEL_PREFIX/$ROOT_PREFIX/bin/tabs"
  539. mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-tic" "$SKEL_PREFIX/$ROOT_PREFIX/bin/tic"
  540. mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-toe" "$SKEL_PREFIX/$ROOT_PREFIX/bin/toe"
  541. mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-tput" "$SKEL_PREFIX/$ROOT_PREFIX/bin/tput"
  542. mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-tset" "$SKEL_PREFIX/$ROOT_PREFIX/bin/tset"
  543. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/captoinfo"
  544. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/clear"
  545. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/infocmp"
  546. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/infotocap"
  547. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/reset"
  548. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tabs"
  549. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tic"
  550. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/toe"
  551. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tput"
  552. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tset"
  553. fi
  554. }
  555. #https://git.elucubratus.com/elucubratus/elucubratus/-/raw/master/data/bash/bash-5.0.tar.gz
  556. buildBash() {
  557. PKG_NAME="bash-5.0"
  558. checkBuilt $PKG_NAME
  559. if [[ $? != 0 ]]; then
  560. echo "$PKG_NAME already exists, skipping!"
  561. else
  562. echo "building $PKG_NAME..."
  563. splitName $PKG_NAME
  564. downloadProduct https://git.elucubratus.com/elucubratus/elucubratus/-/raw/master/data/bash/bash-5.0.tar.gz - $RAW_NAME $VERSION
  565. patchBash
  566. buildProduct $PKG_NAME "--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"
  567. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bash"
  568. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/basename"
  569. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/dirname"
  570. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/finfo"
  571. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/head"
  572. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/id"
  573. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/ln"
  574. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/logname"
  575. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/mkdir"
  576. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/mypid"
  577. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/pathchk"
  578. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/print"
  579. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/printenv"
  580. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/push"
  581. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/realpath"
  582. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/rmdir"
  583. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/setpgid"
  584. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/sleep"
  585. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/strftime"
  586. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/sync"
  587. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/tee"
  588. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/truefalse"
  589. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/tty"
  590. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/uname"
  591. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/unlink"
  592. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/whoami"
  593. fi
  594. }
  595. buildSed() {
  596. PKG_NAME="sed-4.4"
  597. checkBuilt $PKG_NAME
  598. if [[ $? != 0 ]]; then
  599. echo "$PKG_NAME already exists, skipping!"
  600. else
  601. echo "building $PKG_NAME..."
  602. splitName $PKG_NAME
  603. downloadProduct https://ftp.gnu.org/gnu/sed/sed-4.4.tar.xz https://ftp.gnu.org/gnu/sed/sed-4.4.tar.xz.sig $RAW_NAME $VERSION
  604. buildProduct $PKG_NAME
  605. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sed"
  606. fi
  607. }
  608. buildGrep() {
  609. PKG_NAME="grep-3.0"
  610. checkBuilt $PKG_NAME
  611. if [[ $? != 0 ]]; then
  612. echo "$PKG_NAME already exists, skipping!"
  613. else
  614. echo "building $PKG_NAME..."
  615. splitName $PKG_NAME
  616. downloadProduct https://ftp.gnu.org/gnu/grep/grep-3.0.tar.xz https://ftp.gnu.org/gnu/grep/grep-3.0.tar.xz.sig $RAW_NAME $VERSION
  617. buildProduct $PKG_NAME
  618. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/grep"
  619. fi
  620. }
  621. patchCoreutils() {
  622. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  623. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' lib/config.hin
  624. sed -i -- 's|#undef HAVE_CLOCK_SETTIME||' lib/config.hin
  625. sed -i -- 's|#undef HAVE_FDATASYNC||' lib/config.hin
  626. sed -i -- 's|# define __stpncpy stpncpy||' lib/stpncpy.c
  627. if [[ ! -d "$SKEL_PREFIX/$ROOT_PREFIX/include" ]]; then
  628. mkdir -p "$SKEL_PREFIX/$ROOT_PREFIX/include"
  629. fi
  630. if [[ ! -e "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h" ]]; then
  631. echo "#include <sys/cdefs.h>" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  632. echo "" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  633. echo "__BEGIN_DECLS" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  634. echo "extern char ***_NSGetArgv(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  635. echo "extern int *_NSGetArgc(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  636. echo "extern char ***_NSGetEnviron(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  637. echo "extern char **_NSGetProgname(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  638. echo "extern struct mach_header *_NSGetMachExecuteHeader(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  639. echo "__END_DECLS" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
  640. fi
  641. fi
  642. }
  643. buildCoreutils() {
  644. PKG_NAME="coreutils-8.9"
  645. checkBuilt $PKG_NAME
  646. if [[ $? != 0 ]]; then
  647. echo "$PKG_NAME already exists, skipping!"
  648. else
  649. echo "building $PKG_NAME..."
  650. splitName $PKG_NAME
  651. downloadProduct http://gnu.mirror.constant.com/coreutils/coreutils-8.9.tar.xz http://gnu.mirror.constant.com/coreutils/coreutils-8.9.tar.xz.sig $RAW_NAME $VERSION
  652. patchCoreutils
  653. export HOST="arm"
  654. buildProduct $PKG_NAME
  655. export HOST="aarch64"
  656. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/["
  657. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/base64"
  658. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/basename"
  659. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cat"
  660. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chcon"
  661. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chgrp"
  662. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chmod"
  663. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chown"
  664. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chroot"
  665. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cksum"
  666. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/comm"
  667. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cp"
  668. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/csplit"
  669. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cut"
  670. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/date"
  671. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dd"
  672. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/df"
  673. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dir"
  674. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dircolors"
  675. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dirname"
  676. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/du"
  677. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/echo"
  678. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/env"
  679. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/expand"
  680. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/expr"
  681. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/factor"
  682. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/false"
  683. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/fmt"
  684. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/fold"
  685. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/groups"
  686. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/head"
  687. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/hostid"
  688. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/id"
  689. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/install"
  690. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/join"
  691. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/kill"
  692. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/link"
  693. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/ln"
  694. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/logname"
  695. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/ls"
  696. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/md5sum"
  697. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mkdir"
  698. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mkfifo"
  699. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mknod"
  700. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mktemp"
  701. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mv"
  702. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nice"
  703. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nl"
  704. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nohup"
  705. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nproc"
  706. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/od"
  707. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/paste"
  708. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pathchk"
  709. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pinky"
  710. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pr"
  711. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/printenv"
  712. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/printf"
  713. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/ptx"
  714. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pwd"
  715. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/readlink"
  716. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/rm"
  717. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/rmdir"
  718. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/runcon"
  719. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/seq"
  720. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha1sum"
  721. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha224sum"
  722. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha256sum"
  723. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha384sum"
  724. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha512sum"
  725. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/shred"
  726. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/shuf"
  727. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sleep"
  728. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sort"
  729. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/split"
  730. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/stat"
  731. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/stty"
  732. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sum"
  733. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sync"
  734. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tac"
  735. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tail"
  736. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tee"
  737. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/test"
  738. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/timeout"
  739. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/touch"
  740. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tr"
  741. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/true"
  742. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/truncate"
  743. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tsort"
  744. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tty"
  745. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/uname"
  746. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/unexpand"
  747. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/uniq"
  748. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/unlink"
  749. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/uptime"
  750. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/users"
  751. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/vdir"
  752. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/wc"
  753. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/who"
  754. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/whoami"
  755. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/yes"
  756. fi
  757. }
  758. buildFindUtils() {
  759. PKG_NAME="findutils-4.6.0"
  760. checkBuilt $PKG_NAME
  761. if [[ $? != 0 ]]; then
  762. echo "$PKG_NAME already exists, skipping!"
  763. else
  764. echo "building $PKG_NAME..."
  765. splitName $PKG_NAME
  766. downloadProduct http://mirror.keystealth.org/gnu/findutils/findutils-4.6.0.tar.gz - $RAW_NAME $VERSION
  767. buildProduct $PKG_NAME
  768. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/find"
  769. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/locate"
  770. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/xargs"
  771. fi
  772. }
  773. buildDiffUtils() {
  774. PKG_NAME="diffutils-3.6"
  775. checkBuilt $PKG_NAME
  776. if [[ $? != 0 ]]; then
  777. echo "$PKG_NAME already exists, skipping!"
  778. else
  779. echo "building $PKG_NAME..."
  780. splitName $PKG_NAME
  781. downloadProduct http://ftp.gnu.org/gnu/diffutils/diffutils-3.6.tar.xz http://ftp.gnu.org/gnu/diffutils/diffutils-3.6.tar.xz.sig $RAW_NAME $VERSION
  782. buildProduct $PKG_NAME
  783. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cmp"
  784. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/diff"
  785. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/diff3"
  786. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sdiff"
  787. fi
  788. }
  789. downloadDarwinTools() {
  790. if [[ ! -d DarwinToolsARM ]]; then
  791. echo "Fetching DarwinTools"
  792. mkdir -p DarwinToolsARM
  793. cd DarwinToolsARM
  794. curl -LO https://opensource.apple.com/source/DarwinTools/DarwinTools-1/sw_vers.c
  795. #Not built yet
  796. curl -LO https://opensource.apple.com/source/launchd/launchd-842.92.1/support/launchctl.c
  797. #sw_vers.c
  798. checkSHA256 sw_vers.c 55aab510b465f7687b8ebe23f0e51926606fd5316da138778838b2dac3e7c7e0
  799. else
  800. echo "Using existing DarwinTools"
  801. cd DarwinToolsARM
  802. fi
  803. WORKING_DIR="DarwinToolsARM"
  804. PKG_NAME="darwintools"
  805. PKG_VERSION="1.0-1"
  806. }
  807. patchDarwinTools() {
  808. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  809. sed -i -- 's|#include <CoreFoundation/CFPriv.h>|extern CFDictionaryRef _CFCopySystemVersionDictionary(void);\
  810. extern CFDictionaryRef _CFCopyServerVersionDictionary(void);|' sw_vers.c
  811. sed -i -- 's|_kCFSystemVersionProductNameKey|CFSTR(\"ProductName\")|g' sw_vers.c
  812. sed -i -- 's|_kCFSystemVersionProductVersionKey|CFSTR(\"ProductVersion\")|g' sw_vers.c
  813. sed -i -- 's|_kCFSystemVersionBuildVersionKey|CFSTR(\"ProductBuildVersion\")|g' sw_vers.c
  814. fi
  815. }
  816. #darwintools
  817. #Notes:
  818. # This only builds a striped down version of the one on iOS
  819. # If you're building for a non-appletv platform, you may need to fix things here.
  820. buildDarwinTools() {
  821. downloadDarwinTools
  822. patchDarwinTools
  823. "$CLANG_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -framework CoreFoundation "$MIN_VERSION" -o "sw_vers" sw_vers.c
  824. codesign "$BUILD_ROOT/$WORKING_DIR/sw_vers"
  825. cp sw_vers "$SKEL_PREFIX/$ROOT_PREFIX/bin/"
  826. cd "$BUILD_ROOT"
  827. }
  828. #Download uikittools
  829. downloadUIKitTools() {
  830. if [[ ! -d uikittools ]]; then
  831. echo "Fetching uikittools"
  832. git clone git://git.saurik.com/uikittools.git
  833. else
  834. echo "Using existing uikittools"
  835. fi
  836. WORKING_DIR="uikittools"
  837. PKG_NAME="uikittools"
  838. PKG_VERSION="1.1.12-1"
  839. cd "$WORKING_DIR"
  840. git checkout tags/v1.1.12
  841. }
  842. #uikittools
  843. #Notes:
  844. # This only builds a striped down version of the one on iOS
  845. # If you're building for a non-appletv platform, you may need to fix things here.
  846. buildUIKitTools() {
  847. downloadUIKitTools
  848. "$CLANGPLUS_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -Os -Werror -framework CoreFoundation -framework Foundation "$MIN_VERSION" -o cfversion cfversion.mm
  849. "$CLANGPLUS_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -Os -Werror -framework CoreFoundation -framework Foundation "$MIN_VERSION" -o gssc gssc.mm
  850. "$CLANGPLUS_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -Os -Werror -framework CoreFoundation -framework Foundation -framework UIKit "$MIN_VERSION" -o uiduid uiduid.mm
  851. codesign "$BUILD_ROOT/$WORKING_DIR/cfversion"
  852. codesign "$BUILD_ROOT/$WORKING_DIR/gssc"
  853. codesign "$BUILD_ROOT/$WORKING_DIR/uiduid"
  854. cp gssc cfversion uiduid "$SKEL_PREFIX/$ROOT_PREFIX/bin/"
  855. cd "$BUILD_ROOT"
  856. }
  857. buildBasicUtils() {
  858. notifyProgress "Building sed"
  859. buildSed
  860. notifyProgress "Building grep"
  861. buildGrep
  862. notifyProgress "Building coreutils"
  863. buildCoreutils
  864. notifyProgress "Building findutils"
  865. buildFindUtils
  866. notifyProgress "Building diffutils"
  867. buildDiffUtils
  868. notifyProgress "Building DarwinTools"
  869. buildDarwinTools
  870. notifyProgress "Building UIKitTools"
  871. buildUIKitTools
  872. }
  873. mkdirIfNecessary() {
  874. MK_DIR="$1"
  875. if [[ ! -d $MK_DIR ]]; then
  876. mkdir -p $MK_DIR
  877. fi
  878. }
  879. removeIfNecessary() {
  880. REMOVE_FILE="$1"
  881. if [[ -f $REMOVE_FILE ]]; then
  882. rm -rf $REMOVE_FILE
  883. fi
  884. }
  885. #=====================
  886. #DPKG and Dependencies
  887. #---------------------
  888. #Download zlib
  889. downloadZLib() {
  890. #Download zlib
  891. if [[ ! -d zlib ]]; then
  892. echo "Downloading zlib git"
  893. git clone https://github.com/madler/zlib.git
  894. else
  895. echo "Using existing zlib"
  896. fi
  897. WORKING_DIR="zlib"
  898. PKG_NAME="zlib"
  899. PKG_VERSION="1.2.11-1"
  900. cd "$WORKING_DIR"
  901. git checkout tags/v1.2.11
  902. removeIfNecessary build
  903. mkdirIfNecessary build
  904. cd build
  905. WORKING_DIR="$WORKING_DIR/build"
  906. }
  907. #zlib
  908. buildZLib() {
  909. PKG_NAME="zlib"
  910. checkBuilt $PKG_NAME
  911. if [[ $? != 0 ]]; then
  912. echo "$PKG_NAME already exists, skipping!"
  913. else
  914. downloadZLib
  915. cmake -DCMAKE_INSTALL_NAME_DIR="/$ROOT_PREFIX/lib" -DCMAKE_OSX_SYSROOT="$SDK_PATH/" -DCMAKE_C_FLAGS="-arch $ARCH" -DCMAKE_INSTALL_PREFIX="/$ROOT_PREFIX" ..
  916. checkStatus $PKG_NAME $? "false"
  917. make -j8 DESTDIR="$SKEL_PREFIX" install
  918. checkStatus $PKG_NAME $? "true"
  919. cd "$BUILD_ROOT"
  920. fi
  921. }
  922. patchXZ() {
  923. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  924. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' config.h.in
  925. fi
  926. }
  927. patchTar() {
  928. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  929. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' config.h.in
  930. fi
  931. }
  932. patchOpenSSL() {
  933. sed -i -- "s|-arch $ARCH -mios-version-min=7.0.0|-arch $ARCH $MIN_VERSION|" Configurations/10-main.conf
  934. }
  935. patchBZip2() {
  936. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  937. #fix up our makefile...
  938. sed -i -- "s|CC=gcc|CC=$(xcrun --sdk $PLATFORM_LOWER --find clang)|" Makefile
  939. sed -i -- "s|AR=ar|AR=$(xcrun --sdk $PLATFORM_LOWER --find ar)|" Makefile
  940. sed -i -- "s|RANLIB=ranlib|RANLIB=$(xcrun --sdk $PLATFORM_LOWER --find ranlib)|" Makefile
  941. sed -i -- "s|LDFLAGS=|LDFLAGS=$MIN_VERSION -isysroot \"$SDK_PATH\" -arch $ARCH|" Makefile
  942. sed -i -- "s|CFLAGS=|CFLAGS=$MIN_VERSION -isysroot \"$SDK_PATH\" -arch $ARCH |" Makefile
  943. sed -i -- 's|all:\(.*\) test$|all: \1|' Makefile
  944. sed -i -- 's|ln -s -f \$(PREFIX)/bin/|ln -s -f |g' Makefile
  945. fi
  946. }
  947. patchCurl() {
  948. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  949. #(Forcibly) Remove that dirty clock_gettime
  950. #TODO: Determine if this is the best way
  951. sed -i -- 's|#undef HAVE_CLOCK_GETTIME_MONOTONIC||' lib/curl_config.h.in
  952. fi
  953. }
  954. buildXZ() {
  955. PKG_NAME="xz-5.2.3"
  956. checkBuilt $PKG_NAME
  957. if [[ $? != 0 ]]; then
  958. echo "$PKG_NAME already exists, skipping!"
  959. else
  960. echo "building $PKG_NAME..."
  961. splitName $PKG_NAME
  962. downloadProduct http://tukaani.org/xz/xz-5.2.3.tar.gz http://tukaani.org/xz/xz-5.2.3.tar.gz.sig $RAW_NAME $VERSION
  963. patchXZ
  964. buildProduct $PKG_NAME
  965. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lzmadec"
  966. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lzmainfo"
  967. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/xz"
  968. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/xzdec"
  969. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/liblzma.5.dylib"
  970. fi
  971. }
  972. buildBZip2() {
  973. PKG_NAME="bzip2-1.0.6"
  974. checkBuilt $PKG_NAME
  975. if [[ $? != 0 ]]; then
  976. echo "$PKG_NAME already exists, skipping!"
  977. else
  978. echo "building $PKG_NAME..."
  979. splitName $PKG_NAME
  980. downloadProduct https://gigenet.dl.sourceforge.net/project/bzip2/bzip2-1.0.6.tar.gz - $RAW_NAME $VERSION
  981. patchBZip2
  982. make -j8 install PREFIX="$SKEL_PREFIX/$ROOT_PREFIX"
  983. checkStatus $PKG_NAME $? "true"
  984. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bunzip2"
  985. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bzcat"
  986. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bzip2"
  987. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bzip2recover"
  988. cd "$BUILD_ROOT"
  989. fi
  990. }
  991. buildLZ4() {
  992. PKG_NAME="lz4-1.7.5"
  993. checkBuilt $PKG_NAME
  994. if [[ $? != 0 ]]; then
  995. echo "$PKG_NAME already exists, skipping!"
  996. else
  997. echo "building $PKG_NAME..."
  998. splitName $PKG_NAME
  999. downloadProduct https://github.com/lz4/lz4/archive/v1.7.5.tar.gz - $RAW_NAME $VERSION
  1000. cd contrib/cmake_unofficial/
  1001. mkdirIfNecessary build
  1002. cd build
  1003. cmake -DCMAKE_INSTALL_NAME_DIR="/$ROOT_PREFIX/lib" -DCMAKE_OSX_SYSROOT="$SDK_PATH/" -DCMAKE_C_FLAGS="-arch $ARCH" -DCMAKE_INSTALL_PREFIX="/$ROOT_PREFIX" ..
  1004. checkStatus $PKG_NAME $? "false"
  1005. make -j8
  1006. make -j8 DESTDIR="$SKEL_PREFIX" install
  1007. checkStatus $PKG_NAME $? "true"
  1008. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lz4"
  1009. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lz4c"
  1010. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/liblz4.1.7.5.dylib"
  1011. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/liblz4.1.dylib"
  1012. cd "$BUILD_ROOT"
  1013. fi
  1014. }
  1015. downloadOpenSSL() {
  1016. if [[ ! -d openssl ]]; then
  1017. git clone -b OpenSSL_1_1_0-stable https://github.com/openssl/openssl.git
  1018. else
  1019. echo "Using existing openssl repo"
  1020. fi
  1021. WORKING_DIR="openssl"
  1022. PKG_NAME="openssl"
  1023. PKG_VERSION="1.1.0-1"
  1024. cd "$WORKING_DIR"
  1025. }
  1026. buildOpenSSL() {
  1027. PKG_NAME="openssl"
  1028. checkBuilt $PKG_NAME
  1029. if [[ $? != 0 ]]; then
  1030. echo "$PKG_NAME already exists, skipping!"
  1031. else
  1032. LOG_FILE="$ROOT_LOG_FOLDER/openssl.log"
  1033. touch $LOG_FILE
  1034. downloadOpenSSL
  1035. patchOpenSSL
  1036. export AR=""
  1037. export PLATFORM="$PLATFORM"
  1038. export BUILD_TOOLS="$(xcode-select --print-path)"
  1039. export CC="clang -fembed-bitcode"
  1040. export CROSS_COMPILE="$(xcode-select --print-path)/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
  1041. export CROSS_TOP="$(xcode-select --print-path)/Platforms/$PLATFORM.platform/Developer"
  1042. export CROSS_SDK="$(echo $SDK_PATH | sed 's/.*\///g')"
  1043. notifyProgress "Configuring openSSL"
  1044. if [[ $LOG_VERBOSE == "verbose"* ]]; then
  1045. ./Configure ios64-cross no-dso no-hw no-engine --prefix="/$ROOT_PREFIX" | tee "${LOG_FILE}"
  1046. EC=$(grep "configure: error:" -i "${LOG_FILE}" -c)
  1047. checkStatus $PKG_NAME $EC "false"
  1048. else
  1049. (./Configure ios64-cross no-dso no-hw no-engine --prefix="/$ROOT_PREFIX" > "$LOG_FILE" 2>&1)
  1050. checkStatus $PKG_NAME $? "false"
  1051. if [[ $OPEN_LOG == "true" ]]; then
  1052. open "${LOG_FILE}"
  1053. fi
  1054. fi
  1055. echo -e "\n\nPOST CONFIGURE\n\n" >> "$LOG_FILE"
  1056. notifyProgress "making openSSL"
  1057. if [[ $LOG_VERBOSE == "verbose"* ]]; then
  1058. make DESTDIR="$SKEL_PREFIX" install | tee -a "${LOG_FILE}"
  1059. EC=$(grep "fatal error:" -i "${LOG_FILE}" -c)
  1060. checkStatus $PKG_NAME $EC "true"
  1061. else
  1062. (make DESTDIR="$SKEL_PREFIX" install >> "${LOG_FILE}" 2>&1)
  1063. checkStatus $PKG_NAME $? "true"
  1064. fi
  1065. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/openssl"
  1066. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libcrypto.1.1.dylib"
  1067. cd "$BUILD_ROOT"
  1068. fi
  1069. }
  1070. buildCurl() {
  1071. PKG_NAME="curl-7.50.1"
  1072. checkBuilt $PKG_NAME
  1073. if [[ $? != 0 ]]; then
  1074. echo "$PKG_NAME already exists, skipping!"
  1075. else
  1076. echo "building $PKG_NAME..."
  1077. splitName $PKG_NAME
  1078. downloadProduct https://curl.haxx.se/download/curl-7.50.1.tar.gz - $RAW_NAME $VERSION
  1079. patchCurl
  1080. buildProduct $PKG_NAME
  1081. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/curl"
  1082. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libcurl.4.dylib"
  1083. fi
  1084. }
  1085. patchBerkeleyDB() {
  1086. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  1087. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' ../dist/config.hin
  1088. #if [[ "$PKG_VERSION" == "6.2.23-1" ]]; then
  1089. cat ../lang/sql/sqlite/src/shell.c | head -n 14 > shell.patched.c
  1090. echo "#include <stdint.h>" >> shell.patched.c
  1091. echo "#include <stdio.h>" >> shell.patched.c
  1092. echo "#include <stdlib.h>" >> shell.patched.c
  1093. echo "#include <spawn.h>" >> shell.patched.c
  1094. echo "#include <sys/wait.h>" >> shell.patched.c
  1095. echo "#include <sys/stat.h>" >> shell.patched.c
  1096. echo "" >> shell.patched.c
  1097. echo "extern char **environ;" >> shell.patched.c
  1098. echo "" >> shell.patched.c
  1099. cat ../lang/sql/sqlite/src/shell.c | tail -n 4847 | head -n 2622 >> shell.patched.c
  1100. fixSystem "shell.patched.c"
  1101. cat ../lang/sql/sqlite/src/shell.c | tail -n 2226 | sed 's/system(zCmd)/RunCmd(zCmd)/g' >> shell.patched.c
  1102. cp shell.patched.c ../lang/sql/sqlite/src/shell.c
  1103. #fi
  1104. fi
  1105. }
  1106. buildBerkeleyDB() {
  1107. PKG_NAME="db-6.2.23"
  1108. checkBuilt $PKG_NAME
  1109. if [[ $? != 0 ]]; then
  1110. echo "$PKG_NAME already exists, skipping!"
  1111. else
  1112. echo "building $PKG_NAME..."
  1113. LOG_FILE="$ROOT_LOG_FOLDER/$PKG_NAME.log"
  1114. touch $LOG_FILE
  1115. splitName $PKG_NAME
  1116. DOWNLOAD_URL="http://download.oracle.com/berkeley-db/db-6.2.23.tar.gz"
  1117. downloadProduct $DOWNLOAD_URL - $RAW_NAME $VERSION
  1118. cd build_unix
  1119. patchBerkeleyDB
  1120. export CPP="$(xcrun --sdk $PLATFORM_LOWER -f clang) -E "
  1121. export CXXCPP="$(xcrun --sdk $PLATFORM_LOWER -f clang++) -E "
  1122. export PLATFORM="$PLATFORM" #TODO: Maybe necessary? Need to test.
  1123. export BUILD_TOOLS="$(xcode-select --print-path)"
  1124. export CC="clang"
  1125. export CROSS_COMPILE="$(xcode-select --print-path)/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
  1126. export CROSS_TOP="$(xcode-select --print-path)/Platforms/$PLATFORM.platform/Developer"
  1127. export CROSS_SDK="$(echo $SDK_PATH | sed 's/.*\///g')"
  1128. export CFLAGS="-arch $ARCH -pipe -Os -gdwarf-2 -isysroot $SDK_PATH $MIN_VERSION"
  1129. export CXXFLAGS="-arch $ARCH -pipe -Os -gdwarf-2 -isysroot $SDK_PATH $MIN_VERSION"
  1130. export LDFLAGS="-arch $ARCH -isysroot $SDK_PATH" # -L${SKEL_PREFIX}/lib"
  1131. #buildProduct $PKG_NAME
  1132. if [[ $LOG_VERBOSE == "verbose"* ]]; then
  1133. ../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" | tee "${LOG_FILE}"
  1134. else
  1135. (../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" > "$LOG_FILE" 2>&1)
  1136. if [[ $OPEN_LOG == "true" ]]; then
  1137. open "${LOG_FILE}"
  1138. fi
  1139. fi
  1140. checkStatus $PKG_NAME $? "false"
  1141. if [[ $LOG_VERBOSE == "verbose"* ]]; then
  1142. make DESTDIR="$SKEL_PREFIX" install | tee "${LOG_FILE}"
  1143. else
  1144. (make DESTDIR="$SKEL_PREFIX" install >> "${LOG_FILE}" 2>&1)
  1145. fi
  1146. checkStatus $PKG_NAME $? "true"
  1147. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_archive"
  1148. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_checkpoint"
  1149. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_deadlock"
  1150. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_dump"
  1151. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_hotbackup"
  1152. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_load"
  1153. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_log_verify"
  1154. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_printlog"
  1155. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_recover"
  1156. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_replicate"
  1157. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_sql_codegen"
  1158. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_stat"
  1159. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_tuner"
  1160. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_upgrade"
  1161. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_verify"
  1162. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dbsql"
  1163. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libdb_sql-6.2.dylib"
  1164. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libdb-6.2.dylib"
  1165. fi
  1166. }
  1167. buildTar(){
  1168. PKG_NAME="tar-1.33"
  1169. checkBuilt $PKG_NAME
  1170. if [[ $? != 0 ]]; then
  1171. echo "$PKG_NAME already exists, skipping!"
  1172. else
  1173. echo "building $PKG_NAME..."
  1174. splitName $PKG_NAME
  1175. downloadProduct http://ftp.gnu.org/gnu/tar/tar-1.33.tar.xz - $RAW_NAME $VERSION
  1176. patchTar
  1177. buildProduct $PKG_NAME
  1178. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tar"
  1179. fi
  1180. }
  1181. #Download dpkg
  1182. downloadDpkg() {
  1183. if [[ ! -d dpkg ]]; then
  1184. echo "Downlading dpkg"
  1185. git clone https://git.nito.tv/NitoTV/dpkg.git
  1186. else
  1187. echo "Using existing dpkg"
  1188. fi
  1189. WORKING_DIR="dpkg"
  1190. PKG_NAME="dpkg"
  1191. PKG_VERSION="1.18.23-1" #FIXME
  1192. cd "$WORKING_DIR"
  1193. }
  1194. #dpkg
  1195. buildDpkg() {
  1196. PKG_NAME="dpkg"
  1197. LOG_FILE="$ROOT_LOG_FOLDER/$PKG_NAME.log"
  1198. touch $LOG_FILE
  1199. checkBuilt $PKG_NAME
  1200. if [[ $? != 0 ]]; then
  1201. echo "$PKG_NAME already exists, skipping!"
  1202. else
  1203. downloadDpkg
  1204. local dont_die_here=$(./autogen.sh)
  1205. # need to clear these preprocessor flags or they get all wonky
  1206. export CPP="$(xcrun --sdk $PLATFORM_LOWER -f clang) -E "
  1207. export CXXCPP="$(xcrun --sdk $PLATFORM_LOWER -f clang++) -E "
  1208. export LZMA_LIBS="$SKEL_PREFIX/$ROOT_PREFIX/lib/liblzma.dylib"
  1209. export CC=$(xcrun --sdk $PLATFORM_LOWER --find clang)
  1210. export CXX=$(xcrun --sdk $PLATFORM_LOWER --find clang++)
  1211. export CFLAGS="-isysroot $SDK_PATH -I$SDK_PATH/usr/include -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH"
  1212. export CXXFLAGS=$CFLAGS
  1213. export LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH"
  1214. export CPPFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH"
  1215. export CXXFLAGS=$CFLAGS
  1216. export LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH"
  1217. if [[ $LOG_VERBOSE == "verbose"* ]]; then
  1218. ./configure --prefix="/$ROOT_PREFIX" --disable-start-stop-daemon --host=aarch64-apple-darwin --disable-dependency-tracking PERL_LIBDIR='$(prefix)/lib/' --disable-dselect --localstatedir="/var/" --sysconfdir="/fs/jb/etc" | tee "${LOG_FILE}"
  1219. EC=$(grep "configure: error:" -i "${LOG_FILE}" -c)
  1220. checkStatus $PKG_NAME $EC "false"
  1221. else
  1222. (./configure --prefix="/$ROOT_PREFIX" --disable-start-stop-daemon --host=aarch64-apple-darwin --disable-dependency-tracking PERL_LIBDIR='$(prefix)/lib/' --disable-dselect --localstatedir="/var/" --sysconfdir="/fs/jb/etc" > "${LOG_FILE}" 2>&1)
  1223. if [[ $OPEN_LOG == "true" ]]; then
  1224. open "${LOG_FILE}"
  1225. fi
  1226. fi
  1227. checkStatus $PKG_NAME $? "false"
  1228. patchDpkg #Must be after configure for now. I'll deal with this later
  1229. if [[ $LOG_VERBOSE == "verbose"* ]]; then
  1230. make -j8 DESTDIR="$SKEL_PREFIX" install | tee "${LOG_FILE}"
  1231. EC=$(grep "fatal error:" -i "${LOG_FILE}" -c)
  1232. checkStatus $PKG_NAME $EC "true"
  1233. else
  1234. (make -j8 DESTDIR="$SKEL_PREFIX" install >> "${LOG_FILE}" 2>&1)
  1235. checkStatus $PKG_NAME $? "true"
  1236. fi
  1237. #lzma conflicts with built in libraries when running in certian conditions.
  1238. #we make -j8 a symlink our version of lzma in the xz build process
  1239. #here we change dpkg-deb to look for this version instead
  1240. #if we do not do this, apt-get/dpkg* will fail from our setuid tool
  1241. install_name_tool -change /usr/lib/liblzma.5.dylib /usr/local/lib/liblzma.5.dylib "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-deb"
  1242. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg"
  1243. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-deb"
  1244. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-divert"
  1245. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-query"
  1246. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-split"
  1247. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-trigger"
  1248. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-statoverride"
  1249. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/update-alternatives"
  1250. echo "appletvos-arm64" >> "$SKEL_PREFIX/var/lib/dpkg/arch"
  1251. echo "darwin-arm64" >> "$SKEL_PREFIX/var/lib/dpkg/arch"
  1252. cd "$BUILD_ROOT"
  1253. fi
  1254. }
  1255. buildDPKGAndDependencies() {
  1256. notifyProgress "Building zlib"
  1257. buildZLib
  1258. notifyProgress "Building xz"
  1259. buildXZ
  1260. notifyProgress "Building bzip2"
  1261. buildBZip2
  1262. notifyProgress "Building lz4"
  1263. buildLZ4
  1264. notifyProgress "Building openSSL"
  1265. buildOpenSSL
  1266. notifyProgress "Building curl"
  1267. buildCurl
  1268. notifyProgress "Building BerkeleyDB"
  1269. buildBerkeleyDB
  1270. notifyProgress "Building tar"
  1271. buildTar
  1272. notifyProgress "Building dpkg"
  1273. buildDpkg
  1274. }
  1275. buildGpgError() {
  1276. PKG_NAME="libgpg-error-1.32"
  1277. checkBuilt $PKG_NAME
  1278. if [[ $? != 0 ]]; then
  1279. echo "$PKG_NAME already exists, skipping!"
  1280. else
  1281. echo "building $PKG_NAME..."
  1282. #splitName $PKG_NAME
  1283. DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.32.tar.bz2"
  1284. downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig libgpg-error 1.32
  1285. #sed -i -- 's|#include <stdlib.h>|\n#if !defined(__arm64__)\n#define __arm64__\n#endif\n\n#include <stdlib.h>|' ncurses/build.priv.h
  1286. #echo -e "\n#if !defined(__arm64__)\n#define __arm64__\n#endif\n\n" >> config.h.in
  1287. #export HOST="arm"
  1288. buildProduct $PKG_NAME "--enable-threads=posix"
  1289. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libgpg-error.0.dylib"
  1290. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-error"
  1291. #export HOST="aarch64"
  1292. fi
  1293. }
  1294. patchGcrypt() {
  1295. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  1296. #if [[ "$PKG_VERSION" == "1.8.2-1" ]]; then
  1297. cat tests/random.c | head -n 39 > random.patched.c
  1298. echo "#include <stdint.h>" >> random.patched.c
  1299. echo "#include <stdio.h>" >> random.patched.c
  1300. echo "#include <stdlib.h>" >> random.patched.c
  1301. echo "#include <spawn.h>" >> random.patched.c
  1302. echo "#include <sys/wait.h>" >> random.patched.c
  1303. echo "#include <sys/stat.h>" >> random.patched.c
  1304. echo "" >> random.patched.c
  1305. echo "extern char **environ;" >> random.patched.c
  1306. echo "" >> random.patched.c
  1307. fixSystem "random.patched.c"
  1308. cat tests/random.c | tail -n 727 | sed 's/system (cmdline)/RunCmd(cmdline)/g' >> random.patched.c
  1309. cp random.patched.c tests/random.c
  1310. #fi
  1311. fi
  1312. }
  1313. buildGcrypt() {
  1314. PKG_NAME="libgcrypt-1.8.2"
  1315. checkBuilt $PKG_NAME
  1316. if [[ $? != 0 ]]; then
  1317. echo "$PKG_NAME already exists, skipping!"
  1318. else
  1319. echo "building $PKG_NAME..."
  1320. splitName $PKG_NAME
  1321. downloadProduct https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.8.2.tar.bz2 https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.8.2.tar.bz2.sig $RAW_NAME $VERSION
  1322. patchGcrypt
  1323. export HOST="arm"
  1324. buildProduct $PKG_NAME "--with-libgpg-error-prefix=$SKEL_PREFIX/$ROOT_PREFIX/"
  1325. export HOST="aarch64"
  1326. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dumpsexp"
  1327. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/hmac256"
  1328. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mpicalc"
  1329. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libgcrypt.20.dylib"
  1330. fi
  1331. }
  1332. patchKSBA() {
  1333. sed -i -- 's|#include <stdarg.h>|#include <stdarg.h>\n#include "ksba.h"\n|' src/asn1-gentables.c
  1334. FIND='$(CC_FOR_BUILD) -I$(srcdir)'
  1335. sed -i -- "s|$FIND |$FIND -I$SKEL_PREFIX/$ROOT_PREFIX/include |" src/Makefile.in
  1336. # sed -i -- "s|$(CC_FOR_BUILD) -I$(srcdir) |$(CC_FOR_BUILD) -I$(srcdir) -I$SKEL_PREFIX/$ROOT_PREFIX/include/ |" src/Makefile.in
  1337. sed -i -- 's|const char \*gpg_strerror|//const char \*gpg_strerror|' src/gen-help.h
  1338. }
  1339. buildKSBA() {
  1340. PKG_NAME="libksba-1.3.5"
  1341. checkBuilt $PKG_NAME
  1342. if [[ $? != 0 ]]; then
  1343. echo "$PKG_NAME already exists, skipping!"
  1344. else
  1345. echo "building $PKG_NAME..."
  1346. splitName $PKG_NAME
  1347. DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/libksba/libksba-1.3.5.tar.bz2"
  1348. downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig $RAW_NAME $VERSION
  1349. patchKSBA
  1350. buildProduct $PKG_NAME "--with-libgpg-error-prefix=$SKEL_PREFIX/$ROOT_PREFIX/"
  1351. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libksba.8.dylib"
  1352. fi
  1353. }
  1354. patchNpth() {
  1355. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  1356. sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' config.h.in
  1357. #if [[ "$PKG_VERSION" == "1.5-1" ]]; then
  1358. cat src/npth.c | head -n 19 > npth.patched.c
  1359. echo "#include <stdint.h>" >> npth.patched.c
  1360. echo "#include <stdio.h>" >> npth.patched.c
  1361. echo "#include <stdlib.h>" >> npth.patched.c
  1362. echo "#include <spawn.h>" >> npth.patched.c
  1363. echo "#include <sys/wait.h>" >> npth.patched.c
  1364. echo "" >> npth.patched.c
  1365. echo "extern char **environ;" >> npth.patched.c
  1366. echo "" >> npth.patched.c
  1367. cat src/npth.c | tail -n 757 | head -n 537 >> npth.patched.c
  1368. fixSystem "npth.patched.c"
  1369. cat src/npth.c | tail -n 220 | sed 's/system(cmd)/RunCmd(cmd)/g' >> npth.patched.c
  1370. cp npth.patched.c src/npth.c
  1371. #fi
  1372. fi
  1373. }
  1374. buildNpth() {
  1375. PKG_NAME="npth-1.5"
  1376. checkBuilt $PKG_NAME
  1377. if [[ $? != 0 ]]; then
  1378. echo "$PKG_NAME already exists, skipping!"
  1379. else
  1380. echo "building $PKG_NAME..."
  1381. splitName $PKG_NAME
  1382. DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/npth/npth-1.5.tar.bz2"
  1383. downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig $RAW_NAME $VERSION
  1384. patchNpth
  1385. buildProduct $PKG_NAME
  1386. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libnpth.0.dylib"
  1387. fi
  1388. }
  1389. #https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-2.5.1.tar.bz2
  1390. buildAssuan() {
  1391. PKG_NAME="libassuan-2.5.1"
  1392. checkBuilt $PKG_NAME
  1393. if [[ $? != 0 ]]; then
  1394. echo "$PKG_NAME already exists, skipping!"
  1395. else
  1396. echo "building $PKG_NAME..."
  1397. splitName $PKG_NAME
  1398. DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-2.5.1.tar.bz2"
  1399. downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig $RAW_NAME $VERSION
  1400. buildProduct $PKG_NAME "--with-libgpg-error-prefix=$SKEL_PREFIX/$ROOT_PREFIX/"
  1401. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libassuan.0.dylib"
  1402. fi
  1403. }
  1404. patchNtbtls() {
  1405. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  1406. # this is required because prior dependencies write /$ROOT_PREFIX/lib/libgpg-error.la as a dependency in the .la file
  1407. 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"
  1408. 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"
  1409. rm -f "$SKEL_PREFIX/$ROOT_PREFIX/lib/libgcrypt.la--"
  1410. rm -f "$SKEL_PREFIX/$ROOT_PREFIX/lib/libksba.la--"
  1411. fi
  1412. }
  1413. buildNtbtls() {
  1414. PKG_NAME="ntbtls-0.1.2"
  1415. checkBuilt $PKG_NAME
  1416. if [[ $? != 0 ]]; then
  1417. echo "$PKG_NAME already exists, skipping!"
  1418. else
  1419. echo "building $PKG_NAME..."
  1420. splitName $PKG_NAME
  1421. DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/ntbtls/ntbtls-0.1.2.tar.bz2"
  1422. downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig $RAW_NAME $VERSION
  1423. patchNtbtls
  1424. buildProduct $PKG_NAME "--with-libgpg-error-prefix=$SKEL_PREFIX/$ROOT_PREFIX/ --with-libgcrypt-prefix=$SKEL_PREFIX/$ROOT_PREFIX --with-ksba-prefix=$SKEL_PREFIX/$ROOT_PREFIX"
  1425. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libntbtls.0.dylib"
  1426. fi
  1427. }
  1428. patchGpg() {
  1429. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  1430. #if [[ "$PKG_VERSION" == "2.2.3-1" ]]; then
  1431. cat "g10/exec.c" | head -n 54 > "exec.patched.c"
  1432. echo "#include <stdint.h>" >> "exec.patched.c"
  1433. echo "#include <stdio.h>" >> "exec.patched.c"
  1434. echo "#include <stdlib.h>" >> "exec.patched.c"
  1435. echo "#include <spawn.h>" >> "exec.patched.c"
  1436. echo "#include <sys/wait.h>" >> "exec.patched.c"
  1437. echo "" >> "exec.patched.c"
  1438. echo "extern char **environ;" >> "exec.patched.c"
  1439. echo "" >> "exec.patched.c"
  1440. cat "g10/exec.c" | head -n 111 | tail -n 57 >> "exec.patched.c"
  1441. fixSystem "exec.patched.c"
  1442. cat "g10/exec.c" | tail -n 524 | sed 's/=system(info->command)/=RunCmd(info->command)/g' >> "exec.patched.c"
  1443. cp "exec.patched.c" "g10/exec.c"
  1444. #fi
  1445. fi
  1446. }
  1447. #
  1448. buildGpg() {
  1449. PKG_NAME="gnupg-2.2.3"
  1450. checkBuilt $PKG_NAME
  1451. if [[ $? != 0 ]]; then
  1452. echo "$PKG_NAME already exists, skipping!"
  1453. else
  1454. echo "building $PKG_NAME..."
  1455. splitName $PKG_NAME
  1456. DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.2.3.tar.bz2"
  1457. downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig $RAW_NAME $VERSION
  1458. patchGpg
  1459. buildProduct $PKG_NAME "--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/"
  1460. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dirmngr"
  1461. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dirmngr-client"
  1462. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg"
  1463. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-agent"
  1464. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-connect-agent"
  1465. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgconf"
  1466. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgparsemail"
  1467. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgscm"
  1468. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgsm"
  1469. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgtar"
  1470. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgv"
  1471. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/kbxutil"
  1472. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/watchgnupg"
  1473. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-check-pattern"
  1474. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-preset-passphrase"
  1475. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-protect-tool"
  1476. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-wks-client"
  1477. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/scdaemon"
  1478. fi
  1479. }
  1480. patchAPT() {
  1481. if [[ "$PLATFORM" == "AppleTVOS" ]]; then
  1482. sed -i -- '/^INCLUDE_DIRECTORIES/d' ../CMakeLists.txt
  1483. sed -i -- '/^LINK_DIRECTORIES/d' ../CMakeLists.txt
  1484. cat ../CMakeLists.txt | head -n 15 > newCmakeLists.txt
  1485. echo "INCLUDE_DIRECTORIES($SKEL_PREFIX/$ROOT_PREFIX/include)" >> newCmakeLists.txt
  1486. echo "LINK_DIRECTORIES($SKEL_PREFIX/$ROOT_PREFIX/lib)" >> newCmakeLists.txt
  1487. echo "" >> newCmakeLists.txt
  1488. cat ../CMakeLists.txt | tail -n 217 >> newCmakeLists.txt
  1489. mv newCmakeLists.txt ../CmakeLists.txt
  1490. #sed -i -- "s|/Users/jaywalker/RnD/ATV/packages/test/skel/|$SKEL_PREFIX/|g" ../CMakeLists.txt
  1491. fi
  1492. }
  1493. downloadApt() {
  1494. if [[ ! -d apt ]]; then
  1495. echo "Downlading apt"
  1496. git clone https://git.nito.tv/NitoTV/apt.git
  1497. else
  1498. echo "Using existing apt"
  1499. fi
  1500. WORKING_DIR="apt"
  1501. cd "$WORKING_DIR"
  1502. removeIfNecessary build
  1503. mkdirIfNecessary build
  1504. cd build
  1505. WORKING_DIR="$WORKING_DIR/build"
  1506. }
  1507. buildAPT() {
  1508. PKG_NAME="apt7-0.7.25.3"
  1509. LOG_FILE="$ROOT_LOG_FOLDER/$PKG_NAME.log"
  1510. touch $LOG_FILE
  1511. checkBuilt $PKG_NAME
  1512. if [[ $? != 0 ]]; then
  1513. echo "$PKG_NAME already exists, skipping!"
  1514. else
  1515. downloadApt
  1516. patchAPT
  1517. echo "build output going to: " $LOG_FILE
  1518. if [[ $LOG_VERBOSE == "verbose"* ]]; then
  1519. cmake -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 -Wno-unused-parameter -Wno-unused-private-field -Wno-unknown-warning-option -Wno-writable-strings" -DCMAKE_C_FLAGS="-arch $ARCH -Wno-unused-parameter -Wno-unused-private-field -Wno-unknown-warning-option -Wno-writable-strings" -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" .. | tee "${LOG_FILE}"
  1520. #FIXME : need status / error checking here!
  1521. else
  1522. (cmake -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 -Wno-unused-parameter -Wno-unused-private-field -Wno-unknown-warning-option -Wno-writable-strings" -DCMAKE_C_FLAGS="-arch $ARCH -Wno-unused-parameter -Wno-unused-private-field -Wno-unknown-warning-option -Wno-writable-strings" -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" .. > "${LOG_FILE}" 2>&1)
  1523. checkStatus $PKG_NAME $? "false"
  1524. if [[ $OPEN_LOG == "true" ]]; then
  1525. open "${LOG_FILE}"
  1526. fi
  1527. fi
  1528. sed -i -- "s|#define COMMON_ARCH \"darwin-amd64\"|#define COMMON_ARCH \"$PLATFORM_LOWER-$ARCH\"|" include/config.h
  1529. pwd
  1530. sed -i -- "s|_error->Warning(_(\"No sandbox user|//_error->Warning(_(\"No sandbox user|" ../apt-pkg/acquire.cc
  1531. if [[ $LOG_VERBOSE == "verbose"* ]]; then
  1532. make -j8 DESTDIR="$SKEL_PREFIX" install | tee "${LOG_FILE}"
  1533. EC=$(grep "fatal error:" -i "${LOG_FILE}" -c)
  1534. checkStatus $PKG_NAME $EC "true"
  1535. else
  1536. (make -j8 DESTDIR="$SKEL_PREFIX" install >> "${LOG_FILE}" 2>&1)
  1537. checkStatus $PKG_NAME $? "true"
  1538. fi
  1539. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt"
  1540. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-cache"
  1541. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-cdrom"
  1542. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-config"
  1543. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-ftparchive"
  1544. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-get"
  1545. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-mark"
  1546. codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-sortpkgs"
  1547. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libapt-inst.2.0.0.dylib"
  1548. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libapt-private.0.0.0.dylib"
  1549. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/apt-helper"
  1550. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/cdrom"
  1551. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/copy"
  1552. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/file"
  1553. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/ftp"
  1554. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/gpgv"
  1555. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/http"
  1556. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/https"
  1557. #codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/mirror"
  1558. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/rred"
  1559. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/rsh"
  1560. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/store"
  1561. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/planners/apt"
  1562. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/solvers/apt"
  1563. codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/solvers/dump"
  1564. sed -i -- "s|/bin/sh|/fs/jb/bin/sh|" "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-key"
  1565. rm "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-key--"
  1566. #lzma conflicts with built in libraries we make -j8 an extra copy of our version of lzma in the xz build process
  1567. #here we change libapt-pkg*.dylib to look for this version instead
  1568. #if we do not do this, apt-get will fail from our helper tool
  1569. 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
  1570. codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libapt-pkg.5.0.1.dylib"
  1571. cd "$BUILD_ROOT"
  1572. fi
  1573. }
  1574. buildAPTAndDependencies() {
  1575. notifyProgress "Building gpg-error"
  1576. buildGpgError
  1577. notifyProgress "Building gcrypt"
  1578. buildGcrypt
  1579. notifyProgress "Building KSBA"
  1580. buildKSBA
  1581. notifyProgress "Building npth"
  1582. buildNpth
  1583. notifyProgress "Building Assuan"
  1584. buildAssuan
  1585. notifyProgress "Building ntbtls"
  1586. buildNtbtls
  1587. notifyProgress "Building gpg"
  1588. buildGpg
  1589. notifyProgress "Building apt"
  1590. buildAPT
  1591. }
  1592. prepSDK() {
  1593. if [[ ! -e "$SDK_PATH/usr/include/sys/ttydev.h" ]]; then
  1594. echo "Missing <sys/ttydev.h>. Moving it in from MacOSX SDK (with sudo)"
  1595. sudo cp "$(xcrun --sdk macosx --show-sdk-path)/usr/include/sys/ttydev.h" "$SDK_PATH/usr/include/sys/ttydev.h"
  1596. fi
  1597. if [[ ! -e "$SDK_PATH/usr/include/lockdown.h" ]]; then
  1598. echo "Missing lockdown.h! Generating the bare essentials for apt to build..."
  1599. echo "#ifndef LOCKDOWN_LOCKDOWN_H" >> "$SDK_PATH/usr/include/lockdown.h"
  1600. echo "#define LOCKDOWN_LOCKDOWN_H" >> "$SDK_PATH/usr/include/lockdown.h"
  1601. echo "" >> "$SDK_PATH/usr/include/lockdown.h"
  1602. echo "#include <CoreFoundation/CFString.h>" >> "$SDK_PATH/usr/include/lockdown.h"
  1603. echo "" >> "$SDK_PATH/usr/include/lockdown.h"
  1604. echo "#ifdef __cplusplus" >> "$SDK_PATH/usr/include/lockdown.h"
  1605. echo "extern \"C\" {" >> "$SDK_PATH/usr/include/lockdown.h"
  1606. echo "#endif" >> "$SDK_PATH/usr/include/lockdown.h"
  1607. echo "" >> "$SDK_PATH/usr/include/lockdown.h"
  1608. echo "extern CFStringRef kLockdownUniqueDeviceIDKey;" >> "$SDK_PATH/usr/include/lockdown.h"
  1609. echo "" >> "$SDK_PATH/usr/include/lockdown.h"
  1610. echo "extern void *lockdown_connect(void);" >> "$SDK_PATH/usr/include/lockdown.h"
  1611. echo "extern CFStringRef lockdown_copy_value(void *lockdown, void *null, CFStringRef key);" >> "$SDK_PATH/usr/include/lockdown.h"
  1612. echo "extern void lockdown_disconnect(void *lockdown);" >> "$SDK_PATH/usr/include/lockdown.h"
  1613. echo "" >> "$SDK_PATH/usr/include/lockdown.h"
  1614. echo "#ifdef __cplusplus" >> "$SDK_PATH/usr/include/lockdown.h"
  1615. echo "}" >> "$SDK_PATH/usr/include/lockdown.h"
  1616. echo "#endif" >> "$SDK_PATH/usr/include/lockdown.h"
  1617. echo "" >> "$SDK_PATH/usr/include/lockdown.h"
  1618. echo "#endif/*LOCKDOWN_LOCKDOWN_H*/" >> "$SDK_PATH/usr/include/lockdown.h"
  1619. fi
  1620. IOKIT_MATCH="`find ~/Library/Developer/Xcode/tvOS\ DeviceSupport/ -name IOKit.framework | grep "$SDK_VERSION" -m 1`"
  1621. echo "IOKit match: $IOKIT_MATCH"
  1622. echo "IOKit: $SDK_PATH/System/Library/Frameworks/IOKit.framework"
  1623. if [[ ! -d "$SDK_PATH/System/Library/Frameworks/IOKit.framework" ]]; then
  1624. if [[ ! -z "$IOKIT_MATCH" ]]; then
  1625. echo "we do indeed have an IOKit match and IOKit is missing!!"
  1626. echo "cp -r $IOKIT_MATCH $SDK_PATH/System/Library/Frameworks/"
  1627. cp -r "$IOKIT_MATCH" "$SDK_PATH/System/Library/Frameworks/"
  1628. fi
  1629. fi
  1630. # patch fork to be available in tvOS
  1631. sed -i -- "s|__TVOS_PROHIBITED| |" $SDK_PATH/usr/include/unistd.h
  1632. # patch 'system' in places where it isnt patched out and replaced by our own version (ie cdromtools etc)
  1633. sed -i -- "s|__TVOS_PROHIBITED| |" $SDK_PATH/usr/include/stdlib.h
  1634. sed -i -- "s|__API_AVAILABLE(macos(10.0))|__API_AVAILABLE(macos(10.0), tvos(9.0))|" $SDK_PATH/usr/include/stdlib.h
  1635. }
  1636. if [[ $LOG_VERBOSE == "verbose"* ]]; then
  1637. set -x
  1638. fi
  1639. if [[ "$VERIFY" == "true" ]]; then
  1640. command -v gpg >/dev/null 2>&1 || { echo >&2 "Missing GPG. Cannot verify. Dying."; exit 127 ; }
  1641. echo "Importing necessary PGP keys"
  1642. gpg --recv-key 69184620 7C0135FB088AAF6C66C650B9BB5869F064EA74AB 702353E0F7E48EDB 7FD9FCCB000BEEEE A15B725964A95EE5 D8692123C4065DEA5E0F3AB5249B39D24F25E3B6 031EC2536E580D8EA286A9F22071B08A33BD3F06 9D5EAAF69013B842
  1643. fi
  1644. createListFile() {
  1645. echo -e "\ncreateListFile $1\n"
  1646. DEB=$1
  1647. INFOPATH="$SKEL_PREFIX/private/var/lib/dpkg/info"
  1648. PKG=$(dpkg-deb -f "$DEB" Package 2>/dev/null)
  1649. #echo $PKG list
  1650. rm -rf tmp
  1651. mkdir tmp
  1652. dpkg-deb -e "$DEB" tmp
  1653. dpkg-deb -c "$DEB" | awk '{ print $6 }' | cut -c 2- > $PKG.list #| sed "s|usr|fs/usr|g"
  1654. sed -e '1 s|/|/.|' $PKG.list > $INFOPATH/$PKG.list
  1655. rm $PKG.list
  1656. FILES="tmp/*"
  1657. for f in $FILES; do
  1658. file=${f##*/}
  1659. if [[ "$file" != "control" ]]; then
  1660. echo "Processing $file in $PKG..";
  1661. cp "$f" "$INFOPATH/$PKG.$file"
  1662. fi
  1663. done
  1664. }
  1665. createStatusFile() {
  1666. cd "$BUILD_ROOT"
  1667. rm -rf status
  1668. rm -rf available
  1669. for f in debs/*.deb; do
  1670. echo "Processing $f..";
  1671. dpkg-deb -f "$f" >> status
  1672. dpkg-deb -f "$f" >> available
  1673. echo "Status: install ok installed" >> status
  1674. echo "" >> status
  1675. echo "" >> available
  1676. createListFile $f
  1677. done
  1678. for f in ndeb/*.deb; do
  1679. echo "Processing $f..";
  1680. dpkg-deb -f "$f" >> status
  1681. dpkg-deb -f "$f" >> available
  1682. echo "Status: install ok installed" >> status
  1683. echo "" >> status
  1684. echo "" >> available
  1685. createListFile $f
  1686. done
  1687. if [[ -d "$SKEL_PREFIX/private/var/lib/dpkg/" ]]; then
  1688. mv status "$SKEL_PREFIX/private/var/lib/dpkg/status"
  1689. mv available "$SKEL_PREFIX/private/var/lib/dpkg/available"
  1690. else
  1691. echo "### [WARNING]: $SKEL_PREFIX/private/var/lib/dpkg/ is missing! this bootstrap is likely malformed..."
  1692. echo ""
  1693. mv status "$SKEL_PREFIX/var/lib/dpkg/status"
  1694. mv available "$SKEL_PREFIX/var/lib/dpkg/available"
  1695. fi
  1696. }
  1697. cleanBootstrap() {
  1698. # Get rid of the docs
  1699. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/docs"
  1700. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/doc"
  1701. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/info"
  1702. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/man"
  1703. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/man"
  1704. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/gnupg" #TODO: See if the keys in this folder are needed
  1705. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/readline"
  1706. # Get rid of dev stuff
  1707. #rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/include"
  1708. #rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/aclocal"
  1709. #rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/pkgconfig"
  1710. #rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/common-lisp"
  1711. # remove all the static and libtool libraries from the bootstrap, they take up a LOT of space
  1712. #cd "$SKEL_PREFIX/$ROOT_PREFIX/lib"
  1713. rm *.a
  1714. rm *.la
  1715. #rmdir "$SKEL_PREFIX/$ROOT_PREFIX/var"
  1716. #Get rid of non-skel packages which were needed to compile
  1717. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-error-config"
  1718. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/libgcrypt-config"
  1719. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/lib/pkgconfig"
  1720. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/curl-config"
  1721. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/ncurses6-config"
  1722. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/npth-config"
  1723. rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/ntbtls-config"
  1724. }
  1725. mkdirIfNecessary $ROOT_LOG_FOLDER
  1726. mkdirIfNecessary $ALREADY_BUILT
  1727. # Ensure our SDK has all the required "extras" installed/setup
  1728. prepSDK
  1729. buildBashAndFriends
  1730. buildBasicUtils
  1731. buildDPKGAndDependencies
  1732. buildAPTAndDependencies
  1733. # comment the below in to clean up aftewards to slim down the bootstrap
  1734. if [[ $TRIM == "true" ]]; then
  1735. cleanBootstrap
  1736. fi
  1737. if [[ $CREATE_STATUS == "true" ]]; then
  1738. createStatusFile
  1739. fi
  1740. echo -e "\nDone!\n"
  1741. sayIfVerbal "Finished!"