#!/bin/bash case $1 in install ) #パッケージ名取得 package_name=("$@") echo "package name1="$@ package_name=$# echo "package name="$# #bapt_path="$( cd "$( dirname "$0" )" && pwd -P )" echo ${bapt_path} for i in $(seq $(($package_name - 1))) do #i=package number #package_num1=$(seq $package_name) #package_num2=$((${package_num1} - 1)) #max=10 #for ((i=0; i < $package_num2; i++)); do #for i in $package_num2 #do work=$HOME'/bapt/'${package_name[$i]}'/source' if [ -d $work ]; then echo "package already downloaded" exit else mkdir -p $work cd $work apt source ${package_name[$i]} #build deb package #cd source source_dir=$(find '/root/bapt/'${package_name[$i]}'/source/' -mindepth 1 -maxdepth 1 -type d) cd ${source_dir} mkdir ../../deb #cd deb #echo "deb作成開始" #debuild -uc -us -b #dpkg -i *.deb fi build_deps=$(cat '/root/bapt/'${package_name[$i]}'/source/'*'.dsc' | grep Build-Dep | awk '{c="";for(i=2;i<=NF;i++) c=c $i" "; print c}' | awk -F ", " '{c="";for(i=1;i<=NF;i++) c=c $i" "; print c}' | sed 's/([^)]*)//g' ) if [ -n $(${build_deps} | sed 's/ //g') ]; then echo "ビルド依存関係が存在します。" echo "baptじっこう" #bug #apt install ${build_deps} #apt_result=$(echo $?) #if [ $apt_result = "100" ]; then #bapt install ${build_deps} #echo ${build_deps}"installed." #fi fi #elseはif build deps #else echo "no depends" for d in ${build_deps} ; do sudo apt-get install $d||failed+=' '$d done bapt $failed echo "deb作成開始" debuild -uc -us -b echo "debインストール開始" pwd ls mv ../*.deb ../../deb ls ../../deb pwd dpkg -i ../../deb/*.deb cd ../../ pwd #rm -r source #ls | grep -v -E 'deb$' | xargs rm -r not_build+=("$source_dir") echo "いぞん=""${source_dir[@]}" #fiはif build depsといっちしている #fi #cat ./*.dsc | grep Build-Depends | awk '{c="";for(i=2;i<=NF;i++) c=c $i" "; print c}' | awk -F ", " '{c="";for(i=1;i<=NF;i++) c=c $i" "; print c}' | sed -e 's/(*)//' #cat ./*.dsc | grep Build-Depends done ;; enable ) grep '^deb ' /etc/apt/sources.list | \ sed 's/^deb /deb-src /g' | \ sudo tee /etc/apt/sources.list.d/deb-src.list sudo apt update -y sudo apt install -y build-essential dh-make dpkg-dev devscripts lintian git-buildpackage quilt pbuilder dput debhelper debmake fakeroot equivs cdbs ;; clean ) rm -r $HOME'/bapt/'* ;; help ) cat <