dpkg build package error : debian/rules clean gave error exit status 2

33,497

Solution 1

This can be caused by whitespace somewhere in debian/rules

For nano edit the first line of /usr/share/nano/sh.nanorc & change it to:

syntax "sh" "\.sh$" "rules"

Now when you edit debian/rules with nano the whitespace will show up as green.

Solution 2

In my case: This error message "dpkg-buildpackage: error: debian/rules clean gave error exit status 2" just means: "One of the actions in the debian/rules file fail." You should fix the real error, which usually is the error message just before this error message.

Solution 3

This is the usual error that make produces when you have spaces instead of a tab preceding the lines after a target. In this case, the target looks like clean. So, check the lines following the clean target, and see if any of them contain spaces before the beginning of the text.

Share:
33,497
Nandaraj Ks
Author by

Nandaraj Ks

Updated on January 20, 2021

Comments

  • Nandaraj Ks
    Nandaraj Ks over 3 years

    I have tried to build the package using the command

    sudo fakeroot dpkg-buildpackage -F.
    

    And encountered these result in the ternimal.

    dpkg-buildpackage: source package calender
    dpkg-buildpackage: source version 1.5-1
    dpkg-buildpackage: source distribution unstable
    dpkg-buildpackage: source changed by Nandaraj <[email protected]>
    dpkg-buildpackage: host architecture amd64
    dpkg-source --before-build calender-1.5
    debian/rules clean
    debian/rules:18: *** missing separator.  Stop.
    dpkg-buildpackage: error: debian/rules clean gave error exit status 2
    

    My rules file is:

    #!/usr/bin/make -f
    
    icon=$(CURDIR)/calender.png
    script=$(CURDIR)/calender.py
    launcher=$(CURDIR)/calender.desktop
    links=$(CURDIR)/links.txt
    
    DEST1=$(CURDIR)/debian/calender/usr/share/calender
    DEST2=$(CURDIR)/debian/calender/usr/share/applications
    
    build: build-stamp
    
    build-stamp:
        dh_testdir
        touch build-stamp
    
    clean:
        dh_testdir
        dh_testroot
        rm -f build-stamp
        dh_clean
    
    
    install: build clean $(icon) $(script) $(links) $(launcher)
        dh_testdir
        dh_testroot
        dh_prep
        dh_installdirs
    
    
        mkdir -m 755 -p $(DEST1)
        mkdir -m 755 -p $(DEST2)
    
    
        install -m 666 $(icon) $(DEST1) 
        install -m 777 $(script) $(DEST1)
        install -m 666 $(links) $(DEST1)
        install -m 777 $(launcher) $(DEST2)
    
    binary-indep: build install
        dh_testdir
        dh_testroot
        dh_installchangelogs
        dh_installdocs
        dh_installexamples
        dh_installman
        dh_link
        dh_compress
        dh_fixperms
        dh_installdeb
        dh_gencontrol
        dh_md5sums
        dh_builddeb
    
    # Build architecture-dependent files here.
    binary-arch: build install
    # We have nothing to do by default.
    
    binary: binary-indep binary-arch
    .PHONY: build clean binary-indep binary-arch binary install
    

    And my .desktop file is:

    [Desktop Entry]
    Version=1.0
    Type=Application
    Terminal=false
    Icon[en_IN]=/
    Name[en_IN]=calender
    Exec=/usr/share/applications/calender.py
    Comment[en_IN]=program prints calender
    Name=calender
    Comment=program prints calender
    Icon=/usr/share/calender/cal.png
    Categories=Network;GTK;GNOME
    

    Not able to build the package issue is

    debian/rules:18: *** missing separator.  Stop.
    dpkg-buildpackage: error: debian/rules clean gave error exit status 2
    
  • Veverke
    Veverke over 3 years
    I have to admit I was about to flag this as not helpful, but yes, you are right. Found the real error message ;)
  • Veverke
    Veverke over 3 years
    Well, that helped for the 1st and 2nd errors. But now I stuck with this message without errors above...
  • Nico Haase
    Nico Haase over 3 years
    Please add some explanation to your answer such that others can learn from it
  • Mhd Alaa Alhaj
    Mhd Alaa Alhaj over 3 years
    Hello and welcome to SO! While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. Please read the tour, and How do I write a good answer?