1. 애플리케이션 배포
애플리케이션을 생성하고 부팅 시 자동으로 시작되도록 해야 하는 경우가 종종 있습니다. 이는 Systemd 서비스를 설정하여 달성할 수 있습니다. 아래에서는 간단한 hello.service 생성을 예로 들어 ArmSoM 보드에서 자신만의 Systemd 서비스를 설정하는 과정을 안내하겠습니다.
1.1 스크립트 작성
/opt 디렉토리에 hello.sh 스크립트를 작성합니다:
#!/bin/bash
for ((i=1; i<=3; i++))
do
echo "hello,armsom!" >> /tmp/hello.log
sleep 1
done
이 스크립트로 구현된 함수는 "Hello, ArmSoM!"을 인쇄하는 것입니다. /tmp/wello.log 파일에 1초에 3번씩 문자열을 추가합니다.
스크립트에 실행 권한을 추가합니다.
chmod +x hello.sh
1.2 프로필 만들기
안녕하세요 armsom을 만듭니다. /etc/systemd/system/디렉토리의 서비스 구성 파일:
[Unit]
Description=Hello Armsom Service
After=network.target
[Service]
Type=simple
User=armsom
ExecStart=/opt/hello.sh
Restart=no
StandardOutput=journal
[Install]
WantedBy=multi-user.target
ExecutStart 필드는 hello armsom에 대한 자체 시작 스크립트를 정의합니다. 서비스 서비스는/opt/hello.sh입니다. hello를 활성화하면. 서비스 시작 기능, /opt/hello.sh는 시작 후 실행됩니다.
1.3 hello-armsom.service 활성화
'sudo systemctl list unit files - type=service | grep hello'를 사용하여 hello.service가 서비스 목록에 추가되었는지 확인합니다.
armsom@armsom:/etc/systemd/system$ sudo systemctl list-unit-files --type=service | grep hello
hello-armsom.service disabled enabled
보시면 아시겠지만 안녕하세요. 서비스가 비활성화된 상태입니다. 위 명령어를 입력한 후에도 화면이 나오지 않는다면, 생성한 서비스에 문제가 있는 것이므로 면밀히 조사해야 합니다. systemd를 다시 로드하고 서비스를 활성화합니다.
# Reload systemd configuration
sudo systemctl daemon-reload
# Enable self startup upon startup
sudo systemctl enable hello-armsom.service
# Start the service immediately
sudo systemctl start hello-armsom.service
# View service status
sudo systemctl status hello-armsom.service
# View service logs
sudo journalctl -u hello-armsom.service -f
위의 명령을 입력하면 Hello가 표시됩니다. 서비스가 실행 중입니다
armsom@armsom:~$ sudo systemctl status hello-armsom.service
○ hello-armsom.service - Hello Armsom Service
Loaded: loaded (/etc/systemd/system/hello-armsom.service; enabled; preset: enabled)
Active: inactive (dead) since Thu 2026-01-08 11:30:33 CST; 3s ago
Duration: 3.059s
Process: 3510 ExecStart=/opt/hello.sh (code=exited, status=0/SUCCESS)
Main PID: 3510 (code=exited, status=0/SUCCESS)
CPU: 15ms
armsom@armsom:~$
armsom@armsom:~$ cat /tmp/hello.log
hello,armsom!
hello,armsom!
hello,armsom!
2.deb 패키지 설치
Deb 패키지는 Linux 시스템의 설치 패키지입니다. 가끔 온라인에서 다운로드한 Linux 소프트웨어 설치 패키지도 deb 패키지 형태로 나타나는 경우가 있습니다. tar 패키지 기반이므로 파일의 권한 정보(읽기, 쓰기, 실행), 소유자, 사용자 그룹 등도 기록합니다.
다음 명령을 사용하십시오. dpkg - l 시스템과 설치된 deb 패키지를 확인합니다.
2.1 deb 패키지의 구성 구조
Deb 패키지는 일반적으로 두 부분으로 나뉩니다.
- 설치 내용은 Linux의 루트 디렉터리와 유사하며, 이는 소프트웨어가 Linux 시스템의 파일 디렉터리에 설치되어야 함을 나타냅니다.
- 제어 정보(DEBIAN 디렉터리에 위치), 일반적으로 DEBIAN 디렉터리에는 다음과 같은 여러 파일이 있습니다.
- 변경 로그: 파일은 deb 패키지의 작성자, 버전 및 마지막 업데이트 날짜와 같은 정보를 기록합니다.
- 제어: 파일은 패키지 이름, 버전 번호, 아키텍처, 관리자 및 설명과 같은 정보를 기록합니다.
- 저작권: 파일에는 일부 저작권 정보가 기록되어 있습니다.
- 사후 스크립트: 일반 디렉터리 파일을 시스템에 복사한 후 소프트웨어가 실행해야 하는 스크립트입니다.
- Postrm 파일: 소프트웨어 제거 후 실행해야 하는 스크립트입니다.
- 그 중 컨트롤, 포스터, 포스터가 꼭 필요한 파일입니다.
2.2 deb 패키지 빌드
설치 도구 및 종속성:
sudo apt-get install build-essential debhelper make autoconf automake dpkg-dev fakeroot pbuilder gnupg
다음 디렉터리와 파일을 만듭니다.
armsom@armsom:~$ tree armsom-service/
armsom-service/
├── DEBIAN
│ ├── control
│ ├── postinst
│ └── postrm
├── etc
│ └── systemd
│ └── system
│ └── hello-armsom.service
└── opt
└── hello.sh
6 directories, 5 files
데비안/제어:
Package: armsom-service
Version: 1.0.0-1
Section: utils
Priority: optional
Architecture: arm64
Depends: bash, systemd
Maintainer: armsom <armsom@example.com>
Description: Armsom
postinst:
#!/bin/bash
if [ "$1" = "upgrade" ] || [ "$1" = "install" ];then
echo "armsom-service installing"
if [ -f "/opt/hello.sh" ]; then
chmod +x /opt/hello.sh
echo "✓ The execution permission of/opt/hello.sh has been set"
fi
systemctl enable hello-armsom
systemctl start hello-armsom
fi
postrm
#!/bin/bash
if [ "$1" = "upgrade" ] ; then
echo "upgrade"
elif [ "$1" = "remove" ] || [ "$1" = "purge" ] ; then
echo "remove armsom-service"
systemctl stop hello-armsom.service
systemctl disable hello-armsom.service
fi
위 디렉터리를 deb 파일로 패키징하고 dpkg 명령을 사용하여 보드에 설치합니다.
dpkg-deb --build -Zgzip armsom-service armsom-service.deb
sudo dpkg -i armsom-service.deb
2.3 deb 패키지 수정
일반적인 방법은 다음과 같습니다.
#Extract the file from the package to the extract/ directory
dpkg -X rkwifibt-broadcom-firmware_1.0.0-1_arm64.deb extract/
#Extract the control information of the extracted package to the extract/DEBIAN/ directory
dpkg -e rkwifibt-broadcom-firmware_1.0.0-1_arm64.deb extract/DEBIAN/
#Modify file xxx
#Repackage the modified content
dpkg-deb --build -Zgzip extract/ *****.deb
