#!/bin/sh ######## WARNING: on pi /bin/sh is linked to /bin/dash. if you have problems, advise linking /bin/sh to /bin/bash. ######## WARNING: this script is meant to be run as ./pi_install.sh, and checks that it is installed in ../bin. ##################################### USAGE #################################### usage() { status=$1 cat << EOF Usage: $p Install Git Fusion 14.1 on Raspberry Pi, using specially compiled sources. EOF exit $status } show_install_procedure() { cat << EOF This script will install the requirements for Git Fusion. It will: * Download and install Git 1.8.2.3 and its build dependencies * Download and install Python 3.3.5, the P4API, p4d, and the p4 command line. * Download, build, and install P4Python * Download, build, and install libgit2 and pygit2 * Download, build, and install pytz * Install the Git Fusion scripts * Optionally, create a user account for Git To install Git Fusion you will need to have Perforce super user access and you will need to be able to install triggers on the Perforce server machine itself. This script will only install software to this machine. We will detail the trigger installation process after Git Fusion is configured locally. EOF } ################################### UTILITIES ################################## confirm_continue() { while [ loop ]; do /bin/echo -n 'Do you wish to continue? (yes or no): ' && read yn case $yn in yes ) break;; no ) echo "Goodbye!" && exit ;; * ) echo Please enter yes or no ;; esac done } installmsg() #display a timestamped message to stdout #Usage: installmsg arg... { echo " " echo `date '+%m/%d/%y.%H:%M:%S'`: $* } fetchfile() #Usage: fetchfile url filename { if [ -z "$1" -o -z "$2" ]; then 2>&1 echo Usage: fetchfile url filename exit 1 fi if [ ! -r "$2" ]; then installmsg $2 "<--" $1 curl -sS -o "$2" "$1" else installmsg $2 already downloaded from $1 fi } exit_if_not_64_bit_cpu() #NOTE: check disabled on Pi. Git Fusion is not officially supported on 32 bit architectures. { #check to make sure this is a 64-bit machine getconf LONG_BIT | grep 64 > /dev/null || ( echo "Git Fusion requires a 64-bit machine. Exiting." && exit 1) } check_network_connection() { # Because apt-get will happily fail miserably _and_ return an exit code of # 0, we are forced to check for a functional network connection rather than # relying on set -e to work effectively with the apt-get command. installmsg 'Checking network connection...' set +e # don't exit due to ping returning non-zero, we want that code packagehost=archive.raspbian.org ping -c 3 $packagehost > /dev/null 2>&1 if [ $? != 0 ]; then installmsg 'Unable to reach $packagehost host, please check your connection' exit 1 fi set -e # now go back to exiting if a command returns non-zero } download_resources() { SWARM_DOWNLOAD_URL=https://swarm.workshop.perforce.com/download WORKSHOP_LOC=guest/russ_tremain/p4blogs/perforcefulpi/linux26armhf #git debian package for rpi: GIT_DEBIAN_PKG=git_1.8.3.2-1_armhf.deb GIT_DEBIAN_MAN_PKG=git-man_1.8.3.2-1_all.deb fetchfile "$SWARM_DOWNLOAD_URL/$WORKSHOP_LOC/$GIT_DEBIAN_PKG" "$GIT_DEBIAN_PKG" fetchfile "$SWARM_DOWNLOAD_URL/$WORKSHOP_LOC/$GIT_DEBIAN_MAN_PKG" "$GIT_DEBIAN_MAN_PKG" #p4 API compiled for rpi: fetchfile "$SWARM_DOWNLOAD_URL/$WORKSHOP_LOC/p4api-2014.1.886167.linux26armhf.tgz" p4api.tgz ###### TEST URL url="file:///home/pi/perforce/gfnew/python3.3" url="$SWARM_DOWNLOAD_URL/$WORKSHOP_LOC" PYTHON33_DEBIAN_PKG=python3.3_3.3.5-1_armhf.deb fetchfile "$url/$PYTHON33_DEBIAN_PKG" "$PYTHON33_DEBIAN_PKG" PYTHON33_DEBIAN_DEV_PKG=python3.3-dev_3.3.5-1_armhf.deb fetchfile "$url/$PYTHON33_DEBIAN_DEV_PKG" "$PYTHON33_DEBIAN_DEV_PKG" LIBPYTHON33_DEBIAN_PKG=libpython3.3_3.3.5-1_armhf.deb fetchfile "$url/$LIBPYTHON33_DEBIAN_PKG" "$LIBPYTHON33_DEBIAN_PKG" LIBPYTHON33_DEBIAN_DEV_PKG=libpython3.3-dev_3.3.5-1_armhf.deb fetchfile "$url/$LIBPYTHON33_DEBIAN_DEV_PKG" "$LIBPYTHON33_DEBIAN_DEV_PKG" fetchfile "$url/python3.3-minimal_3.3.5-1_armhf.deb" python3.3-minimal_3.3.5-1_armhf.deb fetchfile "$url/libpython3.3-minimal_3.3.5-1_armhf.deb" libpython3.3-minimal_3.3.5-1_armhf.deb fetchfile "$url/libpython3.3-stdlib_3.3.5-1_armhf.deb" libpython3.3-stdlib_3.3.5-1_armhf.deb #needed for p4python compile: fetchfile "$url/python3.3-dev_3.3.5-1_armhf.deb" python3.3-dev_3.3.5-1_armhf.deb #non-essential: #fetchfile "$url/idle-python3.3_3.3.5-1_all.deb" idle-python3.3_3.3.5-1_all.deb #fetchfile "$url/python3.3-dbg_3.3.5-1_armhf.deb" python3.3-dbg_3.3.5-1_armhf.deb #fetchfile "$url/python3.3-doc_3.3.5-1_all.deb" python3.3-doc_3.3.5-1_all.deb #fetchfile "$url/python3.3-examples_3.3.5-1_all.deb" python3.3-examples_3.3.5-1_all.deb #fetchfile "$url/libpython3.3-dbg_3.3.5-1_armhf.deb" libpython3.3-dbg_3.3.5-1_armhf.deb #fetchfile "$url/libpython3.3-dev_3.3.5-1_armhf.deb" libpython3.3-dev_3.3.5-1_armhf.deb #fetchfile "$url/libpython3.3-testsuite_3.3.5-1_all.deb" libpython3.3-testsuite_3.3.5-1_all.deb #python timezone: fetchfile https://pypi.python.org/packages/source/p/pytz/pytz-2013b.tar.bz2 pytz-2013b.tar.bz2 #pull down install packages from perforce FTP site: BINTOOLSDIST=http://ftp.perforce.com/perforce/r14.1/bin.tools ARMELDIST=http://ftp.perforce.com/perforce/r14.1/bin.linux26armel fetchfile "$BINTOOLSDIST/p4python.tgz" p4python.tgz fetchfile "$ARMELDIST/p4" p4 fetchfile "$ARMELDIST/p4d" p4d } update_build_tools() { installmsg 'Grabbing build tools...' sudo apt-get update sudo apt-get install -y build-essential } install_git() { installmsg Installing Git Dependencies... #NOTE: some of these dependencies are for building git from source - we don't need. RT 7/27/14 # sudo apt-get -y install autoconf # sudo apt-get -y install zlib1g-dev # sudo apt-get -y install gettext sudo apt-get -y install tk8.5 tcl8.5 installmsg Installing Git packages $GIT_DEBIAN_PKG $GIT_DEBIAN_MAN_PKG ... sudo dpkg -i "$GIT_DEBIAN_PKG" "$GIT_DEBIAN_MAN_PKG" installmsg Git Install complete. } install_python() { installmsg Installing Python Dependencies ... #NOTE: these dependencies are for building python from source - we don't need. RT 7/27/14 # installmsg sudo apt-get -y build-dep python3.2 # sudo apt-get -y build-dep python3.2 # sudo apt-get -y build-dep python3.2-dev # installmsg sudo apt-get -y install libreadline-dev libncurses5-dev libssl1.0.0 tk8.5-dev liblzma-dev # sudo apt-get -y install libreadline-dev libncurses5-dev tk8.5-dev liblzma-dev installmsg sudo apt-get -y install libexpat1-dev libssl1.0.0 openssl ... sudo apt-get -y install libexpat1-dev libssl1.0.0 openssl installmsg Installing python3.3 packages: python3.3*.deb libpython3.3*.deb sudo dpkg -i python3.3*.deb libpython3.3*.deb #update symlinks to use new python 3.3: (fn=python && cd /usr/bin && sudo rm -f ${fn}3 && sudo ln -s ${fn}3.3 ${fn}3) (fn=2to && cd /usr/bin && sudo rm -f ${fn}3 && sudo ln -s ${fn}3-3.3 ${fn}3) (fn=pdb && cd /usr/bin && sudo rm -f ${fn}3 && sudo ln -s ${fn}3.3 ${fn}3) (fn=pydoc && cd /usr/bin && sudo rm -f ${fn}3 && sudo ln -s ${fn}3.3 ${fn}3) (fn=pygettext && cd /usr/bin && sudo rm -f ${fn}3 && sudo ln -s ${fn}3.3 ${fn}3) (fn=pyenv && cd /usr/bin && sudo rm -f ${fn}3 && sudo ln -s ${fn}3.3 ${fn}3) (cd /usr/bin && sudo rm -f python3-config && sudo ln -s python3.3-config python3-config) (cd /usr/bin && sudo rm -f python3m-config && sudo ln -s python3.3m-config python3m-config) (cd /usr/bin && sudo rm -f python3m && sudo ln -s python3.3m python3m) installmsg Python Install complete. } install_git_fusion() { installmsg Unpacking p4api ... rm -rf p4api-* tar xzf p4api.tgz p4apidir=`echo p4api-*` installmsg Unpacked p4api to $p4apidir installmsg Unpacking p4python ... rm -rf p4python-* tar xzf p4python.tgz p4pythondir=`echo p4python-*` installmsg Unpacked p4python to $p4pythondir installmsg Installing p4d and p4 to /usr/local/bin ... chmod +x p4 p4d sudo cp p4 p4d /usr/local/bin installmsg Installing p4d and p4 to $p4pythondir ... cp p4 p4d "$p4pythondir" installmsg Installing build dependencies for p4python ... sudo apt-get -y install libcurl4-openssl-dev installmsg Building p4python ... cd "$p4pythondir" export PATH=.:$PATH python3 setup.py build --apidir "../$p4apidir/" --ssl python3 p4test.py sudo python3 setup.py install --apidir "../$p4apidir/" --ssl installmsg 'Testing the p4python installation...' echo import P4 > p4python_version_check.py echo 'print(P4.P4.identify())' >> p4python_version_check.py python3 p4python_version_check.py cd .. installmsg Installing cmake ... sudo apt-get -y install cmake installmsg 'Installing libgit2 v0.18.0 ...' rm -rf libgit2 git clone https://github.com/libgit2/libgit2.git cd libgit2 git checkout v0.18.0 mkdir build cd build cmake .. cmake --build . sudo cmake --build . --target install cd ../.. installmsg 'Installing pygit2 v0.18.0 ...' rm -rf pygit2 git clone https://github.com/libgit2/pygit2.git cd pygit2 git checkout v0.18.0 export LIBGIT2="/usr/local" export LDFLAGS="-Wl,-rpath='$LIBGIT2/lib',--enable-new-dtags $LDFLAGS" python3 setup.py build sudo python3 setup.py install python3 setup.py test cd .. installmsg 'Installing pytz for time zone support...' rm -rf pytz-2013b tar jxf pytz-2013b.tar.bz2 cd pytz-2013b python3 setup.py build sudo python3 setup.py install cd .. installmsg Finished building and installing Git Fusion required components. echo "" default_filepath=/usr/local/git-fusion/bin /bin/echo -n "What directory should the Git Fusion scripts be installed to? ($default_filepath): " && read FILEPATH [ "$FILEPATH" = "" ] && FILEPATH=$default_filepath installmsg Installing Git Fusion to "'$FILEPATH'" sudo mkdir -p $FILEPATH sudo cp *.py $FILEPATH sudo cp *.txt $FILEPATH sudo cp Version $FILEPATH echo "" echo "Do you wish to create a user account for Git? This will be the account your users use when connecting to Git." echo "For example: git clone <user account name>@$HOSTNAME:repo" echo "If you choose not to create a user for Git, your current username ($USER) will be used." while [ loop ]; do /bin/echo -n 'Do you wish to create a user account for Git? (yes or no): ' && read yn case $yn in yes ) create_account=1; break;; no ) create_account=0; break;; * ) echo Please enter yes or no ;; esac done if [ $create_account -eq 1 ]; then default_git_user=git /bin/echo -n "Account name? ($default_git_user): " && read GF_ACCOUNTNAME [ "$GF_ACCOUNTNAME" = "" ] && GF_ACCOUNTNAME=$default_git_user installmsg "Creating git user account $GF_ACCOUNTNAME..." sudo adduser --gecos "" $GF_ACCOUNTNAME else GF_ACCOUNTNAME="$USER" fi installmsg Git user account is "'$GF_ACCOUNTNAME'" echo '' installmsg 'Enabling logging to the system log...' sudo cp git-fusion.log.conf /etc/git-fusion.log.conf echo ':syslogtag,contains,"git-fusion[" -/var/log/git-fusion.log' > /tmp/out echo ':syslogtag,contains,"git-fusion-auth[" -/var/log/git-fusion-auth.log' >> /tmp/out sudo cp /tmp/out /etc/rsyslog.d/git-fusion.conf echo "/var/log/git-fusion-auth.log" | cat - /etc/logrotate.d/rsyslog > /tmp/out && sudo cp /tmp/out /etc/logrotate.d/syslog echo "/var/log/git-fusion.log" | cat - /etc/logrotate.d/rsyslog > /tmp/out && sudo cp /tmp/out /etc/logrotate.d/syslog sudo service rsyslog restart } switch_to_git_user() { if [ "$GF_ACCOUNTNAME" != "$USER" ]; then installmsg 'Switching you to the new user account for Git Fusion...' installmsg 'Done' sudo su - $GF_ACCOUNTNAME fi } show_post_install_instructions() { cat << EOF ==================================================================================== Automated install complete! Now a few final bits to do manually. ==================================================================================== Create a working directory for the Git Fusion instance in your filesystem. Suggested location is /home/$GF_ACCOUNTNAME/.git-fusion Create p4gf_environment.cfg configuration file with the following contents: [environment] P4GF_HOME=</path/to/working/directory/for/git-fusion> P4PORT=<your Perforce port> Add the following export lines to the top of the $GF_ACCOUNTNAME .bashrc (/home/$GF_ACCOUNTNAME/.bashrc) export PATH="$FILEPATH" export P4GF_ENV=</path/to/p4gf_environment.cfg> After updating your .bashrc file run: source /home/$GF_ACCOUNTNAME/.bashrc p4 -u <Perforce super user account> login p4gf_super_init.py --user <Perforce super user account> Make sure to set a password for git-fusion-user and run p4 login as git-fusion-user to setup a ticket Git Fusion requires a trigger to be installed on your Perforce server to properly support atomic checkins in Git. To install the trigger: 1) Copy p4gf_submit_trigger.py to your Perforce server machine 2) Run the following to generate the trigger lines needed by Git Fusion p4gf_submit_trigger.py --generate-trigger-entries /absolute/path/to/python /absolute/path/to/p4gf_submit_trigger.py \$P4PORT 3) As a Perforce super user run "p4 triggers" and add those entries. You will need to add triggers as above for each depot where you want to enable Git Fusion. The final step is to setup the version counter by running the following commands from the Perforce server p4 -u git-fusion-user login p4gf_submit_trigger.py --set-version-counter \$P4PORT If your server runs in Unicode mode, you will need to make a slight change to the trigger script: For unicode servers uncomment the following line #CHARSET = [ You will need to add a cronjob to check for and install new SSH keys. See the Git Fusion Guide section on "Create a cron job" for details. Now either add user keys and/or run the following to create a repository p4gf_init_repo.py EOF } ##################################### MAIN ##################################### set -e #default user account for git fusion: GF_ACCOUNTNAME=git #makes output from gcc more legible: export LC_CTYPE=POSIX p=`basename $0` exit_status=0 if [ ! -r ../bin/$p ]; then echo ${p}: please install and run this script from the git-fusion/bin install directory. exit 1 fi ######### #to debug, just comment out the steps that you don't need... ######### show_install_procedure confirm_continue check_network_connection download_resources #note - this does an "apt-get update", which needs to be done prior to the first "apt-get install" command. update_build_tools install_python install_git install_git_fusion show_post_install_instructions switch_to_git_user exit 0
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#7 | 9794 | russ_tremain | update_build_tools needs to be done before first apt-get | ||
#6 | 9778 | russ_tremain | add installmsg at end of automated install | ||
#5 | 9777 | russ_tremain | add back hidden dependency for p4python build | ||
#4 | 9776 | russ_tremain | speed up pi_install script - remove obsolete build-from-source dependencies | ||
#3 | 9775 | russ_tremain | add git 1.8.3.2 packages, update pi installer | ||
#2 | 9774 | russ_tremain |
Update rpi installer, add python3.3 raspbian debs. Need to re-test on new raspbian install. |
||
#1 | 9743 | russ_tremain | Add scripts and packages to allow install of Git Fusion on the Raspberry Pi. |