diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-09-05 15:10:31 +0200 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-09-06 12:15:24 +0200 |
commit | af08db027b6214306683c8cbf9980798c5f85977 (patch) | |
tree | 97211afd7b11bace6ce508984d110ddf10dc41f2 /prebuilt/common/bin | |
parent | dc5051ce0272ddb572aaa72ecd0e1d00ad9b0f83 (diff) | |
download | external_wget-replicant-11.tar.gz external_wget-replicant-11.tar.bz2 external_wget-replicant-11.zip |
This way:
- We can rebase more easily if needed
- We don't have to bring in the other part of vendor/lineage that
is potentially incompatible with what we have
wget was also moved in the top directory along the way.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Diffstat (limited to 'prebuilt/common/bin')
-rwxr-xr-x | prebuilt/common/bin/50-lineage.sh | 43 | ||||
-rw-r--r-- | prebuilt/common/bin/backuptool.functions | 43 | ||||
-rwxr-xr-x | prebuilt/common/bin/backuptool.sh | 122 | ||||
-rw-r--r-- | prebuilt/common/bin/backuptool_ab.functions | 48 | ||||
-rwxr-xr-x | prebuilt/common/bin/backuptool_ab.sh | 98 | ||||
-rwxr-xr-x | prebuilt/common/bin/backuptool_postinstall.sh | 11 | ||||
-rw-r--r-- | prebuilt/common/bin/sysinit | 9 | ||||
-rwxr-xr-x | prebuilt/common/bin/wget | 184 |
8 files changed, 0 insertions, 558 deletions
diff --git a/prebuilt/common/bin/50-lineage.sh b/prebuilt/common/bin/50-lineage.sh deleted file mode 100755 index 0158744d..00000000 --- a/prebuilt/common/bin/50-lineage.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/sbin/sh -# -# ADDOND_VERSION=2 -# -# /system/addon.d/50-lineage.sh -# During a LineageOS 16.0 upgrade, this script backs up /system/etc/hosts, -# /system is formatted and reinstalled, then the file is restored. -# - -. /tmp/backuptool.functions - -list_files() { -cat <<EOF -etc/hosts -EOF -} - -case "$1" in - backup) - list_files | while read FILE DUMMY; do - backup_file $S/"$FILE" - done - ;; - restore) - list_files | while read FILE REPLACEMENT; do - R="" - [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT" - [ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R" - done - ;; - pre-backup) - # Stub - ;; - post-backup) - # Stub - ;; - pre-restore) - # Stub - ;; - post-restore) - # Stub - ;; -esac diff --git a/prebuilt/common/bin/backuptool.functions b/prebuilt/common/bin/backuptool.functions deleted file mode 100644 index 4319b783..00000000 --- a/prebuilt/common/bin/backuptool.functions +++ /dev/null @@ -1,43 +0,0 @@ -#!/sbin/sh -# -# Functions for backuptool.sh -# - -copy_file() { - cp -dp "$1" "$2" - # symlinks don't have a context - if [ ! -L "$1" ]; then - # it is assumed that every label starts with 'u:object_r' and has no white-spaces - local context=`ls -Z "$1" | grep -o 'u:object_r:[^ ]*' | head -1` - chcon "$context" "$2" - fi -} - -backup_file() { - if [ -e "$1" -o -L "$1" ]; then - local F=`basename "$1"` - local D=`dirname "$1"` - # dont backup any apps that have odex files, they are useless - if ( echo "$F" | grep -q "\.apk$" ) && [ -e `echo "$1" | sed -e 's/\.apk$/\.odex/'` ]; then - echo "Skipping odexed apk $1"; - else - mkdir -p "$C/$D" - copy_file "$1" "$C/$D/$F" - fi - fi -} - -restore_file() { - local FILE=`basename "$1"` - local DIR=`dirname "$1"` - if [ -e "$C/$DIR/$FILE" -o -L "$C/$DIR/$FILE" ]; then - if [ ! -d "$DIR" ]; then - mkdir -p "$DIR"; - fi - copy_file "$C/$DIR/$FILE" "$1"; - if [ -n "$2" ]; then - echo "Deleting obsolete file $2" - rm "$2"; - fi - fi -} diff --git a/prebuilt/common/bin/backuptool.sh b/prebuilt/common/bin/backuptool.sh deleted file mode 100755 index 7ab703ee..00000000 --- a/prebuilt/common/bin/backuptool.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/sbin/sh -# -# Backup and restore addon /system files -# - -export C=/tmp/backupdir -export SYSDEV="$(readlink -nf "$2")" -export SYSFS="$3" -export V=16.0 - -export ADDOND_VERSION=1 - -# Scripts in /system/addon.d expect to find backuptool.functions in /tmp -cp -f /tmp/install/bin/backuptool.functions /tmp - -# Preserve /system/addon.d in /tmp/addon.d -preserve_addon_d() { - if [ -d $S/addon.d/ ]; then - mkdir -p /tmp/addon.d/ - cp -a $S/addon.d/* /tmp/addon.d/ - - # Discard any scripts that aren't at least our version level - for f in /postinstall/tmp/addon.d/*sh; do - SCRIPT_VERSION=$(grep "^# ADDOND_VERSION=" $f | cut -d= -f2) - if [ -z "$SCRIPT_VERSION" ]; then - SCRIPT_VERSION=1 - fi - if [ $SCRIPT_VERSION -lt $ADDOND_VERSION ]; then - rm $f - fi - done - - chmod 755 /tmp/addon.d/*.sh - fi -} - -# Restore /system/addon.d from /tmp/addon.d -restore_addon_d() { - if [ -d /tmp/addon.d/ ]; then - mkdir -p $S/addon.d/ - cp -a /tmp/addon.d/* $S/addon.d/ - rm -rf /tmp/addon.d/ - fi -} - -# Proceed only if /system is the expected major and minor version -check_prereq() { -# If there is no build.prop file the partition is probably empty. -if [ ! -r $S/build.prop ]; then - return 1 -fi -if ! grep -q "^ro.lineage.version=$V.*" $S/build.prop; then - echo "Not backing up files from incompatible version: $V" - return 2 -fi -return 0 -} - -# Execute /system/addon.d/*.sh scripts with $1 parameter -run_stage() { -if [ -d /tmp/addon.d/ ]; then - for script in $(find /tmp/addon.d/ -name '*.sh' |sort -n); do - $script $1 - done -fi -} - -determine_system_mount() { - if grep -q -e"^$SYSDEV" /proc/mounts; then - umount $(grep -e"^$SYSDEV" /proc/mounts | cut -d" " -f2) - fi - - if [ -d /system_root ]; then - SYSMOUNT="/system_root" - export S=/system_root/system - else - SYSMOUNT="/system" - export S=/system - fi - -} - -mount_system() { - mount -t $SYSFS $SYSDEV $SYSMOUNT -o rw,discard -} - -unmount_system() { - umount $SYSMOUNT -} - -determine_system_mount - -case "$1" in - backup) - mount_system - if check_prereq; then - mkdir -p $C - preserve_addon_d - run_stage pre-backup - run_stage backup - run_stage post-backup - fi - unmount_system - ;; - restore) - mount_system - if check_prereq; then - run_stage pre-restore - run_stage restore - run_stage post-restore - restore_addon_d - rm -rf $C - sync - fi - unmount_system - ;; - *) - echo "Usage: $0 {backup|restore}" - exit 1 -esac - -exit 0 diff --git a/prebuilt/common/bin/backuptool_ab.functions b/prebuilt/common/bin/backuptool_ab.functions deleted file mode 100644 index be42261f..00000000 --- a/prebuilt/common/bin/backuptool_ab.functions +++ /dev/null @@ -1,48 +0,0 @@ -#!/system/bin/sh -# -# Functions for backuptool_ab.sh -# - -export S=/system -export C=/postinstall/tmp/backupdir -export V=16.0 -export backuptool_ab=true - -copy_file() { - old=`umask` - umask 0322 - mkdir -m755 -p `dirname $2` - umask "$old" - - cp -dp --preserve=a "$1" "$2" -} - -move_file() { - old=`umask` - umask 0322 - mkdir -m755 -p `dirname $2` - umask "$old" - - mv "$1" "$2" -} - -backup_file() { - if [ -e "$1" -o -L "$1" ]; then - # dont backup any apps that have odex files, they are useless - if ( echo "$1" | grep -q "\.apk$" ) && [ -e `echo "$1" | sed -e 's/\.apk$/\.odex/'` ]; then - echo "Skipping odexed apk $1"; - else - copy_file "$1" "$C/$1" - fi - fi -} - -restore_file() { - if [ -e "$C/$1" -o -L "$C/$1" ]; then - move_file "$C/$1" "/postinstall/$1"; - if [ -n "$2" ]; then - echo "Deleting obsolete file $2" - rm "$2"; - fi - fi -} diff --git a/prebuilt/common/bin/backuptool_ab.sh b/prebuilt/common/bin/backuptool_ab.sh deleted file mode 100755 index 5b0dc08e..00000000 --- a/prebuilt/common/bin/backuptool_ab.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/system/bin/sh -# -# Backup and restore addon /system files -# - -export S=/system -export C=/postinstall/tmp/backupdir -export V=16.0 - -export ADDOND_VERSION=2 - -# Scripts in /system/addon.d expect to find backuptool.functions in /tmp -mkdir -p /postinstall/tmp/ -cp -f /postinstall/system/bin/backuptool_ab.functions /postinstall/tmp/backuptool.functions - -# Preserve /system/addon.d in /tmp/addon.d -preserve_addon_d() { - if [ -d /system/addon.d/ ]; then - mkdir -p /postinstall/tmp/addon.d/ - cp -a /system/addon.d/* /postinstall/tmp/addon.d/ - - # Discard any scripts that aren't at least our version level - for f in /postinstall/tmp/addon.d/*sh; do - SCRIPT_VERSION=$(grep "^# ADDOND_VERSION=" $f | cut -d= -f2) - if [ -z "$SCRIPT_VERSION" ]; then - SCRIPT_VERSION=1 - fi - if [ $SCRIPT_VERSION -lt $ADDOND_VERSION ]; then - rm $f - fi - done - - chmod 755 /postinstall/tmp/addon.d/*.sh - fi -} - -# Restore /postinstall/system/addon.d from /postinstall/tmp/addon.d -restore_addon_d() { - if [ -d /postinstall/tmp/addon.d/ ]; then - mkdir -p /postinstall/system/addon.d/ - cp -a /postinstall/tmp/addon.d/* /postinstall/system/addon.d/ - rm -rf /postinstall/tmp/addon.d/ - fi -} - -# Proceed only if /system is the expected major and minor version -check_prereq() { -# If there is no build.prop file the partition is probably empty. -if [ ! -r /system/build.prop ]; then - exit 127 -fi - -grep -q "^ro.lineage.version=$V.*" /system/build.prop && return 1 - -echo "Not backing up files from incompatible version: $V" -exit 127 -} - -# Execute /system/addon.d/*.sh scripts with $1 parameter -run_stage() { -if [ -d /postinstall/tmp/addon.d/ ]; then - for script in $(find /postinstall/tmp/addon.d/ -name '*.sh' |sort -n); do - # we have no /sbin/sh in android, only recovery - # use /system/bin/sh here instead - sed -i '0,/#!\/sbin\/sh/{s|#!/sbin/sh|#!/system/bin/sh|}' $script - # we can't count on /tmp existing on an A/B device, so utilize /postinstall/tmp - # as a pseudo-/tmp dir - sed -i 's|. /tmp/backuptool.functions|. /postinstall/tmp/backuptool.functions|g' $script - $script $1 - done -fi -} - -case "$1" in - backup) - mkdir -p $C - check_prereq - preserve_addon_d - run_stage pre-backup - run_stage backup - run_stage post-backup - ;; - restore) - check_prereq - run_stage pre-restore - run_stage restore - run_stage post-restore - restore_addon_d - rm -rf $C - rm -rf /postinstall/tmp - sync - ;; - *) - echo "Usage: $0 {backup|restore}" - exit 1 -esac - -exit 0 diff --git a/prebuilt/common/bin/backuptool_postinstall.sh b/prebuilt/common/bin/backuptool_postinstall.sh deleted file mode 100755 index eef04098..00000000 --- a/prebuilt/common/bin/backuptool_postinstall.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/system/bin/sh -# -# LineageOS A/B OTA Postinstall Script -# - -/postinstall/system/bin/backuptool_ab.sh backup -/postinstall/system/bin/backuptool_ab.sh restore - -sync - -exit 0 diff --git a/prebuilt/common/bin/sysinit b/prebuilt/common/bin/sysinit deleted file mode 100644 index 431afbc1..00000000 --- a/prebuilt/common/bin/sysinit +++ /dev/null @@ -1,9 +0,0 @@ -#!/system/bin/sh - -export PATH=/sbin:/system/sbin:/system/bin:/system/xbin -for i in /system/etc/init.d/*; do - if [ -x $i ]; then - /system/bin/log -t sysinit Running $i - $i - fi -done diff --git a/prebuilt/common/bin/wget b/prebuilt/common/bin/wget deleted file mode 100755 index 1d04de54..00000000 --- a/prebuilt/common/bin/wget +++ /dev/null @@ -1,184 +0,0 @@ -#!/system/bin/sh -# wget-curl, a curl wrapper acting as a wget drop-in replacement - version git-HEAD -# Usage: wget [wget args] [i need to fill this in later] <url(s)> -# Download all URLs given using curl, but using wget's options. -# -# -# End of help. -# Copyright (c) 2015 Kylie McClain <somasis@exherbo.org> -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# End of copyright. -# - -set -o pipefail -shopt -u shift_verbose >/dev/null 2>&1 - -help() { - sed -n '/^#/!d;s/^# //;s/^#//;3,${p;}' "$0" | \ - while IFS= read help_line;do - if [[ "$help_line" == "End of help." ]];then - exit 0 - else - printf "%s\n" "$help_line" - fi - done - exit 0 -} - -version() { - sed 's/^# //;s/, .* - version / /;2q;$!d' "$0" - copyright - exit 0 -} - -copyright() { - sed -n '/^#/!d;s/^# //;s/^#//;/End of help./,${p;}' "$0" | \ - while IFS= read copyright_line;do - if [[ "$copyright_line" == "End of help." ]];then - true - elif [[ "$copyright_line" == "End of copyright." ]];then - break - else - printf '%s\n' "$copyright_line" - fi - done -} - -stderr() { - printf "$@" >&2 -} - -error() { - stderr "$0: $1\n" - exit "$2" -} - -invalid_arg() { - error "invalid option -- '$1'" 2 -} - -append_opt() { - for opt in $@;do - CURL_OPTS="${CURL_OPTS} ${opt}" - done -} - -curl() { - eval "command curl $@ ${CURL_RAW}" -} - -append_raw_arg() { - CURL_RAW="$CURL_RAW $@" -} - -has_opt() { # exit 0 if CURL_OPTS has arg, non-zero if doesn't - if [[ "$CURL_OPTS" == *" $1"* ]];then - return 0 - else - return 1 - fi -} - -reexec_without() { # download afterwards without $1 in OPTS - reexec_args_without="$reexec_args_without $@" - reexec=1 -} - -reexec_only() { - for arg in $@;do - CURL_OPTS_REEXEC_ONLY="${CURL_OPTS_REEXEC_ONLY} $arg" - done -} - -print_url() { - has_opt -s || printf "%s\n" "$1" -} - -# 46ABDFHIKLNOPQRSTUVXabcdhiklm nH nc nd np nv opqrtvwx -while getopts ':46ABDFHIKLNO:PQRST:U:VXa:bcdhiklmopqrtvwx' argument "$@";do - case "$argument" in - # a lot of these are noop right now because they are wget mirror args - # which curl doesn't really do, and i am not sure if i should implement them - 4) append_opt -4 ;; - 6) append_opt -6 ;; - A) true ;; # probably can't implement this easily... - B) true ;; - D) true ;; - E) true ;; - F) true ;; # curl doesn't care what the input is - H) true ;; - I) true ;; - K) true ;; - L) true ;; - N) true ;; - O) append_opt "-o $OPTARG" ;; - P) true ;; - Q) true ;; - R) true ;; - S) append_opt -I;reexec_without -I -s ;; - T) append_opt "-m $OPTARG" ;; - U) append_opt "--user-agent \"$OPTARG\"" ;; - V) version; curl --version; exit 0 ;; - X) true ;; - a) append_raw_arg "2>&1 | tee -a $OPTARG" ;; - b) - wget_log="wget-log" - i=1 - while [[ -f "${wget_log}" ]];do - # if that exists, increment until we find something that doesn't - i=$(($i+1)) - wget_log="wget-log.${i}" - done - append_raw_arg ">\"$wget_log\" 2>&1 &" - printf "Continuing in background, pid %s.\nOutput will be written to '$wget_log'.\n" "$$" - ;; - c) append_opt "-C -" ;; - d) append_opt "-v" ;; - e) true ;; - h) help ;; - i) - [[ ! -f "$OPTARG" ]] && error "$OPTARG does not exist" 3 - for url in $(<"$OPTARG");do - URLS=( ${URLS[@]} "$url" ) - done - ;; - q) append_opt "-s" ;; - esac - shift $(($OPTIND-1)) -done - -# set wget default equivilants -append_opt -L # follow redirects -append_opt -# # progress bar - -if [[ -z "${URLS[@]}" ]];then - URLS=( ${@} ) -fi - -for url in ${URLS[@]};do - url_file=${url##*/} - if [[ "$url" == "$url_file" ]];then - # has no remote file name and -o is not in CURL_OPTS... assume index.html - has_opt -o || append_opt "-o index.html" - fi - - eval "print_url '$url';curl ${CURL_OPTS} -- $url" - if [[ "$reexec" ]];then - for reexec_arg in ${reexec_args_without};do - CURL_OPTS_REEXEC=$(echo "${CURL_OPTS_REEXEC:-$CURL_OPTS}" | sed "s# $reexec_arg##") - done - eval "print_url '$url';curl ${CURL_OPTS_REEXEC} ${CURL_OPTS_REEXEC_ONLY} -- $url" - fi -done |