Skip to content

Commit f40285b

Browse files
committed
测试pkg打包
1 parent 2463ce8 commit f40285b

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

.github/workflows/build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,12 @@ jobs:
557557
pkg install -y perl5 p5-JSON-XS p5-Try-Tiny p5-MaxMind-DB-Reader wget
558558
run: |
559559
cd /home/runner/work/vstats/vstats/make
560+
echo "=== 检测 Perl 操作系统名称 ==="
561+
perl -e 'print "OS: $^O\n";'
562+
echo "=== 检查 /etc/freebsd-version 文件 ==="
563+
ls -la /etc/freebsd-version || echo "文件不存在"
564+
cat /etc/freebsd-version 2>/dev/null || echo "无法读取"
565+
echo "=== 运行打包脚本 ==="
560566
perl makepack-awstats.pl --target=PKG
561567
562568
- name: 上传 FreeBSD 包

make/makepack-awstats.pl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@
5757

5858
# 检测操作系统
5959
sub detect_os {
60-
if ($^O =~ /linux/i || (-d "/etc" && -d "/var" && $^O !~ /cygwin/i)) {
60+
if (-f "/etc/freebsd-version") {
61+
return 'freebsd';
62+
}
63+
elsif ($^O =~ /linux/i || (-d "/etc" && -d "/var" && $^O !~ /cygwin/i)) {
6164
return 'linux';
6265
}
6366
elsif (-d "/etc" && -d "/Users") {
@@ -530,7 +533,7 @@ sub build_pkg {
530533
print "=" x 60, "\n";
531534

532535
# 步骤1: 检查是否在 FreeBSD 系统
533-
if (! -f "/etc/freebsd-version") {
536+
if ($OS ne 'freebsd') {
534537
print " ⚠️ Not running on FreeBSD, skipping pkg build\n";
535538
print " 💡 FreeBSD packages must be built on FreeBSD system\n";
536539
return undef;
@@ -561,9 +564,17 @@ sub build_pkg {
561564
print $mf $makefile_content;
562565
close $mf;
563566

564-
# 创建 files 目录并复制源码
565-
make_path("$port_dir/www/awstats/files");
566-
system("cp -pr '$SOURCE'/* '$port_dir/www/awstats/files/' 2>/dev/null");
567+
# 复制源码到 port 的 files 目录或 distdir
568+
my $src_dir = "$BUILDROOT/$filename";
569+
if (!-d $src_dir) {
570+
print " ❌ Source directory not found: $src_dir\n";
571+
return undef;
572+
}
573+
574+
# FreeBSD ports 期望源码在 distdir 或者 files 目录
575+
# 创建软链接或直接复制
576+
make_path("$port_dir/www/awstats/work");
577+
system("ln -sf '$src_dir' '$port_dir/www/awstats/work/$PROJECT-$version' 2>/dev/null");
567578

568579
print " ✅ Port directory created at: $port_dir/www/awstats\n";
569580

@@ -586,14 +597,9 @@ sub build_pkg {
586597

587598
# 步骤4: 查找生成的包
588599
print "\n📋 Step 4: Locating generated package...\n";
589-
my $pkg_file = `find work/pkg -name "*.pkg" -type f 2>/dev/null | head -1`;
600+
my $pkg_file = `find . -name "*.pkg" -type f 2>/dev/null | head -1`;
590601
chomp $pkg_file;
591602

592-
if (!$pkg_file || !-f $pkg_file) {
593-
$pkg_file = `find . -name "*.pkg" -type f | head -1`;
594-
chomp $pkg_file;
595-
}
596-
597603
if ($pkg_file && -f $pkg_file) {
598604
my $size = -s $pkg_file;
599605
print " ✅ Package created: $pkg_file (" . int($size/1024) . " KB)\n";

0 commit comments

Comments
 (0)