2014-05-16 3 views
1

우리는 Angstrom Linux 및 opkg 패키지 관리자를 실행하는 BeagleBone Black을 사용하여 일부 시스템에 전원을 공급합니다. 특정 버전의 opkg 패키지에 일관되고 안정적인 액세스를 보장해야합니다. 필자는 사내 opkg 저장소를 설정했습니다. 리파지토리간에 패키지를 동기화 할 수있는 방법이 있습니까? 예 : 필자는 속도가 빠르고 신뢰할 수있는 액세스를 위해 공용/항상 액세스 할 수있는 리포지토리의 특정 패키지를 우리의 내부 리포지토리에 복사하고 싶습니다.opkg와 패키지 동기화

답변

2

다양한 패키지 등으로 어리둥절한 후에 우분투 시스템을 사용하여 저장소를 복제하는 방법을 발견했습니다. 내 개발자 머신에

echo "src/gz reponame http://myserver/repositories/opkg/beaglebone" > /etc/opkg/rms-feed.conf 
chmod 666 /etc/opkg/reponame-feed.conf 
opkg update 

, 내가 백업 패키지를 필요로하는 어떤 시간 :

을 내 고객 BeagleBone 흑인에

# Install apache 
sudo apt-get install apache2 

# Install git 
sudo apt-get install git 

# Download the opkg-utils from the Yocto Project 
git clone http://git.yoctoproject.org/git/opkg-utils 

# Build the opkg-utils 
cd opkg-utils && make; cd - 

# Move them to a common directory 
mv opkg-utils /usr/local/share\ 

# Add them to my path 
echo "PATH=\"\$PATH:/usr/local/share/opkg-utils\"" >> /etc/environment 

# Update my environment 
source /etc/environment 

# Create the structure of my repository 
mkdir -p /var/www/repositories/opkg/beaglebone 

# Create an index for the packages 
opkg-make-index -l Packages.filelist -p Packages /var/www/repositories/opkg/beaglebone 
cd /var/www/repositories/opkg/beaglebone 
gzip -c Packages > Packages.gz 

이 저장소에 설정에 액세스하려면 : 여기가 수행 한 단계입니다

#!/bin/bash 

############################################################################### 
# 
# bbb_clone_package_to_internal_repo.sh 
# 
# Description: 
# Clones an ipkg/opkg package to the internal repository server so that it can be deployed 
# to BeagleBone Black clients on demand. This is so that we can have backups in 
# the event that a public server becomes temporarily or permanently 
# inaccessible. 
# 
# Pre-conditions: 
# 1) The given package file must exist at the path specified. 
# 
# Post-conditions: 
# 1) The given package file will be sent to the internal repository server. 
# 2) The opkg repository indexes will all be updated 
# 
# Parameters: 
# -p <file path.opk> : The package to be cloned 
# 
############################################################################### 

PACKAGE_FILE_PATH="" 
SERVER="myserver" 

ERR_INVALID_PACKAGE_FILE_NAME=1 
ERR_PACKAGE_FILE_NOT_ACCESSIBLE=2 
ERR_FAILED_TO_COPY_PACKAGE_TO_SERVER=3 
ERR_FAILED_TO_DEPLOY_PACKAGE_ON_SERVER=4 

usage() 
{ 
cat << EOF 
usage: $0 [options] 

This script copies a remote ipkg/opkg file to the $SERVER server for subsequent 
deployment to BeagleBone Black boards. 

OPTIONS: 
    -p <file path.[io]pk> The package file to be deployed 

    -h,?     Show this message 

EOF 
} 

while getopts “p:h?” OPTION 
do 
    case $OPTION in 
    p) 
     PACKAGE_FILE_PATH="$OPTARG" 
     ;; 
    h) 
     usage 
     exit 
     ;; 
    ?) 
     usage 
     exit 
     ;; 
    esac 
done 

if [[ -z "$PACKAGE_FILE_PATH" || ! ("$PACKAGE_FILE_PATH" =~ \.[io]pk$) ]]; then 
    echo "The package file must not be blank and must have an .ipk or .opk suffix" 
    exit $ERR_INVALID_PACKAGE_FILE_NAME 
fi 

# Retrieve the package 
wget -q "$PACKAGE_FILE_PATH" 
RESULT="$?" 
if [[ $RESULT -ne 0 ]]; then 
    echo "Failed to retrieve file $PACKAGE_FILE_PATH with result $RESULT" 
    exit $ERR_PACKAGE_FILE_NOT_ACCESSIBLE 
fi 

# Deploy the package to myserver 

PACKAGE_FILE_NAME="$(basename $PACKAGE_FILE_PATH)" 
REPOSITORY_ROOT="/var/www/repositories/opkg/beaglebone" 
scp "$PACKAGE_FILE_NAME" [email protected]$SERVER:$REPOSITORY_ROOT 
RESULT="$?" 
if [[ $RESULT -ne 0 ]]; then 

    echo "Failed to copy file $PACKAGE_FILE_NAME to server with result $RESULT" 
    exit $ERR_FAILED_TO_COPY_PACKAGE_TO_SERVER 
fi 

ssh [email protected]$SERVER "chmod 644 $REPOSITORY_ROOT/$PACKAGE_FILE_NAME; opkg-make-index -l $REPOSITORY_ROOT/Packages.filelist -p $REPOSITORY_ROOT/Packages -r $REPOSITORY_ROOT/Packages $REPOSITORY_ROOT && gzip -c $REPOSITORY_ROOT/Packages > $REPOSITORY_ROOT/Packages.gz" 
RESULT="$?" 
if [[ $RESULT -ne 0 ]]; then 

    echo "Failed to deploy file $PACKAGE_FILE_NAME in repository with result $RESULT" 
    exit $ERR_FAILED_TO_DEPLOY_PACKAGE_ON_SERVER 
fi 

exit 0 
+0

스크립트 사용 팁 : 스크립트를 사용할 때 반복적으로 암호를 입력하지 않아도되도록 컴퓨터와 서버간에 공개 키 인증을 설정하십시오. –