Skip to content
Permalink
Browse files

Initial push

  • Loading branch information...
fornwall committed Jun 12, 2015
1 parent 798619b commit 59f0d218a6ff34c80cf898f6d7ac62555ba8eb11
Showing 663 changed files with 44,233 additions and 0 deletions.
@@ -0,0 +1,26 @@
#!/bin/bash
# build-all.sh - script to build all packages with a build order specified by buildorder.py

set -e -u -o pipefail

BUILDSCRIPT=`dirname $0`/build-package.sh
BUILDORDER_FILE=$HOME/termux/_buildall/buildorder.txt

if [ -e $BUILDORDER_FILE ]; then
echo "Continuing with existing buildorder file: $BUILDORDER_FILE"
else
rm -Rf $HOME/termux /data/data $HOME/termux/_buildall
mkdir -p $HOME/termux/_buildall
./buildorder.py packages > $BUILDORDER_FILE
fi

exec >> $HOME/termux/_buildall/ALL.out 2>> $HOME/termux/_buildall/ALL.err

for package in `cat $BUILDORDER_FILE`; do
echo -n "Building $package... " >> $HOME/termux/_buildall/ALL.out
BUILD_START=`date "+%s"`
bash -x $BUILDSCRIPT $package > $HOME/termux/_buildall/${package}.out 2> $HOME/termux/_buildall/${package}.err
BUILD_END=`date "+%s"`
BUILD_SECONDS=$(( $BUILD_END - $BUILD_START ))
echo "done in $BUILD_SECONDS"
done

Large diffs are not rendered by default.

@@ -0,0 +1,88 @@
#!/usr/bin/env python3
# buildorder.py - script to generate a build order respecting package dependencies

import os, sys

def die(msg):
print('ERROR: ' + msg)
sys.exit(1)

if len(sys.argv) != 2: die("Supply path to packages directory as first and only argument")
packages_dir = sys.argv[1]
if not os.path.isdir(packages_dir): die(packages_dir + ' is not a directory')

class DebianPackage:
def __init__(self, name):
self.name = name
self.remaining_dependencies = set() # String
self.sub_packages = set() # String
self.prerequisite_for = set() # Packages that needs this package

all_packages = [] # List of all DebianPackage:s
packages_map = {} # Mapping from package name to DebianPackage (if subpackage, mapping from subpackage name to parent package)

for subdir_name in sorted(os.listdir(packages_dir)):
subdir_path = packages_dir + '/' + subdir_name
if os.path.exists(subdir_path + '/BROKEN.txt'): continue
build_sh_path = subdir_path + '/build.sh'

this_package = DebianPackage(subdir_name)
all_packages.append(this_package)
packages_map[this_package.name] = this_package

if not os.path.isfile(build_sh_path): die('The directory ' + subdir_name + ' does not contain build.sh')
with open(build_sh_path) as build_sh_file:
for line in build_sh_file:
if line.startswith('TERMUX_PKG_DEPENDS='):
deps_comma_separated = line[(line.index('=')+2):(len(line)-2)]
for dep in deps_comma_separated.split(','):
dep = dep.strip()
this_package.remaining_dependencies.add(dep)
for file_in_subdir_name in sorted(os.listdir(subdir_path)):
if file_in_subdir_name.endswith('.subpackage.sh'):
subpackage_name = file_in_subdir_name[0:-len(".subpackage.sh"):]
this_package.sub_packages.add(subpackage_name)
packages_map[subpackage_name] = this_package
with open(subdir_path + '/' + file_in_subdir_name) as subpackage_sh_file:
for line in subpackage_sh_file:
if line.startswith('TERMUX_SUBPKG_DEPENDS='):
deps_comma_separated = line[(line.index('=')+2):(len(line)-2)]
for dep in deps_comma_separated.split(','):
dep = dep.strip()
this_package.remaining_dependencies.add(dep)
this_package.remaining_dependencies.discard(this_package.name) # Do not depend on itself
this_package.remaining_dependencies.difference_update(this_package.sub_packages) # Do not depend on any sub package

for package in all_packages:
for remaining in package.remaining_dependencies:
if not remaining in packages_map: die('Package ' + package.name + ' depends on non-existing package "' + remaining + '"')
packages_map[remaining].prerequisite_for.add(package)

# List of all DebianPackage:s without dependencies
packages_without_deps = [p for p in all_packages if not p.remaining_dependencies]
if not packages_without_deps: die('No package without dependency - where to start?')

# Sort alphabetically, but with libandroid-support first (since dependency on libandroid-support
# does not need to be declared explicitly, so anything might in theory depend on it to build):
packages_without_deps.sort(key=lambda p: 'aaaa' if p.name == 'libandroid-support' else p.name, reverse=True)

# Topological sorting
build_order = []
while packages_without_deps:
pkg = packages_without_deps.pop()
build_order.append(pkg)
for other_package in pkg.prerequisite_for:
other_package.remaining_dependencies.discard(pkg.name) # Remove this package
other_package.remaining_dependencies.difference_update(pkg.sub_packages) # .. and all its subpackages
if not other_package.remaining_dependencies:
# Check if the other package is ready to build now
packages_without_deps.append(other_package)

if len(all_packages) != len(build_order):
print("ERROR: Cycle exists. Remaining: ");
for pkg in all_packages:
if pkg not in build_order: print(pkg.name)
sys.exit(1)

for pkg in build_order: print(pkg.name)

@@ -0,0 +1,9 @@
#!/bin/sh
# check-pie.sh - script to detect non-PIE binaries (which does not work on Android)

cd /data/data/com.termux/files/usr/bin/
for file in *; do
if readelf -h $file 2>/dev/null | grep -q 'Type:[[:space:]]*EXEC'; then
echo $file
fi
done
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# check-versions.sh - script to open packages in a browser for checking their versions

OPEN=xdg-open
if [ `uname` = Darwin ]; then OPEN=open; fi

# Run each package in separate process since we include their environment variables:
for path in packages/*; do
(
pkg=`basename $path`
. $path/build.sh
echo -n "$pkg - $TERMUX_PKG_VERSION - press Return to check homepage"
read
$OPEN $TERMUX_PKG_HOMEPAGE
)
done
@@ -0,0 +1,5 @@
#!/bin/sh
# clean-rebuild-all.sh - clean everything and rebuild

rm -Rf /data/data $HOME/termux $HOME/lib/android-standalone-toolchain-*
bash -x build-all.sh
@@ -0,0 +1,3 @@
#!/bin/sh

android update sdk --all --no-https --no-ui --filter build-tools-22.0.1,android-21
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# list-packages.sh - tool to list all package with home pages and descriptions

for path in packages/*; do (
pkg=`basename $path`
. $path/build.sh
echo "$pkg($TERMUX_PKG_VERSION): $TERMUX_PKG_HOMEPAGE"
echo " $TERMUX_PKG_DESCRIPTION"
) done
@@ -0,0 +1,120 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* JNI helper functions.
*
* This file may be included by C or C++ code, which is trouble because jni.h
* uses different typedefs for JNIEnv in each language.
*/
#ifndef _NATIVEHELPER_JNIHELP_H
#define _NATIVEHELPER_JNIHELP_H

#include "jni.h"
#include "utils/Log.h"

#ifndef NELEM
# define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
#endif

#ifdef __cplusplus
extern "C" {
#endif

/*
* Register one or more native methods with a particular class.
*/
int jniRegisterNativeMethods(C_JNIEnv* env, const char* className,
const JNINativeMethod* gMethods, int numMethods);

/*
* Throw an exception with the specified class and an optional message.
* The "className" argument will be passed directly to FindClass, which
* takes strings with slashes (e.g. "java/lang/Object").
*
* Returns 0 on success, nonzero if something failed (e.g. the exception
* class couldn't be found).
*
* Currently aborts the VM if it can't throw the exception.
*/
int jniThrowException(C_JNIEnv* env, const char* className, const char* msg);

/*
* Throw a java.lang.RuntimeException, with an optional message.
*/
int jniThrowRuntimeException(JNIEnv* env, const char* msg);

/*
* Throw a java.io.IOException, generating the message from errno.
*/
int jniThrowIOException(C_JNIEnv* env, int errnum);

/*
* Create a java.io.FileDescriptor given an integer fd
*/
jobject jniCreateFileDescriptor(C_JNIEnv* env, int fd);

/*
* Get an int file descriptor from a java.io.FileDescriptor
*/
int jniGetFDFromFileDescriptor(C_JNIEnv* env, jobject fileDescriptor);

/*
* Set an int file descriptor to a java.io.FileDescriptor
*/
void jniSetFileDescriptorOfFD(C_JNIEnv* env, jobject fileDescriptor, int value);

#ifdef __cplusplus
}
#endif


/*
* For C++ code, we provide inlines that map to the C functions. g++ always
* inlines these, even on non-optimized builds.
*/
#if defined(__cplusplus) && !defined(JNI_FORCE_C)
inline int jniRegisterNativeMethods(JNIEnv* env, const char* className,
const JNINativeMethod* gMethods, int numMethods)
{
return jniRegisterNativeMethods(&env->functions, className, gMethods,
numMethods);
}
inline int jniThrowException(JNIEnv* env, const char* className,
const char* msg)
{
return jniThrowException(&env->functions, className, msg);
}
inline int jniThrowIOException(JNIEnv* env, int errnum)
{
return jniThrowIOException(&env->functions, errnum);
}
inline jobject jniCreateFileDescriptor(JNIEnv* env, int fd)
{
return jniCreateFileDescriptor(&env->functions, fd);
}
inline int jniGetFDFromFileDescriptor(JNIEnv* env, jobject fileDescriptor)
{
return jniGetFDFromFileDescriptor(&env->functions, fileDescriptor);
}
inline void jniSetFileDescriptorOfFD(JNIEnv* env, jobject fileDescriptor,
int value)
{
return jniSetFileDescriptorOfFD(&env->functions, fileDescriptor, value);
}
#endif

#endif /*_NATIVEHELPER_JNIHELP_H*/
@@ -0,0 +1,111 @@
Add <arpa/ftp.h> for some ftp defines which some packages needs.

diff -Nur /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/arpa/ftp.h ./usr/include/arpa/ftp.h
--- /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/arpa/ftp.h 1970-01-01 01:00:00.000000000 +0100
+++ ./usr/include/arpa/ftp.h 2014-02-07 02:07:52.000000000 +0100
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 1983, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ftp.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _ARPA_FTP_H
+#define _ARPA_FTP_H 1
+
+/* Definitions for FTP; see RFC-765. */
+
+/*
+ * Reply codes.
+ */
+#define PRELIM 1 /* positive preliminary */
+#define COMPLETE 2 /* positive completion */
+#define CONTINUE 3 /* positive intermediate */
+#define TRANSIENT 4 /* transient negative completion */
+#define ERROR 5 /* permanent negative completion */
+
+/*
+ * Type codes
+ */
+#define TYPE_A 1 /* ASCII */
+#define TYPE_E 2 /* EBCDIC */
+#define TYPE_I 3 /* image */
+#define TYPE_L 4 /* local byte size */
+
+#ifdef FTP_NAMES
+char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" };
+#endif
+
+/*
+ * Form codes
+ */
+#define FORM_N 1 /* non-print */
+#define FORM_T 2 /* telnet format effectors */
+#define FORM_C 3 /* carriage control (ASA) */
+#ifdef FTP_NAMES
+char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" };
+#endif
+
+/*
+ * Structure codes
+ */
+#define STRU_F 1 /* file (no record structure) */
+#define STRU_R 2 /* record structure */
+#define STRU_P 3 /* page structure */
+#ifdef FTP_NAMES
+char *strunames[] = {"0", "File", "Record", "Page" };
+#endif
+
+/*
+ * Mode types
+ */
+#define MODE_S 1 /* stream */
+#define MODE_B 2 /* block */
+#define MODE_C 3 /* compressed */
+#ifdef FTP_NAMES
+char *modenames[] = {"0", "Stream", "Block", "Compressed" };
+#endif
+
+/*
+ * Record Tokens
+ */
+#define REC_ESC '\377' /* Record-mode Escape */
+#define REC_EOR '\001' /* Record-mode End-of-Record */
+#define REC_EOF '\002' /* Record-mode End-of-File */
+
+/*
+ * Block Header
+ */
+#define BLK_EOR 0x80 /* Block is End-of-Record */
+#define BLK_EOF 0x40 /* Block is End-of-File */
+#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */
+#define BLK_RESTART 0x10 /* Block is Restart Marker */
+
+#define BLK_BYTECOUNT 2 /* Bytes in this block */
+
+#endif /* arpa/ftp.h */

0 comments on commit 59f0d21

Please sign in to comment.
You can’t perform that action at this time.