Build script for 'Nightlies' - General Omni Discussion

Hi guys,
just shameless ripped from the jenkins build script from the wiki and adapted it to our build environment, for 1 device:
build.sh
Code:
#!/bin/bash
export USE_CCACHE=1
################# Your device here:
DEVICE=n7100
################################
cd ~/android/omni
. build/envsetup.sh
repo sync -j4
rm -rf out/target
brunch $DEVICE
make it executeable:
Code:
chmod +x build.sh
Pretty simple, but works for my private nightlies - and maybe as a cron job.
TODO / IDEAS:
Checking if build did work (exit codes? checking for if zip exists?)
Moving the flashable ZIP to a safe (public?) place
purging old builds (tmpwatch?)
check for changes before building
notify on finished builds (notify my android?)

check for changes before building
notify on finished builds (notify my android?)

cb5264 said:
Hi guys,
just shameless ripped from the jenkins build script from the wiki and adapted it to our build environment, for 1 device:
build.sh
Code:
#!/bin/bash
export USE_CCACHE=1
Click to expand...
Click to collapse
This is incomplete. It could be good enough for Jerkins™, but for your desktop rig it should be
Code:
export USE_CCACHE=1
prebuilts/misc/linux-x86/ccache/ccache -M 50G <---- whatever you can spare, I use 50Gbs
cb5264 said:
repo sync -j4
Click to expand...
Click to collapse
Also unnecessary, because the default is -j4.
Code:
repo sync
would suffice.

Keep in mind that we don't have nightlies ready yet as none of the devices are ready yet (nightly builds for us are meant to be stable) but we will have some ready soon
Sent from my SM-N900T using XDA Premium 4 mobile app

Regarding ccache, why should we need to set up the ccache size every compile?
It's a set once value...
Gesendet von meinem GT-N7100 mit Tapatalk

You dont need to. You might add a 'ccache -s' afterwards though - to see how useful ccache was for the build.
If you build OmniROM (when its ready), for yourself, you will want to cherry-pick changes from the Gerrit review, or add changes of your own, to make your build different from that on Jenkins. So it might be better not to have 'repo sync' in your script -- that will wipe out all your changes.

HippyTed said:
You dont need to. You might add a 'ccache -s' afterwards though - to see how useful ccache was for the build.
If you build OmniROM (when its ready), for yourself, you will want to cherry-pick changes from the Gerrit review, or add changes of your own, to make your build different from that on Jenkins. So it might be better not to have 'repo sync' in your script -- that will wipe out all your changes.
Click to expand...
Click to collapse
regarding ccache, as far as I know data that needs to be computed more than once but doesn't change is put into a cache so it will be generated once and then read from the cache, in that case if I delete the cache every time i lose the advantage of a cache...
regarding cherry picks, I would put the cherry picks after the repo sync command to have the best of both worlds (updated core and cherry picks)
regards
Steven

NemesisRE said:
regarding ccache, as far as I know data that needs to be computed more than once but doesn't change is put into a cache so it will be generated once and then read from the cache, in that case if I delete the cache every time i lose the advantage of a cache...
Click to expand...
Click to collapse
Check man pages for ccache - '-C' clears it, '-z' zeroes stats, '-s' shows stats.
regarding cherry picks, I would put the cherry picks after the repo sync command to have the best of both worlds (updated core and cherry picks)
Click to expand...
Click to collapse
Ok.

HippyTed said:
Check man pages for ccache - '-C' clears it, '-z' zeroes stats, '-s' shows stats.
Ok.
Click to expand...
Click to collapse
this doesn't disprove my assertion...

NemesisRE said:
this doesn't disprove my assertion...
Click to expand...
Click to collapse
True. Maybe I misunderstood your reason for making the assertion.

HippyTed said:
True. Maybe I misunderstood your reason for making the assertion.
Click to expand...
Click to collapse
I think so ^^ the reason was to say that rebuilding the cache on every run would be dumb

cb5264 said:
Hi guys,
just shameless ripped from the jenkins build script from the wiki and adapted it to our build environment, for 1 device:
build.sh
Code:
rm -rf out/target
brunch $DEVICE
Click to expand...
Click to collapse
for personal use I don't remove the /out folder but maybe once every few weeks. You're essentially doing a make clobber but leaving your out/host folder so that's good but, even so, it isn't necessary to flush out the target folder every time unless your compiling is pooping out. I suppose it depends whether you're making it a cron job in which case I'd do what you're doing.
---------- Post added at 12:16 AM ---------- Previous post was at 12:14 AM ----------
... what I do think would be nice is to set up a delta update mechanism like cyandelta so we could update on mobile data without killing our data plans.

cd omni
rm -rf out
repo sync -j 16
time brunch n7100
that's what I use

Seems I have the most Advances
Code:
#!/bin/bash
cd ~/
clear
export USE_CCACHE=1
export CCACHE_DIR=~/.ccache
prebuilts/misc/linux-x86/ccache/ccache -M 50G
DATE=$(date -u +%Y%m%d)
OMNIBUILDTODEL=`expr $DATE - 5`
DEVICE=$*
. build/envsetup.sh
rm -f out/target/product/$DEVICE/obj/KERNEL_OBJ/.version
rm -f out/target/product/$DEVICE/system/build.prop
rm -f out/target/product/$DEVICE/system/app/*.odex
rm -f out/target/product/$DEVICE/omni*.zip
rm -f out/target/product/$DEVICE/omni*.zip.md5sum
rm -f out/target/product/$DEVICE/system/framework/*.odex
brunch omni_$DEVICE-userdebug -j12
sftp {-p PORT#} {USER-NAME}@xxx.xxx.xxx.xxx << EOF
cd /var/www/mithun46/hammerhead/omni/
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip.md5sum
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip.md5sum
EOF
This:
Uses 50 gigs of ccache
Uploads to my personal server [zip+md5]
Deletes 5 days old builds and their md5sum
This is not clean builds [i clean manually] [is kinda clean though]
Is in the smallest form possible

mithun46 said:
#!/bin/{SHELL}
...
sftp {-p PORT#} {USER-NAME}@xxx.xxx.xxx.xxx
cd /var/www/{what/should/possibly/be/an/obscured/path/to}/omni/
Click to expand...
Click to collapse
You also just provided me with:
1) Verification of an operable {SHELL} compatible shell.
2) Your server's IP.
3) A good indicator that your server accepts SSH AND SFTP connections at the port {PORT#}.
4) Verification that your SSH server accepts "{USER-NAME}" logins.
5) Pretty solid evidence of, and possibly even an otherwise inaccessible path on, a web server
Please edit your post. Ive already made my post as vague as possible without failing to make my point, i hope.
Also, please consider SSH's known_hosts or at the least shell aliases/functions so you don't have to hardcode IP addresses and user-names in random shell scripts.
-Mike
* While it's possible that... EDIT: *REDACTED* no problem, Mithun. I said it for myself as much as I did you; nobody likes a botnet. Well, maybe very few like a botnet.

mithun46 said:
Code:
...
sftp {-p PORT#} {USER-NAME}@xxx.xxx.xxx.xxx << EOF
cd /var/www/mithun46/hammerhead/omni/
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip.md5sum
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip.md5sum
EOF
[/LIST]
Click to expand...
Click to collapse
That part got a disturbing 'issue' imho - it doesn't check for a build being successful. I'd work that out with an if-clause checking if the file exists...

cb5264 said:
That part got a disturbing 'issue' imho - it doesn't check for a build being successful. I'd work that out with an if-clause checking if the file exists...
Click to expand...
Click to collapse
If no file exists it shows errors while trying to upload the file in sftp

This is my try, it´s not perfect and for the most people too much... but it`s mine ^^
https://gist.github.com/NemesisRE/7518954
EDIT: Will update the gist until i think it is all ok, but the code here will stay as it is
Code:
#!/bin/bash
##################################################
#
# vim: ai ts=4 sw=4 noet sts=4 ft=sh
#
# Copyright 2013, Steven Koeberich ([email protected])
#
# Title: dinner.sh
# Author: Steven "NemesisRE" Koeberich
# Date: 20131117
# Version: 1.1
# Description: Builds Roms automatically
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License at (http://www.gnu.org/licenses/) for
# more details.
#set -e #do not enable otherwise brunch will fail
#set -x
#For compatibility set Language to en_US.UTF8 and timezone to UTC
export LANGUAGE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
export TZ="/usr/share/zoneinfo/UTC"
#Make us of CCACHE
export USE_CCACHE=1
# Define global variables
REPO_DIR="${HOME}/android/omni"
MAIL_BIN=$(which mail)
LOG_DIR="${HOME}/logs"
SHOW_VERBOSE="> /dev/null 2>&1"
CONVERT_TO_HTML="| ansi2html" # install package kbtin to use this feature
#Set initial exitcodes
SYNC_REPO_EXIT_CODE="0"
GET_BREAKFAST_VARIABLES_EXIT_CODE="0"
BRUNCH_DEVICE_EXIT_CODE="0"
MOVE_BUILD_EXIT_CODE="0"
RUN_COMMAND_EXIT_CODE="0"
CLEAN_OLD_BUILDS_EXIT_CODE="0"
SEND_MAIL_EXIT_CODE="0"
# This variables can be overwritten by command line parameters
MAIL='' # set this if you want always an email
ADMIN_MAIL='' # set this if you want always an email (with logs)
TARGET_DIR='' # set this if you want always move your build to the given directorie
CLEANUP_OLDER_THEN="" # set this if you want always automatic cleanup
DOWNLOAD_LINK='' # set this if you want always a download link
RUN_COMMAND='' # set this if you want always run a command after a build was successful
BUILD_FOR_DEVICE="" # set this if you want always build for the given device/s
#Source envsetup
. ${REPO_DIR}/build/envsetup.sh > /dev/null 2>&1
######################
#
# function _usage
#
#
function _usage() {
echo $"Usage: ${0} [-n \"[email protected]\"] [-t \'/var/www/awsome-download-dir\'] [-r \'scp \$\{OUTPUT_FILE\} example.com:\' ][-l \"http://example.com/download/omnirom\"] [-c 7] [-v] [-- i9300 mako ]"
cat<<EOF
Options:
-n Send notification to given Mail-Adress
-t Move files into given Directorie
-r Run command on successful build
-l If you choose a target dir you may want put
a download link into the mail message
-c Cleanup builds older then N days
-v Verbose Output
-h See this Message
EOF
}
function _e_notice () {
echo -e "NOTICE: ${1}"
}
function _e_warning () {
echo -e "WARNING:Something went wrong ${1} (${2})"
}
function _e_error () {
echo -e "ERROR: ${1}"
}
function _check_prerequisites () {
if [ ! -x $(which ansi2html) ]; then
CONVERT_TO_HTML=""
fi
if [ ${TARGET_DIR} ]; then
TARGET_DIR=$(echo "${TARGET_DIR}"|sed 's/\/$//g')
fi
if [ ${LOG_DIR} ]; then
LOG_DIR=$(echo "${LOG_DIR}"|sed 's/\/$//g')
fi
if [ -z ${BUILD_FOR_DEVICE} ]; then
echo "ERROR: No Device given! Stopping..."
_usage
exit 1
fi
if [ ! -d ${LOG_DIR} ]; then
mkdir -p ${LOG_DIR}
fi
}
function _sync_repo () {
_e_notice "Running repo sync..."
eval "repo sync ${SHOW_VERBOSE}"
SYNC_REPO_EXIT_CODE=$?
if [ ${SYNC_REPO_EXIT_CODE} != 0 ]; then
_e_warning "while doing repo sync" "${SYNC_REPO_EXIT_CODE}"
fi
}
function _get_breakfast_variables () {
for VARIABLE in `breakfast ${DEVICE} | sed -e 's/^=.*//' -e 's/[ ^I]*$//' -e '/^$/ d'`; do
eval ${VARIABLE}
done
GET_BREAKFAST_VARIABLES_EXIT_CODE=$?
if [ ${GET_BREAKFAST_VARIABLES_EXIT_CODE} != 0 ]; then
_e_warning "while getting breakfast variables" "${GET_BREAKFAST_VARIABLES_EXIT_CODE}"
fi
}
function _brunch_device () {
_e_notice "Running brunch for ${DEVICE} with version ${PLATFORM_VERSION} ..."
eval "brunch ${DEVICE} 2>&1 | tee ${LOG_DIR}/brunch_${DEVICE}.log ${SHOW_VERBOSE}"
BRUNCH_DEVICE_EXIT_CODE=$?
BRUNCH_RUN_TIME=$(tail ${LOG_DIR}/brunch_${DEVICE}.log | grep "real" | awk '{print $2}')
if [ ${BRUNCH_DEVICE_EXIT_CODE} != 0 ]; then
_e_warning "while brunch the ${DEVICE}, see logfile for more information" "${BRUNCH_DEVICE_EXIT_CODE}"
fi
}
function _move_build () {
_e_notice "Moving files to target directory..."
mv ${OUTPUT_FILE}* ${TARGET_DIR}/
MOVE_BUILD_EXIT_CODE=$?
if [ ${MOVE_BUILD_EXIT_CODE} != 0 ]; then
_e_warning "while moving the build" "${MOVE_BUILD_EXIT_CODE}"
fi
}
function _run_command () {
_e_notice "Run command..."
eval ${RUN_COMMAND}
RUN_COMMAND_EXIT_CODE=$?
if [ ${RUN_COMMAND_EXIT_CODE} != 0 ]; then
_e_warning "while running your command" "${RUN_COMMAND_EXIT_CODE}"
fi
}
function _clean_old_builds () {
_e_notice "Running cleanup of old builds..."
if [ ${TARGET_DIR} ]; then
CLEANED_FILES=$(find ${TARGET_DIR}/ -name "omni-${PLATFORM_VERSION}-*-${DEVICE}-HOMEMADE.zip*" -type f -mtime +${CLEANUP_OLDER_THEN}d -delete)
else
CLEANED_FILES=$(find `dirname ${OUTPUT_FILE}` -name "omni-${PLATFORM_VERSION}-*-${DEVICE}-HOMEMADE.zip*" -type f -mtime +${CLEANUP_OLDER_THEN}d -delete)
fi
CLEAN_OLD_BUILDS_EXIT_CODE=$?
if [ ! ${CLEANED_FILES} ]; then
CLEANED_FILES="Nothing to clean up."
fi
_e_notice "${CLEANED_FILES}"
if [ ${CLEAN_OLD_BUILDS_EXIT_CODE} != 0 ]; then
_e_warning "while cleaning builds" "${CLEAN_OLD_BUILDS_EXIT_CODE}"
fi
}
function _send_mail () {
_e_notice "Sending status mail..."
MAIL_MESSAGE="Build Status:\n\n"
ADMIN_MAIL_MESSAGE=""
if ${BUILD_SUCCESSFUL}; then
MAIL_MESSAGE+="Build for ${DEVICE} was successfull finished after ${BRUNCH_RUN_TIME}\n"
if [ ${DOWNLOAD_LINK} ]; then
MAIL_MESSAGE+="You can download your Build at ${DOWNLOAD_LINK}\n\n"
fi
if [ ${CLEANED_FILES} ]; then
ADMIN_MAIL_MESSAGE+="Removed the following files:\n"
ADMIN_MAIL_MESSAGE+=${CLEANED_FILES}
fi
else
MAIL_MESSAGE+="Build was not successfull ran ${BRUNCH_RUN_TIME}.\n\n"
ADMIN_MAIL_MESSAGE+="Logfile:"
ADMIN_MAIL_MESSAGE+=$(cat ${HOME}/brunch_${DEVICE}.log ${CONVERT_TO_HTML})
fi
if [ ${MAIL} ]; then
echo -e "${MAIL_MESSAGE}" | ${MAIL_BIN} -s "Finished dinner." "${MAIL}"
fi
if [ ${ADMIN_MAIL} ]; then
echo -e "${MAIL_MESSAGE}${ADMIN_MAIL_MESSAGE}" | ${MAIL_BIN} -s "Finished dinner." "${ADMIN_MAIL}"
fi
SEND_MAIL_EXIT_CODE=$?
if [ ${SEND_MAIL_EXIT_CODE} != 0 ]; then
_e_warning "while sending E-Mail" "${SEND_MAIL_EXIT_CODE}"
fi
}
function _check_build () {
OUT_FILE_SECONDS_SINCE_CREATION=$(/bin/date -d "now - $( /usr/bin/stat -c "%Y" ${OUTPUT_FILE} ) seconds" +%s)
if [ -f ${OUTPUT_FILE} ] && [ "${OUT_FILE_SECONDS_SINCE_CREATION}" -lt "120" ] ; then
BUILD_SUCCESSFUL=true
else
BUILD_SUCCESSFUL=false
fi
}
######################
#
# function _main
#
#
function _main() {
_check_prerequisites
cd ${REPO_DIR}
_sync_repo
for DEVICE in ${BUILD_FOR_DEVICE}; do
_get_breakfast_variables
_brunch_device
OUTPUT_FILE="${OUT_DIR}/target/product/${DEVICE}/omni-${PLATFORM_VERSION}-$(date +%Y%m%d)-${DEVICE}-HOMEMADE.zip"
_check_build
if ${BUILD_SUCCESSFUL} && [ ${TARGET_DIR} ]; then
eval TARGET_DIR=${TARGET_DIR}
_move_build
fi
if ${BUILD_SUCCESSFUL} && [ ${CLEANUP_OLDER_THEN} ]; then
_clean_old_builds
fi
if [ ${MAIL} ] || [ ${ADMIN_MAIL} ]; then
eval MAIL=${MAIL}
eval ADMIN_MAIL=${ADMIN_MAIL}
_send_mail
fi
done
OVERALL_EXIT_CODE=$((${SYNC_REPO_EXIT_CODE}+${GET_BREAKFAST_VARIABLES_EXIT_CODE}+${BRUNCH_DEVICE_EXIT_CODE}+${MOVE_BUILD_EXIT_CODE}+${CLEAN_OLD_BUILDS_EXIT_CODE}+${SEND_MAIL_EXIT_CODE}))
if ! ${BUILD_SUCCESSFUL} && [ ${OVERALL_EXIT_CODE} -gt 0 ]; then
_e_warning "buildcheck failed and Overall exit code is higher then 0 will exit with 1" "${OVERALL_EXIT_CODE}"
exit 1
elif ${BUILD_SUCCESSFUL} && [ ${OVERALL_EXIT_CODE} -gt 0 ]; then
_e_warning "buildcheck was successful but Overall exit code is higher then 0 will exit with 1" "${OVERALL_EXIT_CODE}"
exit 1
else
_e_notice "All jobs finished successfully."
fi
}
## Parameter handling
while getopts ":n:t:l:c:vh" opt; do
case ${opt} in
"n")
MAIL='${OPTARG}'
;;
"t")
TARGET_DIR='${OPTARG}'
;;
"r")
RUN_COMMAND='${OPTARG}'
;;
"l")
DOWNLOAD_LINK='${OPTARG}'
;;
"c")
CLEANUP_OLDER_THEN="${OPTARG}"
;;
"v")
SHOW_VERBOSE=""
;;
"h")
_usage
exit 0
;;
\?)
echo "Invalid option: -${OPTARG}"
_usage
exit 1
;;
:)
echo "Option -${OPTARG} requires an argument."
_usage
exit 1
;;
esac
done
shift $((${OPTIND}-1))
if [ ${@} ]; then
BUILD_FOR_DEVICE=${@}
fi
_main
exit 0
Cheers
Steven

No more gist
The script is now called Dinner, more information at http://forum.xda-developers.com/showthread.php?t=2690995

Related

[Q] Anyone good with BASH? (linux)

Hey, I wonder if anyone is good with BASH is around here, what I want is simple, but for some reason it didn't work for me
So here is what I want, a .sh (or any other linux executable) file that executes the following code if the user input was the character 'm'
Code:
sudo mkdir /media/mp3
sudo chmod 775 /media/mp3
sudo mtpfs -o allow_other /media/mp3
and this if the input was 'u'
Code:
sudo umount /media/mp3
sudo rmdir /media/mp3
anything else: exit
thanks in advance
are you looking for something like this?
Code:
#!/bin/bash
if [ `whoami` != "root" ]; then
echo "you must execute this script with root priveleges!"
exit
fi
clear
echo
echo "enter m to mount /media/mp3 or enter u to unmount it"
echo
read moru
if [ "$moru" = "m" ]; then
mkdir -p /media/mp3
chmod 775 /media/mp3
mtpfs -o allow_other /media/mp3
elif [ "$moru" = "u" ]; then
umount /media/mp3
rmdir /media/mp3
fi
exit
HTH
the code seems ok, but still not working, the is the output in kate when I pipe it to terminal
(not that I was root when before I pipe it using su)
Code:
Dash-Netbook Desktop # #!/bin/bash
Dash-Netbook Desktop #
Dash-Netbook Desktop # if [ `whoami` != "root" ]; then
> echo "you must execute this script with root priveleges!"
echo "you must execute this script with root priveleges"]; then
bash: syntax error near unexpected token `then'
Dash-Netbook Desktop # exit
exit
[email protected] ~/Desktop $ fi
bash: syntax error near unexpected token `fi'
[email protected] ~/Desktop $
[email protected] ~/Desktop $ clear
[email protected] ~/Desktop $ echo
[email protected] ~/Desktop $ echo "enter m to mount /media/mp3 or enter u to unmount it"
enter m to mount /media/mp3 or enter u to unmount it
[email protected] ~/Desktop $ echo
[email protected] ~/Desktop $ read moru
[email protected] ~/Desktop $
[email protected] ~/Desktop $ if [ "$moru" = "m" ]; then
> mkdir -p /media/mp3
> chmod 775 /media/mp3
> mtpfs -o allow_other /media/mp3
> elif [ "$moru" = "u" ]; then
> umount /media/mp3
> rmdir /media/mp3
> fi
[email protected] ~/Desktop $
[email protected] ~/Desktop $ exit
husam666 said:
Hey, I wonder if anyone is good with BASH is around here, what I want is simple, but for some reason it didn't work for me
So here is what I want, a .sh (or any other linux executable) file that executes the following code if the user input was the character 'm'
Code:
sudo mkdir /media/mp3
sudo chmod 775 /media/mp3
sudo mtpfs -o allow_other /media/mp3
and this if the input was 'u'
Code:
sudo umount /media/mp3
sudo rmdir /media/mp3
anything else: exit
thanks in advance
Click to expand...
Click to collapse
I know it sounds stuff, but I don't know my way around Linux. What does that script actually do?
Sent from my HTC Wildfire S A510e using XDA
Bad-Wolf said:
I know it sounds stuff, but I don't know my way around Linux. What does that script actually do?
Sent from my HTC Wildfire S A510e using XDA
Click to expand...
Click to collapse
the first part mounts my mp3 player (MTP device) on the /media/mp3 directory
The other part unmounts it and deletes the directory
Sent from the brick
What distribution are you using?
Also, what errors do you get when you save that text to a text file (do this in linux, not windows), e.g. mountmp3.sh, make it executable (chmod +x mountmp3.sh) and run it (./mountmp3.sh)?
It seems to run the commands fine here (running Porteus, which is based on Slackware) but I don't have mtpfs installed, so I'm not testing every element...
use this one Husam!
on a terminal:
Code:
sudo -s
chmod +x husam.sh
sh husam.sh
I tweaked the code a bit and added extra functionality
You might wanna try that script without root...
.Ahau said:
What distribution are you using?
Also, what errors do you get when you save that text to a text file (do this in linux, not windows), e.g. mountmp3.sh, make it executable (chmod +x mountmp3.sh) and run it (./mountmp3.sh)?
It seems to run the commands fine here (running Porteus, which is based on Slackware) but I don't have mtpfs installed, so I'm not testing every element...
Click to expand...
Click to collapse
ok, I'm using linux mint kde 12.1, and I use kate for a text editor, I didn't do the chmod thing, I only used sh file.sh
@dex, ok..
.Ahau said:
What distribution are you using?
Also, what errors do you get when you save that text to a text file (do this in linux, not windows), e.g. mountmp3.sh, make it executable (chmod +x mountmp3.sh) and run it (./mountmp3.sh)?
It seems to run the commands fine here (running Porteus, which is based on Slackware) but I don't have mtpfs installed, so I'm not testing every element...
Click to expand...
Click to collapse
ok, it worked
thx
@dex, what kind of idiot do you think I am -_-
I always check executables before executing
husam666 said:
ok, it worked
thx
@dex, what kind of idiot do you think I am -_-
I always check executables before executing
Click to expand...
Click to collapse
oh come on
I know you liked my modifications
dexter93 said:
oh come on
I know you liked my modifications
Click to expand...
Click to collapse
btw, should I check the link you gave me?
husam666 said:
btw, should I check the link you gave me?
Click to expand...
Click to collapse
the "surprise" one? depends.. if you are brave enough
(you already know what it is though)
but the download link in my post is legit, it works
dexter93 said:
the "surprise" one? depends.. if you are brave enough
(you already know what it is though)
but the download link in my post is legit, it works
Click to expand...
Click to collapse
lmao, check my latest fb status then
husam666 said:
lmao, check my latest fb status then
Click to expand...
Click to collapse
that's where i got the idea from
glad it's working for you!

pre_boot.sh

there is a .sh file in the system/etc folder on my Z1 that checks and loads the touch screen firmware - I tried running it through an adb shell (very new to this stuff) and got permission denied - my phone is rooted correctly as far as I can see with su #
can someone help me to run this manually on my rooted Z1 or offer some help in forcing a firmware load of the touchscreen FW
I have a Z1 with a replaced screen all hardware has been replaced except for the main board
surely some of you whiz kids can help me out here
@Geoffxx, u mean pre_hw_config.sh ?
Code:
#!/system/bin/sh
# pre_hw_config.sh.
# Used to set special parameters during early boot.
#KOTO hw boot
if [ -e /system/bin/snfcboot ]; then
/system/bin/snfcboot
fi
#Touch fw update
touch_path="/sys/devices/virtual/input/"
touch_vendor_id=$(/system/bin/ta_param_loader -p -t 4950 -d 0 -f "0x%02x")
if [ "$touch_vendor_id" = "0x01" ]; then
touch_module_id=0x$(/system/bin/ta_param_loader -p -t 4950 -d 3 -c 2 -f "%02x")
/system/bin/clearpad_fwloader default $touch_module_id
elif [ "$touch_vendor_id" = "0x02" ]; then
touch_chip_id=0x$(/system/bin/ta_param_loader -p -t 4950 -d 1 -c 2 -f "%02x")
touch_config_id=0x$(/system/bin/ta_param_loader -p -t 4950 -d 3 -c 2 -f "%02x")
echo 1 $touch_config_id $touch_chip_id > "$touch_path/max1187x/dflt_cfg"
echo default > "$touch_path/max1187x/fw_update"
else
if [ -a "$touch_path/clearpad" ]; then
touch_module_id=$(/system/bin/ta_param_loader -t 60221 -f "0x%02x")
if [ "$touch_module_id" = "0x00" ]; then
touch_module_id=0x$(cat $touch_path/clearpad/fwfamily)
fi
/system/bin/clearpad_fwloader default $touch_module_id
elif [ -a "$touch_path/max1187x" ]; then
touch_chip_id=$(cat $touch_path/max1187x/chip_id)
touch_config_id=$(cat $touch_path/max1187x/config_id)
echo 1 $touch_config_id $touch_chip_id > "$touch_path/max1187x/dflt_cfg"
echo default > "$touch_path/max1187x/fw_update"
fi
log "*** touch: No valid Misc TA 4950"
fi
yes sorry I was doing it from memory, the phone is in bits right now
There are about 15 different variants of touch firmware, I believe the above code checks to see which variant is present then loads the FW for it from the selection
what I don't know is if this routine runs every time or is called from another part of the boot process to run on an error condition
at present all I know is that I have a dead touchscreen and all the hardware has been replace except the motherboard - everything on the phone works 100% except the touch, so I want to make sure that touch firmware has been loaded by doing it manually
the Z1 has the synaptics touch hardware and so must be identified somewhere
So there are two checks I'd like to do
see if the hardware is being identified/read - there must be a manual way to do this through adb shell
and if the hardware is being identified then force load the Firmware for it
there was a problem with the xperia T family and here is a thread that identified a similar solution http://forum.xda-developers.com/showthread.php?t=2220290&highlight=touch+screen+not+working , unfortunately the Z family of phones/tablets are different, I suspect it's because they all use the same main firmware and have to identify hardware between all the devices and load appropriate software to drive them

Telnetd,password protected

I borrowed a few shell scripts from Boxee+Hacks project
they got a password protected telnet (not encrypted and password file is in ASCII)
All the files got to be located in /data dir
telnet.sh
------------
/bin/busybox telnetd -p 2323 -l /data/shell.sh &
shell.sh
------------
#!/bin/sh
VALID_PASSWORD=`/bin/busybox head -n 1 /data/passwd`
THEPATH='/usr/bin:/bin'
export PATH="${THEPATH}"
export HOME='/data'
read -p "Password: " PASSWORD
echo ""
if [ "$PASSWORD" == "$VALID_PASSWORD" ]; then
echo "Welcome to Chromecast"
cd /data
/bin/ash
else
echo "Incorrect password"
fi
passwd
-----------
<password>

Ethernet support on XSP?

Hello guys,
I need some help here, I want to add Ethernet driver to my XSP, but I don't know what to do
Currently my XSP ROM is AICP (still on old version, Lollipop), with Helium kernel
I already built the asix.ko module, using this guide, and DooMLoRD' Android Toolchain
When I tried to "insmod asix.ko" on my XSP terminal, it returns error
Code:
init_module failed (Exec format error)
And this is my makefile on ASIX driver
Code:
CURRENT = $(shell uname -r)
TARGET = asix
OBJS = asix.o
MDIR = drivers/net/usb
KDIR = /home/smankusors/Projects/XSP_ASIX_Driver/helium_kernel
SUBLEVEL= $(shell uname -r | cut -d '.' -f 3 | cut -d '.' -f 1 | cut -d '-' -f 1 | cut -d '_' -f 1)
ifneq (,$(filter $(SUBLEVEL),14 15 16 17 18 19 20 21))
MDIR = drivers/usb/net
endif
EXTRA_CFLAGS = -DEXPORT_SYMTAB
PWD = $(shell pwd)
DEST = /lib/modules/$(CURRENT)/kernel/$(MDIR)
obj-m := $(TARGET).o
default:
make ARCH=arm CROSS_COMPILE=/home/smankusors/Projects/XSP_ASIX_Driver/android_prebuilt_toolchains/arm-linux-androideabi-4.7/bin/arm-linux-androideabi- -C $(KDIR) SUBDIRS=$(PWD) modules
$(TARGET).o: $(OBJS)
$(LD) $(LD_RFLAG) -r -o [email protected] $(OBJS)
install:
su -c "cp -v $(TARGET).ko $(DEST) && /sbin/depmod -a"
clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
.PHONY: modules clean
-include $(KDIR)/Rules.make
What I exactly do :
1. Download the android prebuilt toolchains, kernel sourcecode, asix sourcecode
2. Modify the makefile from ASIX sourcecode
3. Make from it
4. Flash to my XSP along with the helium kernel
5. Error.
Is there anything wrong? :crying:

How To Guide How to configure the WiFI in Android via script

In the current version of Android the WiFi configuration is stored in the file
/data/misc/apexdata/com.android.wifi/WifiConfigStore.xml
e.g.
Code:
ASUS_I006D:/ # ls -lZtr /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml
-rw------- 1 system system u:object_r:apex_system_server_data_file:s0 4884 2023-01-29 08:55 /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml
ASUS_I006D:/ #
The file is in plain ASCII xml format so it can be processed by any executable to change text files (editor, sed, etc).
But IMHO it's better to configure the WiFi manually via GUI and then use the file WifiConfigStore.xml with that configuration for configuring the WiFi via script. Therefor I use this code in the post install script to install and configure my phone (see How to install and configure the Android OS via Script):
Spoiler: script commands to enable and configure WiFi
Bash:
#
# sample post install script for the customizing of the phone
#
# This script will be copied to the phone and executed there
#
# The script is executed by the user shell; use "su - -c <command>" to execute commands as user root
#
echo ""
echo "*** Postinstall script is running ..."
echo ""
# ... other customizations ....
#
# create the WiFi config file
#
# -rw------- 1 system system u:object_r:apex_system_server_data_file:s0 4884 2023-01-29 08:55 /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml
#
WIFI_CONFIG_FILE="/data/misc/apexdata/com.android.wifi/WifiConfigStore.xml"
WIFI_CONFIG_FILE_BACKUP="${WIFI_CONFIG_FILE}.$$.bkp"
NEW_WIFI_CONFIG_FILE="/sdcard/Download/WifiConfigStore.xml"
if [ -r "${WIFI_CONFIG_FILE}" ] ; then
echo "Creating a backup of the file \"${WIFI_CONFIG_FILE}\" in \"${WIFI_CONFIG_FILE_BACKUP}\" ...."
cp "${WIFI_CONFIG_FILE}" "${WIFI_CONFIG_FILE_BACKUP}"
fi
echo "Creating the file \"${NEW_WIFI_CONFIG_FILE}\" ..."
cat >"${NEW_WIFI_CONFIG_FILE}" <<-\EOT
*** add here the contents of the file /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml from the phone after manually configuring the WLAN
EOT
if [ $? -eq 0 ] ; then
echo "Creating the file \"${WIFI_CONFIG_FILE}\" ..."
su - -c cp "${NEW_WIFI_CONFIG_FILE}" "${WIFI_CONFIG_FILE}" && \
su - -c chmod 600 "${WIFI_CONFIG_FILE}" && \
su - -c chown system:system "${WIFI_CONFIG_FILE}" && \
su - -c chcon -v "u:object_r:apex_system_server_data_file:s0" "${WIFI_CONFIG_FILE}"
if [ $? -ne 0 ] ; then
echo "Error creating the file \"${WIFI_CONFIG_FILE}\" "
fi
else
echo "Error creating the file \"${NEW_WIFI_CONFIG_FILE}\" "
fi
# enable WiFi
#
echo "Enabling WiFi ..."
svc wifi enable
# optional: Disable mobile data connections
#
echo "Disabling mobile data ..."
svc data disable
# Now reboot the phone to activate the new WiFi config ..
#
echo "Waiting 15 seconds now before rebooting - press CTRL-C to abort ...."
i=0
while [ $i -lt 15 ] ; do
(( i = i + 1 ))
printf "."
sleep 1
done
printf "\n"
echo "Now rebooting the phone ..."
reboot
#
Notes:
Be aware the the file /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml contains the passwords for all configured WLANs in plain text.
There should be a command to force Android to reread the file WifIConfigStore.xml but I don't know that.
Android can be forced to re-read the file WifIConfigStore.xml by killing the process system_server, e.g:
Bash:
pkill system_server
But that is more or less a warm reboot and I do not know what other side effects that restart triggers
There is an app to configure WiFi via adb command
https://github.com/steinwurf/adb-join-wifi
Bash:
adb shell am start -n com.steinwurf.adbjoinwifi/.MainActivity -e ssid myssid -e password mywlan_password -e password_type WPA
The app works but unfortunately it does not support enabling the setting to use the device MAC instead of the random MAC so it's not usable in my environment.
Another app to configure WiFi via adb command is available here:
https://github.com/pr4bh4sh/adb-wifi-setting-manager
Unfortunately that app also does not support enabling choosing the MAC address for the connection.
There is also a script to convert an old Android wpa_supplicant.conf file to the newer (post-Oreo) WifiConfigStore.xml file (not tested):
https://github.com/mnalis/android-wifi-upgrade
It's also possible to use the command wpa_cli to configure WiFi but be aware the wpa_cli only works if selinux is (temporary) disabled, example:
Spoiler: wpa_cli example
Code:
ASUS_I006D:/ $ su -
ASUS_I006D:/ #
ASUS_I006D:/ # setenforce 0
ASUS_I006D:/ #
ASUS_I006D:/ #
ASUS_I006D:/ # wpa_cli
wpa_cli v2.10-devel-11
Copyright (c) 2004-2019, Jouni Malinen <[email protected]> and contributors
This software may be distributed under the terms of the BSD license.
See README for more details.
Using interface 'wlan0'
Interactive mode
<3>Control interface command 'BSS RANGE=ALL MASK=0x2'
<3>Control interface command 'LIST_CREDS'
<3>Control interface command 'LIST_NETWORKS'
<3>Control interface command 'STA-FIRST'
>
> list_networks
network id / ssid / bssid / flags
0 Zeilsheim any [CURRENT]
1 any [DISABLED]
<3>Control interface command 'LIST_NETWORKS'
>
> quit
ASUS_I006D:/ #
Note: Use help to get list of known commands
Test Environment
I tested the WiFi config via script described above in these Android distributions:
OmniROM 13 (Android 13)
OmniROM 12 (Android 12)
ASUS Android 12
ASUS Android 13
This method seems not to work in Android 11

Categories

Resources