Skip to contentSkip to conversation

tzdata_2011n: provide pkg_postinst and timezone defaults

PATCH Superseded Andrea Adami 5 participants 13 messages Jan 14, 2012 – Feb 1, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tzdata_2011n: provide pkg_postinst and timezone defaults

* Take the extra bits in do_install from meta-openembedded
* and add pkg_postinst script (adapted from Gentoo).
* Default to 'Universal' timezone, present in the base package
* and allow override using DEFAULT_TIMEZONE variable.
* /etc/localtime and /etc/timezone are purposedly not packaged.
* Bump PR

---
 meta/recipes-extended/tzdata/tzdata_2011n.bb |   55 +++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 2 deletions(-)
meta/recipes-extended/tzdata/tzdata_2011n.bb +53 -2
index de9281a..862a196 100644
@@ -5,7 +5,7 @@ LICENSE = "PD"
 LIC_FILES_CHKSUM = "file://asia;beginline=2;endline=3;md5=06468c0e84ef4d4c97045a4a29b08234"
 DEPENDS = "tzcode-native"
 
-PR = "r0"
+PR = "r1"
 
 RCONFLICTS= "timezones timezone-africa timezone-america timezone-antarctica \
              timezone-arctic timezone-asia timezone-atlantic \
@@ -19,6 +19,8 @@ SRC_URI[tzdata.sha256sum] = "a343e542486b2b8ebdeca474eed79f1c04f69420ca943c2b9bd
 
 S = "${WORKDIR}"
 
+DEFAULT_TIMEZONE ?= "Universal"
+
 TZONES= "africa antarctica asia australasia europe northamerica southamerica  \
          factory solar87 solar88 solar89 etcetera backward systemv \
         "
@@ -41,7 +43,56 @@ do_install () {
         # libc is removing zoneinfo files from package
         cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo
         cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo
-	chown -R root:root ${D}
+
+        # Install defaults
+        install -d ${D}${sysconfdir}
+        echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
+        cp -pP ${S}/${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime
+
+        chown -R root:root ${D}
+}
+
+pkg_postinst_${PN} () {
+
+# code taken from Gentoo's tzdata ebuild
+
+	etc_lt="${sysconfdir}/localtime"
+	src="${sysconfdir}/timezone"
+
+	if [[ -e ${src} ]] ; then
+		tz=$(sed -e 's:#.*::' -e 's:[[:space:]]*::g' -e '/^$/d' "${src}")
+	else
+		tz="FUBAR"
+	fi
+	
+	[[ -z ${tz} ]] && return 0
+
+	if [[ ${tz} == "FUBAR" ]] ; then
+		echo "You do not have TIMEZONE set in ${src}."
+
+		if [[ ! -e ${etc_lt} ]] ; then
+			# if /etc/localtime is a symlink somewhere, assume they
+			# know what they're doing and they're managing it themselves
+			if [[ ! -L ${etc_lt} ]] ; then
+				cp -f "${datadir}/zoneinfo/Universal" "${etc_lt}"
+				echo "Setting ${etc_lt} to Universal."
+			else
+				echo "Assuming your ${etc_lt} symlink is what you want; skipping update."
+			fi
+		else
+			echo "Skipping auto-update of ${etc_lt}."
+		fi
+		return 0
+	fi
+
+	if [[ ! -e "${datadir}/zoneinfo/${tz}" ]] ; then
+		echo "You have an invalid TIMEZONE setting in ${src}"
+		echo "Your ${etc_lt} has been reset to Universal; enjoy!"
+		tz="Universal"
+	fi
+	echo "Updating ${etc_lt} with ${datadir}/zoneinfo/${tz}"
+	[[ -L ${etc_lt} ]] && rm -f "${etc_lt}"
+	cp -f "${datadir}/zoneinfo/${tz}" "${etc_lt}"
 }
 
 # Packages primarily organized by directory with a major city
Signature · 1 line
1.7.3.4
#1 lore raw

Op 14 jan. 2012, om 14:07 heeft Andrea Adami het volgende geschreven:

Quoted 35 lines

* Take the extra bits in do_install from meta-openembedded
* and add pkg_postinst script (adapted from Gentoo).
* Default to 'Universal' timezone, present in the base package
* and allow override using DEFAULT_TIMEZONE variable.
* /etc/localtime and /etc/timezone are purposedly not packaged.
* Bump PR

---
meta/recipes-extended/tzdata/tzdata_2011n.bb | 55 +++++++++++++++++++++++++-

1 files changed, 53 insertions(+), 2 deletions(-)
meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
index de9281a..862a196 100644
@@ -5,7 +5,7 @@ LICENSE = "PD"

LIC_FILES_CHKSUM = "file://asia;beginline=2;endline=3;md5=06468c0e84ef4d4c97045a4a29b08234" DEPENDS = "tzcode-native"

meta/recipes-extended/tzdata/tzdata_2011n.bb +1 -1
-PR = "r0"
+PR = "r1"
RCONFLICTS= "timezones timezone-africa timezone-america timezone-antarctica \
             timezone-arctic timezone-asia timezone-atlantic \
meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
@@ -19,6 +19,8 @@ SRC_URI[tzdata.sha256sum] = "a343e542486b2b8ebdeca474eed79f1c04f69420ca943c2b9bd
 

S = "${WORKDIR}"

meta/recipes-extended/tzdata/tzdata_2011n.bb +2 -0
+DEFAULT_TIMEZONE ?= "Universal"
+

TZONES= "africa antarctica asia australasia europe northamerica southamerica \

         factory solar87 solar88 solar89 etcetera backward systemv \
        "

meta/recipes-extended/tzdata/tzdata_2011n.bb do_install () { · line 50

Quoted 9 lines
meta/recipes-extended/tzdata/tzdata_2011n.bb +5 -1
@@ -41,7 +43,56 @@ do_install () {
        # libc is removing zoneinfo files from package
        cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo
        cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo
-	chown -R root:root ${D}
+
+        # Install defaults
+        install -d ${D}${sysconfdir}
+        echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
+        cp -pP ${S}/${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime

Shouldn't that be an 'ln -sf' instead of a 'cp'?

#2 lore raw
Quoted 7 lines · Koen Kooi

meta/recipes-extended/tzdata/tzdata_2011n.bb do_install () { · line 50

Quoted 4 lines
meta/recipes-extended/tzdata/tzdata_2011n.bb +4 -0
+        # Install defaults
+        install -d ${D}${sysconfdir}
+        echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
+        cp -pP ${S}/${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime

Shouldn't that be an 'ln -sf' instead of a 'cp'?

that would make a link from ${D} to ${S}

Eric

#3 lore raw

Op 14 jan. 2012, om 16:54 heeft Eric Bénard het volgende geschreven:

Quoted 10 lines
Quoted 7 lines · Koen Kooi

meta/recipes-extended/tzdata/tzdata_2011n.bb do_install () { · line 50

Quoted 4 lines
meta/recipes-extended/tzdata/tzdata_2011n.bb +4 -0
+        # Install defaults
+        install -d ${D}${sysconfdir}
+        echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
+        cp -pP ${S}/${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime

Shouldn't that be an 'ln -sf' instead of a 'cp'?

that would make a link from ${D} to ${S}

How about this one:

if [ -e ${S}/${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ] ; then

	ln -sf ${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime
else
	echo "Timezone ${DEFAULT_TIMEZONE} not found, exiting"
	exit 1

fi

#4 lore raw
In reply to Koen Kooi
Quoted 41 lines · Koen Kooi

Op 14 jan. 2012, om 14:07 heeft Andrea Adami het volgende geschreven:

Quoted 38 lines

* Take the extra bits in do_install from meta-openembedded
* and add pkg_postinst script (adapted from Gentoo).
* Default to 'Universal' timezone, present in the base package
* and allow override using DEFAULT_TIMEZONE variable.
* /etc/localtime and /etc/timezone are purposedly not packaged.
* Bump PR

---
meta/recipes-extended/tzdata/tzdata_2011n.bb |   55 +++++++++++++++++++++++++-

1 files changed, 53 insertions(+), 2 deletions(-)
meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
index de9281a..862a196 100644
@@ -5,7 +5,7 @@ LICENSE = "PD"

LIC_FILES_CHKSUM = "file://asia;beginline=2;endline=3;md5=06468c0e84ef4d4c97045a4a29b08234" DEPENDS = "tzcode-native"

meta/recipes-extended/tzdata/tzdata_2011n.bb +1 -1
-PR = "r0"
+PR = "r1"

RCONFLICTS= "timezones timezone-africa timezone-america timezone-antarctica \
             timezone-arctic timezone-asia timezone-atlantic \

meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
@@ -19,6 +19,8 @@ SRC_URI[tzdata.sha256sum] = "a343e542486b2b8ebdeca474eed79f1c04f69420ca943c2b9bd
 

S = "${WORKDIR}"

meta/recipes-extended/tzdata/tzdata_2011n.bb +2 -0
+DEFAULT_TIMEZONE ?= "Universal"
+

TZONES= "africa antarctica asia australasia europe northamerica southamerica  \
         factory solar87 solar88 solar89 etcetera backward systemv \
        "

meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
@@ -41,7 +43,56 @@ do_install () {
         # libc is removing zoneinfo files from package

        cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo

Quoted 9 lines
Quoted 6 lines

-     chown -R root:root ${D}
+
+        # Install defaults
+        install -d ${D}${sysconfdir}
+        echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
+        cp -pP ${S}/${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime

Shouldn't that be an 'ln -sf' instead of a 'cp'?

No, I don't think so.First reason is /usr may not be mounted, maybe living on another device..
See first Google link about this:
http://www.redhat.com/archives/rhl-devel-list/2006-April/msg00017.html
Then, as you see, the postinst takes care of both cases.

Thanks for reviewing

Regards

Andrea

P.S. I have indeed a doubt, about " # libc is removing zoneinfo files from package ". This will be a second patch maybe.

Quoted 5 lines

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

#5 lore raw

Op 15 jan. 2012, om 12:17 heeft Andrea Adami het volgende geschreven:

Quoted 51 lines · Koen Kooi
Quoted 41 lines

Op 14 jan. 2012, om 14:07 heeft Andrea Adami het volgende geschreven:

Quoted 38 lines

* Take the extra bits in do_install from meta-openembedded
* and add pkg_postinst script (adapted from Gentoo).
* Default to 'Universal' timezone, present in the base package
* and allow override using DEFAULT_TIMEZONE variable.
* /etc/localtime and /etc/timezone are purposedly not packaged.
* Bump PR

---
meta/recipes-extended/tzdata/tzdata_2011n.bb | 55 +++++++++++++++++++++++++-

1 files changed, 53 insertions(+), 2 deletions(-)
meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
index de9281a..862a196 100644
@@ -5,7 +5,7 @@ LICENSE = "PD"

LIC_FILES_CHKSUM = "file://asia;beginline=2;endline=3;md5=06468c0e84ef4d4c97045a4a29b08234" DEPENDS = "tzcode-native"

meta/recipes-extended/tzdata/tzdata_2011n.bb +1 -1
-PR = "r0"
+PR = "r1"
RCONFLICTS= "timezones timezone-africa timezone-america timezone-antarctica \
             timezone-arctic timezone-asia timezone-atlantic \
meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
@@ -19,6 +19,8 @@ SRC_URI[tzdata.sha256sum] = "a343e542486b2b8ebdeca474eed79f1c04f69420ca943c2b9bd
 

S = "${WORKDIR}"

meta/recipes-extended/tzdata/tzdata_2011n.bb +2 -0
+DEFAULT_TIMEZONE ?= "Universal"
+

TZONES= "africa antarctica asia australasia europe northamerica southamerica \

         factory solar87 solar88 solar89 etcetera backward systemv \
        "
meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
@@ -41,7 +43,56 @@ do_install () {
        # libc is removing zoneinfo files from package
        cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo
        cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo
Quoted 9 lines

meta/recipes-extended/tzdata/tzdata_2011n.bb do_install () { · line 50

Quoted 6 lines
meta/recipes-extended/tzdata/tzdata_2011n.bb +5 -1
-     chown -R root:root ${D}
+
+        # Install defaults
+        install -d ${D}${sysconfdir}
+        echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
+        cp -pP ${S}/${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime

Shouldn't that be an 'ln -sf' instead of a 'cp'?

Quoted 5 lines

No, I don't think so.First reason is /usr may not be mounted, maybe living on another device..
See first Google link about this:
http://www.redhat.com/archives/rhl-devel-list/2006-April/msg00017.html
Then, as you see, the postinst takes care of both cases.

That only applies to non-UTC times in RTC, which we don't use. And furthermore, no machine has /usr on a seperate partition since support for that is broken.

#6 lore raw
Quoted 54 lines · Koen Kooi

Op 15 jan. 2012, om 12:17 heeft Andrea Adami het volgende geschreven:

Quoted 51 lines · Koen Kooi
Quoted 50 lines

Op 14 jan. 2012, om 14:07 heeft Andrea Adami het volgende geschreven:

Quoted 36 lines

* Take the extra bits in do_install from meta-openembedded
* and add pkg_postinst script (adapted from Gentoo).
* Default to 'Universal' timezone, present in the base package
* and allow override using DEFAULT_TIMEZONE variable.
* /etc/localtime and /etc/timezone are purposedly not packaged.
* Bump PR

---
meta/recipes-extended/tzdata/tzdata_2011n.bb |   55 +++++++++++++++++++++++++-

1 files changed, 53 insertions(+), 2 deletions(-)
meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
index de9281a..862a196 100644
@@ -5,7 +5,7 @@ LICENSE = "PD"

LIC_FILES_CHKSUM = "file://asia;beginline=2;endline=3;md5=06468c0e84ef4d4c97045a4a29b08234" DEPENDS = "tzcode-native"

meta/recipes-extended/tzdata/tzdata_2011n.bb +1 -1
-PR = "r0"
+PR = "r1"

RCONFLICTS= "timezones timezone-africa timezone-america timezone-antarctica \
             timezone-arctic timezone-asia timezone-atlantic \

meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
@@ -19,6 +19,8 @@ SRC_URI[tzdata.sha256sum] = "a343e542486b2b8ebdeca474eed79f1c04f69420ca943c2b9bd
 

S = "${WORKDIR}"

meta/recipes-extended/tzdata/tzdata_2011n.bb +2 -0
+DEFAULT_TIMEZONE ?= "Universal"
+

TZONES= "africa antarctica asia australasia europe northamerica southamerica  \
         factory solar87 solar88 solar89 etcetera backward systemv \
        "

meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
@@ -41,7 +43,56 @@ do_install () {
         # libc is removing zoneinfo files from package
Quoted 8 lines

        cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo
        cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo
-     chown -R root:root ${D}
+
+        # Install defaults
+        install -d ${D}${sysconfdir}
+        echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
+        cp -pP ${S}/${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime

Shouldn't that be an 'ln -sf' instead of a 'cp'?

Quoted 7 lines
Quoted 5 lines

No, I don't think so.First reason is /usr may not be mounted, maybe living on another device..
See first Google link about this:
http://www.redhat.com/archives/rhl-devel-list/2006-April/msg00017.html
Then, as you see, the postinst takes care of both cases.

That only applies to non-UTC times in RTC, which we don't use. And furthermore, no machine has /usr on a seperate partition since support for that is broken.

I try to bump the thread before the sources get renamed ;)

About separation of exec_prefix, pls see

http://lists.linuxtogo.org/pipermail/openembedded-core/2012-January/015672.html
http://lists.linuxtogo.org/pipermail/openembedded-core/2012-January/015771.html

So, what is the position to take? Symlink or copy?

Regards

Andrea

Quoted 4 lines

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

#7 lore raw
Quoted 63 lines · Andrea Adami
Quoted 54 lines · Koen Kooi

Op 15 jan. 2012, om 12:17 heeft Andrea Adami het volgende geschreven:

Quoted 51 lines · Koen Kooi
Quoted 50 lines

Op 14 jan. 2012, om 14:07 heeft Andrea Adami het volgende geschreven:

Quoted 35 lines

* Take the extra bits in do_install from meta-openembedded
* and add pkg_postinst script (adapted from Gentoo).
* Default to 'Universal' timezone, present in the base package
* and allow override using DEFAULT_TIMEZONE variable.
* /etc/localtime and /etc/timezone are purposedly not packaged.
* Bump PR

---
meta/recipes-extended/tzdata/tzdata_2011n.bb | 55 +++++++++++++++++++++++++-

1 files changed, 53 insertions(+), 2 deletions(-)
meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
index de9281a..862a196 100644
@@ -5,7 +5,7 @@ LICENSE = "PD"

LIC_FILES_CHKSUM = "file://asia;beginline=2;endline=3;md5=06468c0e84ef4d4c97045a4a29b08234" DEPENDS = "tzcode-native"

meta/recipes-extended/tzdata/tzdata_2011n.bb +1 -1
-PR = "r0"
+PR = "r1"
RCONFLICTS= "timezones timezone-africa timezone-america timezone-antarctica \
              timezone-arctic timezone-asia timezone-atlantic \
meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
@@ -19,6 +19,8 @@ SRC_URI[tzdata.sha256sum] = "a343e542486b2b8ebdeca474eed79f1c04f69420ca943c2b9bd
 

S = "${WORKDIR}"

meta/recipes-extended/tzdata/tzdata_2011n.bb +2 -0
+DEFAULT_TIMEZONE ?= "Universal"
+

TZONES= "africa antarctica asia australasia europe northamerica southamerica \

          factory solar87 solar88 solar89 etcetera backward systemv \
         "

meta/recipes-extended/tzdata/tzdata_2011n.bb do_install () { · line 50

Quoted 9 lines
meta/recipes-extended/tzdata/tzdata_2011n.bb +5 -1
@@ -41,7 +43,56 @@ do_install () {
         # libc is removing zoneinfo files from package
         cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo
         cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo
-     chown -R root:root ${D}
+
+        # Install defaults
+        install -d ${D}${sysconfdir}
+        echo ${DEFAULT_TIMEZONE}>  ${D}${sysconfdir}/timezone
+        cp -pP ${S}/${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime

Shouldn't that be an 'ln -sf' instead of a 'cp'?

Quoted 7 lines
Quoted 5 lines

No, I don't think so.First reason is /usr may not be mounted, maybe living on another device..
See first Google link about this:
http://www.redhat.com/archives/rhl-devel-list/2006-April/msg00017.html
Then, as you see, the postinst takes care of both cases.

That only applies to non-UTC times in RTC, which we don't use. And furthermore, no machine has /usr on a seperate partition since support for that is broken.

Quoted 8 lines

I try to bump the thread before the sources get renamed ;)

About separation of exec_prefix, pls see

http://lists.linuxtogo.org/pipermail/openembedded-core/2012-January/015672.html
http://lists.linuxtogo.org/pipermail/openembedded-core/2012-January/015771.html

So, what is the position to take? Symlink or copy?

On other systems I've used.. the rule has been: hardlink (same disk) or copy. Since the symlink would point into /usr and that should usually be avoided (as mentioned above).

I thought there used to be a tool that would do the hardlink, if possible and then copy if not.. but I'm not sure if that is even reasonable with our image creation... (so copy is likely best answer then)

--Mark

Quoted 14 lines

Regards

Andrea

Quoted 4 lines

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

#8 lore raw
Quoted 122 lines · Mark Hatle
Quoted 82 lines · Andrea Adami
Quoted 72 lines · Koen Kooi

Op 15 jan. 2012, om 12:17 heeft Andrea Adami het volgende geschreven:

Quoted 61 lines
Quoted 50 lines · Koen Kooi

Op 14 jan. 2012, om 14:07 heeft Andrea Adami het volgende geschreven:

Quoted 46 lines

* Take the extra bits in do_install from meta-openembedded
* and add pkg_postinst script (adapted from Gentoo).
* Default to 'Universal' timezone, present in the base package
* and allow override using DEFAULT_TIMEZONE variable.
* /etc/localtime and /etc/timezone are purposedly not packaged.
* Bump PR

---
meta/recipes-extended/tzdata/tzdata_2011n.bb |   55
+++++++++++++++++++++++++-

1 files changed, 53 insertions(+), 2 deletions(-)
meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
index de9281a..862a196 100644
@@ -5,7 +5,7 @@ LICENSE = "PD"

LIC_FILES_CHKSUM = "file://asia;beginline=2;endline=3;md5=06468c0e84ef4d4c97045a4a29b08234" DEPENDS = "tzcode-native"

meta/recipes-extended/tzdata/tzdata_2011n.bb +1 -1
-PR = "r0"
+PR = "r1"

RCONFLICTS= "timezones timezone-africa timezone-america timezone-antarctica \
             timezone-arctic timezone-asia timezone-atlantic \

meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
@@ -19,6 +19,8 @@ SRC_URI[tzdata.sha256sum] =

"a343e542486b2b8ebdeca474eed79f1c04f69420ca943c2b9bd

S = "${WORKDIR}"

meta/recipes-extended/tzdata/tzdata_2011n.bb +2 -0
+DEFAULT_TIMEZONE ?= "Universal"
+

TZONES= "africa antarctica asia australasia europe northamerica southamerica  \
         factory solar87 solar88 solar89 etcetera backward systemv \
        "

meta/recipes-extended/tzdata/tzdata_2011n.bb +0 -0
@@ -41,7 +43,56 @@ do_install () {
         # libc is removing zoneinfo files from package

        cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo
-     chown -R root:root ${D}
+

Quoted 9 lines
Quoted 5 lines

+        # Install defaults
+        install -d ${D}${sysconfdir}
+        echo ${DEFAULT_TIMEZONE}>  ${D}${sysconfdir}/timezone
+        cp -pP ${S}/${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime

Shouldn't that be an 'ln -sf' instead of a 'cp'?

Quoted 5 lines

No, I don't think so.First reason is /usr may not be mounted, maybe living on another device..
See first Google link about this:
http://www.redhat.com/archives/rhl-devel-list/2006-April/msg00017.html
Then, as you see, the postinst takes care of both cases.

Quoted 3 lines

That only applies to non-UTC times in RTC, which we don't use. And furthermore, no machine has /usr on a seperate partition since support for that is broken.

I try to bump the thread before the sources get renamed ;)

Quoted 8 lines

About separation of exec_prefix, pls see

http://lists.linuxtogo.org/pipermail/openembedded-core/2012-January/015672.html

http://lists.linuxtogo.org/pipermail/openembedded-core/2012-January/015771.html

So, what is the position to take?  Symlink or copy?

On other systems I've used.. the rule has been: hardlink (same disk) or copy. Since the symlink would point into /usr and that should usually be avoided (as mentioned above).

I thought there used to be a tool that would do the hardlink, if possible and then copy if not.. but I'm not sure if that is even reasonable with our image creation... (so copy is likely best answer then)

--Mark

Quoted 11 lines

Regards

Andrea

Quoted 4 lines

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Quoted 4 lines

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Quoted 4 lines

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Please take on hold this patch.
Further inspection of do_rootfs logs reveals that the postinst is run during that task and the code tries to write /etc/localtime on host, fails and exits 1.

I'll add a check like

pkg_postinst_${PN}() {
if test "x$D" != "x"; then
exit 1
else

and send a revised patch in a few hours.

Regards

Andrea

P.S.
This is a low hanging fruit wrt recipes duplication between oe-core and meta-oe. Please add your review/comments, thanks.

#9 lore raw
Quoted 5 lines · Andrea Adami

Please take on hold this patch.
Further inspection of do_rootfs logs reveals that the postinst is run during that task and the code tries to write /etc/localtime on host, fails and exits 1.

Quoted 8 lines

I'll add a check like

pkg_postinst_${PN}() {
if test "x$D" != "x"; then
exit 1
else

and send a revised patch in a few hours.

How about prefixing the paths with $D instead of forcing this onto the target? (note, not ${D})

Cheers,

Richard

#10 lore raw

PATCH v2 1/1 tzdata_2011n: provide pkg_postinst and timezone defaults

In reply to Andrea Adami

* Introduce DEFAULT_TIMEZONE variable ('Universal', present in base package)
* and add /etc/timezone during do_install.
* While there, fix hardcoded references to $exec_prefix (/usr).
* Add the pkg_postinst script (adapted from Gentoo).
* Create /etc/localtime during postinst.
* Bump PR

---
 meta/recipes-extended/tzdata/tzdata_2011n.bb |   62 ++++++++++++++++++++++++--
 1 files changed, 58 insertions(+), 4 deletions(-)
meta/recipes-extended/tzdata/tzdata_2011n.bb +58 -4
index de9281a..9a41131 100644
@@ -5,7 +5,7 @@ LICENSE = "PD"
 LIC_FILES_CHKSUM = "file://asia;beginline=2;endline=3;md5=06468c0e84ef4d4c97045a4a29b08234"
 DEPENDS = "tzcode-native"
 
-PR = "r0"
+PR = "r1"
 
 RCONFLICTS= "timezones timezone-africa timezone-america timezone-antarctica \
              timezone-arctic timezone-asia timezone-atlantic \
@@ -19,6 +19,8 @@ SRC_URI[tzdata.sha256sum] = "a343e542486b2b8ebdeca474eed79f1c04f69420ca943c2b9bd
 
 S = "${WORKDIR}"
 
+DEFAULT_TIMEZONE ?= "Universal"
+
 TZONES= "africa antarctica asia australasia europe northamerica southamerica  \
          factory solar87 solar88 solar89 etcetera backward systemv \
         "
@@ -36,12 +38,64 @@ do_compile () {
 }
 
 do_install () {
-        install -d ${D}/usr ${D}${datadir}/zoneinfo
-        cp -pPR ${S}/usr ${D}/
+        install -d ${D}/$exec_prefix ${D}${datadir}/zoneinfo
+        cp -pPR ${S}/$exec_prefix ${D}/
         # libc is removing zoneinfo files from package
         cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo
         cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo
-	chown -R root:root ${D}
+
+        # Install default timezone
+        install -d ${D}${sysconfdir}
+        echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
+
+        chown -R root:root ${D}
+}
+
+pkg_postinst_${PN} () {
+
+# code taken from Gentoo's tzdata ebuild
+
+	etc_lt="$D${sysconfdir}/localtime"
+	src="$D${sysconfdir}/timezone"
+
+	if [ -e ${src} ] ; then
+		tz=$(sed -e 's:#.*::' -e 's:[[:space:]]*::g' -e '/^$/d' "${src}")
+	else
+		tz="FUBAR"
+	fi
+	
+	if [ -z ${tz} ] ; then
+		return 0
+	fi
+	
+	if [ ${tz} = "FUBAR" ] ; then
+		echo "You do not have TIMEZONE set in ${src}."
+
+		if [ ! -e ${etc_lt} ] ; then
+			# if /etc/localtime is a symlink somewhere, assume they
+			# know what they're doing and they're managing it themselves
+			if [ ! -L ${etc_lt} ] ; then
+				cp -f "$D${datadir}/zoneinfo/Universal" "${etc_lt}"
+				echo "Setting ${etc_lt} to Universal."
+			else
+				echo "Assuming your ${etc_lt} symlink is what you want; skipping update."
+			fi
+		else
+			echo "Skipping auto-update of ${etc_lt}."
+		fi
+		return 0
+	fi
+
+	if [ ! -e "$D${datadir}/zoneinfo/${tz}" ] ; then
+		echo "You have an invalid TIMEZONE setting in ${src}"
+		echo "Your ${etc_lt} has been reset to Universal; enjoy!"
+		tz="Universal"
+	fi
+	echo "Updating ${etc_lt} with $D${datadir}/zoneinfo/${tz}"
+	if [ -L ${etc_lt} ] ; then
+		rm -f "${etc_lt}"
+	fi
+	cp -f "$D${datadir}/zoneinfo/${tz}" "${etc_lt}"
 }
 
 # Packages primarily organized by directory with a major city
Signature · 1 line
1.7.3.4
#11 lore raw

Op 28 jan. 2012, om 08:57 heeft Andrea Adami het volgende geschreven:

Quoted 8 lines

* Introduce DEFAULT_TIMEZONE variable ('Universal', present in base package)
* and add /etc/timezone during do_install.
* While there, fix hardcoded references to $exec_prefix (/usr).
* Add the pkg_postinst script (adapted from Gentoo).
* Create /etc/localtime during postinst.
* Bump PR

A quick look makes me think this patch is a lot better than the current situation.

#12 lore raw
In reply to Andrea Adami
Quoted 11 lines · Andrea Adami

* Introduce DEFAULT_TIMEZONE variable ('Universal', present in base package)
* and add /etc/timezone during do_install.
* While there, fix hardcoded references to $exec_prefix (/usr).
* Add the pkg_postinst script (adapted from Gentoo).
* Create /etc/localtime during postinst.
* Bump PR

---
 meta/recipes-extended/tzdata/tzdata_2011n.bb |   62 ++++++++++++++++++++++++--
 1 files changed, 58 insertions(+), 4 deletions(-)

Merged to master, thanks.

Richard