架設 Cydia 軟體源
前言
繼上一篇 Hugo+GitHub 架設部落格 後,這次來架設 Cydia 軟體源。
過程十分簡單,下載模板 Reposi3 放入static
目錄,視需求自行修改後,push 上 GitHub 即可。
但是,control 檔、deb 檔與 Package 檔的處理均有些許繁瑣,本文內容將著重於自動化發佈流程。
實作過程
依據此模板的規則,欲發佈專案需將其 control 檔填入Depiction
再進行打包。
還需要於指定目錄建立info.xml
,著實繁瑣,以下我寫了個腳本檔來完成整個過程。
#!/bin/bash
repo_path=~/Desktop/資料/Blog/yuripe-murmur/static/repo
repo_url=https://yuripe-murmur.github.io/repo
clear
restore()
{
rm ./control
mv ./control_orig ./control
echo "[*]已恢復 control 檔"
rm -r ./packages
mv ./packages_orig ./packages
echo "[*]已恢復 ./packages"
echo "[*]開始清理"
make clean
echo "[*]清理結束"
}
end()
{
echo "[!]程式結束"
exit
}
if [ -f ./control ]; then
cp -f ./control ./control_orig
echo "[*]已備份 control 檔"
else
echo "[!]不存在 control 檔"
echo "[!]程式結束"
exit
fi
package=$(grep -i "^Package:" ./control | cut -d' ' -f2-)
echo "[*]Package 名稱:$package"
if grep -q "Depiction" ./control; then
line=$(grep -n "Depiction" ./control | awk -F':' '{print $1}')
echo "[*]Depiction 行號:$line"
sed -i "" $line'c\'$'\n''Depiction: '$repo_url'/depictions/?p='$package ./control
echo "[*]Depiction 已更新"
else
echo "[*]Depiction 不存在"
echo "Depiction: "$repo_url"/depictions/?p="$package >> ./control
echo "[*]Depiction 已建立"
fi
if [ -d ./packages ]; then
mv ./packages ./packages_orig
echo "[*]已備份 ./packages"
else
echo "[!]不存在 ./packages"
fi
echo "[*]開始打包"
make clean package
if [ -f ./packages/*.deb ]; then
deb=$(ls ./packages/)
echo "[*]打包成功:$deb"
else
echo "[!]打包失敗"
restore
end
fi
if [ ! -d $repo_path ]; then
echo "[!]不存在 $repo_path"
restore
end
else
mkdir -p $repo_path/debs
mkdir -p $repo_path/depictions/$package
fi
if [ -f $repo_path/debs/$deb ]; then
rm $repo_path/debs/$deb
fi
if [[ $(find $repo_path/debs/$package*.deb 2> /dev/null) ]]; then
echo "[*]repo 中可能含有舊版 .deb:"
ls $repo_path/debs/ | grep $package
echo -n "[!]是否刪除?[y/n]"
read del_deb
if [ $del_deb = "y" ]; then
rm $repo_path/debs/$package*.deb
echo "[*]已刪除舊版 .deb"
fi
fi
cp -f ./packages/$deb $repo_path/debs/$deb
echo "[*]已更新 repo .deb"
cp -f ./info.xml $repo_path/depictions/$package/info.xml
echo "[*]已更新 repo .xml"
restore
cd $repo_path
dpkg-scanpackages -m ./debs > ./Packages
echo "[*]已更新 repo/Packages"
bzip2 -fks ./Packages
echo "[*]已更新 repo/Packages.bz2"
end
貼文底端