您尚未登录。

#1 2011-12-07 17:51:37

darkavenger
会员
注册时间: 2011-12-07
帖子: 1

[分享] 实现类似于apt-get source的获取对应源码包的功能

vim ~/usr/bin/getsrc

输入以下代码:

#!/bin/bash
# This script is used for downloading package source tarball under Archlinux,  just like apt-get source pkg in ubuntu.

#make sure abs is installed
pacman -Q abs >/dev/null 2>&1
if [ $? -ne 0 ];then
    echo "abs is not installed."
    echo "installing abs..."
    if [ `whoami` == "root" ];then
        pacman -S abs
        abs -t
    else
        sudo pacman -S abs
        if [ $? -ne 0 ];then
            exit
        fi
        sudo abs -t
    fi
fi

#geting source through the PKGBUILD file
find /var/abs -type d -name $1 -exec cp -a {} /tmp/ \;
if [  -d /tmp/$1 ];then
    echo package found.
else
    echo "package $1 not found."
    exit
fi
pushd /tmp/$1 >/dev/null 2>&1
#sed -i 's:\./configure.*$:exit:' PKGBUILD
makepkg -od --asroot
popd >/dev/null 2>&1
#cp -a /tmp/$1/src ./$1 >/dev/null 2>&1
mkdir -p ~/Source/$1
cp -a /tmp/$1/src/* ~/Source/$1
chmod +x /usr/bin/getsrc

离线

页脚