Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
function echoError(){
red='\e[0;31m'; NC='\e[0m' # No Color
[ $# -gt 0 ] && echo -e "${red}$1${NC}" >&2
}
function echoInfo(){
COLOR='\e[0;32m'; NC='\e[0m' # No Color
[ $# -gt 0 ] && echo -e "${COLOR}$1${NC}" >&2
}
function errorExit(){
[ $# -gt 0 ] && echoError "$1"
[ $# -gt 1 ] && [[ "$2" =~ ^[0-9]*$ ]] && exit $2
exit
}
function shure(){
if [ $# -gt 1 ] && [[ "$2" =~ ^[yY]*$ ]] ; then
arg="[Y/n]"
reg=$(locale noexpr)
default=(0 1)
else
arg="[y/N]"
reg=$(locale yesexpr)
default=(1 0)
fi
read -p "$1 ${arg}? : " answer
[[ "$answer" =~ $reg ]] && return ${default[1]} || return ${default[0]}
}
function getDepends(){
LANG= apt-get -s install "$1" | sed -n -e '/The following NEW packages will be installed/,/^[^ ]/p' | sed -e '1d;$d' | tee "$2"
return ${PIPESTATUS[0]}
}
function getBuildDepends(){
LANG= apt-get -s build-dep "$1" | sed -n -e '/The following NEW packages will be installed/,/^[^ ]/p' | sed -e '1d;$d' | tee "$2"
return ${PIPESTATUS[0]}
}
function toLowerCase(){
tr '[:upper:]' '[:lower:]' <<<"$1"
}
depFiles=()
function removeTmpFiles(){
for tmpFile in "${depFiles[@]}" ; do rm "$tmpFile" ; done
}
echoInfo "please add 'deb-src http://packages.linuxmint.com/ petra main' to your /etc/apt/sources.list"
echoInfo "and run: sudo apt-get update"
read -p "Press Enter to continue" trash
repositories=('cjs' 'cinnamon-desktop' 'cinnamon-translations' 'cinnamon-session' 'cinnamon-settings-daemon' 'cinnamon-control-center' 'muffin' 'Cinnamon' 'nemo' 'cinnamon-screensaver')
requiredPackages=('gnome-pkg-tools')
tmpDependsFile="core-packages.deps"
depFiles+=("$tmpDependsFile")
echoInfo "install required packages"
for package in "${requiredPackages[@]}" ; do
dpkg -s "$package" > /dev/null 2>&1 && echo "required package '$package' is installed" && continue
echoInfo "install package '$package'"
getDepends "$package" "$tmpDependsFile" || errorExit "$?"
sudo apt-get install -qq "$package" || errorExit "required package '$package' not installed"
done
for repo in "${repositories[@]}" ; do
package=$(toLowerCase "$repo")
tmpDependsFile="$repo.deps"
shure "build package $package" y || continue
echoInfo "Build depends on $package"
getBuildDepends "$package" "$tmpDependsFile" || errorExit "$?"
depFiles+=("$tmpDependsFile")
sudo apt-get -qq build-dep "$package"
echoInfo "Clone Git $repo"
if [ ! -d "$package/git/.git" ] ; then
git clone "https://github.com/linuxmint/${repo}.git" "$package/git" || errorExit "failed clone repository"
fi
cd "$package/git"
git pull
echoInfo "Build package $package"
dpkg-buildpackage > "../../$package.log" || errorExit "failed build package '$package'"
cd ..
echoInfo "install all packages from $package"
sudo dpkg -i *.deb
sudo apt-get install -f
cd ..
done
#shure "delete tmp files" y && removeTmpFiles
for (( idx=${#depFiles[@]}-1 ; idx>=0 ; idx-- )) ; do
file="${depFiles[idx]}"
package="${file%%.*}"
shure "remove build depends for package '$package'" y && cat "$file" | xargs sudo dpkg -r
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.