ターゲットが/usr/local/binの場合、Debianパッケージのビルドは失敗します。

ターゲットが/usr/local/binの場合、Debianパッケージのビルドは失敗します。

私は非常に単純なCプロジェクトを作成し、このプロジェクトでDebianパッケージを作成したいと思います。 Makefileを使用してCプロジェクトを手動でビルドすることは期待どおりに機能し、バイナリをビルドして/usr/local/binにインストールできます。しかし、Debian パッケージをビルドしようとすると失敗します。 dh_usrlocal: error: debian/myhelloworld/usr/local/bin/myhelloworld is not a directory

Makefileは次のようになります。

prefix = /usr/local/bin

all: src/myhelloworld

src/hello: src/myhelloworld.c
    @echo "CFLAGS=$(CFLAGS)" | \
        fold -s -w 70 | \
        sed -e 's/^/# /'
    $(CC) $(CPPFLAGS) $(CFLAGS) $(LDCFLAGS) -o $@ $^

install: src/myhelloworld
    install -D src/myhelloworld \
        $(DESTDIR)$(prefix)/myhelloworld

clean:
    -rm -f src/myhelloworld

distclean: clean

uninstall:
    -rm -f $(DESTDIR)$(prefix)/myhelloworld

.PHONY: all install clean distclean uninstall

debianディレクトリが作成され、それをdebmake使用debuildしてビルドします。

プロジェクト構造は次のとおりです。

.
├── debian
│   ├── changelog
│   ├── control
│   ├── copyright
│   ├── debhelper-build-stamp
│   ├── files
│   ├── myhelloworld
│   │   ├── DEBIAN
│   │   │   ├── control
│   │   │   └── md5sums
│   │   └── usr
│   │       ├── myhelloworld
│   │       └── share
│   │           └── doc
│   │               └── myhelloworld
│   │                   ├── changelog.Debian.gz
│   │                   ├── copyright
│   │                   └── README.Debian
│   ├── myhelloworld.debhelper.log
│   ├── myhelloworld.substvars
│   ├── patches
│   │   └── series
│   ├── README.Debian
│   ├── rules
│   ├── source
│   │   ├── format
│   │   └── local-options
│   └── watch
├── LICENSE
├── Makefile
└── src
    ├── myhelloworld
    └── myhelloworld.c

debian/rulesdh_auto_installを無視するようにデフォルトファイルを変更してみました。

%:
    dh $@  

override_dh_auto_install:
    dh_auto_install -- prefix=/usr/local/bin

これも失敗しました。 .dllファイルにバイナリが存在することを確認しましたdebian/myhelloworld/usr/local/bin

プレフィックスを/usr/bin/usr/bin

エラーメッセージを見ると、debuildがmyhelloworldディレクトリを期待しているようですが、これはバイナリファイルです。それでは、目的地/usr/local/binでデビルドが失敗するのはなぜですか?

ビルドログ:

ep@ep-xps:~/sandbox/myhelloworld-1.0$ debuild 
 dpkg-buildpackage -us -uc -ui
dpkg-buildpackage: info: source package myhelloworld
dpkg-buildpackage: info: source version 1.0-1
dpkg-buildpackage: info: source distribution UNRELEASED
dpkg-buildpackage: info: source changed by Erik <>
 dpkg-source --before-build .
dpkg-buildpackage: info: host architecture amd64
 fakeroot debian/rules clean
dh clean  
   dh_auto_clean
        make -j12 distclean
make[1]: Entering directory '/home/ep/sandbox/myhelloworld-1.0'
rm -f src/myhelloworld
make[1]: Leaving directory '/home/ep/sandbox/myhelloworld-1.0'
   dh_clean
 dpkg-source -b .
dpkg-source: warning: no source format specified in debian/source/format, see dpkg-source(1)
dpkg-source: info: using source format '1.0'
dpkg-source: info: building myhelloworld using existing myhelloworld_1.0.orig.tar.gz
dpkg-source: info: building myhelloworld in myhelloworld_1.0-1.diff.gz
dpkg-source: warning: newly created empty file 'LICENSE' will not be represented in diff
dpkg-source: warning: the diff modifies the following upstream files: 
 Makefile
 src/myhelloworld.c
dpkg-source: info: use the '3.0 (quilt)' format to have separate and documented changes to upstream files, see dpkg-source(1)
dpkg-source: info: building myhelloworld in myhelloworld_1.0-1.dsc
 debian/rules build
dh build  
   dh_update_autotools_config
   dh_autoreconf
   dh_auto_configure
   dh_auto_build
        make -j12 "INSTALL=install --strip-program=true"
make[1]: Entering directory '/home/ep/sandbox/myhelloworld-1.0'
cc -g -O2 -ffile-prefix-map=/home/ep/sandbox/myhelloworld-1.0=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro  src/myhelloworld.c   -o src/myhelloworld
make[1]: Leaving directory '/home/ep/sandbox/myhelloworld-1.0'
   dh_auto_test
   create-stamp debian/debhelper-build-stamp
 fakeroot debian/rules binary
dh binary  
   dh_testroot
   dh_prep
   debian/rules override_dh_auto_install
make[1]: Entering directory '/home/ep/sandbox/myhelloworld-1.0'
dh_auto_install -- prefix=/usr/local/bin
        make -j12 install DESTDIR=/home/ep/sandbox/myhelloworld-1.0/debian/myhelloworld AM_UPDATE_INFO_DIR=no "INSTALL=install --strip-program=true" prefix=/usr/local/bin
make[2]: Entering directory '/home/ep/sandbox/myhelloworld-1.0'
install -D src/myhelloworld \
        /home/ep/sandbox/myhelloworld-1.0/debian/myhelloworld/usr/local/bin/myhelloworld
make[2]: Leaving directory '/home/ep/sandbox/myhelloworld-1.0'
make[1]: Leaving directory '/home/ep/sandbox/myhelloworld-1.0'
   dh_installdocs
   dh_installchangelogs
   dh_perl
   dh_usrlocal
dh_usrlocal: error: debian/myhelloworld/usr/local/bin/myhelloworld is not a directory
make: *** [debian/rules:9: binary] Error 25
dpkg-buildpackage: error: fakeroot debian/rules binary subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui failed


ベストアンサー1

小包はファイルを送信できません/usr/local、ディレクトリにのみ適用されますdh_usrlocal

最善の解決策は、Debianの規則に従い、次にインストールすることです/usr

override_dh_auto_install:
        dh_auto_install -- prefix=/usr/bin

にインストールするには、/usr/local/bin以下を上書きしてくださいdh_usrlocal

override_dh_usrlocal:

プレフィックスは通常、さまざまなディレクトリが配置される「ルート」として理解されるため、次のことができます。

prefix = /usr/local


install: src/myhelloworld
        install -D src/myhelloworld \
            $(DESTDIR)$(prefix)/bin/myhelloworld

だから最初に:をmyhelloworldに設定してインストールしようとしました。上記のように変更すると、上書きを完全に中止できます。/usrdh_auto_installprefix/usrMakefiledh_auto_install

(あなたのものに少し誤字があります。代わりにする必要がありMakefileます。)$(LDFLAGS)$(LDCFLAGS)

あなたは見つけることができますDebian アップストリームガイド効果がある

おすすめ記事