12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865 |
- #!/bin/bash
- BUILD_ROOT="$(pwd)"
- ROOT_LOG_FOLDER="$BUILD_ROOT/Logs"
- VERIFY="false"
- PLATFORM="AppleTVOS"
- PLATFORM_LOWER="appletvos"
- SDK_VERSION="$(xcrun --show-sdk-version --sdk $PLATFORM_LOWER)"
- ROOT_PREFIX="fs/jb/usr"
- SKEL_PREFIX="$BUILD_ROOT/skel"
- ALREADY_BUILT="$BUILD_ROOT/tracked"
- CLANG_PATH="$(xcrun -f clang)"
- CLANGPLUS_PATH="$(xcrun -f clang++)"
- MIN_VERSION="-mappletvos-version-min=13.0"
- ARCH="arm64"
- SDK_PATH="$(xcrun --sdk $PLATFORM_LOWER --show-sdk-path)"
- SPEAK="false"
- EXTRA_LD_FLAGS=""
- HOST="aarch64"
- FORCE="false"
- LOG_VERBOSE=""
- OPEN_LOG="false"
- TRIM="false"
- CREATE_STATUS="false"
- usage() {
- echo "usage: $0 [-s|--speak-updates] [-V|--verify] [-v|--verbose] [-f|--force] [-o|--open-active-log] [-t|--trim-bootstrap] [-c|--create-status]"
- trap - INT TERM EXIT
- exit 0
- }
- while test $# -gt 0; do
- case "$1" in
- -h|--help)
- usage
- ;;
- -v|--verbose)
- LOG_VERBOSE="verbose"
- shift
- ;;
- -V|--verify)
- VERIFY="true"
- #echo "Working without verifying packages..."
- #echo "YOU BETTER KNOW WHAT YOU'RE DOING"
- #sleep 2 #Give them a couple seconds to think about what they're about to do
- shift
- ;;
- -f|--force)
- FORCE="true"
- shift
- ;;
- -s|--speak-updates|--speak)
- SPEAK="true"
- shift
- ;;
- -t|--trim-bootstrap|--trim)
- TRIM="true"
- shift
- ;;
- -o|--open-log|--open)
- OPEN_LOG="true"
- shift
- ;;
- -c|--create-status|--create)
- CREATE_STATUS="true"
- shift
- ;;
- *)
- break
- ;;
- esac
- done
- patchAvailability() {
- PATCH_FILE=$1
- sed -i -- "s|__TVOS_PROHIBITED||" "$PATCH_FILE"
- }
- # for some reason the files signed this way don't run on tvOS 9 anymore
- codesign() {
- BIN=$1
- ENT=$2
- if [[ ! -z $ENT ]]; then
- ldid -S$ENT $BIN
- else
- ldid -S $BIN
- fi
- }
- printPreprocessor() {
- $(xcrun --sdk $PLATFORM_LOWER --find clang) -E - - -dM < /dev/null
- }
- sayIfVerbal() {
- if [[ $SPEAK == "true" ]]; then
- say $1
- fi
- }
- splitName() {
- IN=$1
- i=0
- while [ "$IN" != "$iter" ] ;do
- # extract the substring from start of string up to delimiter.
- iter=${IN%%-*}
- # delete this first "element" AND next separator, from $IN.
- IN="${IN#$iter-}"
- ((i=i+1))
- if [[ $i == 1 ]]; then
- echo "set RAW_NAME var to $iter"
- RAW_NAME=$iter
- elif [[ $i == 2 ]]; then
- VERSION=$iter
- echo "set VERSION var to $iter"
- fi
- #echo $iter at $i
- done
- }
- spinner() {
- local pid=$!
- local delay=0.75
- local spinstr='|/-\'
- while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
- local temp=${spinstr#?}
- printf " [%c]" "$spinstr"
- local spinstr=$temp${spinstr%"$temp"}
- sleep $delay
- printf "\b\b\b\b\b"
- done
- wait $pid
- return $?
- }
- setBuilt() {
- DIRECTORY_NAME=$1
- FULL=$ALREADY_BUILT/$DIRECTORY_NAME
- touch "$FULL"
- }
- checkStatus() {
- PKG=$1
- STATUS=$2
- FINISHED=$3
- if [[ $STATUS != 0 ]]; then
- echo "configure or make $PKG returned with non zero: $STATUS check $LOG_FILE for errors!"
- sayIfVerbal "configure or make of $PKG returned with non zero: $STATUS"
- open $LOG_FILE
- #printPreprocessor
- #/bin/bash ./finish.sh
- exit $STATUS
- else
- #echo "make returned with zero"
- if [[ $FINISHED == "true" ]]; then
- setBuilt $PKG
- fi
- fi
- }
- checkBuilt() {
- if [[ "$FORCE" == "true" ]]; then
- return 0
- fi
- DIRECTORY_NAME=$1
- FULL=$ALREADY_BUILT/$DIRECTORY_NAME
- if [[ ! -f $FULL ]]; then
- return 0
- fi
- return 1
- }
- notifyProgress() {
- echo "$1"
- sayIfVerbal "$1"
- }
- checkSHA256() {
- if [[ "$VERIFY" == "true" ]]; then
- FILE="$1"
- VALID_SHA="$2"
- VERIFY_TEST="`shasum -a 256 $FILE | cut -c 1-64`"
- if [[ "$VERIFY_TEST" != "$VALID_SHA" ]]; then
- echo "Failed to validate SHA256 signature for $FILE"
- trap - INT TERM EXIT
- exit 127
- fi
- echo "*** VALID SIGNATURE"
- fi
- }
- checkPGPSig() {
- if [[ "$VERIFY" == "true" ]]; then
- SIGFILE="$1"
- FILE="$2"
- local VERIFY_TEST="`gpg --verify $SIGFILE $FILE 2>&1 | grep 'Good signature'`"
- if [[ "$VERIFY_TEST" == "" ]]; then
- echo "Failed to validate PGP signature for $FILE"
- trap - INT TERM EXIT
- exit 127
- fi
- echo "*** VALID SIGNATURE"
- fi
- }
- exportBuildScript() {
- EXPORT_FILE="$1"
- echo -e "#!/bin/bash" > $EXPORT_FILE
- echo -e "\nexport CC=$(xcrun --sdk $PLATFORM_LOWER --find clang)" >> $EXPORT_FILE
- echo -e "export CXX=$(xcrun --sdk $PLATFORM_LOWER --find clang++)" >> $EXPORT_FILE
- echo -e "export LD=$(xcrun --sdk $PLATFORM_LOWER --find ld)" >> $EXPORT_FILE
- echo -e "export AR=$(xcrun --sdk $PLATFORM_LOWER --find ar)" >> $EXPORT_FILE
- echo -e "export 'CPP=$(xcrun --sdk $PLATFORM_LOWER -f clang) -E -D__arm__ -I$SDKROOT/usr/include' " >> $EXPORT_FILE
- echo -e "export 'CXXCPP=$(xcrun --sdk $PLATFORM_LOWER -f clang++) -E -D__arm__ -I$SDKROOT/usr/include' " >> $EXPORT_FILE
- echo -e "export RANLIB=$(xcrun --sdk $PLATFORM_LOWER --find ranlib)" >> $EXPORT_FILE
- echo -e "export LIBTOOL=$(xcrun --sdk $PLATFORM_LOWER --find libtool)" >> $EXPORT_FILE
- echo -e "export STRIP=$(xcrun --sdk $PLATFORM_LOWER --find strip)" >> $EXPORT_FILE
- 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
- 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
- echo -e "export 'LDFLAGS=-arch arm64 -isysroot $SDKROOT -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ $EXTRA_LD_FLAGS'" >> $EXPORT_FILE
- 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
- echo -e "make -j8 DESTDIR="$SKEL_PREFIX" install" >> $EXPORT_FILE
- chmod +x $EXPORT_FILE
- }
- buildProduct() {
- PKG_NAME=$1
- EXTRA_CFG=$2
- LOG_FILE="$ROOT_LOG_FOLDER/$PKG_NAME.log"
- #exit 2
- touch $LOG_FILE
- echo $PKG_NAME
- echo "build output going to: " $LOG_FILE
- echo $EXTRA_CFG
- local SDKROOT=$(xcrun --sdk $PLATFORM_LOWER --show-sdk-path)
- local VER_MIN=13.0
- export CC=$(xcrun --sdk $PLATFORM_LOWER --find clang)
- export CXX=$(xcrun --sdk $PLATFORM_LOWER --find clang++)
- export LD=$(xcrun --sdk $PLATFORM_LOWER --find ld)
- export AR=$(xcrun --sdk $PLATFORM_LOWER --find ar)
- #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"
- #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"
- export CPP="$(xcrun --sdk $PLATFORM_LOWER -f clang) -E -D__arm__ -I$SDKROOT/usr/include"
- export CXXCPP="$(xcrun --sdk $PLATFORM_LOWER -f clang++) -E -D__arm__ -I$SDKROOT/usr/include"
- export RANLIB=$(xcrun --sdk $PLATFORM_LOWER --find ranlib)
- export LIBTOOL=$(xcrun --sdk $PLATFORM_LOWER --find libtool)
- export STRIP=$(xcrun --sdk $PLATFORM_LOWER --find strip)
- 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 CXXFLAGS=$CFLAGS
- export LDFLAGS="-arch arm64 -isysroot $SDKROOT -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ $EXTRA_LD_FLAGS"
- exportBuildScript "finish.sh"
- notifyProgress "configuring $PKG_NAME"
- if [[ $LOG_VERBOSE == "verbose"* ]]; then
- ./configure --prefix=/$ROOT_PREFIX --host=$HOST-apple-darwin --target=$HOST-apple-darwin --disable-dependency-tracking --without-manpages --disable-tests $EXTRA_CFG | tee "${LOG_FILE}"
- EC=$(grep "configure: error:" -i "${LOG_FILE}" -c)
- checkStatus $PKG_NAME $EC "false"
- else
- (./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)
- checkStatus $PKG_NAME $? "false"
- if [[ $OPEN_LOG == "true" ]]; then
- open "${LOG_FILE}"
- fi
- fi
- notifyProgress "making $PKG_NAME"
- echo -e "\n\nPOST CONFIGURE\n\n" >> "$LOG_FILE"
- if [[ $LOG_VERBOSE == "verbose"* ]]; then
- make -j8 DESTDIR="$SKEL_PREFIX" install | tee -a "${LOG_FILE}"
- EC=$(grep "fatal error:" -i "${LOG_FILE}" -c)
- checkStatus $PKG_NAME $EC "true"
- else
- (make -j8 DESTDIR="$SKEL_PREFIX" install >> "${LOG_FILE}" 2>&1) #& spinner
- checkStatus $PKG_NAME $? "true"
- fi
- cd "$BUILD_ROOT"
- }
- downloadProduct() {
- cd "$BUILD_ROOT"
- DOWNLOAD_LINK=$1
- FILENAME=$(basename $DOWNLOAD_LINK)
- SIG_DOWNLOAD=$2
- RAW_NAME=$3
- VERSION=$4
- FILE_EXTENSION="${FILENAME##*.}"
- DIRECTORY_NAME="$RAW_NAME-$VERSION"
- SIG_FILE=$(basename $SIG_DOWNLOAD)
- if [[ ! -e $FILENAME ]]; then
- echo "Downloading $FILENAME"
- curl -LO $DOWNLOAD_LINK
- if [[ ! $SIG_FILE == "-" ]]; then
- curl -LO $SIG_DOWNLOAD
- checkPGPSig $SIG_FILE $FILENAME
- fi
- else
- echo "Using existing $FILENAME"
- fi
- rm -rf $DIRECTORY_NAME
- if [[ $FILE_EXTENSION == "gz" ]]; then
- echo "is gz file!"
- tar xzvf $FILENAME
- fi
- if [[ $FILE_EXTENSION == "xz" ]]; then
- echo "is lzma file!"
- tar xJvf $FILENAME
- fi
- if [[ $FILE_EXTENSION == "bz2" ]]; then
- echo "is bzip2 file!"
- tar xjvf $FILENAME
- fi
- WORKING_DIR=$DIRECTORY_NAME
- PKG_VERSION=$VERSION-1
- cd "$WORKING_DIR"
- #buildProduct
- }
- patchBash() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- sed -i -- 's|^#undef HAVE_SYS_SIGLIST$|#define HAVE_SYS_SIGLIST 1|' config.h.in
- fi
- }
- patchDpkg() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- sed -i -- "s|#define ARCHITECTURE \"darwin-arm64\"|#define ARCHITECTURE \"$PLATFORM_LOWER-$ARCH\"|" config.h
- sed -i -- "s|#define ARCHITECTURE_OS \"darwin\"|#define ARCHITECTURE_OS \"$PLATFORM_LOWER\"|" config.h
- sed -i -- 's|gtar|tar|' config.h
- fi
- }
- # DONT USE UNLESS YOU ARE ON 11+; OVERWRITE BASH (or any other apple-signed file, for that matter), LEAD TO BRICK
- # 10.2 and up
- buildBashAndFriends() {
- notifyProgress "Building readline"
- buildReadline
- notifyProgress "Building ncurses"
- buildNcurses
- notifyProgress "Building bash"
- buildBash
- }
- buildReadline() {
- PKG_NAME="readline-7.0"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- 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
- buildProduct $PKG_NAME
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libhistory.7.0.dylib"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libreadline.7.0.dylib"
- fi
- }
- fixSystem() {
- FILE="$1"
- echo '#define PROC_PIDPATHINFO_MAXSIZE (1024)' >> "$FILE"
- echo 'static int file_exist(const char *filename) {' >> "$FILE"
- echo ' struct stat buffer;' >> "$FILE"
- echo ' int r = stat(filename, &buffer);' >> "$FILE"
- echo ' return (r == 0);' >> "$FILE"
- echo '}' >> "$FILE"
- echo '' >> "$FILE"
- echo 'static char *searchpath(const char *binaryname){' >> "$FILE"
- echo ' if (strstr(binaryname, "/") != NULL){' >> "$FILE"
- echo ' if (file_exist(binaryname)){' >> "$FILE"
- echo ' char *foundpath = malloc((strlen(binaryname) + 1) * (sizeof(char)));' >> "$FILE"
- echo ' strcpy(foundpath, binaryname);' >> "$FILE"
- echo ' return foundpath;' >> "$FILE"
- echo ' } else {' >> "$FILE"
- echo ' return NULL;' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' char *pathvar = getenv("PATH");' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' char *dir = strtok(pathvar,":");' >> "$FILE"
- echo ' while (dir != NULL){' >> "$FILE"
- echo ' char searchpth[PROC_PIDPATHINFO_MAXSIZE];' >> "$FILE"
- echo ' strcpy(searchpth, dir);' >> "$FILE"
- echo ' strcat(searchpth, "/");' >> "$FILE"
- echo ' strcat(searchpth, binaryname);' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' if (file_exist(searchpth)){' >> "$FILE"
- echo ' char *foundpath = malloc((strlen(searchpth) + 1) * (sizeof(char)));' >> "$FILE"
- echo ' strcpy(foundpath, searchpth);' >> "$FILE"
- echo ' return foundpath;' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' dir = strtok(NULL, ":");' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' return NULL;' >> "$FILE"
- echo '}' >> "$FILE"
- echo '' >> "$FILE"
- echo 'static int isShellScript(const char *path){' >> "$FILE"
- echo ' FILE *file = fopen(path, "r");' >> "$FILE"
- echo ' uint8_t header[2];' >> "$FILE"
- echo ' if (fread(header, sizeof(uint8_t), 2, file) == 2){' >> "$FILE"
- echo " if (header[0] == '#' && header[1] == '!'){" >> "$FILE"
- echo ' fclose(file);' >> "$FILE"
- echo ' return 1;' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' fclose(file);' >> "$FILE"
- echo ' return -1;' >> "$FILE"
- echo '}' >> "$FILE"
- echo '' >> "$FILE"
- echo 'static char *getInterpreter(char *path){' >> "$FILE"
- echo ' FILE *file = fopen(path, "r");' >> "$FILE"
- echo ' char *interpreterLine = NULL;' >> "$FILE"
- echo ' unsigned long lineSize = 0;' >> "$FILE"
- echo ' getline(&interpreterLine, &lineSize, file);' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' char *rawInterpreter = (interpreterLine+2);' >> "$FILE"
- echo ' rawInterpreter = strtok(rawInterpreter, " ");' >> "$FILE"
- echo ' rawInterpreter = strtok(rawInterpreter, "\n");' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' char *interpreter = malloc((strlen(rawInterpreter)+1) * sizeof(char));' >> "$FILE"
- echo ' strcpy(interpreter, rawInterpreter);' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' free(interpreterLine);' >> "$FILE"
- echo ' fclose(file);' >> "$FILE"
- echo ' return interpreter;' >> "$FILE"
- echo '}' >> "$FILE"
- echo '' >> "$FILE"
- echo 'static char *fixedCmd(const char *cmdStr){' >> "$FILE"
- echo ' char *cmdCpy = malloc((strlen(cmdStr)+1) * sizeof(char));' >> "$FILE"
- echo ' strcpy(cmdCpy, cmdStr);' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' char *cmd = strtok(cmdCpy, " ");' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' uint8_t size = strlen(cmd) + 1;' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' char *args = cmdCpy + size;' >> "$FILE"
- echo ' if ((strlen(cmdStr) - strlen(cmd)) == 0)' >> "$FILE"
- echo ' args = NULL;' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' char *abs_path = searchpath(cmd);' >> "$FILE"
- echo ' if (abs_path){' >> "$FILE"
- echo ' int isScript = isShellScript(abs_path);' >> "$FILE"
- echo ' if (isScript == 1){' >> "$FILE"
- echo ' char *interpreter = getInterpreter(abs_path);' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' uint8_t commandSize = strlen(interpreter) + 1 + strlen(abs_path);' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' if (args){' >> "$FILE"
- echo ' commandSize += 1 + strlen(args);' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' char *rawCommand = malloc(sizeof(char) * (commandSize + 1));' >> "$FILE"
- echo ' strcpy(rawCommand, interpreter);' >> "$FILE"
- echo ' strcat(rawCommand, " ");' >> "$FILE"
- echo ' strcat(rawCommand, abs_path);' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' if (args){' >> "$FILE"
- echo ' strcat(rawCommand, " ");' >> "$FILE"
- echo ' strcat(rawCommand, args);' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' rawCommand[(commandSize)+1] = "\0";' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' free(interpreter);' >> "$FILE"
- echo ' free(abs_path);' >> "$FILE"
- echo ' free(cmdCpy);' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' return rawCommand;' >> "$FILE"
- echo ' } else {' >> "$FILE"
- echo ' uint8_t commandSize = strlen(abs_path);' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' if (args){' >> "$FILE"
- echo ' commandSize += 1 + strlen(args);' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' char *rawCommand = malloc(sizeof(char) * (commandSize + 1));' >> "$FILE"
- echo ' strcat(rawCommand, abs_path);' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' if (args){' >> "$FILE"
- echo ' strcat(rawCommand, " ");' >> "$FILE"
- echo ' strcat(rawCommand, args);' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' rawCommand[(commandSize)+1] = "\0";' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' free(abs_path);' >> "$FILE"
- echo ' free(cmdCpy);' >> "$FILE"
- echo ' ' >> "$FILE"
- echo ' return rawCommand;' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' return cmdCpy;' >> "$FILE"
- echo '}' >> "$FILE"
- echo '' >> "$FILE"
- echo 'int RunCmd(const char *cmd) {' >> "$FILE"
- echo ' pid_t pid;' >> "$FILE"
- echo ' char *rawCmd = fixedCmd(cmd);' >> "$FILE"
- echo ' char *argv[] = {"sh", "-c", (char*)rawCmd, NULL};' >> "$FILE"
- echo ' int status;' >> "$FILE"
- echo ' status = posix_spawn(&pid, "/fs/jb/bin/sh", NULL, NULL, argv, environ);' >> "$FILE"
- echo ' if (status == 0) {' >> "$FILE"
- echo ' if (waitpid(pid, &status, 0) == -1) {' >> "$FILE"
- echo ' perror("waitpid");' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' } else {' >> "$FILE"
- echo ' printf("posix_spawn: %s\n", strerror(status));' >> "$FILE"
- echo ' }' >> "$FILE"
- echo ' free(rawCmd);' >> "$FILE"
- echo ' return status;' >> "$FILE"
- echo '}' >> "$FILE"
- }
- patchNcurses() {
- PKG_NAME=$1
- echo "patchNCurses PKG_NAME: $PKG_NAME"
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- if [[ "$PKG_VERSION" == "6.0-1" ]]; then
- # LEFT ERROR ON environ)' no ;
- # For some reason, building never fails on the error...
- # But still, tput is in /usr/bin... so.... ??
- cat progs/tput.c | head -n 55 > tput.patched.c
- echo "#include <stdint.h>" >> tput.patched.c
- echo "#include <stdio.h>" >> tput.patched.c
- echo "#include <stdlib.h>" >> tput.patched.c
- echo "#include <spawn.h>" >> tput.patched.c
- echo "#include <sys/wait.h>" >> tput.patched.c
- echo "" >> tput.patched.c
- echo "extern char **environ;" >> tput.patched.c
- echo "" >> tput.patched.c
- cat progs/tput.c | tail -n 350 | head -n 50 >> tput.patched.c
- fixSystem "tput.patched.c"
- cat progs/tput.c | tail -n 301 | sed 's/system(init_prog)/RunCmd(init_prog)/g' >> tput.patched.c
- cp tput.patched.c progs/tput.c
- fi
- fi
- #sed -i -- 's|#include <stdlib.h>|\n#if !defined(__arm64__)\n#define __arm64__\n#endif\n\n#include <stdlib.h>|' ncurses/build.priv.h
- # CURSES_PRIV="$SKEL_PREFIX/$ROOT_PREFIX/include/curses.priv.h"
- # FIFO="$SKEL_PREFIX/$ROOT_PREFIX/include/fifo_defs.h"
- # BUILD_P="$SKEL_PREFIX/$ROOT_PREFIX/include/build.priv.h"
- # if [[ ! -f "$CURSES_PRIV" ]]; then
- # cp $BUILD_ROOT/$1/ncurses/*.h "$SKEL_PREFIX/$ROOT_PREFIX/include/"
- #cp "$BUILD_ROOT/$1/ncurses/fifo_defs.h" "$FIFO"
- #cp "$BUILD_ROOT/$1/ncurses/build.priv.h" "$BUILD_P"
- # fi
- }
- #http://gnu.mirror.constant.com/ncurses/ncurses-6.0.tar.gz
- #https://git.elucubratus.com/elucubratus/elucubratus/-/raw/master/data/ncurses/ncurses_6.1+20181013.orig.tar.gz
- buildNcurses() {
- PKG_NAME="ncurses-6.1-20181013"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- #splitName $PKG_NAME
- downloadProduct https://git.elucubratus.com/elucubratus/elucubratus/-/raw/master/data/ncurses/ncurses_6.1+20181013.orig.tar.gz - ncurses 6.1-20181013
- patchNcurses $PKG_NAME
- export HOST="arm"
- buildProduct $PKG_NAME
- export HOST="aarch64"
- mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-captoinfo" "$SKEL_PREFIX/$ROOT_PREFIX/bin/captoinfo"
- mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-clear" "$SKEL_PREFIX/$ROOT_PREFIX/bin/clear"
- mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-infocmp" "$SKEL_PREFIX/$ROOT_PREFIX/bin/infocmp"
- mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-infotocap" "$SKEL_PREFIX/$ROOT_PREFIX/bin/infotocap"
- mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-reset" "$SKEL_PREFIX/$ROOT_PREFIX/bin/reset"
- mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-tabs" "$SKEL_PREFIX/$ROOT_PREFIX/bin/tabs"
- mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-tic" "$SKEL_PREFIX/$ROOT_PREFIX/bin/tic"
- mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-toe" "$SKEL_PREFIX/$ROOT_PREFIX/bin/toe"
- mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-tput" "$SKEL_PREFIX/$ROOT_PREFIX/bin/tput"
- mv "$SKEL_PREFIX/$ROOT_PREFIX/bin/arm-apple-darwin-tset" "$SKEL_PREFIX/$ROOT_PREFIX/bin/tset"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/captoinfo"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/clear"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/infocmp"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/infotocap"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/reset"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tabs"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tic"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/toe"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tput"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tset"
- fi
- }
- #https://git.elucubratus.com/elucubratus/elucubratus/-/raw/master/data/bash/bash-5.0.tar.gz
- buildBash() {
- PKG_NAME="bash-5.0"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- downloadProduct https://git.elucubratus.com/elucubratus/elucubratus/-/raw/master/data/bash/bash-5.0.tar.gz - $RAW_NAME $VERSION
- patchBash
- 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"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bash"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/basename"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/dirname"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/finfo"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/head"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/id"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/ln"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/logname"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/mkdir"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/mypid"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/pathchk"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/print"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/printenv"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/push"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/realpath"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/rmdir"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/setpgid"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/sleep"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/strftime"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/sync"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/tee"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/truefalse"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/tty"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/uname"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/unlink"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/bash/whoami"
- fi
- }
- buildSed() {
- PKG_NAME="sed-4.4"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- 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
- buildProduct $PKG_NAME
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sed"
- fi
- }
- buildGrep() {
- PKG_NAME="grep-3.0"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- 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
- buildProduct $PKG_NAME
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/grep"
- fi
- }
- patchCoreutils() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' lib/config.hin
- sed -i -- 's|#undef HAVE_CLOCK_SETTIME||' lib/config.hin
- sed -i -- 's|#undef HAVE_FDATASYNC||' lib/config.hin
- sed -i -- 's|# define __stpncpy stpncpy||' lib/stpncpy.c
- if [[ ! -d "$SKEL_PREFIX/$ROOT_PREFIX/include" ]]; then
- mkdir -p "$SKEL_PREFIX/$ROOT_PREFIX/include"
- fi
- if [[ ! -e "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h" ]]; then
- echo "#include <sys/cdefs.h>" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
- echo "" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
- echo "__BEGIN_DECLS" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
- echo "extern char ***_NSGetArgv(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
- echo "extern int *_NSGetArgc(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
- echo "extern char ***_NSGetEnviron(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
- echo "extern char **_NSGetProgname(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
- echo "extern struct mach_header *_NSGetMachExecuteHeader(void);" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
- echo "__END_DECLS" >> "$SKEL_PREFIX/$ROOT_PREFIX/include/crt_externs.h"
- fi
- fi
- }
- buildCoreutils() {
- PKG_NAME="coreutils-8.9"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- 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
- patchCoreutils
- export HOST="arm"
- buildProduct $PKG_NAME
- export HOST="aarch64"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/["
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/base64"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/basename"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cat"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chcon"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chgrp"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chmod"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chown"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/chroot"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cksum"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/comm"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cp"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/csplit"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cut"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/date"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dd"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/df"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dir"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dircolors"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dirname"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/du"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/echo"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/env"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/expand"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/expr"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/factor"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/false"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/fmt"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/fold"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/groups"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/head"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/hostid"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/id"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/install"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/join"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/kill"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/link"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/ln"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/logname"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/ls"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/md5sum"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mkdir"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mkfifo"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mknod"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mktemp"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mv"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nice"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nl"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nohup"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/nproc"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/od"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/paste"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pathchk"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pinky"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pr"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/printenv"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/printf"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/ptx"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/pwd"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/readlink"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/rm"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/rmdir"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/runcon"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/seq"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha1sum"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha224sum"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha256sum"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha384sum"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sha512sum"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/shred"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/shuf"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sleep"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sort"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/split"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/stat"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/stty"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sum"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sync"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tac"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tail"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tee"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/test"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/timeout"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/touch"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tr"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/true"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/truncate"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tsort"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tty"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/uname"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/unexpand"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/uniq"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/unlink"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/uptime"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/users"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/vdir"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/wc"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/who"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/whoami"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/yes"
- fi
- }
- buildFindUtils() {
- PKG_NAME="findutils-4.6.0"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- downloadProduct http://mirror.keystealth.org/gnu/findutils/findutils-4.6.0.tar.gz - $RAW_NAME $VERSION
- buildProduct $PKG_NAME
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/find"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/locate"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/xargs"
- fi
- }
- buildDiffUtils() {
- PKG_NAME="diffutils-3.6"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- 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
- buildProduct $PKG_NAME
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/cmp"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/diff"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/diff3"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/sdiff"
- fi
- }
- downloadDarwinTools() {
- if [[ ! -d DarwinToolsARM ]]; then
- echo "Fetching DarwinTools"
- mkdir -p DarwinToolsARM
- cd DarwinToolsARM
- curl -LO https://opensource.apple.com/source/DarwinTools/DarwinTools-1/sw_vers.c
- #Not built yet
- curl -LO https://opensource.apple.com/source/launchd/launchd-842.92.1/support/launchctl.c
- #sw_vers.c
- checkSHA256 sw_vers.c 55aab510b465f7687b8ebe23f0e51926606fd5316da138778838b2dac3e7c7e0
- else
- echo "Using existing DarwinTools"
- cd DarwinToolsARM
- fi
- WORKING_DIR="DarwinToolsARM"
- PKG_NAME="darwintools"
- PKG_VERSION="1.0-1"
- }
- patchDarwinTools() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- sed -i -- 's|#include <CoreFoundation/CFPriv.h>|extern CFDictionaryRef _CFCopySystemVersionDictionary(void);\
- extern CFDictionaryRef _CFCopyServerVersionDictionary(void);|' sw_vers.c
- sed -i -- 's|_kCFSystemVersionProductNameKey|CFSTR(\"ProductName\")|g' sw_vers.c
- sed -i -- 's|_kCFSystemVersionProductVersionKey|CFSTR(\"ProductVersion\")|g' sw_vers.c
- sed -i -- 's|_kCFSystemVersionBuildVersionKey|CFSTR(\"ProductBuildVersion\")|g' sw_vers.c
- fi
- }
- #darwintools
- #Notes:
- # This only builds a striped down version of the one on iOS
- # If you're building for a non-appletv platform, you may need to fix things here.
- buildDarwinTools() {
- downloadDarwinTools
- patchDarwinTools
- "$CLANG_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -framework CoreFoundation "$MIN_VERSION" -o "sw_vers" sw_vers.c
- codesign "$BUILD_ROOT/$WORKING_DIR/sw_vers"
- cp sw_vers "$SKEL_PREFIX/$ROOT_PREFIX/bin/"
- cd "$BUILD_ROOT"
- }
- #Download uikittools
- downloadUIKitTools() {
- if [[ ! -d uikittools ]]; then
- echo "Fetching uikittools"
- git clone git://git.saurik.com/uikittools.git
- else
- echo "Using existing uikittools"
- fi
- WORKING_DIR="uikittools"
- PKG_NAME="uikittools"
- PKG_VERSION="1.1.12-1"
- cd "$WORKING_DIR"
- git checkout tags/v1.1.12
- }
- #uikittools
- #Notes:
- # This only builds a striped down version of the one on iOS
- # If you're building for a non-appletv platform, you may need to fix things here.
- buildUIKitTools() {
- downloadUIKitTools
- "$CLANGPLUS_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -Os -Werror -framework CoreFoundation -framework Foundation "$MIN_VERSION" -o cfversion cfversion.mm
- "$CLANGPLUS_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -Os -Werror -framework CoreFoundation -framework Foundation "$MIN_VERSION" -o gssc gssc.mm
- "$CLANGPLUS_PATH" -arch "$ARCH" -isysroot"$SDK_PATH" -Os -Werror -framework CoreFoundation -framework Foundation -framework UIKit "$MIN_VERSION" -o uiduid uiduid.mm
- codesign "$BUILD_ROOT/$WORKING_DIR/cfversion"
- codesign "$BUILD_ROOT/$WORKING_DIR/gssc"
- codesign "$BUILD_ROOT/$WORKING_DIR/uiduid"
- cp gssc cfversion uiduid "$SKEL_PREFIX/$ROOT_PREFIX/bin/"
- cd "$BUILD_ROOT"
- }
- buildBasicUtils() {
- notifyProgress "Building sed"
- buildSed
- notifyProgress "Building grep"
- buildGrep
- notifyProgress "Building coreutils"
- buildCoreutils
- notifyProgress "Building findutils"
- buildFindUtils
- notifyProgress "Building diffutils"
- buildDiffUtils
- notifyProgress "Building DarwinTools"
- buildDarwinTools
- notifyProgress "Building UIKitTools"
- buildUIKitTools
- }
- mkdirIfNecessary() {
- MK_DIR="$1"
- if [[ ! -d $MK_DIR ]]; then
- mkdir -p $MK_DIR
- fi
- }
- removeIfNecessary() {
- REMOVE_FILE="$1"
- if [[ -f $REMOVE_FILE ]]; then
- rm -rf $REMOVE_FILE
- fi
- }
- #=====================
- #DPKG and Dependencies
- #---------------------
- #Download zlib
- downloadZLib() {
- #Download zlib
- if [[ ! -d zlib ]]; then
- echo "Downloading zlib git"
- git clone https://github.com/madler/zlib.git
- else
- echo "Using existing zlib"
- fi
- WORKING_DIR="zlib"
- PKG_NAME="zlib"
- PKG_VERSION="1.2.11-1"
- cd "$WORKING_DIR"
- git checkout tags/v1.2.11
- removeIfNecessary build
- mkdirIfNecessary build
- cd build
- WORKING_DIR="$WORKING_DIR/build"
- }
- #zlib
- buildZLib() {
- PKG_NAME="zlib"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- downloadZLib
- cmake -DCMAKE_INSTALL_NAME_DIR="/$ROOT_PREFIX/lib" -DCMAKE_OSX_SYSROOT="$SDK_PATH/" -DCMAKE_C_FLAGS="-arch $ARCH" -DCMAKE_INSTALL_PREFIX="/$ROOT_PREFIX" ..
- checkStatus $PKG_NAME $? "false"
- make -j8 DESTDIR="$SKEL_PREFIX" install
- checkStatus $PKG_NAME $? "true"
- cd "$BUILD_ROOT"
- fi
- }
- patchXZ() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' config.h.in
- fi
- }
- patchTar() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' config.h.in
- fi
- }
- patchOpenSSL() {
- sed -i -- "s|-arch $ARCH -mios-version-min=7.0.0|-arch $ARCH $MIN_VERSION|" Configurations/10-main.conf
- }
- patchBZip2() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- #fix up our makefile...
- sed -i -- "s|CC=gcc|CC=$(xcrun --sdk $PLATFORM_LOWER --find clang)|" Makefile
- sed -i -- "s|AR=ar|AR=$(xcrun --sdk $PLATFORM_LOWER --find ar)|" Makefile
- sed -i -- "s|RANLIB=ranlib|RANLIB=$(xcrun --sdk $PLATFORM_LOWER --find ranlib)|" Makefile
- sed -i -- "s|LDFLAGS=|LDFLAGS=$MIN_VERSION -isysroot \"$SDK_PATH\" -arch $ARCH|" Makefile
- sed -i -- "s|CFLAGS=|CFLAGS=$MIN_VERSION -isysroot \"$SDK_PATH\" -arch $ARCH |" Makefile
- sed -i -- 's|all:\(.*\) test$|all: \1|' Makefile
- sed -i -- 's|ln -s -f \$(PREFIX)/bin/|ln -s -f |g' Makefile
- fi
- }
- patchCurl() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- #(Forcibly) Remove that dirty clock_gettime
- #TODO: Determine if this is the best way
- sed -i -- 's|#undef HAVE_CLOCK_GETTIME_MONOTONIC||' lib/curl_config.h.in
- fi
- }
- buildXZ() {
- PKG_NAME="xz-5.2.3"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- 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
- patchXZ
- buildProduct $PKG_NAME
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lzmadec"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lzmainfo"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/xz"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/xzdec"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/liblzma.5.dylib"
- fi
- }
- buildBZip2() {
- PKG_NAME="bzip2-1.0.6"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- downloadProduct https://gigenet.dl.sourceforge.net/project/bzip2/bzip2-1.0.6.tar.gz - $RAW_NAME $VERSION
- patchBZip2
- make -j8 install PREFIX="$SKEL_PREFIX/$ROOT_PREFIX"
- checkStatus $PKG_NAME $? "true"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bunzip2"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bzcat"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bzip2"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/bzip2recover"
- cd "$BUILD_ROOT"
- fi
- }
- buildLZ4() {
- PKG_NAME="lz4-1.7.5"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- downloadProduct https://github.com/lz4/lz4/archive/v1.7.5.tar.gz - $RAW_NAME $VERSION
- cd contrib/cmake_unofficial/
- mkdirIfNecessary build
- cd build
- cmake -DCMAKE_INSTALL_NAME_DIR="/$ROOT_PREFIX/lib" -DCMAKE_OSX_SYSROOT="$SDK_PATH/" -DCMAKE_C_FLAGS="-arch $ARCH" -DCMAKE_INSTALL_PREFIX="/$ROOT_PREFIX" ..
- checkStatus $PKG_NAME $? "false"
- make -j8
- make -j8 DESTDIR="$SKEL_PREFIX" install
- checkStatus $PKG_NAME $? "true"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lz4"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/lz4c"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/liblz4.1.7.5.dylib"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/liblz4.1.dylib"
- cd "$BUILD_ROOT"
- fi
- }
- downloadOpenSSL() {
- if [[ ! -d openssl ]]; then
- git clone -b OpenSSL_1_1_0-stable https://github.com/openssl/openssl.git
- else
- echo "Using existing openssl repo"
- fi
- WORKING_DIR="openssl"
- PKG_NAME="openssl"
- PKG_VERSION="1.1.0-1"
- cd "$WORKING_DIR"
- }
- buildOpenSSL() {
- PKG_NAME="openssl"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- LOG_FILE="$ROOT_LOG_FOLDER/openssl.log"
- touch $LOG_FILE
- downloadOpenSSL
- patchOpenSSL
- export AR=""
- export PLATFORM="$PLATFORM"
- export BUILD_TOOLS="$(xcode-select --print-path)"
- export CC="clang -fembed-bitcode"
- export CROSS_COMPILE="$(xcode-select --print-path)/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
- export CROSS_TOP="$(xcode-select --print-path)/Platforms/$PLATFORM.platform/Developer"
- export CROSS_SDK="$(echo $SDK_PATH | sed 's/.*\///g')"
- notifyProgress "Configuring openSSL"
- if [[ $LOG_VERBOSE == "verbose"* ]]; then
- ./Configure ios64-cross no-dso no-hw no-engine --prefix="/$ROOT_PREFIX" | tee "${LOG_FILE}"
- EC=$(grep "configure: error:" -i "${LOG_FILE}" -c)
- checkStatus $PKG_NAME $EC "false"
- else
- (./Configure ios64-cross no-dso no-hw no-engine --prefix="/$ROOT_PREFIX" > "$LOG_FILE" 2>&1)
- checkStatus $PKG_NAME $? "false"
- if [[ $OPEN_LOG == "true" ]]; then
- open "${LOG_FILE}"
- fi
- fi
- echo -e "\n\nPOST CONFIGURE\n\n" >> "$LOG_FILE"
- notifyProgress "making openSSL"
- if [[ $LOG_VERBOSE == "verbose"* ]]; then
- make DESTDIR="$SKEL_PREFIX" install | tee -a "${LOG_FILE}"
- EC=$(grep "fatal error:" -i "${LOG_FILE}" -c)
- checkStatus $PKG_NAME $EC "true"
- else
- (make DESTDIR="$SKEL_PREFIX" install >> "${LOG_FILE}" 2>&1)
- checkStatus $PKG_NAME $? "true"
- fi
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/openssl"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libcrypto.1.1.dylib"
- cd "$BUILD_ROOT"
- fi
- }
- buildCurl() {
- PKG_NAME="curl-7.50.1"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- downloadProduct https://curl.haxx.se/download/curl-7.50.1.tar.gz - $RAW_NAME $VERSION
- patchCurl
- buildProduct $PKG_NAME
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/curl"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libcurl.4.dylib"
- fi
- }
- patchBerkeleyDB() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' ../dist/config.hin
- #if [[ "$PKG_VERSION" == "6.2.23-1" ]]; then
- cat ../lang/sql/sqlite/src/shell.c | head -n 14 > shell.patched.c
- echo "#include <stdint.h>" >> shell.patched.c
- echo "#include <stdio.h>" >> shell.patched.c
- echo "#include <stdlib.h>" >> shell.patched.c
- echo "#include <spawn.h>" >> shell.patched.c
- echo "#include <sys/wait.h>" >> shell.patched.c
- echo "#include <sys/stat.h>" >> shell.patched.c
- echo "" >> shell.patched.c
- echo "extern char **environ;" >> shell.patched.c
- echo "" >> shell.patched.c
- cat ../lang/sql/sqlite/src/shell.c | tail -n 4847 | head -n 2622 >> shell.patched.c
- fixSystem "shell.patched.c"
- cat ../lang/sql/sqlite/src/shell.c | tail -n 2226 | sed 's/system(zCmd)/RunCmd(zCmd)/g' >> shell.patched.c
- cp shell.patched.c ../lang/sql/sqlite/src/shell.c
- #fi
- fi
- }
- buildBerkeleyDB() {
- PKG_NAME="db-6.2.23"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- LOG_FILE="$ROOT_LOG_FOLDER/$PKG_NAME.log"
- touch $LOG_FILE
- splitName $PKG_NAME
- DOWNLOAD_URL="http://download.oracle.com/berkeley-db/db-6.2.23.tar.gz"
- downloadProduct $DOWNLOAD_URL - $RAW_NAME $VERSION
- cd build_unix
- patchBerkeleyDB
- export CPP="$(xcrun --sdk $PLATFORM_LOWER -f clang) -E "
- export CXXCPP="$(xcrun --sdk $PLATFORM_LOWER -f clang++) -E "
- export PLATFORM="$PLATFORM" #TODO: Maybe necessary? Need to test.
- export BUILD_TOOLS="$(xcode-select --print-path)"
- export CC="clang"
- export CROSS_COMPILE="$(xcode-select --print-path)/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
- export CROSS_TOP="$(xcode-select --print-path)/Platforms/$PLATFORM.platform/Developer"
- export CROSS_SDK="$(echo $SDK_PATH | sed 's/.*\///g')"
- export CFLAGS="-arch $ARCH -pipe -Os -gdwarf-2 -isysroot $SDK_PATH $MIN_VERSION"
- export CXXFLAGS="-arch $ARCH -pipe -Os -gdwarf-2 -isysroot $SDK_PATH $MIN_VERSION"
- export LDFLAGS="-arch $ARCH -isysroot $SDK_PATH" # -L${SKEL_PREFIX}/lib"
- #buildProduct $PKG_NAME
- if [[ $LOG_VERBOSE == "verbose"* ]]; then
- ../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}"
- else
- (../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)
- if [[ $OPEN_LOG == "true" ]]; then
- open "${LOG_FILE}"
- fi
- fi
- checkStatus $PKG_NAME $? "false"
- if [[ $LOG_VERBOSE == "verbose"* ]]; then
- make DESTDIR="$SKEL_PREFIX" install | tee "${LOG_FILE}"
- else
- (make DESTDIR="$SKEL_PREFIX" install >> "${LOG_FILE}" 2>&1)
- fi
- checkStatus $PKG_NAME $? "true"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_archive"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_checkpoint"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_deadlock"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_dump"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_hotbackup"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_load"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_log_verify"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_printlog"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_recover"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_replicate"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_sql_codegen"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_stat"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_tuner"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_upgrade"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/db_verify"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dbsql"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libdb_sql-6.2.dylib"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libdb-6.2.dylib"
- fi
- }
- buildTar(){
- PKG_NAME="tar-1.33"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- downloadProduct http://ftp.gnu.org/gnu/tar/tar-1.33.tar.xz - $RAW_NAME $VERSION
- patchTar
- buildProduct $PKG_NAME
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/tar"
- fi
- }
- #Download dpkg
- downloadDpkg() {
- if [[ ! -d dpkg ]]; then
- echo "Downlading dpkg"
- git clone https://git.nito.tv/NitoTV/dpkg.git
- else
- echo "Using existing dpkg"
- fi
- WORKING_DIR="dpkg"
- PKG_NAME="dpkg"
- PKG_VERSION="1.18.23-1" #FIXME
- cd "$WORKING_DIR"
- }
- #dpkg
- buildDpkg() {
- PKG_NAME="dpkg"
- LOG_FILE="$ROOT_LOG_FOLDER/$PKG_NAME.log"
- touch $LOG_FILE
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- downloadDpkg
- local dont_die_here=$(./autogen.sh)
- # need to clear these preprocessor flags or they get all wonky
- export CPP="$(xcrun --sdk $PLATFORM_LOWER -f clang) -E "
- export CXXCPP="$(xcrun --sdk $PLATFORM_LOWER -f clang++) -E "
- export LZMA_LIBS="$SKEL_PREFIX/$ROOT_PREFIX/lib/liblzma.dylib"
- export CC=$(xcrun --sdk $PLATFORM_LOWER --find clang)
- export CXX=$(xcrun --sdk $PLATFORM_LOWER --find clang++)
- export CFLAGS="-isysroot $SDK_PATH -I$SDK_PATH/usr/include -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH"
- export CXXFLAGS=$CFLAGS
- export LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH"
- export CPPFLAGS="-isysroot $SDK_PATH -I$SKEL_PREFIX/$ROOT_PREFIX/include/ -arch $ARCH"
- export CXXFLAGS=$CFLAGS
- export LDFLAGS="-isysroot $SDK_PATH -L$SKEL_PREFIX/$ROOT_PREFIX/lib/ -arch $ARCH"
- if [[ $LOG_VERBOSE == "verbose"* ]]; then
- ./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}"
- EC=$(grep "configure: error:" -i "${LOG_FILE}" -c)
- checkStatus $PKG_NAME $EC "false"
- else
- (./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)
- if [[ $OPEN_LOG == "true" ]]; then
- open "${LOG_FILE}"
- fi
- fi
- checkStatus $PKG_NAME $? "false"
- patchDpkg #Must be after configure for now. I'll deal with this later
- if [[ $LOG_VERBOSE == "verbose"* ]]; then
- make -j8 DESTDIR="$SKEL_PREFIX" install | tee "${LOG_FILE}"
- EC=$(grep "fatal error:" -i "${LOG_FILE}" -c)
- checkStatus $PKG_NAME $EC "true"
- else
- (make -j8 DESTDIR="$SKEL_PREFIX" install >> "${LOG_FILE}" 2>&1)
- checkStatus $PKG_NAME $? "true"
- fi
- #lzma conflicts with built in libraries when running in certian conditions.
- #we make -j8 a symlink our version of lzma in the xz build process
- #here we change dpkg-deb to look for this version instead
- #if we do not do this, apt-get/dpkg* will fail from our setuid tool
- install_name_tool -change /usr/lib/liblzma.5.dylib /usr/local/lib/liblzma.5.dylib "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-deb"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-deb"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-divert"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-query"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-split"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-trigger"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dpkg-statoverride"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/update-alternatives"
- echo "appletvos-arm64" >> "$SKEL_PREFIX/var/lib/dpkg/arch"
- echo "darwin-arm64" >> "$SKEL_PREFIX/var/lib/dpkg/arch"
- cd "$BUILD_ROOT"
- fi
- }
- buildDPKGAndDependencies() {
- notifyProgress "Building zlib"
- buildZLib
- notifyProgress "Building xz"
- buildXZ
- notifyProgress "Building bzip2"
- buildBZip2
- notifyProgress "Building lz4"
- buildLZ4
- notifyProgress "Building openSSL"
- buildOpenSSL
- notifyProgress "Building curl"
- buildCurl
- notifyProgress "Building BerkeleyDB"
- buildBerkeleyDB
- notifyProgress "Building tar"
- buildTar
- notifyProgress "Building dpkg"
- buildDpkg
- }
- buildGpgError() {
- PKG_NAME="libgpg-error-1.32"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- #splitName $PKG_NAME
- DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.32.tar.bz2"
- downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig libgpg-error 1.32
- #sed -i -- 's|#include <stdlib.h>|\n#if !defined(__arm64__)\n#define __arm64__\n#endif\n\n#include <stdlib.h>|' ncurses/build.priv.h
- #echo -e "\n#if !defined(__arm64__)\n#define __arm64__\n#endif\n\n" >> config.h.in
- #export HOST="arm"
- buildProduct $PKG_NAME "--enable-threads=posix"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libgpg-error.0.dylib"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-error"
- #export HOST="aarch64"
- fi
- }
- patchGcrypt() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- #if [[ "$PKG_VERSION" == "1.8.2-1" ]]; then
- cat tests/random.c | head -n 39 > random.patched.c
- echo "#include <stdint.h>" >> random.patched.c
- echo "#include <stdio.h>" >> random.patched.c
- echo "#include <stdlib.h>" >> random.patched.c
- echo "#include <spawn.h>" >> random.patched.c
- echo "#include <sys/wait.h>" >> random.patched.c
- echo "#include <sys/stat.h>" >> random.patched.c
- echo "" >> random.patched.c
- echo "extern char **environ;" >> random.patched.c
- echo "" >> random.patched.c
- fixSystem "random.patched.c"
- cat tests/random.c | tail -n 727 | sed 's/system (cmdline)/RunCmd(cmdline)/g' >> random.patched.c
- cp random.patched.c tests/random.c
- #fi
- fi
- }
- buildGcrypt() {
- PKG_NAME="libgcrypt-1.8.2"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- 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
- patchGcrypt
- export HOST="arm"
- buildProduct $PKG_NAME "--with-libgpg-error-prefix=$SKEL_PREFIX/$ROOT_PREFIX/"
- export HOST="aarch64"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dumpsexp"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/hmac256"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/mpicalc"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libgcrypt.20.dylib"
- fi
- }
- patchKSBA() {
- sed -i -- 's|#include <stdarg.h>|#include <stdarg.h>\n#include "ksba.h"\n|' src/asn1-gentables.c
- FIND='$(CC_FOR_BUILD) -I$(srcdir)'
- sed -i -- "s|$FIND |$FIND -I$SKEL_PREFIX/$ROOT_PREFIX/include |" src/Makefile.in
- # sed -i -- "s|$(CC_FOR_BUILD) -I$(srcdir) |$(CC_FOR_BUILD) -I$(srcdir) -I$SKEL_PREFIX/$ROOT_PREFIX/include/ |" src/Makefile.in
- sed -i -- 's|const char \*gpg_strerror|//const char \*gpg_strerror|' src/gen-help.h
- }
- buildKSBA() {
- PKG_NAME="libksba-1.3.5"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/libksba/libksba-1.3.5.tar.bz2"
- downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig $RAW_NAME $VERSION
- patchKSBA
- buildProduct $PKG_NAME "--with-libgpg-error-prefix=$SKEL_PREFIX/$ROOT_PREFIX/"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libksba.8.dylib"
- fi
- }
- patchNpth() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- sed -i -- 's|#undef HAVE_CLOCK_GETTIME||' config.h.in
- #if [[ "$PKG_VERSION" == "1.5-1" ]]; then
- cat src/npth.c | head -n 19 > npth.patched.c
- echo "#include <stdint.h>" >> npth.patched.c
- echo "#include <stdio.h>" >> npth.patched.c
- echo "#include <stdlib.h>" >> npth.patched.c
- echo "#include <spawn.h>" >> npth.patched.c
- echo "#include <sys/wait.h>" >> npth.patched.c
- echo "" >> npth.patched.c
- echo "extern char **environ;" >> npth.patched.c
- echo "" >> npth.patched.c
- cat src/npth.c | tail -n 757 | head -n 537 >> npth.patched.c
- fixSystem "npth.patched.c"
- cat src/npth.c | tail -n 220 | sed 's/system(cmd)/RunCmd(cmd)/g' >> npth.patched.c
- cp npth.patched.c src/npth.c
- #fi
- fi
- }
- buildNpth() {
- PKG_NAME="npth-1.5"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/npth/npth-1.5.tar.bz2"
- downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig $RAW_NAME $VERSION
- patchNpth
- buildProduct $PKG_NAME
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libnpth.0.dylib"
- fi
- }
- #https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-2.5.1.tar.bz2
- buildAssuan() {
- PKG_NAME="libassuan-2.5.1"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-2.5.1.tar.bz2"
- downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig $RAW_NAME $VERSION
- buildProduct $PKG_NAME "--with-libgpg-error-prefix=$SKEL_PREFIX/$ROOT_PREFIX/"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libassuan.0.dylib"
- fi
- }
- patchNtbtls() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- # this is required because prior dependencies write /$ROOT_PREFIX/lib/libgpg-error.la as a dependency in the .la file
- 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"
- 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"
- rm -f "$SKEL_PREFIX/$ROOT_PREFIX/lib/libgcrypt.la--"
- rm -f "$SKEL_PREFIX/$ROOT_PREFIX/lib/libksba.la--"
- fi
- }
- buildNtbtls() {
- PKG_NAME="ntbtls-0.1.2"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/ntbtls/ntbtls-0.1.2.tar.bz2"
- downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig $RAW_NAME $VERSION
- patchNtbtls
- 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"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libntbtls.0.dylib"
- fi
- }
- patchGpg() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- #if [[ "$PKG_VERSION" == "2.2.3-1" ]]; then
- cat "g10/exec.c" | head -n 54 > "exec.patched.c"
- echo "#include <stdint.h>" >> "exec.patched.c"
- echo "#include <stdio.h>" >> "exec.patched.c"
- echo "#include <stdlib.h>" >> "exec.patched.c"
- echo "#include <spawn.h>" >> "exec.patched.c"
- echo "#include <sys/wait.h>" >> "exec.patched.c"
- echo "" >> "exec.patched.c"
- echo "extern char **environ;" >> "exec.patched.c"
- echo "" >> "exec.patched.c"
- cat "g10/exec.c" | head -n 111 | tail -n 57 >> "exec.patched.c"
- fixSystem "exec.patched.c"
- cat "g10/exec.c" | tail -n 524 | sed 's/=system(info->command)/=RunCmd(info->command)/g' >> "exec.patched.c"
- cp "exec.patched.c" "g10/exec.c"
- #fi
- fi
- }
- #
- buildGpg() {
- PKG_NAME="gnupg-2.2.3"
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- echo "building $PKG_NAME..."
- splitName $PKG_NAME
- DOWNLOAD_URL="https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.2.3.tar.bz2"
- downloadProduct $DOWNLOAD_URL $DOWNLOAD_URL.sig $RAW_NAME $VERSION
- patchGpg
- 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/"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dirmngr"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/dirmngr-client"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-agent"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-connect-agent"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgconf"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgparsemail"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgscm"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgsm"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgtar"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpgv"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/kbxutil"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/watchgnupg"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-check-pattern"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-preset-passphrase"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-protect-tool"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/gpg-wks-client"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/scdaemon"
- fi
- }
- patchAPT() {
- if [[ "$PLATFORM" == "AppleTVOS" ]]; then
- sed -i -- '/^INCLUDE_DIRECTORIES/d' ../CMakeLists.txt
- sed -i -- '/^LINK_DIRECTORIES/d' ../CMakeLists.txt
- cat ../CMakeLists.txt | head -n 15 > newCmakeLists.txt
- echo "INCLUDE_DIRECTORIES($SKEL_PREFIX/$ROOT_PREFIX/include)" >> newCmakeLists.txt
- echo "LINK_DIRECTORIES($SKEL_PREFIX/$ROOT_PREFIX/lib)" >> newCmakeLists.txt
- echo "" >> newCmakeLists.txt
- cat ../CMakeLists.txt | tail -n 217 >> newCmakeLists.txt
- mv newCmakeLists.txt ../CmakeLists.txt
- #sed -i -- "s|/Users/jaywalker/RnD/ATV/packages/test/skel/|$SKEL_PREFIX/|g" ../CMakeLists.txt
- fi
- }
- downloadApt() {
- if [[ ! -d apt ]]; then
- echo "Downlading apt"
- git clone https://git.nito.tv/NitoTV/apt.git
- else
- echo "Using existing apt"
- fi
- WORKING_DIR="apt"
- cd "$WORKING_DIR"
- removeIfNecessary build
- mkdirIfNecessary build
- cd build
- WORKING_DIR="$WORKING_DIR/build"
- }
- buildAPT() {
- PKG_NAME="apt7-0.7.25.3"
- LOG_FILE="$ROOT_LOG_FOLDER/$PKG_NAME.log"
- touch $LOG_FILE
- checkBuilt $PKG_NAME
- if [[ $? != 0 ]]; then
- echo "$PKG_NAME already exists, skipping!"
- else
- downloadApt
- patchAPT
- echo "build output going to: " $LOG_FILE
- if [[ $LOG_VERBOSE == "verbose"* ]]; then
- 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}"
- #FIXME : need status / error checking here!
- else
- (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)
- checkStatus $PKG_NAME $? "false"
- if [[ $OPEN_LOG == "true" ]]; then
- open "${LOG_FILE}"
- fi
- fi
- sed -i -- "s|#define COMMON_ARCH \"darwin-amd64\"|#define COMMON_ARCH \"$PLATFORM_LOWER-$ARCH\"|" include/config.h
- pwd
- sed -i -- "s|_error->Warning(_(\"No sandbox user|//_error->Warning(_(\"No sandbox user|" ../apt-pkg/acquire.cc
- if [[ $LOG_VERBOSE == "verbose"* ]]; then
- make -j8 DESTDIR="$SKEL_PREFIX" install | tee "${LOG_FILE}"
- EC=$(grep "fatal error:" -i "${LOG_FILE}" -c)
- checkStatus $PKG_NAME $EC "true"
- else
- (make -j8 DESTDIR="$SKEL_PREFIX" install >> "${LOG_FILE}" 2>&1)
- checkStatus $PKG_NAME $? "true"
- fi
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-cache"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-cdrom"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-config"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-ftparchive"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-get"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-mark"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-sortpkgs"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libapt-inst.2.0.0.dylib"
-
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libapt-private.0.0.0.dylib"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/apt-helper"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/cdrom"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/copy"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/file"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/ftp"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/gpgv"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/http"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/https"
- #codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/mirror"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/rred"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/rsh"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/methods/store"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/planners/apt"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/solvers/apt"
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/libexec/apt/solvers/dump"
- sed -i -- "s|/bin/sh|/fs/jb/bin/sh|" "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-key"
- rm "$SKEL_PREFIX/$ROOT_PREFIX/bin/apt-key--"
- #lzma conflicts with built in libraries we make -j8 an extra copy of our version of lzma in the xz build process
- #here we change libapt-pkg*.dylib to look for this version instead
- #if we do not do this, apt-get will fail from our helper tool
- 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
- codesign "$SKEL_PREFIX/$ROOT_PREFIX/lib/libapt-pkg.5.0.1.dylib"
- cd "$BUILD_ROOT"
- fi
- }
- buildAPTAndDependencies() {
- notifyProgress "Building gpg-error"
- buildGpgError
- notifyProgress "Building gcrypt"
- buildGcrypt
- notifyProgress "Building KSBA"
- buildKSBA
- notifyProgress "Building npth"
- buildNpth
- notifyProgress "Building Assuan"
- buildAssuan
- notifyProgress "Building ntbtls"
- buildNtbtls
- notifyProgress "Building gpg"
- buildGpg
- notifyProgress "Building apt"
- buildAPT
- }
- prepSDK() {
- if [[ ! -e "$SDK_PATH/usr/include/sys/ttydev.h" ]]; then
- echo "Missing <sys/ttydev.h>. Moving it in from MacOSX SDK (with sudo)"
- sudo cp "$(xcrun --sdk macosx --show-sdk-path)/usr/include/sys/ttydev.h" "$SDK_PATH/usr/include/sys/ttydev.h"
- fi
- if [[ ! -e "$SDK_PATH/usr/include/lockdown.h" ]]; then
- echo "Missing lockdown.h! Generating the bare essentials for apt to build..."
- echo "#ifndef LOCKDOWN_LOCKDOWN_H" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "#define LOCKDOWN_LOCKDOWN_H" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "#include <CoreFoundation/CFString.h>" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "#ifdef __cplusplus" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "extern \"C\" {" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "#endif" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "extern CFStringRef kLockdownUniqueDeviceIDKey;" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "extern void *lockdown_connect(void);" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "extern CFStringRef lockdown_copy_value(void *lockdown, void *null, CFStringRef key);" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "extern void lockdown_disconnect(void *lockdown);" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "#ifdef __cplusplus" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "}" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "#endif" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "" >> "$SDK_PATH/usr/include/lockdown.h"
- echo "#endif/*LOCKDOWN_LOCKDOWN_H*/" >> "$SDK_PATH/usr/include/lockdown.h"
- fi
- IOKIT_MATCH="`find ~/Library/Developer/Xcode/tvOS\ DeviceSupport/ -name IOKit.framework | grep "$SDK_VERSION" -m 1`"
- echo "IOKit match: $IOKIT_MATCH"
- echo "IOKit: $SDK_PATH/System/Library/Frameworks/IOKit.framework"
- if [[ ! -d "$SDK_PATH/System/Library/Frameworks/IOKit.framework" ]]; then
- if [[ ! -z "$IOKIT_MATCH" ]]; then
- echo "we do indeed have an IOKit match and IOKit is missing!!"
- echo "cp -r $IOKIT_MATCH $SDK_PATH/System/Library/Frameworks/"
- cp -r "$IOKIT_MATCH" "$SDK_PATH/System/Library/Frameworks/"
- fi
- fi
- # patch fork to be available in tvOS
- sed -i -- "s|__TVOS_PROHIBITED| |" $SDK_PATH/usr/include/unistd.h
- # patch 'system' in places where it isnt patched out and replaced by our own version (ie cdromtools etc)
- sed -i -- "s|__TVOS_PROHIBITED| |" $SDK_PATH/usr/include/stdlib.h
- sed -i -- "s|__API_AVAILABLE(macos(10.0))|__API_AVAILABLE(macos(10.0), tvos(9.0))|" $SDK_PATH/usr/include/stdlib.h
- }
- if [[ $LOG_VERBOSE == "verbose"* ]]; then
- set -x
- fi
- if [[ "$VERIFY" == "true" ]]; then
- command -v gpg >/dev/null 2>&1 || { echo >&2 "Missing GPG. Cannot verify. Dying."; exit 127 ; }
- echo "Importing necessary PGP keys"
- gpg --recv-key 69184620 7C0135FB088AAF6C66C650B9BB5869F064EA74AB 702353E0F7E48EDB 7FD9FCCB000BEEEE A15B725964A95EE5 D8692123C4065DEA5E0F3AB5249B39D24F25E3B6 031EC2536E580D8EA286A9F22071B08A33BD3F06 9D5EAAF69013B842
- fi
- createListFile() {
- echo -e "\ncreateListFile $1\n"
- DEB=$1
- INFOPATH="$SKEL_PREFIX/private/var/lib/dpkg/info"
- PKG=$(dpkg-deb -f "$DEB" Package 2>/dev/null)
- #echo $PKG list
- rm -rf tmp
- mkdir tmp
- dpkg-deb -e "$DEB" tmp
- dpkg-deb -c "$DEB" | awk '{ print $6 }' | cut -c 2- > $PKG.list #| sed "s|usr|fs/usr|g"
- sed -e '1 s|/|/.|' $PKG.list > $INFOPATH/$PKG.list
- rm $PKG.list
- FILES="tmp/*"
- for f in $FILES; do
- file=${f##*/}
- if [[ "$file" != "control" ]]; then
- echo "Processing $file in $PKG..";
- cp "$f" "$INFOPATH/$PKG.$file"
- fi
- done
- }
- createStatusFile() {
- cd "$BUILD_ROOT"
- rm -rf status
- rm -rf available
- for f in debs/*.deb; do
- echo "Processing $f..";
- dpkg-deb -f "$f" >> status
- dpkg-deb -f "$f" >> available
- echo "Status: install ok installed" >> status
- echo "" >> status
- echo "" >> available
- createListFile $f
- done
- for f in ndeb/*.deb; do
- echo "Processing $f..";
- dpkg-deb -f "$f" >> status
- dpkg-deb -f "$f" >> available
- echo "Status: install ok installed" >> status
- echo "" >> status
- echo "" >> available
- createListFile $f
- done
- if [[ -d "$SKEL_PREFIX/private/var/lib/dpkg/" ]]; then
- mv status "$SKEL_PREFIX/private/var/lib/dpkg/status"
- mv available "$SKEL_PREFIX/private/var/lib/dpkg/available"
- else
- echo "### [WARNING]: $SKEL_PREFIX/private/var/lib/dpkg/ is missing! this bootstrap is likely malformed..."
- echo ""
- mv status "$SKEL_PREFIX/var/lib/dpkg/status"
- mv available "$SKEL_PREFIX/var/lib/dpkg/available"
- fi
- }
- cleanBootstrap() {
- # Get rid of the docs
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/docs"
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/doc"
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/info"
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/man"
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/man"
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/gnupg" #TODO: See if the keys in this folder are needed
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/readline"
- # Get rid of dev stuff
- #rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/include"
- #rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/aclocal"
- #rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/pkgconfig"
- #rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/share/common-lisp"
- # remove all the static and libtool libraries from the bootstrap, they take up a LOT of space
- #cd "$SKEL_PREFIX/$ROOT_PREFIX/lib"
- rm *.a
- rm *.la
- #rmdir "$SKEL_PREFIX/$ROOT_PREFIX/var"
- #Get rid of non-skel packages which were needed to compile
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/gpg-error-config"
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/libgcrypt-config"
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/lib/pkgconfig"
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/curl-config"
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/ncurses6-config"
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/npth-config"
- rm -rf "$SKEL_PREFIX/$ROOT_PREFIX/bin/ntbtls-config"
- }
- mkdirIfNecessary $ROOT_LOG_FOLDER
- mkdirIfNecessary $ALREADY_BUILT
- # Ensure our SDK has all the required "extras" installed/setup
- prepSDK
- buildBashAndFriends
- buildBasicUtils
- buildDPKGAndDependencies
- buildAPTAndDependencies
- # comment the below in to clean up aftewards to slim down the bootstrap
- if [[ $TRIM == "true" ]]; then
- cleanBootstrap
- fi
- if [[ $CREATE_STATUS == "true" ]]; then
- createStatusFile
- fi
- echo -e "\nDone!\n"
- sayIfVerbal "Finished!"
|