Re: Building binary package, howto enable init.d/systemd start

2023-03-07 Thread Alexandre Rossi
Hi,

> i am trying to build a binary debian package consisting of a python
> script, shell scripts and a config file as daemon with either init.d or
> systemd start.
> 
> The init.d script gets installed also the systemd file, but both are not
> enabled.

[...]

> In debian/rules is:
> 
> #!/usr/bin/make -f
> 
> DH_VERBOSE=1
> 
> %:
>   dh $@
> clean:
>   @# Do nothing
> 
> build:
>   @# Do nothing
> 
> binary:

[...]

I suggest you use override_dh_auto_install instead or better use
debian/install (man dh_install) for what you do in this target.

> I have the strange feeling the entire postinstall stuff is missing.
> Is there a significant typo somewhere so obvious I am to stupid to see?

I think that overriding the binary target breaks debhelper.
 
[...]

> If there is a distribution like Mint Tessa for example, how does the
> system decide which startmethod to choose, if init.d and systemd are
> enabled successfully? I see a mix of init.d and systemd there regading
> starting stuff.

Your package will support both and the magic will happen at package
install phase. I think dh_installinit and dh_installsystemd generate
the postinst scripts that make this happen.

Cheers,

Alex



Re: Re: Building binary package, howto enable init.d/systemd start

2023-03-03 Thread Konstantin Kletschke


Dear Tim,

I followed your advise to restucture my stuff exactly like you
suggested.

Putting all files in a structure below source, Makefile,
PACKAGE.install ... everything.

And now it works!

I get init.d and systemd _enabled_ start scripts.

Installing this way I get an error at the target:

$ sudo dpkg -i Kletschke_deb/loqitmon_1.0-1_amd64.deb
(Reading database ... 261966 files and directories currently installed.)
Preparing to unpack .../loqitmon_1.0-1_amd64.deb ...
Unpacking loqitmon (1.0-1) over (1.0-1) ...
Setting up loqitmon (1.0-1) ...
invoke-rc.d: syntax error: unknown option "--skip-systemd-native"
dpkg: error processing package loqitmon (--install):
 installed loqitmon package post-installation script subprocess returned error 
exit status 1
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (237-3ubuntu10.9) ...
Errors were encountered while processing:
 loqitmon

This is - I suppose - done because the usage of init.d and systemd was
detected and a mechanism was built in to not do native systemd.
May be due to comapt level settings the target system has not this
commandline option available (yet).

I then the omitted the init.d script entirely and I get this on the target:

$ sudo dpkg -i Kletschke_deb/loqitmon_1.0-1_amd64.deb
(Reading database ... 261968 files and directories currently installed.)
Preparing to unpack .../loqitmon_1.0-1_amd64.deb ...
Unpacking loqitmon (1.0-1) over (1.0-1) ...
Setting up loqitmon (1.0-1) ...
Created symlink /etc/systemd/system/loqitmon.service → 
/lib/systemd/system/loqitmon.service.
Created symlink /etc/systemd/system/multi-user.target.wants/loqitmon.service → 
/lib/systemd/system/loqitmon.service.

e voila, it works fine!


Many thanks for your suggestion!


Kind Regards
Konstantin




-- 
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

konstantin.kletsc...@inside-m2m.de
http://www.inside-m2m.de 

Geschäftsführung: Michael Emmert, Derek Uhlig
HRB: 111204, AG Hannover



Re: Re: Building binary package, howto enable init.d/systemd start

2023-03-03 Thread Konstantin Kletschke
Dear Darac,

> > The files
> > /etc/init.d/loqitmon
> > /lib/systemd/system/loqitmon.service
> The manpage for dh_installsystemd suggests these files should be under 
> debian/. Are they, or are they in etc/init.d and lib/systemd/system?

I have those below debian, this way:

-rwxr-xr-x 1 konsti konsti 939 Mar  2 13:35 debian/loqitmon.init
-rw-rw-r-- 1 konsti konsti 189 Mar  1 18:27 debian/loqitmon.service

I restructured the files like Tim suggested in the other mail, those
files are picked up without any change.

Somehow I managed to disable all debhelber automatic stuff in my
approach.


Kind Regards
Konstantin



-- 
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

konstantin.kletsc...@inside-m2m.de
http://www.inside-m2m.de 

Geschäftsführung: Michael Emmert, Derek Uhlig
HRB: 111204, AG Hannover



Re: Building binary package, howto enable init.d/systemd start

2023-03-02 Thread Tim Woodall

On Thu, 2 Mar 2023, Konstantin Kletschke wrote:


In debian/rules is:

#!/usr/bin/make -f

DH_VERBOSE=1

%:
dh $@
clean:
@# Do nothing

build:
@# Do nothing

binary:
mkdir -p debian/loqitmon
mkdir -p debian/loqitmon/usr/
mkdir -p debian/loqitmon/usr/bin
cp loqitmon.py debian/loqitmon/usr/bin/loqitmon
mkdir -p debian/loqitmon/etc
cp loqitmon.ini debian/loqitmon/etc
cp loqitmonaction1 debian/loqitmon/usr/bin
cp loqitmonaction2 debian/loqitmon/usr/bin
cp loqitmonaction3 debian/loqitmon/usr/bin
cp loqitmonstep1 debian/loqitmon/usr/bin
cp loqitmonstep2 debian/loqitmon/usr/bin
cp loqitmonstep3 debian/loqitmon/usr/bin
dh_installinit
dh_installsystemd
dh_gencontrol
dh_install
dh_auto_install
dh_builddeb



I'm no expert. Have you tried manually setting up the directory
structure then using the default dh $@ instead of overriding the binary
step?

I wonder if you're missing something - the error about conffiles is
suspicious, I think that should be automatic.


This is a layout of one of my simple deb-src packages:

apt-mirror@aptmirror17:/mnt/mirror/ftp/mirror/local/pool/main/b/backup
(none)$ tar tvJf backup_1.11+tjw99r1.tar.xz
drwxr-xr-x 0/0   0 2022-05-06 17:52 package/
-rw-r--r-- 0/0 213 2022-04-29 18:02 package/Makefile
drwxr-xr-x 0/0   0 2022-10-12 06:43 package/debian/
-rw-r--r-- 0/0  57 2022-05-07 08:20 package/debian/backup.install
-rw-r--r-- 0/01499 2022-10-12 06:43 package/debian/changelog
-rw-r--r-- 0/0   3 2022-04-28 22:32 package/debian/compat
-rw-r--r-- 0/0 337 2022-04-28 22:32 package/debian/control
-rw-r--r-- 0/01307 2022-04-28 22:03 package/debian/copyright
-rwxr-xr-x 0/0 298 2021-03-13 20:40 package/debian/postinst
-rwxr-xr-x 0/0 438 2021-03-02 17:40 package/debian/postrm
-rwxr-xr-x 0/0 548 2022-04-29 17:45 package/debian/rules
drwxr-xr-x 0/0   0 2022-05-06 17:52 package/debian/source/
-rw-r--r-- 0/0  13 2021-03-02 17:40 package/debian/source/format
drwxr-xr-x 0/0   0 2021-03-02 17:40 package/src/
drwxr-xr-x 0/0   0 2021-03-02 17:40 package/src/etc/
drwxr-xr-x 0/0   0 2022-05-06 17:51 package/src/etc/backup/
-rw-r--r-- 0/02752 2021-11-07 10:46 
package/src/etc/backup/backup.conf
drwxr-xr-x 0/0   0 2022-08-20 07:09 package/src/etc/cron.d/
-rw-r--r-- 0/0 145 2021-06-22 07:00 package/src/etc/cron.d/backup
drwxr-xr-x 0/0   0 2021-03-02 17:40 package/src/usr/
drwxr-xr-x 0/0   0 2022-09-27 03:26 package/src/usr/sbin/
-rwxr-xr-x 0/04081 2022-09-27 03:21 package/src/usr/sbin/backup

This is all that that Makefile does:
apt-mirror@aptmirror17:/mnt/mirror/local-debs/main/b/backup/package (master)$ 
cat Makefile
.PHONY: all install

FILES ::= $(shell [ -d src ] && find src -mindepth 1 -maxdepth 1 )

all:

install:
ifdef FILES
mkdir -p $(DESTDIR)
for i in $(FILES); do \
  cp -dR $$i $(DESTDIR)/$${i#src/}; \
done
endif

And this is the content of debian/rules:
apt-mirror@aptmirror17:/mnt/mirror/local-debs/main/b/backup/package (master)$ 
cat debian/rules
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1


# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
dh $@

override_dh_auto_install:
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp



And here is the .install file:
apt-mirror@aptmirror17:/mnt/mirror/local-debs/main/b/backup/package (master)$ 
cat debian/backup.install
etc/backup/backup.conf
etc/cron.d/backup
usr/sbin/backup






Re: Building binary package, howto enable init.d/systemd start

2023-03-02 Thread Darac Marjal


On 02/03/2023 19:56, Konstantin Kletschke wrote:

Dear debian-user Folks,

i am trying to build a binary debian package consisting of a python
script, shell scripts and a config file as daemon with either init.d or
systemd start.

The init.d script gets installed also the systemd file, but both are not
enabled.

I made a directory loqitmon-1.0 and in there are python script,
shellscripts and config file.

In debian/control is:

Source: loqitmon
Section: base
Priority: optional
Maintainer: Konstantin Kletschke 
Build-Depends: debhelper (>=9.0.0), dh-virtualenv (>= 0.8)
Standards-Version: 4.5.1

Package: loqitmon
Architecture: any
Pre-Depends: dpkg (>= 1.16.1), python3, init-system-helpers (>= 1.51~)
Depends: ${misc:Depends}
Description: LoQiT monitoring daemon
  This daemon monitors /var/log/syslog for
  device removal of card reader and removal of
  display and restarts either the X server or
  the entire system accordingly
  Derived from https://github.com/yxiao168/logmonitor.git

In debian/rules is:

#!/usr/bin/make -f

DH_VERBOSE=1

%:
dh $@
clean:
@# Do nothing

build:
@# Do nothing

binary:
mkdir -p debian/loqitmon
mkdir -p debian/loqitmon/usr/
mkdir -p debian/loqitmon/usr/bin
cp loqitmon.py debian/loqitmon/usr/bin/loqitmon
mkdir -p debian/loqitmon/etc
cp loqitmon.ini debian/loqitmon/etc
cp loqitmonaction1 debian/loqitmon/usr/bin
cp loqitmonaction2 debian/loqitmon/usr/bin
cp loqitmonaction3 debian/loqitmon/usr/bin
cp loqitmonstep1 debian/loqitmon/usr/bin
cp loqitmonstep2 debian/loqitmon/usr/bin
cp loqitmonstep3 debian/loqitmon/usr/bin
dh_installinit
dh_installsystemd


This looks relevant, have you read it's manpage?


dh_gencontrol
dh_install
dh_auto_install
dh_builddeb

When I run

# > debuild -b -us -uc

this is the output:

  dpkg-buildpackage -us -uc -ui -b
dpkg-buildpackage: info: source package loqitmon
dpkg-buildpackage: info: source version 1.0-1
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Konstantin Kletschke 

  dpkg-source --before-build .
dpkg-buildpackage: info: host architecture amd64
  fakeroot debian/rules clean
  debian/rules build
  fakeroot debian/rules binary
mkdir -p debian/loqitmon
mkdir -p debian/loqitmon/usr/
mkdir -p debian/loqitmon/usr/bin
cp loqitmon.py debian/loqitmon/usr/bin/loqitmon
mkdir -p debian/loqitmon/etc
cp loqitmon.ini debian/loqitmon/etc
cp loqitmonaction1 debian/loqitmon/usr/bin
cp loqitmonaction2 debian/loqitmon/usr/bin
cp loqitmonaction3 debian/loqitmon/usr/bin
cp loqitmonstep1 debian/loqitmon/usr/bin
cp loqitmonstep2 debian/loqitmon/usr/bin
cp loqitmonstep3 debian/loqitmon/usr/bin
dh_installinit
dh_installsystemd
dh_gencontrol
dpkg-gencontrol: warning: package loqitmon: substitution variable 
${misc:Pre-Depends} unused, but is defined
dh_install
dh_auto_install
dh_builddeb
dpkg-deb: building package 'loqitmon' in '../loqitmon_1.0-1_amd64.deb'.
  dpkg-genbuildinfo --build=binary -O../loqitmon_1.0-1_amd64.buildinfo
  dpkg-genchanges --build=binary -O../loqitmon_1.0-1_amd64.changes
dpkg-genchanges: info: binary-only upload (no source code included)
  dpkg-source --after-build .
dpkg-buildpackage: info: binary-only upload (no source included)
Now running lintian loqitmon_1.0-1_amd64.changes ...
E: loqitmon changes: bad-distribution-in-changes-file unstable
E: loqitmon: file-in-etc-not-marked-as-conffile etc/init.d/loqitmon
E: loqitmon: file-in-etc-not-marked-as-conffile etc/loqitmon.ini
E: loqitmon: no-changelog usr/share/doc/loqitmon/changelog.Debian.gz 
(non-native package)
E: loqitmon: no-copyright-file
W: loqitmon: no-manual-page usr/bin/loqitmon
W: loqitmon: no-manual-page usr/bin/loqitmonaction1
W: loqitmon: no-manual-page usr/bin/loqitmonaction2
W: loqitmon: no-manual-page usr/bin/loqitmonaction3
W: loqitmon: no-manual-page usr/bin/loqitmonstep1
W: loqitmon: no-manual-page usr/bin/loqitmonstep2
W: loqitmon: no-manual-page usr/bin/loqitmonstep3
W: loqitmon: script-in-etc-init.d-not-registered-via-update-rc.d 
etc/init.d/loqitmon
W: loqitmon: unknown-section base
Finished running lintian.

You probably want to investigate these lintian warnings, at some point.


The files
/etc/init.d/loqitmon
/lib/systemd/system/loqitmon.service
The manpage for dh_installsystemd suggests these files should be under 
debian/. Are they, or are they in etc/init.d and lib/systemd/system?


are in the package, but they are are not enabled.

I have the strange feeling the entire postinstall stuff is missing.
Is there a significant typo somewhere so obvious I am to stupid to see?

If there is a distribution like Mint Tessa for example, how does the
system decide which startmethod to choose, if init.d and systemd are
enabled successfully? I see a mix of init.d and systemd there regading
starting stuff.

Kind Regards
Konstantin




OpenPGP_signature
Description: