b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | function echo_red() |
| 3 | { |
| 4 | echo -e '\033[1;31m'"$@"'\033[0m' |
| 5 | } |
| 6 | |
| 7 | function echo_purple() |
| 8 | { |
| 9 | echo -e '\033[1;35m'"$@"'\033[0m' |
| 10 | } |
| 11 | |
| 12 | function echo_blue() |
| 13 | { |
| 14 | echo -e '\033[1;34m'"$@"'\033[0m' |
| 15 | } |
| 16 | |
| 17 | function doset() |
| 18 | { |
| 19 | local pkg |
| 20 | if [ "$1" = "ALL" ];then |
| 21 | shift |
| 22 | echo_blue "Testing install of $@" |
| 23 | yes | sudo apt-get --fix-missing install $@ |
| 24 | return 0 |
| 25 | fi |
| 26 | for pkg in $@; do |
| 27 | dpkg -l $pkg | grep "ii "; |
| 28 | [ $? -eq 0 ] && continue |
| 29 | echo_blue "Testing install of $pkg" |
| 30 | yes | sudo apt-get --fix-missing install $pkg |
| 31 | echo_blue "===============" |
| 32 | done |
| 33 | return 0 |
| 34 | } |
| 35 | |
| 36 | function update_sources_list() |
| 37 | { |
| 38 | local ptadd="$1" |
| 39 | if sudo grep -q "$ptadd" /etc/apt/sources.list ; then |
| 40 | echo_purple "==== \"$ptadd\" already updated ====" |
| 41 | else |
| 42 | echo_blue "Adding \"$ptadd\"" |
| 43 | sudo add-apt-repository "$ptadd" |
| 44 | fi |
| 45 | } |
| 46 | |
| 47 | function update_src_repositories() |
| 48 | { |
| 49 | sudo apt-get clean |
| 50 | doset python-software-properties |
| 51 | if [ "$UBUNTU" = "10.04" ]; then |
| 52 | for ptadd in "deb http://archive.canonical.com/ lucid partner" \ |
| 53 | "deb http://security.ubuntu.com/ubuntu lucid-security multiverse" \ |
| 54 | "deb http://us.archive.ubuntu.com/ubuntu/ lucid multiverse" \ |
| 55 | "deb-src http://us.archive.ubuntu.com/ubuntu/ lucid multiverse" \ |
| 56 | "deb http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse" \ |
| 57 | "deb-src http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse" ; |
| 58 | do |
| 59 | update_sources_list "$ptadd" |
| 60 | done |
| 61 | if [ ! -f /etc/apt/sources.list.d/git-core-ppa-lucid.list ];then |
| 62 | # get advanced GIT |
| 63 | sudo add-apt-repository ppa:git-core/ppa |
| 64 | else |
| 65 | echo_purple "==== GIT repository already set to PPA ====" |
| 66 | fi |
| 67 | else # ubuntu 12.04 |
| 68 | for ptadd in "deb http://archive.canonical.com/ precise partner" \ |
| 69 | "deb http://security.ubuntu.com/ubuntu precise-security multiverse" \ |
| 70 | "deb http://us.archive.ubuntu.com/ubuntu/ precise multiverse" \ |
| 71 | "deb-src http://us.archive.ubuntu.com/ubuntu/ precise multiverse" \ |
| 72 | "deb http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse" \ |
| 73 | "deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse" ; |
| 74 | do |
| 75 | update_sources_list "$ptadd" |
| 76 | done |
| 77 | fi |
| 78 | sudo apt-get update |
| 79 | yes | sudo apt-get upgrade |
| 80 | } |
| 81 | |
| 82 | function update_openwrt_dev_utils() |
| 83 | { |
| 84 | # open WRT requiered packages (based on http://wiki.openwrt.org/doc/howto/buildroot.exigence) |
| 85 | doset build-essential subversion git-core |
| 86 | doset libncurses5-dev zlib1g-dev gawk |
| 87 | doset gcc-multilib flex gettext g++ |
| 88 | if [ "$(uname -m)" = "x86_64" ];then |
| 89 | update_openwrt_dev_utils_64bit |
| 90 | else # 32 bit environment |
| 91 | update_openwrt_dev_utils_32bit |
| 92 | fi |
| 93 | # GIT basics |
| 94 | doset git-gui git-doc gitk qgit |
| 95 | # perl help utilities for GIT activities |
| 96 | echo_red "Update packages for gerrit wrappers" |
| 97 | doset libconfig-inifiles-perl liblist-moreutils-perl |
| 98 | |
| 99 | # packages for kernel build |
| 100 | doset bc make exuberant-ctags |
| 101 | |
| 102 | #packages for uboot build |
| 103 | doset uboot-mkimage uuid-dev |
| 104 | |
| 105 | # Diff tools & Editors |
| 106 | doset geany hexer vim xxdiff xxdiff-scripts meld |
| 107 | # Emacs + indentation tool + directory viewer |
| 108 | doset indent emacs ispell wamerican-large tree |
| 109 | |
| 110 | # Install Phabricator client packages |
| 111 | doset php5-cli php5-curl |
| 112 | } |
| 113 | |
| 114 | function update_openwrt_dev_utils_32bit() |
| 115 | { |
| 116 | #open WRT 32 bit spesific packages |
| 117 | # (based on http://wiki.openwrt.org/doc/howto/buildroot.exigence) |
| 118 | doset patch bzip2 bison |
| 119 | doset autoconf unzip |
| 120 | doset ncurses-term |
| 121 | doset libz-dev libssl-dev |
| 122 | doset quilt libssl-dev xsltproc |
| 123 | doset libxml-parser-perl mercurial bzr ecj cvs |
| 124 | } |
| 125 | function update_openwrt_dev_utils_64bit() |
| 126 | { |
| 127 | #open WRT 64 bit spesific libraries. |
| 128 | doset geany |
| 129 | } |
| 130 | |
| 131 | #main code starts here: |
| 132 | |
| 133 | if [ "$(uname -m)" = "x86_64" ];then |
| 134 | echo_purple "You are working on 64bit Linux !" |
| 135 | else |
| 136 | echo_purple "You are working on 32bit Linux !" |
| 137 | fi |
| 138 | #check ubuntu version, supported 10.04 and 12.04 only |
| 139 | grep DISTRIB_DESCRIPTION /etc/lsb-release | grep -q 12.04; |
| 140 | if [ $? -eq 0 ];then |
| 141 | UBUNTU=12.04 |
| 142 | else |
| 143 | UBUNTU=10.04 |
| 144 | fi |
| 145 | echo_purple " UBUNTU version $UBUNTU" |
| 146 | update_src_repositories |
| 147 | update_openwrt_dev_utils |
| 148 | echo_purple " UBUNTU version $UBUNTU RUN Phase 2" |
| 149 | update_openwrt_dev_utils |
| 150 | |
| 151 | yes | sudo apt-get autoremove |
| 152 | |
| 153 | echo_blue " Done" |